#include <bits/stdc++.h>
using namespace std;
ifstream fin("in.in");
ofstream fout("out.out");
const int N = 100 + 10;
int n, m, res[2], a[N][N][2];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      char in;
      cin >> in;
      a[i][j][0] = ((in == 'W') ? (1) : (-1));
      a[i][j][1] = -a[i][j][0];
    }
  for (int t = 0; t < 2; t++)
    for (int i = n - 1; i >= 0; i--)
      for (int j = m - 1; j >= 0; j--) {
        int c = a[i][j][t] - 1;
        res[t] += !!c;
        for (int x = 0; x <= i; x++)
          for (int y = 0; y <= j; y++) a[x][y][t] -= c;
      }
  cout << min(res[0], res[1]) + 1 << endl;
  return 0;
}
