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