#include <bits/stdc++.h>
using namespace std;
int i, j, k, it, n, m, a[105][105], rs, value;
char b[105][105];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j) cin >> b[i][j];
  for (i = n; i; --i)
    for (j = m; j; --j) {
      value = ((b[i][j] == 'B') ? 1 - a[i][j] : -1 - a[i][j]);
      if (!value) continue;
      for (k = 1, ++rs; k <= i; ++k)
        for (it = 1; it <= j; ++it) a[k][it] += value;
    }
  cout << rs << '\n';
  return 0;
}
