#include <bits/stdc++.h>
int main() {
  int n, i, counter, lu, ld, ru, rd;
  char s[3];
  while (1) {
    lu = 2;
    ld = 2;
    ru = 2;
    rd = 2;
    counter = 0;
    scanf("%d", &n);
    if (n == 0) break;
    for (i = 0; i < n; i++) {
      scanf("%s", s);
      if (s[1] == 'u') {
        if (s[0] == 'l')
          lu = 1;
        else if (s[0] == 'r')
          ru = 1;
        if (lu == 1 && ru == 1) {
          counter++;
          lu = 2;
          ru = 2;
        }
      } else if (s[1] == 'd') {
        if (s[0] == 'l')
          ld = 0;
        else if (s[0] == 'r')
          rd = 0;
        if (ld == 0 && rd == 0) {
          counter++;
          ld = 2;
          rd = 2;
        }
      }
    }
    printf("%d\n", counter);
  }
  return 0;
}
