#include <bits/stdc++.h>
using namespace std;
char sw(char a) {
  if (a == 'W') return 'B';
  return 'W';
}
int main() {
  int n, m;
  cin >> n >> m;
  int ans = 1;
  char cur;
  char a[120][120];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  int b[120][120];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) b[i][j] = 1;
  cur = a[n - 1][m - 1];
  for (int i = n - 1; i >= 0; i--)
    for (int j = m - 1; j >= 0; j--)
      if (a[i][j] != cur) {
        int del = (-1) - b[i][j];
        if (del != 0) {
          ans++;
          for (int i1 = 0; i1 <= i; i1++)
            for (int j1 = 0; j1 <= j; j1++) b[i1][j1] += del;
        }
      } else {
        int del = (1) - b[i][j];
        if (del != 0) {
          ans++;
          for (int i1 = 0; i1 <= i; i1++)
            for (int j1 = 0; j1 <= j; j1++) b[i1][j1] += del;
        }
      }
  cout << ans << endl;
  return 0;
}
