#include <bits/stdc++.h>
using namespace std;
char mp[110][110];
int a[110];
int main() {
  int n, m;
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 0; i < n; i++) scanf("%s", mp[i]);
    memset(a, 0, sizeof(a));
    int ans = 0;
    for (int i = n - 1; i >= 0; i--) {
      int s = 0;
      for (int j = m - 1; j >= 0; j--) {
        s += a[j];
        if (mp[i][j] == 'W') {
          if (s != 1) {
            ans++;
            a[j] += 1 - s;
            s = 1;
          }
        } else {
          if (s != -1) {
            ans++;
            a[j] += -1 - s;
            s = -1;
          }
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
