#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
const int mod = 1000000007;
const double eps = 1e-9;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int main() {
  int n;
  while (cin >> n, n) {
    int ans = 0;
    for (int i = 0; i < (int)n; ++i) {
      string now = "", next;
      cin >> next;
      if (now == "lu" && next == "ru")
        ans++;
      else if (now == "ru" && next == "lu")
        ans++;
      else if (now == "ld" && next == "rd")
        ans++;
      else if (now == "rd" && next == "ld")
        ans++;
      now = next;
    }
    cout << ans << endl;
  }
  return 0;
}
