#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    string str, str2;
    int N;
    cin >> N;
    if (N == 0) break;
    int count = 0;
    if (N == 1)
      cin >> str;
    else {
      for (int i = 0; i < N / 2; i++) {
        cin >> str;
        cin >> str2;
        if (str[1] == str2[1]) count++;
      }
    }
    cout << count << endl;
  }
  return 0;
}
