#include <bits/stdc++.h>
using namespace std;
const int N = 2002;
int a[N][N], d[N], t[N][N], ad[N][N], b[N][N];
int n, m;
int get(int ii, int jj) {
  int ans = 0;
  for (int i = ii; i > 0; i -= (i & (-i))) {
    for (int j = jj; j > 0; j -= (j & (-j))) {
      ans += t[i][j];
    }
  }
  return ans;
}
void add(int ii, int jj, int x) {
  ad[ii][jj] += x;
  for (int i = ii; i <= n; i -= (i | (-i))) {
    for (int j = jj; j <= m; j -= (j | (-j))) {
      t[i][j] += x;
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    string str;
    cin >> str;
    for (int j = 1; j <= m; j++) {
      if (str[j - 1] == 'B') {
        b[i][j] = -1;
      } else {
        b[i][j] = 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      ad[i][j] += b[i][j];
      ad[i - 1][j] -= b[i][j];
      ad[i][j - 1] -= b[i][j];
      ad[i - 1][j - 1] += b[i][j];
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      ans += ad[i][j] != 0;
    }
  }
  cout << ans << "\n";
  return 0;
}
