#include <bits/stdc++.h>
using namespace std;
static const int N = 101;
char d[N][N];
int di[3] = {1, 1, 0};
int dj[3] = {0, 1, 1};
int n, m;
bool dif(int i, int j, int i2, int j2) {
  if (i2 == n || j2 == m) return 1;
  return (d[i][j] != d[i2][j2]);
}
int main() {
  scanf("%i", &n);
  scanf("%i", &m);
  for (int i = 0; i < n; i++) scanf("%s", &d[i]);
  int res = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      int df = 0;
      for (int k = 0; k < 3; k++)
        if (dif(i, j, i + di[k], j + dj[k])) df += 1 << k;
      if (df == 1 || df == 2 || df == 4 || df == 5 || df == 7) {
        res++;
      }
    }
  printf("%i\n", res);
  return 0;
}
