#include <bits/stdc++.h>
using namespace std;
const int N = 110;
char s[N][N];
int n, m, ans, a[N][N];
bool vis[N][N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  memset(a, 0, sizeof a);
  memset(vis, 0, sizeof vis);
  int x = n, y = m, diff;
  while (1) {
    x = -1, y = -1;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++)
        if (!vis[i][j] &&
            ((s[i][j] == 'W' && a[i][j] != 1) ||
             (s[i][j] == 'B' && a[i][j] != -1)) &&
            i + j > x + y) {
          x = i;
          y = j;
        }
    if (x == -1) break;
    vis[x][y] = 1;
    ans++;
    if (s[x][y] == 'W')
      diff = 1 - a[x][y];
    else
      diff = -1 - a[x][y];
    for (int i = 1; i <= x; i++)
      for (int j = 1; j <= y; j++) a[i][j] += diff;
  }
  printf("%d\n", ans);
  return 0;
}
