import java.io.*;
import java.util.LinkedList;
import java.util.Queue;
public class Main {
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
static int[] dx = {-1, 0, 1, 0}, dy = {0, 1, 0, -1};
static int N = 1010, n;
static char[][] g = new char[N][N];
//每个点只会遍历一次,时间复杂度为O(N * N)
static int bfs() {
int cnt = 0;
boolean[][] st = new boolean[N][N];
Queue<PII> queue = new LinkedList<>();
for (int i = 1; i <= n; i ++) //遍历每行
for (int j = 0; j < n; j ++) //遍历每列
if (g[i][j] == '#' && !st[i][j]) { //加入该岛屿
boolean success = false;
queue.add(new PII(i, j));
st[i][j] = true;
while (!queue.isEmpty()) {
PII p = queue.poll();
int x = p.x, y = p.y;
for (int k = 0; k < 4; k ++) {
int a = x + dx[k], b = y + dy[k];
if (!st[a][b] && g[a][b] == '#') { //题目要求边缘必须是’.‘,所以不会有越界问题
queue.add(new PII(a, b));
st[a][b] = true; //表示该点已经遍历过
if (g[a - 1][b] == '#' && g[a + 1][b] == '#' && g[a][b - 1] == '#' && g[a][b + 1] == '#') success = true;
}
}
}
if (!success) cnt ++; //如果该岛屿存在不会被淹没的点则结果加一
}
return cnt;
}
public static void main(String[] args) throws IOException {
n = Integer.parseInt(in.readLine());
for (int i = 1; i <= n; i ++) g[i] = in.readLine().toCharArray();
out.println(bfs());
out.flush();
}
}
class PII {
int x, y;
PII(int a, int b) {
x = a;
y = b;
}
}