#include <bits/stdc++.h>
int main() {
  int n;
  int i;
  int flag, count;
  char c[300];
  int Answer[100], a = 0;
  for (;;) {
    scanf("%d", &n);
    if (n == 0) break;
    for (i = 0; i < 3 * n; i++) scanf("%c", &c[i]);
    flag = 0, count = 0;
    for (i = 1; i < 3 * n; i += 3) {
      if (c[i + 1] == 'u') {
        if (flag == 0)
          flag++;
        else if (flag == 1) {
          count++;
          flag = 0;
        } else if (flag == -1)
          flag++;
      } else {
        if (flag == 0)
          flag--;
        else if (flag == -1) {
          count++;
          flag = 0;
        } else if (flag == 1)
          flag--;
      }
    }
    Answer[a] = count;
    a++;
  }
  for (i = 0; i < a; i++) printf("%d\n", Answer[i]);
  return 0;
}
