#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    string str;
    int N;
    cin >> N;
    if (N == 0) break;
    int f = 0;
    int count = 0;
    for (int i = 0; i < N; i++) {
      cin >> str;
      if (str[0] == 'l') {
        if (str[1] == 'u') {
          if (f == 1) {
            f = 2;
            count++;
          } else if (f == 0)
            f = 1;
        } else if (str[1] == 'd') {
          if (f == 2)
            f = 3;
          else if (f == 3) {
            f = 0;
            count++;
          }
        }
      } else if (str[0] == 'r') {
        if (str[1] == 'u') {
          if (f == 1) {
            f = 2;
            count++;
          } else if (f == 0)
            f = 1;
        } else if (str[1] == 'd') {
          if (f == 2)
            f = 3;
          else if (f == 3) {
            f = 0;
            count++;
          }
        }
      }
    }
    cout << count << endl;
  }
  return 0;
}
