#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105;
char s[MAXN][MAXN];
int G[MAXN][MAXN];
int mp[MAXN][MAXN];
int n, m;
void change(int x, int y, int v) {
  for (int i = 0; i <= x; ++i) {
    for (int j = 0; j <= y; ++j) {
      G[i][j] += v;
    }
  }
}
void solve() {
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
  }
  memset(G, 0, sizeof G);
  char c = s[n - 1][m - 1];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      mp[i][j] = s[i][j] == c ? 1 : -1;
    }
  }
  int ans = 0;
  for (int i = n - 1; i >= 0; --i) {
    for (int j = m - 1; j >= 0; --j) {
      if (G[i][j] != mp[i][j]) {
        ++ans;
        change(i, j, mp[i][j] - G[i][j]);
      }
    }
  }
  printf("%d\n", ans);
}
int main() {
  while (~scanf("%d%d", &n, &m)) solve();
  return 0;
}
