#include <bits/stdc++.h>
using namespace std;
int main() {
  int a = 0, b = 0, n[150], state, t = 0, sum[150] = {0};
  char str[150][100][3];
  while (1) {
    cin >> n[a];
    if (n[a] == 0) break;
    for (b = 0; b < n[a]; b++) {
      cin >> str[a][b];
    }
    a++;
  }
  for (t = 0; t < a; t++) {
    for (b = 0; b < n[t] / 2; b++) {
      if (str[t][2 * b][0] - str[t][2 * b + 1][0] != 0) sum[t]++;
    }
    cout << sum[t] << endl;
  }
  return 1;
}
