#include <bits/stdc++.h>
using namespace std;
int n, m, d[101][101], c, ans;
char a[101][101];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j];
  for (int i = n; i >= 1; i--)
    for (int j = m; j >= 1; j--)
      if ((a[i][j] == 'B' && d[i][j] != -1) ||
          (a[i][j] == 'W' && d[i][j] != 1)) {
        ans++;
        if (a[i][j] == 'B')
          c = d[i][j] + 1;
        else
          c = d[i][j] - 1;
        for (int k = i; k >= 1; k--)
          for (int l = j; l >= 1; l--) d[k][l] -= c;
      }
  cout << ans << endl;
  return 0;
}
