#include<bits/stdc++.h>
using namespace std;
#define int long long
int Random(int x)
{
return rand() % x;
}
char ch[15][15];
signed main()
{
srand(time(0));
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int r, c;
cin >> r >> c;
for(int i = 1; i <= r; i++)
{
for(int j = 1; j <= c; j++)
{
cin >> ch[i][j];
}
}
for(int i = 1; i <= r; i++)
{
for(int j = 1; j <= c; j++)
{
int cnt = 0;
for(int k = -1; k <= 1; k++)
{
for(int K = 1; K <= 1; K++)
{
if(k || K)
if(!k | !K)
cnt += ch[i + k][j + K] == '.';
}
}
if(cnt == 1)
cout << 1 << endl;
if(cnt == 1)
exit(0);
}
}
cout << 0 << endl;
return 0;
}