#include <bits/stdc++.h>
using namespace std;
int n, m;
int color[128][128];
int value[128][128];
int ans;
void debug() {
  int i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) cout << value[i][j] << " ";
    cout << endl;
  }
}
void fix(int x, int y) {
  int i, j;
  int val = color[x][y] - value[x][y];
  for (i = 0; i <= x; i++) {
    for (j = 0; j <= y; j++) value[i][j] += val;
  }
  ans++;
}
int main() {
  int i, j;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    string a;
    cin >> a;
    for (j = 0; j < m; j++) {
      if (a[j] == 'W')
        color[i][j] = 1;
      else
        color[i][j] = -1;
    }
  }
  while (1) {
    bool different = 1;
    for (i = n - 1; i >= 0; i--) {
      if (different == 0) break;
      for (j = m - 1; j >= 0; j--) {
        if (value[i][j] != color[i][j]) {
          fix(i, j);
          different = 0;
          break;
        }
      }
    }
    if (different == 1) break;
  }
  cout << ans << endl;
  return 0;
}
