#K15866. Sum of Digits in a String

    ID: 24452 Type: Default 1000ms 256MiB

Sum of Digits in a String

Sum of Digits in a String

Given a string S, your task is to calculate the sum of all numeric digits present in the string. For example, if the string contains the digits '1', '2', and '3', then the answer is 1 + 2 + 3 = 6.

The problem can be formally described as follows:

Find:

\( \text{Sum} = \sum_{i=1}^{n} d_i \)

where \( d_i \) is the numeric value of the digit at position \( i \) in the string, if the character at position \( i \) is a digit.

If there are no digits in the string, the output should be 0.

inputFormat

The input will be provided via standard input (stdin) as a single line containing the string S. The string may contain letters, digits, spaces or punctuation.

outputFormat

Output a single integer to standard output (stdout) representing the sum of all digits in the input string.

## sample
ab1231da
7