#include <bits/stdc++.h>
using namespace std;
const int N = 110;
char s[N][N];
int g[N][N];
int m, n;
void fun(int x, int y, int f) {
  for (int i = 0; i <= x; i++)
    for (int j = 0; j <= y; j++) g[i][j] += f;
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    memset(s, '\0', sizeof(s));
    memset(g, 0, sizeof(g));
    for (int i = 0; i < n; i++) scanf("%s", s[i]);
    int cnt = 0;
    for (int i = n - 1; i >= 0; i--)
      for (int j = m - 1; j >= 0; j--) {
        if (g[i][j] != (s[i][j] == 'B' ? -1 : 1)) {
          cnt++;
          int tmp = (s[i][j] == 'B' ? -1 : 1) - g[i][j];
          fun(i, j, tmp);
        }
      }
    printf("%d\n", cnt);
  }
  return 0;
}
