#include <bits/stdc++.h>
using namespace std;
int a[101][101];
char ch[101][101];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("\n");
    for (int j = 0; j < m; j++) scanf("%c", &ch[i][j]);
  }
  int ans = 0;
  for (int i = n - 1; i >= 0; i--)
    for (int j = m - 1; j >= 0; j--) {
      int k;
      if (ch[i][j] == 'W')
        k = 1 - a[i][j];
      else
        k = -1 - a[i][j];
      ans += (k != 0);
      for (int x = 0; x <= i; x++)
        for (int y = 0; y <= j; y++) a[x][y] += k;
    }
  cout << ans << endl;
}
