#include <bits/stdc++.h>
using namespace std;
inline int IN() {
  char c;
  register int first = 0;
  for (; (c = getchar()) < 48 && c ^ '-' || c > 57;)
    ;
  bool f = c == '-';
  if (f) (c = getchar());
  for (; c > 47 && c < 58; (c = getchar())) first = first * 10 + c - 48;
  if (f) first = -first;
  return first;
}
char s[205];
int N, M;
int an, A[105][105], B[105][105];
int main() {
  N = IN();
  M = IN();
  for (int _r = N, i = 1; i <= _r; ++i) {
    scanf("%s", s + 1);
    for (int _r = M, j = 1; j <= _r; ++j)
      if (s[j] == 'W')
        A[i][j] = 1;
      else
        A[i][j] = -1;
  }
  for (int _r = N, i = 1; i <= _r; ++i)
    for (int _r = M, j = 1; j <= _r; ++j) B[i][j] = 0;
  for (int i = N; i; --i)
    for (int j = M; j; --j)
      if (B[i][j] ^ A[i][j]) {
        int xx = A[i][j] - B[i][j];
        for (int ii = i; ii; --ii)
          for (int jj = j; jj; --jj) B[ii][jj] += xx;
        ++an;
      }
  printf("%d\n", an);
}
