#include <bits/stdc++.h>
using namespace std;
char a[110][110];
int b[110][110];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", a[i] + 1);
  int ans = 0;
  for (int i = n; i; i--)
    for (int j = m; j; j--) {
      b[i][j] = b[i][j + 1] + b[i + 1][j] - b[i + 1][j + 1];
      if (a[i][j] == 'W') {
        if (b[i][j] != 1) {
          b[i][j] = 1;
          ans++;
        }
      } else {
        if (b[i][j] != -1) {
          b[i][j] = -1;
          ans++;
        }
      }
    }
  printf("%d\n", ans);
  return 0;
}
