#include <bits/stdc++.h>
using namespace std;
char str[111][111];
int c[111];
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    for (int i = 0; i < n; i++) scanf("%s", str[i]);
    memset(c, 0, sizeof(c));
    long long sum = 0;
    for (int i = n - 1; i >= 0; i--) {
      int tmp = 0;
      for (int j = m - 1; j >= 0; j--) {
        tmp += c[j];
        if (str[i][j] == 'W') {
          if (tmp != 1) {
            sum++;
            c[j] += 1 - tmp;
            tmp = 1;
          }
        } else {
          if (tmp != -1) {
            sum++;
            c[j] += -1 - tmp;
            tmp = -1;
          }
        }
      }
    }
    printf("%I64d\n", sum);
  }
  return 0;
}
