#include <bits/stdc++.h>
int main() {
  int count;
  int n;
  int i, j;
  char a[10];
  char b[10];
  count = 0;
  while (1) {
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    count = 0;
    strcpy(a, " ");
    strcpy(b, " ");
    for (i = 0; i < n; i++) {
      strcpy(b, a);
      scanf("%s", a);
      if ((strcmp(a, "lu") == 0 && strcmp(b, "ru") == 0) ||
          (strcmp(a, "lu") == 0 && strcmp(b, "ru") == 0) ||
          (strcmp(b, "lu") == 0 && strcmp(a, "ru") == 0) ||
          (strcmp(b, "lu") == 0 && strcmp(a, "ru") == 0) ||
          (strcmp(a, "ld") == 0 && strcmp(b, "rd") == 0) ||
          (strcmp(a, "ld") == 0 && strcmp(b, "rd") == 0) ||
          (strcmp(b, "ld") == 0 && strcmp(a, "rd") == 0) ||
          (strcmp(b, "ld") == 0 && strcmp(a, "rd") == 0)) {
        count++;
      }
    }
    printf("%d\n", count);
  }
}
