#include <bits/stdc++.h>
using namespace std;
int N, M, Dp[105][105], sol;
char cad[105][105];
queue<pair<int, int> > Q;
const int pf[2] = {-1, 0};
const int pc[2] = {0, -1};
bool mark[105][105];
void Bfs() {
  Q.push(pair<int, int>(N, M));
  sol = 1;
  if (cad[N][M] == 'W')
    Dp[N][M] = 1;
  else
    Dp[N][M] = -1;
  mark[N][M] = true;
  int fil, col, nf, nc, val, v1;
  while (!Q.empty()) {
    fil = Q.front().first, col = Q.front().second;
    Q.pop();
    for (int i = 0; i < 2; i++) {
      nf = fil + pf[i], nc = col + pc[i];
      if (nf < 1 || nc < 1) continue;
      if (mark[nf][nc]) continue;
      mark[nf][nc] = true;
      if (cad[nf][nc] == 'W')
        val = 1;
      else
        val = -1;
      Dp[nf][nc] = Dp[nf + 1][nc] + Dp[nf][nc + 1] - Dp[nf + 1][nc + 1];
      if (Dp[nf][nc] != val) sol++;
      val = val - Dp[nf][nc];
      Dp[nf][nc] += val;
      Q.push(pair<int, int>(nf, nc));
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= N; i++) scanf("%s", cad[i] + 1);
  Bfs();
  printf("%d", sol);
  return 0;
}
