#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, step = -1, cnt;
  char in[3];
  while (1) {
    cnt = 0;
    scanf("%d", &n);
    if (n == 0) break;
    for (int i = 0; i < n; i++) {
      if (i == n - 1)
        scanf("%s", &in);
      else
        scanf(" %s", &in);
      if (in[0] == 'r' && in[1] == 'u') {
        if (step == 1) {
          cnt++;
          step = -1;
        } else {
          step = 0;
        }
      }
      if (in[0] == 'l' && in[1] == 'u') {
        if (step == 0) {
          cnt++;
          step = -1;
        } else {
          step = 1;
        }
      }
      if (in[0] == 'r' && in[1] == 'd') {
        if (step == 3) {
          cnt++;
          step = -1;
        } else {
          step = 2;
        }
      }
      if (in[0] == 'l' && in[1] == 'd') {
        if (step == 2) {
          cnt++;
          step = -1;
        } else {
          step = 3;
        }
      }
    }
    cout << cnt;
  }
  return 0;
}
