#include <bits/stdc++.h>
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
string board[111];
int target[111][111];
int now[111][111];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> board[i];
    for (int j = 0; j < m; j++) {
      char c = board[i][j];
      if (c == 'W')
        target[i][j] = 1;
      else
        target[i][j] = -1;
    }
  }
  int ans = 0;
  int cur = n * m - 1;
  for (; cur >= 0; cur--) {
    int y = cur / m, x = cur % m;
    if (now[y][x] != target[y][x]) {
      int diff = target[y][x] - now[y][x];
      for (int i = 0; i <= y; i++) {
        for (int j = 0; j <= x; j++) {
          now[i][j] += diff;
        }
      }
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
