#include <bits/stdc++.h>
int a[1005], b[1005];
int main() {
  int h = 0, t = 0, n, i, j, min = 2 * 1000, s;
  char x;
  scanf("%d", &n);
  getchar();
  for (i = 0; i < n; i++) {
    scanf("%c", &x);
    if (x == 'H') {
      h++;
      a[i] = 1;
    } else {
      a[i] = 0;
    }
  }
  for (j = 0; j < h; j++) b[j] = 1;
  for (; j < n; j++) b[j] = 0;
  for (i = 0; i < n; i++) {
    s = 0;
    for (j = 0; j < n; j++) {
      s += a[j] ^ b[(j + i) % n];
    }
    if (s < min) min = s;
  }
  printf("%d\n", min / 2);
  return 0;
}
