#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    int ans = 0;
    int uc1 = 0, uc2 = 0, dc1 = 0, dc2 = 0;
    int n;
    cin >> n;
    if (n == 0) break;
    for (int i = 0; i < n; i++) {
      string c;
      cin >> c;
      if (c == "lu") uc1++;
      if (c == "ru") uc2++;
      if (c == "ld") dc1++;
      if (c == "rd") dc2++;
      if (uc1 == 2) uc1 = 1;
      if (uc2 == 2) uc1 = 1;
      if (dc1 == 2) dc1 = 1;
      if (dc2 == 2) dc2 = 1;
      if (uc1 == 1 && uc2 == 1) {
        ans++;
        uc1 = 0;
        uc2 = 0;
      };
      if (dc1 == 1 && dc2 == 1) {
        ans++;
        dc1 = 0;
        dc2 = 0;
      };
    }
    cout << ans << endl;
  }
  return 0;
}
