#include <bits/stdc++.h>
using namespace std;
long long a[100][100], v[100][100];
int n, m, ans;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    getchar();
    for (int j = 0; j < m; ++j) {
      char ret = getchar();
      if (ret == 'W') {
        v[i][j] = -1;
      } else {
        v[i][j] = 1;
      }
    }
  }
  for (int i = n - 1; i >= 0; --i) {
    for (int j = m - 1; j >= 0; --j) {
      long long d = v[i][j] - a[i][j];
      if (d != 0) {
        ++ans;
        for (int k = i; k >= 0; --k) {
          for (int t = j; t >= 0; --t) {
            if (k == i && t == j) {
              continue;
            }
            a[k][t] += d;
          }
        }
      }
    }
  }
  printf("%d", ans);
  return 0;
}
