JEZIK | 프로그래밍의 벗 PivotOJ
PivotOJ

JEZIK

시간 제한: 1000ms메모리 제한: 128MB출처: CHC 2003 National Competition #2 - SeniorsBOJ 3242

문제

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
.
출력
2

예제 2

입력
IDI 1
RADI
.
출력
1

예제 3

입력
RADI
IDI 4 ILI 6
RADI
IDI 3
RADI
IDI 8
RADI
RADI
.
출력
2
코드를 제출하려면 로그인하세요.