#Q96. 「一本通 3.5 练习 2」消息的传递

「一本通 3.5 练习 2」消息的传递

Description

Our esteemed Guo Jia is living a carefree life under Cao Cao's patronage. However, one day Cao Cao assigned him a mission: within Jianye City, there are NN spies of Yuan Shao, numbered from 11 to NN. There exists a transmission relationship among them—if Ci,j=1C_{i,j}=1, then spy ii can directly pass a message to spy jj.

Now, Cao Cao wants to spread a false message to all the spies. Our task is to determine the minimum number of spies Guo Jia needs to inform initially so that the message reaches every spy.

Input Format

The first line of the input contains NN. The next NN lines form an N×NN \times N matrix (where the II-th row and JJ-th column being 11 means spy II can directly pass a message to spy JJ, and 00 means spy II cannot directly pass a message to spy JJ).

Output Format

The output consists of a single line: the minimum number of spies Guo Jia needs to inform initially.

Sample 1

8
0 0 1 0 0 0 0 0
1 0 0 1 0 0 0 0
0 1 0 1 1 0 0 0
0 0 0 0 0 1 0 0
0 0 0 1 0 0 0 0
0 0 0 1 0 0 0 0
0 0 0 1 0 0 0 1
0 0 0 0 0 0 1 0

2

Constraints & Hints

N1000N \le 1000