#include <bits/stdc++.h>
using namespace std;
char x[100][101];
int s[100], n, m, r = 0;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> x[i];
  for (int i = 0; i < n; i++) {
    int b = 0;
    for (int j = 0; j < m; j++)
      if (auto k = (b += s[j]) + x[n - 1 - i][m - 1 - j] % 2 * 2 - 1)
        s[j] -= k, b -= k, r++;
  }
  cout << r << '\n';
}
