#include <bits/stdc++.h>
using namespace std;
template <typename T>
void hash_combine(size_t& seed, const T& val) {
  seed ^= hash<T>()(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}
template <typename T, typename... Ts>
void hash_combine(size_t& seed, const T& val, const Ts&... args) {
  hash_combine(seed, val);
  hash_combine(seed, args...);
}
void hash_combine(size_t&) {}
template <typename... Ts>
size_t hash_val(const Ts&... args) {
  size_t seed = 0;
  hash_combine(seed, args...);
  return seed;
}
using pt = pair<long long int, long long int>;
using vec2 = pair<pt, pt>;
struct union_find {
  union_find(int n) : A(n), R(n) {
    for (int i = 0; i < (n); ++i) A[i] = i;
    for (int i = 0; i < (n); ++i) R[i] = 0;
  }
  int find(int i) {
    if (A[i] != i) {
      A[i] = find(A[i]);
    }
    return A[i];
  }
  int union_(int i, int j) {
    i = find(i);
    j = find(j);
    if (i != j) {
      if (R[i] < R[j]) {
        A[i] = j;
      } else if (R[j] < R[i]) {
        A[j] = i;
        R[i] += R[i] == R[j];
      }
    }
    return A[i];
  }
  vector<int> A;
  vector<int> R;
};
long long int A[101][101];
int main(int, char**) {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < (n); ++i) {
    string s;
    cin >> s;
    for (int j = 0; j < (m); ++j)
      if (s[j] == 'W')
        A[i][j] = 1;
      else
        A[i][j] = -1;
  }
  int r = 0;
  for (int ipj = (n + m - 2); ipj >= (0); --ipj)
    for (int i = 0; i < (n); ++i) {
      int j = ipj - i;
      if (i >= 0 && j >= 0 && i < n && j < m) {
        if (A[i][j] != 0) {
          long long int v = A[i][j];
          r += 1;
          for (int x = 0; x < (i + 1); ++x)
            for (int y = 0; y < (j + 1); ++y) {
              A[x][y] -= v;
            }
        }
      }
    }
  cout << r << endl;
  return 0;
}
