#CCBOTPBA0000050. Trạm kiểm tra nhiều mức (Multi-Level Inspection Station)

Trạm kiểm tra nhiều mức (Multi-Level Inspection Station)

Multi-Level Inspection Station

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

An inspection station processes records in sequence. Each record contains a code cc and an integer value xx. A record with code 11 passes when x≥5x\ge5; a record with code 22 passes when x≤10x\le10. Code 00 terminates the sequence and its record is not counted. Count the records that pass before the first code 00. Codes can only be 00, 11 or 22, and a terminating record is guaranteed.

Input

A sequence of integer pairs cc and xx, separated by whitespace (pairs may be on separate lines). The sequence ends at the first pair with c=0c=0. The value xx of the terminating pair does not affect the result.

Output

Print one integer: the total number of passing records, excluding the terminating record.

Subtasks

  • Subtask 1 (20%): $0\le k\le20;\ c\in\{0,1\}\text{ trước mã kết thúc};\ -10^9\le x\le10^9$.
  • Subtask 2 (30%): 0≤k≤1000; c∈{0,1,2}; −109≤x≤1090\le k\le1000;\ c\in\{0,1,2\};\ -10^9\le x\le10^9.
  • Subtask 3 (50%): $0\le k\le100000;\ c\in\{0,1,2\};\ -10^9\le x\le10^9$.

Here, kk is the number of records preceding the terminator. The terminating record is not included in kk.

Examples

Example 1

Input:

1 5
2 11
2 10
0 0

Output:

2

Explanation: (1,5) passes because 5≥55\ge5, giving count 1. (2,11) fails because 11>1011>10. (2,10) passes because 10≤1010\le10, giving count 2. Code 0 stops processing, so the answer is 2.

Example 2

Input:

0 99

Output:

0

Explanation: The first code is 0, so no record is processed and the answer is 0.

Example 3

Input:

1 4
2 11
0 -10

Output:

0

Explanation: Both records before the sentinel fail. The value -10 in the terminating record is ignored.