Under construction

Still being built. Things may change

Preliminary Meeting Result Report

Interview

Time limit1sMemory limit1024 MB

Summary
Count the teams that solved at least one of three problems, where each solve time is no earlier than the solve time of any lower-numbered problem.
Level

Easy2 of 10

Topics
Implementation, Array
Solved
No attempts yet

Problem

The day before the PPC main contest, a preliminary meeting is held so that the participating teams can adapt to the environment. The preliminary meeting used 33 problems, and NN teams took part. Problems and teams are numbered in order starting from 11. The PPC staff decided to write a report to find out how effective the preliminary meeting was.

To measure the effect, you need to count the teams that took part diligently. A diligent team satisfies the following conditions.

  • The team solved at least one of the three problems.
  • The team solved the problems in order of their numbers. That is, if a team solved a problem at time TT, it had solved every problem with a smaller number, each at time TT or earlier, and every problem with a larger number is either unsolved or solved at time TT or later.

Given the time each team solved each problem, find the number of diligent teams.

Input

The first line contains the number of teams NN that took part in the preliminary meeting. (1≤N≤1001 \le N \le 100)

From the second line, NN lines follow. Line ii contains three integers Ti,1T_{i,1}, Ti,2T_{i,2}, Ti,3T_{i,3} separated by spaces, which are the times at which team ii solved problems 1, 2, and 3. If team ii did not solve problem jj, then Ti,j=−1T_{i,j} = -1. (−1≤Ti,j≤120-1 \le T_{i,j} \le 120)

Output

Print the number of diligent teams.

Examples1

  1. Example 1

    Input
    6
    1 2 3
    1 -1 1
    -1 -1 -1
    0 4 -1
    10 -1 -1
    120 120 120
    
    Expected output
    4