#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    int steps, count = 0;
    cin >> steps;
    if (steps == 0) {
      break;
    }
    char leg1[2], leg2[2];
    for (int i = 0; i < steps / 2; i++) {
      cin >> leg1 >> leg2;
      if (leg1 == "lu" && leg2 == "ru") {
        count = count + 1;
      }
      if (leg1 == "ru" && leg2 == "lu") {
        count = count + 1;
      }
      if (leg1 == "ld" && leg2 == "rd") {
        count = count + 1;
      }
      if (leg1 == "rd" && leg2 == "ld") {
        count = count + 1;
      }
    }
    cout << count;
  };
  return 0;
}
