BRHMAIL - Chain Mail

Butch is fascinated by how fast chain emails have the possibility to spread. (In case you are completely out-dated, a chain email is an email that one person send to all of his/her friends, who each then send to all of their friends, etc...)

He wants to find out how many times a certain letter will be received. Assume that no person will "receive" it more than once (though we all know how that goes).

For the sake of this investigation, Butch has conveniently named N (1 ≤ N ≤ 10) different people with the numbers 1..N. Each of these N people have Fi (0 ≤ F < N) friends within the group.

Note that if person A is friends with person B, that means that person B is friends with person A. This is guaranteed to be explicitly stated in the data. Also, note that no person will ever be friends with themself (poor lonely people...).

Assuming person 1 starts the chain (count that person 1 received it), determine how many people will receive this letter.

Input

Line 1: A single integer, N
Lines 2..N+1: One integer Fi, then Fi integers (each such that 1 ≤ Fij ≤ N), all space-separated, naming each of person i's friends.

Output

Line 1: A single integer, the number of people who receive it. Be sure not to count a single person twice!

Example

Input:
5
1 2
2 1 3
1 2
1 5
1 4

Output: 3

Output Explanation

Person 1 sends it to 2; 2 sends it to 3 only. Note that 4 and 5 never receive the mail, so the answer is 3: persons 1, 2, and 3 received it.


Added by:Damon Doucet
Date:2009-12-05
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 NODEJS OBJC PERL6 SQLITE VB.NET

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.