#K33742. Count Contiguous Numbers in a String
Count Contiguous Numbers in a String
Count Contiguous Numbers in a String
Given a string S
consisting of alphanumeric characters and symbols, your task is to count the number of contiguous sequences of digits in the string. A contiguous sequence is defined as one or more consecutive digits (0-9) occurring together. For example, in the string abc123def45gh6
, there are three sequences: 123
, 45
, and 6
.
The problem can be expressed mathematically as follows:
Let S be a string of characters. Define a sequence n as a maximal contiguous subsequence of S
where each character satisfies c \in \{0, 1, 2, ..., 9\}
. The output is the total count of such sequences in S.
Please ensure your solution reads from standard input (stdin) and writes the answer to standard output (stdout).
inputFormat
The input consists of a single line which is the string S
. S
can contain letters, digits, and symbols.
outputFormat
Output a single integer that represents the number of contiguous sequences of digits found in the input string.
## sampleabc123def45gh6
3
</p>