#CCBCHHAI0000027. Mã thoát 9 (Exit Code Nine)
Mã thoát 9 (Exit Code Nine)
Exit Code Nine
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
A program receives integer codes from 0 through 9 in order. Code 9 is a terminator rather than a data code. Count the number of non-9 codes before the first 9. If the first code is 9, the answer is zero.
Input
A whitespace-separated sequence of codes in with exactly one 9 at the end; all preceding codes differ from 9.
Output
Print the count of data codes preceding the terminator 9.
Subtasks
- Subtask 1 (20%): At most codes, including the final 9.
- Subtask 2 (30%): At most codes, including the final 9.
- Subtask 3 (50%): At most codes, including the final 9.
Examples
Example 1
Input
2 0 8 9
Output
3
Explanation
2, 0 and 8 are data; the final 9 terminates without increasing the count.
Example 2
Input
9
Output
0
Explanation
The first code is 9, so no data code is counted.