#include <bits/stdc++.h>
int main(void) {
  int N, M;
  int x = 0;
  char s[N][20], t[M][20];
  scanf("%d", &N);
  scanf("%d", &M);
  for (int i = 0; i <= N; i++) {
    scanf("%s", s);
    if (s[N][i] == s[N][i + 1]) x++;
    for (int j = 0; j <= M; j++) {
      scanf("%s", t);
      if (s[N][i] == t[M][j]) x--;
      break;
    }
  }
  printf("%d", x);
  return 0;
}
