#include <bits/stdc++.h>
using namespace std;
char board[110][110];
int a[110][110], b[110][110];
int main() {
  int N, M, ans;
  scanf("%d%d", &N, &M);
  for (int i = (0); i < (N); i++) scanf("%s", board[i]);
  for (int i = (0); i < (N); i++)
    for (int j = (0); j < (M); j++)
      if (board[i][j] == 'W')
        a[i][j] = 1;
      else
        a[i][j] = -1;
  ans = 1;
  for (int i = (0); i < (N); i++)
    for (int j = (0); j < (M); j++) b[i][j] = a[N - 1][M - 1];
  for (int i = N - 1; i >= 0; i--)
    for (int j = M - 1; j >= 0; j--) {
      if (a[i][j] == b[i][j]) continue;
      int t = a[i][j] - b[i][j];
      for (int k = (0); k < (i + 1); k++)
        for (int l = (0); l < (j + 1); l++) b[k][l] += t;
      ans++;
    }
  printf("%d\n", ans);
  return 0;
}
