#include <bits/stdc++.h>
using namespace std;
int g[205][205];
void add(int a, int b, int k) {
  for (int i = 1; i <= a; i++)
    for (int j = 1; j <= b; j++) g[i][j] += k;
}
int main() {
  char ch[205][205];
  int f[205][205];
  int n, m, ans = 0;
  memset(g, 0, sizeof(g));
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", ch[i]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) f[i][j] = (ch[i][j - 1] == 'B') ? -1 : 1;
  for (int i = n + m; i > 1; i--)
    for (int j = 1; j <= n; j++)
      if (i - j > 0 && i - j <= m && f[j][i - j] != g[j][i - j]) {
        ans++;
        add(j, i - j, f[j][i - j] - g[j][i - j]);
      }
  printf("%d\n", ans);
  return 0;
}
