#include <bits/stdc++.h>
using namespace std;
int BIT[200 + 10][200 + 10], mxval;
void update(int r, int idx, int val) {
  idx++;
  while (idx <= mxval) BIT[r][idx] += val, idx += idx & -idx;
}
long long int query(int r, int idx) {
  long long int ret = 0;
  idx++;
  while (idx) ret += BIT[r][idx], idx -= idx & -idx;
  return ret;
}
string in[200 + 10];
int main() {
  int i, j, k, t, cs, n, m, mn, mx, cur, res = 0, inc;
  char ch;
  mxval = 200;
  scanf("%d %d", &n, &m);
  for (i = 0; i < n; i++) cin >> in[i];
  for (i = n; i >= 1; i--)
    for (j = m; j >= 1; j--) {
      cur = query(i, j);
      ch = in[i - 1][j - 1];
      if (ch == 'W') {
        if (cur != 1)
          res++;
        else
          continue;
        for (k = 1; k <= i; k++) {
          update(k, 1, 1 - cur);
          update(k, j + 1, cur - 1);
        }
      } else {
        if (cur != -1)
          res++;
        else
          continue;
        for (k = 1; k <= i; k++) {
          update(k, 1, -1 - cur);
          update(k, j + 1, cur + 1);
        }
      }
    }
  cout << res << endl;
  return 0;
}
