#include <bits/stdc++.h>
using namespace std;
const int N = 105;
char ma[N][N];
int main() {
  std::ios::sync_with_stdio(false);
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      ma[i][j] = 'A';
    }
  }
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> ma[i][j];
    }
  }
  int res = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (ma[i][j] != ma[i + 1][j] && ma[i][j] != ma[i][j + 1]) {
        ++res;
        continue;
      }
      if (ma[i][j] == ma[i + 1][j] && ma[i][j] == ma[i][j + 1] &&
          ma[i][j] != ma[i + 1][j + 1]) {
        ++res;
        continue;
      }
      if (ma[i][j] == ma[i + 1][j] && ma[i][j] == ma[i + 1][j + 1] &&
          ma[i][j] != ma[i][j + 1]) {
        ++res;
        continue;
      }
      if (ma[i][j] == ma[i][j + 1] && ma[i][j] == ma[i + 1][j + 1] &&
          ma[i][j] != ma[i + 1][j]) {
        ++res;
        continue;
      }
    }
  }
  cout << res << endl;
  return 0;
}
