#include <bits/stdc++.h>
int main() {
  int n;
  char foot, to;
  int right;
  int left;
  int step;
  int count;
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    right = left = 0;
    step = 0;
    count = 0;
    while (n > 0) {
      while (1) {
        scanf("%c", &foot);
        if ((foot == 'l') || (foot == 'r')) break;
      }
      while (1) {
        scanf("%c", &to);
        if ((to == 'u') || (to == 'd')) break;
      }
      if (step == 0) {
        if (((foot = 'l') && (to == 'u') && (right == 1)) ||
            ((foot = 'r') && (to == 'u') && (left == 1))) {
          count++;
          step = 1;
        }
      }
      if (step == 1) {
        if (((foot = 'l') && (to == 'd') && (right == 0)) ||
            ((foot = 'r') && (to == 'd') && (left == 0))) {
          count++;
          step = 0;
        }
      }
      if (foot == 'l') {
        if (to == 'u') left = 1;
        if (to == 'd') left = 0;
      }
      if (foot == 'r') {
        if (to == 'u') right = 1;
        if (to == 'd') right = 0;
      }
      foot = ' ';
      to = ' ';
      n--;
    }
    printf("%d\n", count);
  }
  return 0;
}
