#include <bits/stdc++.h>
int main() {
  int i, j, k, l, c, h = 0, swp, x;
  int ans = (int)1e7;
  char seq[1020];
  scanf("%d", &c);
  for (i = 0; i < c; i++) {
    scanf(" %c", &seq[i]);
    h += (seq[i] == 'H');
  }
  for (j = 0; j < i; j++) {
    swp = 0;
    for (k = j, l = 0; l < h; k = (k + 1) % i, l++) {
      swp += (seq[k] == 'T');
    }
    ans = ans < swp ? ans : swp;
  }
  printf("%d\n", ans);
  return 0;
}
