#include <bits/stdc++.h>
using namespace std;
int N, M;
char in[110][110];
int ans = 0;
int col[110];
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; ++i) scanf("%s", &in[i][0]);
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < M; ++j)
      if (in[i][j] == 'B')
        in[i][j] = 1;
      else
        in[i][j] = -1;
  fill(col, col + M, 0);
  for (int i = N - 1; i >= 0; --i)
    for (int j = M - 1; j >= 0; --j) {
      int take = col[j] - in[i][j];
      if (take != 0) ans += 1;
      for (int p = 0; p <= j; ++p) col[p] -= take;
    }
  cout << ans << '\n';
  return 0;
}
