Hi.here is a question I got for assignment.I am stuck in this for hours and couldnt com up with any logic.Any help will be highly appreciated.Thanks

Depth-First-Search

Q.No.1 The undirected unweighted graph with one selected vertex is given. Find the number of

vertices in the connected component where the selected vertex belong (including the selected one).

Specifications

Input

The first line contains two integers n and s (1 ≤ s ≤ n ≤ 100), where n - the number of vertices of the

graph, and s - chosen vertex. The following n lines contains n numbers - the adjacency matrix of the

graph in the MDM figure "0" means no edges between vertices, and the number "1" - its availability. It is

guaranteed that the main diagonal of the matrix are always zero.

Output

Print the desired number of vertices

Example input

5 1

0 1 1 0 0

1 0 1 0 0

1 1 0 0 0

0 0 0 0 1

0 0 0 1 0

Example output

3