#include <bits/stdc++.h>
using namespace std;
int fen[210][210];
void ins(int i, int j, int v) {
  i++;
  j++;
  for (int ci = i; ci > 0; ci -= ci & -ci) {
    for (int cj = j; cj > 0; cj -= cj & -cj) {
      fen[ci][cj] += v;
    }
  }
}
int get(int i, int j) {
  i++;
  j++;
  int ret = 0;
  for (int ci = i; ci <= 200; ci += ci & -ci) {
    for (int cj = j; cj <= 200; cj += cj & -cj) {
      ret += fen[ci][cj];
    }
  }
  return ret;
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<string> V(N);
  for (int i = 0; i < N; ++i) {
    cin >> V[i];
  }
  vector<vector<long long> > VV(N, vector<long long>(M, 0));
  for (int i = N - 1; i >= 0; --i) {
    for (int j = M - 1; j >= 0; --j) {
      int g = get(i, j);
      if (V[i][j] == 'B') {
        if (g != -1) {
          ins(i, j, -g - 1);
          VV[i][j] = 1;
        }
      } else {
        if (g != 1) {
          ins(i, j, -g + 1);
          VV[i][j] = 1;
        }
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      cnt += VV[i][j];
    }
  }
  cout << cnt << endl;
}
