#include <bits/stdc++.h>
using namespace std;
int a[110][110];
vector<string> v;
void add(int x, int y, int val) {
  int i, j, k;
  for (i = 0; i <= x; i++)
    for (j = 0; j <= y; j++) a[i][j] += val;
  return;
}
int main() {
  int i, j, k, n, m, ans = 0;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) a[i][j] = 0;
  for (i = 0; i < n; i++) {
    string s;
    cin >> s;
    v.push_back(s);
  }
  for (i = n - 1; i >= 0; i--) {
    for (j = m - 1; j >= 0; j--) {
      if (v[i][j] == 'W' && a[i][j] != 1) {
        ans += 1;
        add(i, j, 1 - a[i][j]);
      } else if (v[i][j] == 'B' && a[i][j] != -1) {
        ans += 1;
        add(i, j, -1 - a[i][j]);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
