#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 9;
string s[N];
int n, m, ans;
int val[N][N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr << "‌";
  cin >> n >> m;
  for (int i = 0; i < (n); i++) cin >> s[i];
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (m); j++) {
      if (s[i][j] == 'W')
        s[i][j] = 1;
      else
        s[i][j] = -1;
    }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = m - 1; j >= 0; j--) {
      if (s[i][j] != val[i][j]) {
        int add = s[i][j] - val[i][j];
        ans++;
        for (int e = 0; e <= i; e++) {
          for (int k = 0; k <= j; k++) {
            val[e][k] += add;
          }
        }
      }
    }
  }
  cout << ans;
}
