#include <bits/stdc++.h>
int main(void) {
  int count = -1;
  int i, j, k;
  int count_exercise = 0;
  while (scanf("%d", &count), count) {
    char exercise[320] = {};
    gets(exercise);
    count = count * 2;
    for (i = 0; i < count; i += 4) {
      if (count == 2) break;
      if (*(exercise + i + 1) == *(exercise + i + 3) &&
          *(exercise + i) != *(exercise + i + 2))
        count_exercise++;
    }
    count_exercise = 0;
    if (count_exercise != 0) printf("%d\n", count_exercise + 1);
  }
  return 0;
}
