#include <bits/stdc++.h>
using namespace std;
using namespace std;
int main() {
  while (true) {
    int ans = 0;
    int n;
    cin >> n;
    if (!n) break;
    stack<int> stl;
    stack<int> str;
    char s[2];
    scanf("%s", s);
    int lastsize = 0;
    for (int i = 0; i < n; i++) {
      if (i != 0) scanf("%s", s);
      if (strcmp(s, "lu") == 0) stl.push(1);
      if (strcmp(s, "ld") == 0) stl.pop();
      if (strcmp(s, "ru") == 0) str.push(1);
      if (strcmp(s, "rd") == 0) str.pop();
      int lsize = stl.size();
      int rsize = str.size();
      if (lsize == rsize && lsize != lastsize) {
        ans++;
        lastsize = lsize;
      }
    }
    cout << ans << endl;
  }
}
