#include <bits/stdc++.h>
using namespace std;
const long long INF = 1 << 28;
const long long LINF = 1ll << 61;
inline long long getnum() {
  register long long r = 0;
  register bool ng = 0;
  register char c;
  c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') ng = 1, c = getchar();
  while (c != ' ' && c != '\n') r = r * 10 + c - '0', c = getchar();
  if (ng) r = -r;
  return r;
}
template <class T>
inline void putnum(T x) {
  if (x < 0) putchar('-'), x = -x;
  register short a[20] = {}, sz = 0;
  while (x > 0) a[sz++] = x % 10, x /= 10;
  if (sz == 0) putchar('0');
  for (int i = sz - 1; i >= 0; i--) putchar('0' + a[i]);
}
inline void putsp() { putchar(' '); }
inline void putendl() { putchar('\n'); }
int n, m;
char g[111][111];
int c[111][111];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> g[i][j];
    }
  }
  int ans = 0;
  for (int i = n; i >= 1; i--) {
    for (int j = m; j >= 1; j--) {
      if (g[i][j] == 'W' && c[i][j] != 1 || g[i][j] == 'B' && c[i][j] != -1) {
        int delta;
        if (g[i][j] == 'W')
          delta = 1 - c[i][j];
        else
          delta = -1 - c[i][j];
        for (int k = 1; k <= i; k++) {
          for (int l = 1; l <= j; l++) {
            c[k][l] += delta;
          }
        }
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
