#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define endl "\n"
#define vll vector<ll>
#define pll pair<ll,ll>
#define pqb priority_queue<ll>
#define pqs priority_queue<ll,vll,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x)             (int)((x).size())
#define FAST ios_base :: sync_with_stdio (false); cin.tie (NULL)
#define fo(i,s,n) for(ll i=s;i<n;i++)
#define rfo(i,n,s) for(ll i=n;i>=s;i--)
using namespace std;
typedef long long int ll;
//------------------------------MOD-Operations--------------------------------------------------------------------------------------------------------------------------------------------//
const ll M = 1e9 + 7;
const ll N = 2e5 + 5;
const ll inf = 9e18;
ll mod(ll x){   return (x%M);}
ll ml(ll a,ll b){  return mod(mod(a)*mod(b));}
ll power(ll a,ll n){   if(n==0) return 1;   else if(n==1) return a;   ll R=power(a,n/2)%M;    if(n%2==0) {    return mod(ml(R,R));  }   else {   return mod(ml(ml(R,a),mod(R)));  }  }
ll mod_inv(ll n){  return power(n,M-2);}
// only if M is prime
ll mod_div(ll a,ll b){   return ml(a,mod_inv(b));   }
ll C(ll n,  ll r) 
{   if(r > n || n < 0 || r < 0)return 0;
 if (r == 0) 
        return 1; 
   ll nfc=1,rfc=1,nrfc=1;
    for (int i = 1; i <= n; i++) 
      { 
           nfc=ml(nfc,i);
           if(i==r){rfc=nfc;}
           if(i==(n-r)){nrfc=nfc;} 
     } 
    return ml(ml(nfc,mod_inv(rfc)),mod_inv(nrfc)); 
} 
ll ncr(ll n, ll r)
{
    long long p = 1, k = 1;
    if (n - r < r)
        r = n - r;
   if (r != 0) {
        while (r) {
            p *= n;
            k *= r;
  long long m = __gcd(p, k);
            p /= m;
            k /= m;
            n--;
            r--;
        }
    } 
    else
        p = 1;
return p;
}
vector<ll> seive(ll n){
    vector<ll> isprime(n+1,true); 
    isprime[0]=false;
    isprime[1]=false;//kyuki 1 prime nhi hota
    for( ll i=2;i<sqrt(n);i++){
        if(isprime[i]){
            for(int j=i*i;j<=n;j+=i){
                isprime[j]=false;
            }
        }
    }
    vll allp;
    fo(i,2,n+1)if(isprime[i])allp.pb(i);
return allp;
}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
vll vis(N);
vector<vll> adj(N);
void solve() {

}
int main(){
    FAST;
ll h,w; cin>>h>>w;
vector<string> v(h);
fo(i,0,h)cin>>v[i];
ll ans=0;
fo(i,1,h-1){
    fo(j,1,w-1){
        if(v[i][j]=='.'){
            if(v[i-1][j-1]=='#' && v[i-1][j]=='#' && v[i][j-1]=='#')ans++;
             if(v[i+1][j+1]=='#' && v[i+1][j]=='#' && v[i][j+1]=='#')ans++;
              if(v[i-1][j+1]=='#' && v[i][j+1]=='#' && v[i-1][j]=='#')ans++;
               if(v[i][j-1]=='#' && v[i+1][j]=='#' && v[i+1][j-1]=='#')ans++;

        }
        else {
             if(v[i-1][j-1]=='.' && v[i-1][j]=='.' && v[i][j-1]=='.')ans++;
             if(v[i+1][j+1]=='.' && v[i+1][j]=='.' && v[i][j+1]=='.')ans++;
              if(v[i-1][j+1]=='.' && v[i][j+1]=='.' && v[i-1][j]=='.')ans++;
               if(v[i][j-1]=='.' && v[i+1][j]=='.' && v[i+1][j-1]=='.')ans++;

        }
    }
}
cout<<ans<<endl;

}
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef    long long             ll;
typedef    long double           ld;
typedef    unsigned long long    ull;
typedef    pair<int,int>         pii;
typedef    pair<ll,ll>           pll;
typedef    vector<int>           vi;
typedef    vector<ll>            vll;
typedef    vector<vector<int>>   vvi;
 
inline     int         Int(){int x; cin >> x; return x;}
inline     ll          Long(){ll x; cin >> x; return x;}
inline     float       Float(){float x; cin >> x; return x;}
inline     double      Double(){double x; cin >> x; return x;}
inline     void        Yes(){cout << "Yes" << endl;}
inline     void        No(){cout << "No" << endl;}
inline     void        YES(){cout << "YES" << endl;}
inline     void        NO(){cout << "NO" << endl;}
 
const      int N       =(int)2e5 + 5;
const      int maxN    =(int)1e6 + 6;
const      ll  Mod     =(ll)1e9 + 7;
const      int inf     =(int)2e9;
const      ll  Inf     =(ll)1e18;

#define    fastio      ios_base::sync_with_stdio(false),cin.tie(NULL)
#define    T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define    Forn(i,n)   for(int i=0;i<n;i++)
#define    ForN(i,n)   int i;for(i=n-1;n>=0;i--)
#define    forn(i,n)   for(int i=1;i<=n;i++)
#define    forN(i,n)   int i;for(i=n;n>=1;i--)
#define    fors(i,s)   for(int i=0;i<s.size();i++)
#define    Sort(s)     sort(s.begin(),s.end())
#define    debug(x)    cerr << #x << " = " << x << '\n' ;
#define    rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b>e); i=i+1-2*(b>e))
#define    gcd(a,b)    __gcd(a , b)
#define    lcm(a,b)    (a*(b/__gcd(a,b)))
#define    gt          greater<int>()
#define    Int         Int()
#define    Long        Long()
#define    Float       Float()
#define    Double      Double()
#define    all(x)      x.begin() , x.end()
#define    sz(x)       (int)x.size()
#define    ff          first
#define    ss          second
#define    pb          push_back
#define    eb          emplace_back
#define    mp          make_pair
#define    mem(a)      memset(a,0,sizeof a)
#define    memn(a)     memset(a,-1,sizeof a)
#define    biday       return 0 
#define    nl          endl
#define    sp(n)       fixed<<setprecision(n)
#define    pi          acos(-1)
#define    PI          3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342
 
 
int main()
{
    ll h,w,i,j,x,res=0;
    cin >> h >> w;

    char s[h][w];
    for(i=0; i<h; i++)
    {
    	for(j=0; j<w; j++)
    	{
    		cin >> s[i][j];
    	}
    }
    for(i=0; i<h-1; i++)
    {
    	for(j=0; j<w-1; j++)
    	{
    		x=0;
    		if(s[i][j]=='#')x++;
    		if(s[i][j+1]=='#')x++;
    		if(s[i+1][j]=='#')x++;
    		if(s[i+1][j+1]=='#')x++;
    		if(x%2)res++;
    	}
    }
    cout << res << endl;
    

    biday;
}
 
//...............BYE BYE................