#include <bits/stdc++.h>
using namespace std;
namespace stuff {
void solve(int test_num) {
  int R, C;
  cin >> R >> C;
  vector<string> grid(R);
  for (int r = 0; r < R; r++) cin >> grid[r];
  vector<vector<int> > cnt(R, vector<int>(C, 0));
  for (int r = 0; r < R; r++) {
    for (int c = 0; c < C; c++) {
      const int X = grid[r][c] == 'W' ? 1 : -1;
      cnt[r][c] += X;
      if (r > 0) cnt[r - 1][c] -= X;
      if (c > 0) cnt[r][c - 1] -= X;
      if (r > 0 && c > 0) cnt[r - 1][c - 1] += X;
    }
  }
  int res = 0;
  for (int r = 0; r < R; r++)
    for (int c = 0; c < C; c++)
      if (cnt[r][c] != 0) res++;
  cout << res << endl;
}
void solve() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  for (int t = 1; t <= T; t++) solve(t);
}
}  // namespace stuff
int main() {
  stuff::solve();
  return 0;
}
