#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;
struct Grid {
int x;
int y;
};
int n, m, ans;
int direction[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
char c[1005][1005];
int vis[1005][1005];
//题目是描述不清的,样例是懒得写的,想通过是得看别人题解的
int main() {
cin >> n;
m = n;
cin.ignore();
for (int i = 0; i < n; i++) {
cin.getline(c[i], m + 1);
}
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
if (!vis[i][j] && c[i][j] == '#') {
vector<Grid> v;
bool safe = false;
queue<Grid> q;
Grid st;
st.x = i;
st.y = j;
q.push(st);
vis[st.x][st.y] = 1;
while (!q.empty()) {
Grid g = q.front();
q.pop();
bool flag = true;
// if (g.x == 0 || g.y == 0 || g.x == n - 1 || g.y == m - 1) flag = false;
// cnt++;
for (int k = 0; k < 4; k++) {
int x = g.x + direction[k][0];
int y = g.y + direction[k][1];
if (x > -1 && x < n && y > -1 && y < m && c[x][y] == '#') {
if(!vis[x][y]) {
vis[x][y] = 1;
Grid new_grid;
new_grid.x = x;
new_grid.y = y;
q.push(new_grid);
v.push_back(new_grid);
}
} else {
flag = false;
}
}
safe |= flag;
}
ans += safe ? 0 : 1;
}
}
}
cout << ans << endl;
}