#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define ii pair < int , int >
#define ever (;;)
const int N = 1010;
bool vis[N][N];
int n,m,movex[4]={1,-1,0,0},movey[4]={0,0,1,-1};
char a[N][N];
void dfs(int x,int y)
{
vis[x][y] = 1;
for(int i=0;i<4;i++)
{
int newx = x + movex[i];
int newy = y + movey[i];
if( !vis[newx][newy] && a[newx][newy] == '.' )
dfs(newx,newy);
}
}
int main()
{
cin>>n>>m;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
cin>>a[i][j];
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
if( !vis[i][j] && a[i][j] == '.' )
dfs(i,j);
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIEYgZmlyc3QKI2RlZmluZSBTIHNlY29uZAojZGVmaW5lIGlpIHBhaXIgPCBpbnQgLCBpbnQgPgojZGVmaW5lIGV2ZXIgKDs7KQoKY29uc3QgaW50IE4gPSAxMDEwOwoKYm9vbCB2aXNbTl1bTl07CmludCBuLG0sbW92ZXhbNF09ezEsLTEsMCwwfSxtb3ZleVs0XT17MCwwLDEsLTF9OwpjaGFyIGFbTl1bTl07Cgp2b2lkIGRmcyhpbnQgeCxpbnQgeSkKewogICAgdmlzW3hdW3ldID0gMTsKCiAgICBmb3IoaW50IGk9MDtpPDQ7aSsrKQogICAgewogICAgICAgIGludCBuZXd4ID0geCArIG1vdmV4W2ldOwogICAgICAgIGludCBuZXd5ID0geSArIG1vdmV5W2ldOwoKICAgICAgICBpZiggIXZpc1tuZXd4XVtuZXd5XSAmJiBhW25ld3hdW25ld3ldID09ICcuJyApCiAgICAgICAgICAgIGRmcyhuZXd4LG5ld3kpOwogICAgfQp9CgppbnQgbWFpbigpCnsKICAgIGNpbj4+bj4+bTsKICAgIGZvcihpbnQgaT0xO2k8PW47aSsrKQogICAgICAgIGZvcihpbnQgaj0xO2o8PW07aisrKQogICAgICAgICAgICBjaW4+PmFbaV1bal07CgogICAgZm9yKGludCBpPTE7aTw9bjtpKyspCiAgICAgICAgZm9yKGludCBqPTE7ajw9bTtqKyspCiAgICAgICAgICAgIGlmKCAhdmlzW2ldW2pdICYmIGFbaV1bal0gPT0gJy4nICkKICAgICAgICAgICAgICAgIGRmcyhpLGopOwp9Cg==