#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  char s[1100];
  scanf("%s", s);
  int i, homa = 0, ans = n;
  for (i = 0; i < n; i++)
    if (s[i] == 'H') homa++;
  for (i = 0; i < n; i++) {
    int j, tiger = 0;
    for (j = i; j < i + homa; j++) {
      if (s[j % n] == 'T') tiger++;
    }
    ans = min(ans, tiger);
  }
  printf("%d", ans);
  return 0;
}
