import java.io.FileNotFoundException;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main_9 {
static int[] dx = { -1, 1, 0, 0 };
static int[] dy = { 0, 0, -1, 1 };
private static int n;
private static char[][] g;
private static int[][] mark;
private static int ans;
public static void main(String[] args) throws FileNotFoundException {
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
sc.nextLine();
g = new char[n][n];
mark = new int[n][n];
for (int i = 0; i < n; i++) {
g[i] = sc.nextLine().toCharArray();
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (g[i][j] == '#' && mark[i][j] == 0) {
bfs(i, j);
}
}
}
System.out.println(ans);
}
private static void bfs(int x, int y) {
mark[x][y] = 1;
int cntOfBlock = 0;
int cntOfSwed = 0;
Queue<Point> queue = new LinkedList<Point>();
queue.add(new Point(x, y));
while (!queue.isEmpty()) {
Point first = queue.poll();
cntOfBlock++;
boolean swed = false;
for (int d = 0; d < 4; d++) {
int nx = first.x + dx[d];
int ny = first.y + dy[d];
if (0 <= nx && nx < n && 0 <= ny && ny < n) {
if (g[nx][ny] == '.')
swed = true;
if (g[nx][ny] == '#' && mark[nx][ny] == 0) {
queue.add(new Point(nx, ny));
mark[nx][ny] = 1;
}
}
}
if (swed)
cntOfSwed++;
}
if (cntOfBlock == cntOfSwed)
ans++;
}
private static class Point {
int x, y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
}