#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "{";
  for (const T &a : v) out << a << ", ";
  out << "}";
  return out;
}
template <typename S, typename T>
ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}
int z, n, m;
string s[207];
int tab[207][207];
int col[207];
int ret;
void change(int a, int b, int c) {
  for (int i = b; i >= 0; i--) col[i] += c;
}
int val(int a, int b) { return (tab[a][b] + col[b]); }
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < (int)n; i++) cin >> s[i];
  for (int i = 0; i < (int)n; i++)
    for (int j = 0; j < (int)m; j++) s[i][j] = (s[i][j] == 'W' ? 1 : -1);
  for (int i = n - 1; i >= 0; i--)
    for (int j = m - 1; j >= 0; j--) {
      if (val(i, j) != s[i][j]) {
        ret++;
        change(i, j, s[i][j] - val(i, j));
      }
    }
  cout << ret << endl;
}
