import sys input = sys.stdin.readline def dfs(x,y): if x >= n or x = n or y n: graph[x][y] = 0 dfs(x,y-1) dfs(x,y+1) dfs(x-1,y) dfs(x+1,y) return True return False n = int(input()) graph = [] cnt = 0 for i in range(n): graph.append(list(map(int,input().split()))) for i in range(n): for j in range(n): if dfs(i,j) == True: cnt += 1 print(cnt) #틀렸다고 나온다...