#include <bits/stdc++.h>
using namespace std;
char mp[110][110];
int add[110];
int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  for (int i = 1; i <= n; i++) scanf("%s", mp[i] + 1);
  for (int i = n; i >= 1; i--) {
    int cur = 0;
    for (int j = m; j >= 1; j--) {
      cur += add[j];
      if (mp[i][j] == 'W') {
        if (cur != -1) {
          ans++;
          add[j] += -1 - cur;
          cur = -1;
        }
      } else {
        if (cur != 1) {
          ans++;
          add[j] += 1 - cur;
          cur = 1;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
