#include <iostream>

using namespace std;

int main(){
	int h,w;
	cin >> h >> w;
	char** s = (char**)calloc(h, sizeof(char*));
	for(int i = 0; i < h; i++){
		s[i] = (char*)calloc(w+1, sizeof(char));
		cin >> s[i];
	}
	//→と↓だけ見る
	int count = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(s[i][j] == '.'){
				if(i == h-1 && j == w-1) break;
				if(i == h-1 && j != w-1){
					if(s[i][j+1] == '.') count++;
				}else if(j == w-1){
					if(s[i+1][j] == '.') count++;
				}
				else{
					if(s[i+1][j] == '.' && s[i][j+1] == '.') count+=2;
					else if(s[i+1][j] == '.' || s[i][j+1] == '.')count++;
				}
			}
		}
	}
	cout << count << endl;
	
	return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(),v.end()
#define sz(x) (int)sz.size()
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define what(x) cout<<#x<<" is "<<x<<endl;
using namespace std;

#ifdef LOCAL//ONLINE_JUDGE
#include "D:\c_c++\template.h"
#else
#define debug(...) 42
#endif

ll powmod(ll a,ll b,ll mod) {
    ll res=1;a%=mod;
    for(;b;b>>=1){
        if(b&1)res=res*a%mod;
			a=a*a%mod;
    }
    return res;
}
int h,w;
bool isval(int x,int y){
	return x>=0 && x<h && y>=0 && y<w;
}
int dir[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
void solve(){
	cin>>h>>w;
	string s[h];
	for(int i=0;i<h;i++)cin>>s[i];

	ll cnt=0;
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++){
			if(s[i][j]=='#')continue;
			for(int d=0;d<4;d++){
				int nx=i+dir[d][0],ny=j+dir[d][1];
				if(isval(nx,ny)){
					debug(i,j,nx,ny);
					if(s[nx][ny]=='.')cnt++;
				}
			}
		}
	debug(cnt);
	cout<<(cnt/2LL)<<'\n';

}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
//    #ifdef LOCAL
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif
    int tc=1;
    // cin>>tc;
    while(tc--)solve();
}
