#include <bits/stdc++.h>
using namespace std;
const int N = 104;
int n, m, a[N][N], d[N][N];
char s[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < int(n); i++) {
    scanf("%s", s);
    for (int j = 0; j < int(m); j++)
      if (s[j] == 'B')
        a[i][j] = -1;
      else
        a[i][j] = 1;
  }
  for (int i = 0; i < int(n); i++)
    for (int j = 0; j < int(m); j++) {
      d[i][j] = 2;
      if (i == n - 1 || j == m - 1) d[i][j] = 1;
    }
  queue<pair<int, int> > q;
  int ans = 0;
  q.push(pair<int, int>(n - 1, m - 1));
  while (!q.empty()) {
    int i = q.front().first, j = q.front().second;
    q.pop();
    if (a[i][j]) ans++;
    for (int u = 0; u < int(i + 1); u++)
      for (int v = 0; v < int(j + 1); v++) a[u][v] -= a[i][j];
    if (i - 1 >= 0) {
      d[i - 1][j]--;
      if (d[i - 1][j] == 0) q.push(pair<int, int>(i - 1, j));
    }
    if (j - 1 >= 0) {
      d[i][j - 1]--;
      if (d[i][j - 1] == 0) q.push(pair<int, int>(i, j - 1));
    }
  }
  printf("%d\n", ans);
  return 0;
}
