#include <bits/stdc++.h>
using namespace std;
const int N = 1001;
int n;
char tab[N];
char pom[N];
int main() {
  scanf("%d", &n);
  scanf("%s", tab);
  int opt = N * N;
  for (int i = 0; i < (n); ++i) {
    int wyn = 0;
    for (int j = 0; j < (n); ++j) pom[j] = tab[(i + j) % n];
    int p = 0, q = n - 1;
    while (p < q) {
      while (p < n - 1 && pom[p] == 'T') p++;
      while (q >= 0 && pom[q] == 'H') q--;
      if (p >= q) break;
      swap(pom[p], pom[q]);
      wyn++;
    }
    opt = min(opt, wyn);
  }
  printf("%d\n", opt);
}
