#include <bits/stdc++.h>
//define int long long
using namespace std;
const int N = 1010;
int n,vis[N][N],suma,sumb;
char a[N][N],b[N][N];
const int fx[4] = {-1,0,0,1};
const int fy[4] = {0,-1,1,0};
struct point
{
int x,y;
};
void bfs(int x,int y)
{
queue <point> q;
q.push({x,y});
vis[x][y] = 1;
while (!q.empty())
{
point f = q.front();
q.pop();
for (int i = 0;i < 4;i++)
{
int xx = f.x + fx[i],yy = f.y + fy[i];
if (xx >= 1 && xx <= n && yy >= 1 && yy <= n && !vis[xx][yy] && a[xx][yy] == '#')
vis[xx][yy] = 1,q.push({xx,yy});
}
}
}
void solve()
{
cin >> n;
for (int i = 1;i <= n;i++)
cin >> a[i]+1;
for (int i = 1;i <= n;i++)
for (int j = 1;j <= n;j++)
b[i][j] = a[i][j];
for (int i = 1;i <= n;i++)
for (int j = 1;j <= n;j++)
if (!vis[i][j] && a[i][j] == '#')
bfs(i,j),suma++;
memset(vis,0,sizeof(vis));
for (int i = 1;i <= n;i++)
for (int j = 1;j <= n;j++)
if (b[i][j] == '#' && (b[i-1][j] == '.' || b[i+1][j] == '.' || b[i][j-1] == '.' || b[i][j+1] == '.'))
a[i][j] == '.';
for (int i = 1;i <= n;i++)
{
for (int j = 1;j <= n;j++)
cout << a[i][j];
cout << '\n';
}
for (int i = 1;i <= n;i++)
for (int j = 1;j <= n;j++)
if (!vis[i][j] && a[i][j] == '#')
bfs(i,j),sumb++;
cout << suma-sumb;
}
int main()
{
solve();
printf("\n");
return 0;
}
a[i][j]赋值不上去