#include <bits/stdc++.h>
using namespace std;
char str[200];
int arr[200][200], dp[200][200];
int main() {
  int n, m, i, j, ans = 0;
  scanf("%d", &n);
  scanf("%d", &m);
  for (i = 0; i < n; i++) {
    scanf("%s", str);
    for (j = 0; j < m; j++)
      if (str[j] == 'B')
        arr[i][j] = 1;
      else
        arr[i][j] = -1;
  }
  for (i = n - 1; i >= 0; i--) {
    for (j = m - 1; j >= 0; j--) {
      dp[i][j] = dp[i + 1][j] + dp[i][j + 1] - dp[i + 1][j + 1];
      if (dp[i][j] != arr[i][j]) ans++, dp[i][j] = arr[i][j];
    }
  }
  printf("%d\n", ans);
}
