#K36097. Sum of Digits

    ID: 25678 Type: Default 1000ms 256MiB

Sum of Digits

Sum of Digits

Given an integer n, compute the sum of its digits by considering its absolute value. In other words, let \(n\) be an integer, then let \(|n|\) be its absolute value. If \(|n|\) is expressed with digits \(d_1, d_2, \dots, d_k\), the digit sum \(S\) is given by:

$$S = \sum_{i=1}^{k} d_i$$

If the input cannot be interpreted as an integer, output None.

Examples:

  • Input: 123, Output: 6
  • Input: -123, Output: 6
  • Input: abc, Output: None

inputFormat

A single line containing a string. The program should interpret the input as an integer.

outputFormat

Print the sum of the digits of the absolute value of the integer. If the input is not a valid integer, print "None".## sample

123
6