#include <bits/stdc++.h>
using namespace std;
bool DBG;
struct dbg {
  template <typename T>
  dbg& operator,(const T& v) {
    if (DBG) cerr << v << " ";
    return *this;
  }
  ~dbg() {
    if (DBG) cerr << endl;
  }
};
int main(int argc, char const* argv[]) {
  DBG = (argc > 1 && *argv[1]);
  int n, m;
  cin >> n >> m;
  string s[n];
  for (int i = 0; i < n; ++i) cin >> s[i];
  int value = 0;
  int grid[n][m];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) grid[i][j] = 0;
  int painted = 0;
  for (int i = n - 1; i >= 0; --i) {
    for (int j = m - 1; j >= 0; --j) {
      int color = s[i][j] == 'W' ? 1 : -1;
      if (grid[i][j] != color) {
        int change = (color - grid[i][j]);
        for (int r = 0; r <= i; ++r) {
          for (int p = 0; p <= j; ++p) {
            grid[r][p] = grid[r][p] + change;
          }
        }
        value++;
      }
    }
  }
  cout << value << endl;
  return 0;
}
