#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pl = pair<ll, ll>;
using Vs = vector<string>;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;//10の18乗
#define yn {puts("Yes");}else{puts("No");}
#define dame { puts("-1"); return 0;}

int main() {
    ll h,w;
    cin >> h >> w;
    Vs v(h);
    rep(i,h) cin >> v[i];
    ll ans=0;
    rep(i,h-1)rep(j,w-1){
        ll x=0,y=0;
        rep(k,2)rep(l,2){
            if(v[i+k][j+l]=='#') x++;
            else y++;
        }
        if(x%2==1) ans++;
    }
    cout << ans << endl;

}

#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const int maxn=1e6+10;
#define mod 1000000007
int main(){
	fast;
	ll n,m; cin>>n>>m;
	vector<vector<char>> a(n,vector<char>(m,' '));
	vector<vector<ll>> b(n,vector<ll>(m,0));
	for(auto i=0;i<n;++i){
		for(auto j=0;j<m;++j){
			cin>>a[i][j];
		}
	}
	ll cnt=0;
	for(auto i=0;i<n;++i){
		for(auto j=0;j<m;++j){
			if(a[i][j]=='.' && b[i][j]==0){
				if(i-1>=0 && a[i-1][j]=='#' && j-1>=0 && a[i][j-1]=='#'){
					++cnt;
				}if(i-1>=0 && a[i-1][j]=='#' && j+1<m && a[i][j+1]=='#'){
					++cnt;
				}if(i+1<n && a[i+1][j]=='#' && j-1>=0 && a[i][j-1]=='#'){
					++cnt;
				}if(i+1<n && a[i+1][j]=='#' && j+1<m && a[i][j+1]=='#'){
					++cnt;
				}
				b[i][j]=1;
			}else if(a[i][j]=='#' && b[i][j]==0){
				if(i-1>=0 && a[i-1][j]=='.' && j-1>=0 && a[i][j-1]=='.'){
					// b[i][j]=1;
					++cnt;
				}if(i-1>=0 && a[i-1][j]=='.' && j+1<m && a[i][j+1]=='.'){
					// b[i][j]=1;
					++cnt;
				}if(i+1<n && a[i+1][j]=='.' && j-1>=0 && a[i][j-1]=='.'){
					// b[i][j]=1;
					++cnt;
				}if(i+1<n && a[i+1][j]=='.' && j+1<m && a[i][j+1]=='.'){
					// b[i][j]=1;
					++cnt;
				}
				b[i][j]=1;
			}
		}
	}
	cout<<cnt<<'\n';
	return 0;
}
// combnatorics(pigeonhole principle, stars and bars (n+k-1)C(k-1))
// comparator in inbuilt sorting 
// lcs
// period of a string(prefix-function) with KMP
// prime func
// subset production
// factorization
// modpow
// modinv ( a^(p-2)=a^(-1) (mod p) )
// sieve
// ncr
// euler totien func (co prime divisiors upto n)
// matrix exponentation(fast fibonacci)
// dsu
// Trees
// Graphs(dfs,bfs,shortes path etc.)
// DP-Recursion