#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rrep(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr ll INF = 1LL << 30;
constexpr ll mod = 100000; //(ll)1e9 + 7;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
inline void init() {
    cin.tie(nullptr); cout.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}

int dx[] = { 0,1,1 ,0 };
int dy[] = { 0,0, 1,1 };

int main() {
    init();

    int H, W; cin >> H >> W;
    vector<string>vec(H);
    vector<vector<int>>cnt(H + 1, vector<int>(W + 1, 0));
    rep(i, 0, H)cin >> vec[i];
    int ans = 0;
    rep(i, 0, H) {
        rep(j, 0, W) {
            if (vec[i][j] == '#') {
                rep(k, 0, 4)cnt[i + dy[k]][j + dx[k]]++;
            }
        }
    }
    rep(i, 0, H + 1)rep(j, 0, W + 1)if (cnt[i][j] % 2 == 1)ans++;
    cout << ans << "\n";
    

    return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int h,w,i,j,black,white,sum;
    cin>>h>>w;
    char ar[h][w];
    string str;
    for (i=0;i<h;i++)
    {
        cin>>str;
        for(j=0;j<w;j++)
            ar[i][j]=str[j];
    }
    sum=0;
    for (i=0;i<h-1;i++)
    {
        for (j=0;j<w-1;j++)
        {
            white=black=0;
            if (ar[i][j]=='#')
                black++;
            else white++;
            if (ar[i][j+1]=='#')
                black++;
            else white++;
            if (ar[i+1][j]=='#')
                black++;
            else white++;
            if (ar[i+1][j+1]=='#')
                black++;
            else white++;
            if ((black==3 && white==1) || (white==3 && black==1))
                sum++;
        }
    }
    cout<<sum;
    return 0;
}