#include <bits/stdc++.h>
int main() {
  int i, n, cont = 0;
  char S[100][2];
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    for (i = 0; i < n; i++) {
      scanf("%s", S[i]);
    }
    for (i = 0; i < n; i++) {
      if (S[i][1] == S[i + 1][1] && S[i][0] != S[i + 1][0]) cont++;
    }
    printf("%d\n", cont);
    cont = 0;
  }
  return 0;
}
