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