#K83742. Sum of Standalone Integers in a String
Sum of Standalone Integers in a String
Sum of Standalone Integers in a String
Given a string, extract any word that represents a standalone non-negative integer (i.e., composed solely of digits) and sum them up. The string contains words separated by spaces. Any token that is not exclusively digits (for instance, numbers with a leading '-' sign) should be ignored. For example, for the input The 3 little kittens had 9 lives
, the output should be 12
.
inputFormat
The input consists of a single line containing a string with words and possible standalone integers. The string may include extra spaces or no numbers at all.
outputFormat
The output is a single integer representing the sum of all standalone non-negative integers found in the input string.
## sample1 2 3 4 5
15