#include <bits/stdc++.h>
const int N = 111;
using namespace std;
int m, n;
char a[N][N];
int b[N][N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> m >> n;
  for (int i = 1; i <= m; ++i)
    for (int j = 1; j <= n; ++j) cin >> a[i][j];
  int ans = 0;
  for (int i = m; i > 0; --i) {
    for (int j = n; j > 0; --j) {
      int delta = (a[i][j] == 'W' ? 1 : -1) - b[i][j];
      if (delta != 0) {
        ++ans;
        for (int x = 1; x <= i; ++x)
          for (int y = 1; y <= j; ++y) b[x][y] += delta;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
