#include <bits/stdc++.h>
using namespace std;
char x[110][100];
int a[110][110], b[110][110];
int main() {
  int m, n;
  cin >> m >> n;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      cin >> x[i][j];
      a[i][j] = 0;
      if (x[i][j] == 'W')
        b[i][j] = 1;
      else
        b[i][j] = -1;
    }
  }
  int c = 0, r;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = m - 1; j >= 0; j--) {
      if (a[j][i] != b[j][i]) {
        r = b[j][i] - a[j][i];
        for (int q = i; q >= 0; q--) {
          for (int z = j; z >= 0; z--) {
            a[z][q] += r;
          }
        }
        c++;
      }
    }
  }
  cout << c << endl;
  return 0;
}
