#CCBCHHAI0000004. Lệnh thoát ngay (Immediate Exit Command)
Lệnh thoát ngay (Immediate Exit Command)
Immediate Exit Command
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
A sequence of command codes is given. Each code from 1 to 9 counts as an executed command; zero terminates the sequence. Print the number of nonzero codes before the first zero.
Input
A sequence of integer codes in , ending in zero; preceding codes are in .
Output
Print the number of commands executed before the zero.
Subtasks
- Subtask 1 (20%): At most 5 nonzero codes.
- Subtask 2 (30%): At most 100 nonzero codes.
- Subtask 3 (50%): At most nonzero codes.
Examples
Example 1
Input
0
Output
0
Explanation
The first command is zero, so the count remains zero.
Example 2
Input
3 9 1 0
Output
3
Explanation
Codes 3, 9, 1 count as three commands; zero terminates input.