#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  while (n != 0) {
    int jyotai = 0, cnt = 0;
    char f[3];
    for (int lop = 0; lop < n; lop++) {
      cin >> f;
      if (f[0] == 'l' && f[1] == 'u') {
        switch (jyotai) {
          case 0:
            jyotai = 1;
            break;
          case 2:
            jyotai = 3;
            cnt++;
            break;
          default:
            break;
        }
      } else if (f[0] == 'r' && f[1] == 'u') {
        switch (jyotai) {
          case 0:
            jyotai = 2;
            break;
          case 1:
            jyotai = 3;
            cnt++;
            break;
          default:
            break;
        }
      } else if (f[0] == 'l' && f[1] == 'd') {
        switch (jyotai) {
          case 3:
            jyotai = 4;
            break;
          case 5:
            jyotai = 1;
            cnt++;
            break;
          default:
            break;
        }
      } else if (f[0] == 'r' && f[1] == 'd') {
        switch (jyotai) {
          case 3:
            jyotai = 5;
            break;
          case 4:
            jyotai = 1;
            cnt++;
            break;
          default:
            break;
        }
      }
    }
    jyotai = 0;
    cout << cnt << endl;
    cin >> n;
  }
  return 0;
}
