#include <bits/stdc++.h>
using namespace std;
int M[111][111];
int V[111][111];
int ans = 0;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char ch;
      cin >> ch;
      V[i][j] = (ch == 'W');
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int j = m; j >= 1; j--) {
      if (V[i][j]) {
        if (M[i][j] != 1) {
          ans++;
          for (int l = 1; l <= i; l++)
            for (int k = 1; k <= j; k++) M[l][k] += (1 - M[i][j]);
        }
      } else {
        if (M[i][j] != -1) {
          ans++;
          for (int l = 1; l <= i; l++)
            for (int k = 1; k <= j; k++) M[l][k] += (-1 - M[i][j]);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
