PythonEasyNumbers10 min

Sum the digits of an integer

Ignore a leading minus sign. The digit sum of zero is zero. Interviewers use this problem to assess use remainder and integer division by ten.

Input

One integer n.

Output

Print the result on one line; print an empty line for an empty string.

Constraints

-10^18 <= n <= 10^18.

Example

Input

12345

Output

15

Example 2 input

-999999999999999999

Output

162

All repeated digits must contribute.

Public test cases (2)

  • Input

    12345

    Expected output

    15
  • Input

    -908

    Expected output

    17
Hints (2)
  1. Identify the state needed to avoid repeated work.
  2. Use remainder and integer division by ten.

Target complexity: time O(d), where d is the digit count · space O(1)

Your solution

Checking runner availability…

Reference solution

Sign in for solution
All Python programs