#include <bits/stdc++.h>
int main() {
  char o[3], n[3], sute;
  int k, cou, i, stay;
  while (1) {
    scanf("%d", &k);
    if (k == 0) break;
    stay = 0;
    cou = 0;
    for (i = 0; i < k / 2; i++) {
      scanf("%s %s", o, n);
      if (o[1] == 'u' && n[1] == 'u' && stay == 0) {
        cou++;
        stay = 1;
      } else if (o[1] == 'd' && n[1] == 'd' && stay == 1) {
        cou++;
        stay = 0;
      }
    }
    if (k % 2 == 1) scanf("%s", sute);
    printf("%d\n", cou);
  }
  return 0;
}
