#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  while (cin >> n, n) {
    int count = 0;
    int state = 0;
    for (int i = 0; i < int(n); ++i) {
      string s;
      cin >> s;
      if (s == "lu") {
        if (state == 0)
          state += 1;
        else if (state == 2) {
          state += 1;
          count++;
        }
      } else if (s == "ru") {
        if (state == 0)
          state += 2;
        else if (state == 1) {
          state += 2;
          count++;
        }
      } else if (s == "ld") {
        if (state == 3)
          state += 1;
        else if (state == 5) {
          state = 0;
          count++;
        }
      } else if (s == "rd") {
        if (state == 3)
          state += 2;
        else if (state == 4) {
          state = 0;
          count++;
        }
      }
    }
    cout << count << endl;
  }
}
