#include <bits/stdc++.h>
int main(void) {
  int n, i, state = 0;
  for (;;) {
    scanf("%d", &n);
    if (n == 0) break;
    int m = 0, point = 0;
    char s[n][2];
    for (i = 0; i < n; i++) scanf("%s", s[i]);
    for (i = 0; i < n; i++) {
      if (state == 0) {
        if (s[i][1] == 'd') point--;
        if (s[i][1] == 'u') {
          point++;
          if (point == 2) {
            m++;
            state = 1;
            point = 0;
          }
        }
      } else if (state == 1) {
        if (s[i][1] == 'u') point--;
        if (s[i][1] == 'd') {
          point++;
          if (point == 2) {
            m++;
            state = 0;
            point = 0;
          }
        }
      }
    }
    printf("%d\n", m);
  }
  return 0;
}
