import os
import sys
# 请在此输入您的代码
sys.setrecursionlimit(60000)
n = int(input())
dao = []
for _ in range(n):
tmp = list(input())
dao.append(tmp)
dict = [(1, 0), (0, 1), (-1, 0), (0, -1)]
used = [[0 for _ in range(n)] for _ in range(n)]
def dfs(x, y):
global flag
# used[x][y] = 1
if dao[x][y - 1] == "#" and dao[x][y + 1] == "#" and dao[x + 1][y] == "#" and dao[x - 1][y] == "#":
flag = 1
used[x][y] = 1
for x1, y1 in dict:
a = x + x1
b = y + y1
if not used[a][b] and dao[a][b]=="#":
dfs(a, b)
cnt = 0
for i in range(n):
for j in range(n):
if dao[i][j] == "#" and not used[i][j]:
flag = 0
dfs(i, j)
if not flag:
cnt += 1
print(cnt)
from collections import deque n = int(input()) dao = [] for _ in range(n): tmp = list(input()) dao.append(tmp) dict = [(1, 0), (0, 1), (-1, 0), (0, -1)] used = [[0 for _ in range(n)] for _ in range(n)] def bfs(i, j): global flag dq = deque() dq.append(i) dq.append(j) used[i][j] = 1 while dq: x = dq.popleft() y = dq.popleft() if dao[x + 1][y] == "#" and dao[x - 1][y] == "#" and dao[x][y + 1] == "#" and dao[x][y - 1] == "#": flag = 1 for x1, y1 in dict: if not used[x1 + x][y1 + y] and dao[x1 + x][y1 + y] == "#": used[x1 + x][y1 + y] = 1 dq.append(x1 + x) dq.append(y1 + y) cnt = 0 for i in range(n): for j in range(n): if not used[i][j] and dao[i][j] == '#': flag = 0 bfs(i, j) if not flag: cnt += 1 print(cnt)