#include<bits/stdc++.h>
using namespace std;
 
#define INF 1234567890
#define ll long long
 
int N, M, sy, sx, sd, res = 0;
string s[11];
int dir[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
int block[4][2] = {{-1, 1}, {1, 1}, {1, -1}, {-1, -1}};
bool vis[11][11][4];
 
void f(int y, int x, int d)
{
	if (vis[y][x][d]) return;
	vis[y][x][d] = true;
 
	int ny = y + dir[d][0], nx = x + dir[d][1];
	int by = y + block[d][0], bx = x + block[d][1];
	if (s[by][bx] == '#')
	{
		res++;
		f(by, bx, (d+3)%4);
	}
	else if (s[ny][nx] == '.')
	{
		res++;
		f(y, x, (d+1)%4);
	}
	else
		f(ny, nx, d);
}
 
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N >> M;
	for(int i=0; i<N; i++)
		cin >> s[i];
	for(int i=0; i<N; i++)
		for(int j=0; j<M; j++)
			if (s[i][j] == '#')
			{
				f(i, j, 0);
				goto END;
			}
	assert(0);
	END:
	cout << res;
	return 0;
}
#include <iostream>

#define rep(i,a,n) for(int i = a; i < (n); i++)

using namespace std;

int main(){
	int h,w,cnt = 0;
	cin >> h >> w;
	char g[h][w];
	rep(i,0,h)
		rep(j,0,w){
			cin >> g[i][j];
			//if(g[i][j] == '#') cout << "Ye" << endl;
		}
			
	rep(i,0,h-1)
		rep(j,0,w-1){
			int v = (g[i][j] == '#') + (g[i+1][j] == '#') + (g[i][j+1] == '#') + (g[i+1][j+1] == '#');
			//cout << v << endl;
			if(v == 1 || v == 3) cnt++;
			}
	cout << cnt << endl;
	return 0;
	}
