#include <bits/stdc++.h>
using namespace std;
int n, ans;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
char s[1005][1005];
bool f[1005][1005];
void dfs(int x, int y)
{
for (int i = 0; i < 4; i++)
{
int xx = x + dx[i];
int yy = y + dy[i];
if (xx < 1 || xx > n || yy < 1 || yy > n)
{
continue;
}
if (f[xx][yy])
{
continue;
}
f[xx][yy] = 1;
dfs(xx, yy);
}
}
int main()
{
ios::sync_with_stdio(0);cin.tie();cout.tie();
cin >> n;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
cin >> s[i][j];
}
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
if (s[i][j] == '#')
{
for (int k = 0; k < 4; k++)
{
int xx = i + dx[k];
int yy = j + dy[k];
if (xx < 1 || xx > n || yy < 1 || yy > n)
{
continue;
}
if (s[xx][yy] == '.')
{
f[i][j] = 1;
break;
}
}
}
else
{
f[i][j] = 1;
}
}
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
if (f[i][j] == 0)
{
ans++;
dfs(i, j);
}
}
}
cout << ans;
return 0;
}