#K66342. Sum of Digits in a String

    ID: 32399 Type: Default 1000ms 256MiB

Sum of Digits in a String

Sum of Digits in a String

You are given a string consisting of letters, digits, and other characters. Your task is to compute the sum of all digit characters present in the string. If the string contains at least one digit and the sum is greater than zero, output the sum. Otherwise, output the string NO DIGITS.

More formally, if the input string \(s\) contains any digit characters \(d_1, d_2, \dots, d_k\), compute the sum \(S = d_1 + d_2 + \dots + d_k\). If \(S > 0\), print \(S\); if no digits exist or the sum equals zero, print NO DIGITS.

Note: The sum is computed by treating each digit as a numerical value (0 through 9). For example, the input a1b2c3 should produce an output of 6.

inputFormat

The input consists of a single line containing the string \(s\), which may include letters, digits, and/or special characters.

Input Format:

s

outputFormat

If the string contains at least one digit that contributes a sum greater than zero, output the sum; otherwise, output NO DIGITS.

Output Format:

result
## sample
a1b2c3
6