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