#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;}
#define rep(i,n) for(int i=0;i<(n);i++)
#define drep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define debug(x)  cerr << #x << " = " << (x) << endl;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W;
    cin >> H >> W;
    vvec<char> S(H,vec<char>(W));
    rep(i,H) rep(j,W) cin >> S[i][j];
    int ans = 0;
    rep(i,H-1) rep(j,W-1){
        int c = 0;
        rep(a,2) rep(b,2) c += S[i+a][j+b];
        if(c%2) ans++;
    }
    cout << ans << "\n";
}
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define u unsigned
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define in(i,arr) for(auto &i:arr)cin>>i;
#define out(i,arr) for(auto &i:arr)cout<<i<<" ";
#define all(x) (x).begin(), (x).end()
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb empalce_back
#define fe first
#define se second
#define uset unordered_set
#define umap unordered_map

template <typename T>
ll powe(T base, T to){ll ans=1;while(to>0){if (to & 1)ans =(ans*base)%mod, to--;else base = (base*base)%mod, to /= 2;}return ans;}
ll gcd(ll a,ll b){return (b==0)?a:gcd(b,a%b);}
bool prime(ll n){if(n==1)return 0;for(ll i=2;i*i<=n;i++)if(n%i==0)return 0;return 1;}

int main() {
    fast;
    int tl = 1;
    //cin>>tl;
    while (tl--) {
        int h, w;
        cin >> h >> w;
        char mat[h][w];
        f(i, h)f(j, w)cin >> mat[i][j];
        int ans = 0;
        f(i, h)
            f(j, w) {
                if (mat[i][j] == '#' && mat[i][j - 1] == '.') {
                    if ((mat[i - 1][j] != mat[i][j]) || (mat[i - 1][j - 1] == '#'))
                        ans++;
                }
            }
        f(j, w)
            f(i, h) {
                if (mat[i][j] == '#' && mat[i][j - 1] == '.') {
                    if ((mat[i - 1][j] != mat[i][j]) || (mat[i - 1][j - 1] == '#'))
                        ans++;
                }
            }
//            cout<<ans<<" ";
        f(i, h / 2)f(j, w) {
                swap(mat[i][j], mat[h - i - 1][j]);

            }
        f(j, w / 2)f(i, h) {
                swap(mat[i][j], mat[i][w - j - 1]);

            }

//        f(i,h)
//        {
//            f(j,w)cout<<mat[i][j];
//            cout<<"\n";
//        }
        f(i, h)
            f(j, w) {
                if (mat[i][j] == '#' && mat[i][j - 1] == '.') {
                    if ((mat[i - 1][j] != mat[i][j]) || (mat[i - 1][j - 1] == '#'))
                        ans++;
                }
            }
        f(j, w)
            f(i, h) {
                if (mat[i][j] == '#' && mat[i][j - 1] == '.') {
                    if ((mat[i - 1][j] != mat[i][j]) || (mat[i - 1][j - 1] == '#'))
                        ans++;
                }
            }
        cout << ans;
    }
}