#K93612. Sum of Digits Except '7'
Sum of Digits Except '7'
Sum of Digits Except '7'
You are given a string consisting of digits. Your task is to compute the sum of all digits in the string except the digit 7
. However, there are two additional rules:
- If the computed sum exceeds 20, you must output 20 instead.
- If the string consists entirely of the digit
7
(or is empty), then the output should be 0.
In mathematical terms, if you denote the input string as \( S \) and \( d \) as a digit in \( S \), we define the sum \( T \) as:
[ T = \sum_{\substack{d \in S \ d \neq 7}} d ]
Then the result \( R \) is given by:
[ R = \begin{cases} 0, & \text{if } S \text{ contains only } 7 \text{'s or is empty}, \ 20, & \text{if } T > 20, \ T, & \text{otherwise}. \end{cases} ]
</p>Your solution should read the input from standard input and write the result to standard output.
inputFormat
The input consists of a single line containing a string. The string is composed of digit characters (0-9). It may possibly be empty.
outputFormat
Output a single integer as described in the problem statement. The output should be written to standard output.
## sample12345
15