#include<bits/stdc++.h>
using namespace std;

char mp[110][110];
int n, m;

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf("%s", mp[i] + 1);
	}
	int ans = 0;
	for (int i = 2; i <= n; i++) {
		int pre = 0;
		for (int j = 1; j <= m; j++) {
			if (mp[i][j] != mp[i - 1][j]) {
				int now;
				if (mp[i][j] == '#')now = 1;
				else now = 2;
				if (pre != now) {
					ans++;
					pre = now;
				}
			}
			else {
				pre = 0;
			}
		}
	}
	for (int j = 2; j <= m; j++) {
		int pre = 0;
		for (int i = 1; i <= n; i++) {
			if (mp[i][j] != mp[i][j - 1]) {
				int now;
				if (mp[i][j] == '#')now = 1;
				else now = 2;
				if (pre != now) {
					ans++;
					pre = now;
				}
			}
			else {
				pre = 0;
			}
		}
	}
	printf("%d\n", ans);
}
#include <bits/stdc++.h>

// #include <iostream>
// #include <vector>
// #include <algorithm>
// #include <stdio.h>
// #include <math.h>
// #include <string>
// #include <cctype>
// #include <map>
// #include <queue>
// #include <limits>
// #include <iomanip>
// #include <sstream>
// #include <cstdlib>
// #include <locale>
// #include <bitset>
// #include <set>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,n) for(int i = n-1; i >= 0; i--)
#define ll long long
#define P pair<int, int>

#define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf
#define INF64 9223372036854775807 //9.223372036854775807×10^{18}:64bit整数のinf

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif

const double PI = acos(-1);

unsigned GetDigit(unsigned num) { return log10(num)+1; }

int main()
{
	int h, w;
	cin >> h >> w;

	vector< vector<char> > s(h, vector<char>(w));
	rep(i, h) rep(j, w) cin >> s.at(i).at(j);

	int ans = 0;
	for (int i = 1; i < h; i++)
	{
		for (int j = 1; j < w; j++)
		{
			ans += (
				(s.at(i-1).at(j-1) == '#') +
				(s.at(i).at(j-1) == '#') +
				(s.at(i-1).at(j) == '#') +
				(s.at(i).at(j) == '#')) % 2;
		}
	}

	cout << ans << endl;
}