//Iamskk//
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define endl '\n'
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ai(arr,n) for(int i=0;i<n;i++)cin>>arr[i];
#define ao(arr) for(auto asdfasdfasdf:arr) cout<<asdfasdfasdf<<" ";
#define mi(arr,m,n) for(int i=0;i<m;i++){ for(int j=0;j<n;j++) cin>>arr[i][j];}
#define mo(arr,m,n) for(int i=0;i<m;i++){ for(int j=0;j<n;j++) cout<<arr[i][j]<<" "; cout<<endl;}
#define countsetbits(x) __builtin_popcount(x)
#define ll long long
#define debug cout<<"I AM EXECUTING"<<endl
#define testcases int asdf; cin>>asdf; while(asdf--)
#define vi vector<int>
#define vll vector<long long int>
#define vppo(prs) for(auto x:prs){cout<<x.first<<" "<<x.second<<endl;}
#define For(__,hajmola,adfdf) for(int __ = hajmola; __<adfdf;__++)
#define formax 1e18
#define formin -1e18
string sconvert(ll int n)
{
	stringstream ss;
	ss<<n;
	string str = ss.str();
	return str;
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second > b.second); 
}

template<typename T>
void imax(T &x,T y){
	x = max(x,y);
}
template<typename T>
void imin(T &x,T y){
	x = min(x,y);
}

void  single()
{
	int n;
	cin>>n;
	int m;
	cin>>m;
	vector<string> mat(n+1);
	for(int i=0;i<n;i++){
		cin>>mat[i];
	}
	int finalanswer=0;
	For(i,0,n-1){
		For(j,0,m-1){
			int count=0;
            if(mat[i+1][j+1]==mat[i][j]){
            	count++;
            }
            if(mat[i+1][j]==mat[i][j]){
            	count++;
            }
            if(mat[i][j+1]==mat[i][j]){
            	count++;
            }
            if(count==0 or count==2){
            	finalanswer++;
            }
         
		}
	}
	cout<<finalanswer<<endl;
	return;
}
void multiple()
{
	testcases
    {
		single();
	}
}

int main()
{
  IOS;
 // freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  single();
}


















#include <bits/stdc++.h>
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define max(p, q) ((p) > (q) ? (p) : (q))
#define min(p, q) ((p) < (q) ? (p) : (q))
#define INF ((1LL << 62) - (1LL << 31))
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(void)
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int vx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
    int vy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
    int h, w;
    cin >> h >> w;
    char s[h][w];
    pair<int, int> a;
    rep(i, 0, h)
    {
        rep(j, 0, w)
        {
            char tmp;
            cin >> tmp;
            if (tmp == '#' || tmp == '.')
            {
                s[i][j] = tmp;
            }
        }
    }
    ll ans=0;
    rep(i,0,h){
        rep(j,0,w){
            ll tmp=0;
            if(s[i][j]=='#')tmp++;
            if(s[i][j+1]=='#')tmp++;
            if(s[i+1][j]=='#')tmp++;
            if(s[i+1][j+1]=='#')tmp++;
            
            if(tmp%2==1){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}