#include <bits/stdc++.h>
using namespace std;
int N, i, tigers, st, dr, sum[2010], SOL, cnt;
char S[2010], c;
int main() {
  cin >> N;
  for (i = 1; i <= N; i++) {
    cin >> c;
    S[i] = S[i + N] = c;
    if (c == 'T') tigers = tigers + 1;
  }
  for (i = 1; i <= N + N; i++) {
    sum[i] = sum[i - 1];
    if (S[i] == 'T') sum[i] = sum[i] + 1;
  }
  SOL = 50001;
  for (i = 1; i <= N; i++) {
    st = i;
    dr = st + tigers - 1;
    cnt = tigers - (sum[dr] - sum[st - 1]);
    SOL = min(SOL, cnt);
  }
  cout << SOL;
  return 0;
}
