#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
template <class T>
ostream &operator<<(std::ostream &o, const vector<T> &v) {
  for (int i = 0; i < v.size(); i++) {
    o << (i > 0 ? " " : "") << v[i];
  }
  return o;
}
int main() {
  int n, flag;
  while (1) {
    cin >> n;
    if (n == 0) break;
    int ans = 0;
    string str, str2;
    stack<string> v;
    flag = 1;
    cin >> str;
    v.push(str);
    for (int i = 0; i < n - 1; i++) {
      cin >> str;
      if (v.empty()) {
        v.push(str);
        if (str[1] == 'u') {
          flag = 1;
        } else {
          flag = 2;
        }
        continue;
      }
      str2 = v.top();
      if (str[0] != str2[0] && str[1] == str2[1] && flag == 1 &&
          str[1] == 'u') {
        v.pop();
        ans++;
        flag = 2;
      } else if (str[0] != str2[0] && str[1] == str2[1] && flag == 2 &&
                 str[1] == 'd') {
        v.pop();
        ans++;
        flag = 1;
      } else {
        v.push(str);
      }
    }
    cout << ans << endl;
  }
}
