eolymp
bolt
Try our new interface for solving problems
Problems

Gnomes and houses

Gnomes and houses

Long time ago, in Berendeevy Polyany lived not schoolchildren and teachers, but gnomes. Since then, some of the houses are connected by underground tunnels. On this night, the gnomes planned to regain their ancient lands and capture all the LKSH houses while schoolchildren and teachers are asleep. Once in the house, the dwarfs can freely penetrate into any other connected with it tunnels, from it - into connected with it and so on. However, the teachers, having learned about this, closed the doors for the night. And now the dwarfs have to break some number of doors in order to grab the LKSH.

Imagine yourself at the dwarf's place and answer the question: how many doors they have to break?

Input

The first line contains the number of houses n (1n100) at LKSH. The next n lines give the description of tunnels in the form of a table – the cell [i, j] contains "1" if there exists the tunnel between the houses i and j, otherwise "0" is there.

Output

Print the minimum number of doors that the gnomes need to break.

Time limit 1 second
Memory limit 128 MiB
Input example #1
6
0 1 1 0 0 0
1 0 1 0 0 0
1 1 0 0 0 0
0 0 0 0 1 0
0 0 0 1 0 0
0 0 0 0 0 0
Output example #1
3