#61. 字符串中数字求和

    ID: 61 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatString-3gesp1循环结构条件结构

字符串中数字求和

Sum of Digits in String

Background

Congcong is learning string processing. He encountered an interesting problem that requires extracting and calculating the sum of all digits from a string.

Problem Description

Given a string, return the sum of the digits 090-9 that appear in the string, ignoring all other characters. Return 00 if there are no digits in the string.

Input Format

Input is given from Standard Input in the following format.

A single line string SS.

Output Format

Output is printed to Standard Output in the following format.

An integer representing the sum of all digits in the string.

Sample

aa1bc2d3
6
aa11b33
8
Chocolate
0

Sample Explanation

Sample 1: The string "aa1bc2d3" contains digits '1', '2', '3'. Their sum is 1+2+3=61 + 2 + 3 = 6. Sample 2: The string "aa11b33" contains digits '1', '1', '3', '3'. Their sum is 1+1+3+3=81 + 1 + 3 + 3 = 8. Sample 3: The string "Chocolate" does not contain any digits, so the sum is 00.

Constraints

The length of string SS does not exceed 10001000.