#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int b[105][105];
  memset(b, 0, sizeof(b));
  scanf("%d %d\n", &n, &m);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (getchar() == 'B')
        b[i][j] = 1;
      else
        b[i][j] = -1;
    }
    getchar();
  }
  int num = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (b[i][j] + b[i + 1][j + 1] != b[i + 1][j] + b[i][j + 1]) num++;
    }
  }
  printf("%d\n", num);
}
