#include <bits/stdc++.h>
using namespace std;
FILE *in;
FILE *out;
const int MAX = 104;
int n, m;
char a[MAX][MAX];
int b[MAX][MAX];
void add(int toRow, int toCol, int value) {
  for (int row = toRow; row >= 0; row--) {
    for (int col = toCol; col >= 0; col--) {
      b[row][col] += value;
    }
  }
}
int eval() {
  int ans = 0;
  for (int row = 0; row < n; row++)
    for (int col = 0; col < m; col++)
      b[row][col] = (a[row][col] == 'W' ? -1 : +1);
  for (int row = n - 1; row >= 0; row--) {
    for (int col = m - 1; col >= 0; col--) {
      if (b[row][col]) {
        add(row, col, -b[row][col]);
        ans++;
      }
    }
  }
  return ans;
}
int main(void) {
  in = stdin;
  out = stdout;
  fscanf(in, "%d %d", &n, &m);
  for (int i = 0; i < n; i++) fscanf(in, "%s", a[i]);
  fprintf(out, "%d\n", eval());
  return 0;
}
