#T21. 刻录光盘

刻录光盘

Description

At the end of the FJOI2010 summer camp, many campers proposed to burn all the camp materials onto a CD for everyone to take home and continue learning. The organizing committee thought this was a great idea! However, the committee didn’t have enough blank CDs at the moment, making it impossible to ensure everyone could receive a CD with the materials. What could be done?!

DYJ analyzed the geographical relationships among all the campers and found that some campers were from the same city. In fact, they only needed one CD because once one person received the materials, others could copy them using USB drives or similar devices!

Some campers were willing to let certain people copy materials from them, while others might not be willing to share with specific individuals—this went against the spirit of teamwork that FJOI promotes!!!

Now, suppose there are a total of N campers (2 ≤ N ≤ 200), each with an ID from 1 to N. DYJ gave each camper a survey form to fill out, indicating which other campers they were willing to share materials with. Of course, if A is willing to share materials with B, and B is willing to share with C, then once A obtains the materials, both B and C will also receive them.

Now, please write a program to help DYJ calculate the minimum number of CDs the organizing committee must burn to ensure all campers can take the summer camp materials home, based on the collected survey forms.

Input Format

The first line contains a number N. The next N lines indicate which campers each camper is willing to share their materials with. Specifically, the (i+1)-th line of the input represents the IDs of the campers that the i-th camper is willing to share with, ending with a 0. If a camper is unwilling to share with anyone, the corresponding line will only contain a single 0. Multiple numbers in a line are separated by spaces.

Output Format

A single positive integer representing the minimum number of CDs required.

5
2 4 3 0
4 5 0
0
0
1 0

1