#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  while (cin >> n && n) {
    string s1, s2;
    int ans = 0;
    for (int i = 0; i < n; i += 2) {
      cin >> s1 >> s2;
      if (s1[1] == s2[1] && (s1[1] == 'u' || s1[1] == 'd')) {
        if (s1[0] == s2[0]) ans++;
      }
      cout << ans << endl;
    }
  }
  return 0;
}
