#include <bits/stdc++.h>
using namespace std;
bool debug = 1;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long ln, lk, lm;
char s[125][125];
int a[125][125];
int main() {
  scanf("%d%d", &n, &m);
  for (int(i) = 1; (i) <= (int)(n); (i)++) scanf("%s", s[i] + 1);
  for (int i = n; i; i--) {
    for (int j = m; j; j--) {
      int tar = s[i][j] == 'W' ? 1 : -1;
      int z = tar - a[i][j];
      if (z != 0) {
        k++;
        for (int p = 1; p <= i; p++)
          for (int q = 1; q <= j; q++) a[p][q] += z;
      }
    }
  }
  printf("%d\n", k);
  return 0;
}
