#include <bits/stdc++.h>
using namespace std;
int n, m;
int d[255][255], c[255][255];
bool used[255][255];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int(i) = (1); (i) <= (n); i++) {
    for (int(j) = (1); (j) <= (m); j++) {
      char ch;
      cin >> ch;
      if (ch == 'B')
        d[i][j] = 0;
      else
        d[i][j] = 1;
    }
  }
  int res = 0, val = 0;
  for (int(i) = (1); (i) <= (n); i++) {
    for (int(j) = (1); (j) <= (m); j++) {
      if (d[i][j]) {
        c[i][j]++;
        c[i - 1][j]--;
        c[i][j - 1]--;
        c[i - 1][j - 1]++;
      } else {
        c[i][j]--;
        c[i - 1][j]++;
        c[i][j - 1]++;
        c[i - 1][j - 1]--;
      }
    }
  }
  for (int(i) = (1); (i) <= (n); i++) {
    for (int(j) = (1); (j) <= (m); j++) {
      if (!(c[i][j] == 0)) res++;
    }
  }
  cout << res << '\n';
  return 0;
}
