#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long INFL = LLONG_MAX;
const long double pi = acos(-1);
int N, M;
int goal[111][111];
int current[111][111];
int main() {
  ios_base::sync_with_stdio(0);
  cout.precision(15);
  cout << fixed;
  cout.tie(0);
  cin.tie(0);
  cin >> N >> M;
  int cnt = 0;
  for (int(i) = 1, j123 = N; (i) <= j123; (i)++)
    for (int(j) = 1, j123 = M; (j) <= j123; (j)++) {
      char ch;
      cin >> ch;
      if (ch == 'B')
        goal[i][j] = -1;
      else
        goal[i][j] = 1;
    }
  for (int i = N; i >= 1; i--)
    for (int j = M; j >= 1; j--) {
      if (goal[i][j] != current[i][j]) {
        cnt++;
        int delta = goal[i][j] - current[i][j];
        for (int(ii) = 1, j123 = i; (ii) <= j123; (ii)++)
          for (int(jj) = 1, j123 = j; (jj) <= j123; (jj)++)
            current[ii][jj] += delta;
      }
    }
  cout << cnt << '\n';
}
