시간 제한메모리 제한제출정답맞은 사람정답 비율
1 초 128 MB111100.000%

문제

When analyzing source code in some programming language, it’s sometimes useful to know if there are some functions that will never execute. If there are, that may lead to an error in the code.

In this occasion we observe simple programming language that consists of following functions:

  • RADI: program continues to next function
  • IDI a: program goes to a-th function
  • IDI a ILI b: program goes to a-th or b-th function

Program always starts at first function.

Write the program that will calculate the number of functions that will never execute.

입력

In every line of input file there is one function, in i-th line there is i-th function.

In last line (after last function, i+1-th line) there is ‘.’ (a spot). That line is not the part of a program and is not considered function.

Number of functions will be less or equal then 10,000.

출력

In first and only line of output should be printed the number of unexecuted functions.

예제 입력 1

RADI
IDI 4 ILI 6
RADI
IDI 3
RADI
IDI 8
RADI
RADI
.

예제 출력 1

2

예제 입력 2

IDI 1
RADI
.

예제 출력 2

1

예제 입력 3

RADI
IDI 4 ILI 6
RADI
IDI 3
RADI
IDI 8
RADI
RADI
. 

예제 출력 3

2