#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, m, a[N][N], s[N][N], ans = 0;
char ts[N];
inline void fil(int r, int c, int d) {
  for (int i = 1; i <= r; i++)
    for (int j = 1; j <= c; j++) s[i][j] += d;
}
int main(int argc, const char* argv[]) {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%s", ts);
    for (int j = 0; j < m; j++) a[i][j + 1] = (ts[j] == 'W' ? 1 : -1);
  }
  for (int i = n; i >= 1; i--)
    for (int j = m; j >= 1; j--)
      if (s[i][j] != a[i][j]) fil(i, j, a[i][j] - s[i][j]), ans++;
  printf("%d", ans);
  return 0;
}
