#include <bits/stdc++.h>
using namespace std;
int n, m;
int d[105][105];
int c[105][105];
vector<pair<int, pair<int, int>>> v;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    string str;
    cin >> str;
    for (int j = 0; j < m; ++j) d[i][j] = 1 - 2 * (str[j] == 'B');
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) c[i][j] = d[n - 1][m - 1];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) v.push_back(make_pair(i + j, make_pair(i, j)));
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  int res = 1;
  for (auto x : v) {
    auto cell = x.second;
    int row = cell.first;
    int col = cell.second;
    if (d[row][col] == c[row][col]) continue;
    ++res;
    int tmp = d[row][col] - c[row][col];
    for (int i = 0; i <= row; ++i)
      for (int j = 0; j <= col; ++j) c[i][j] += tmp;
  }
  cout << res << endl;
  return 0;
}
