#include <bits/stdc++.h>
using namespace std;
long long n, am = 0, ans = 0, t;
char c[10010];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    c[i + n] = c[i];
    if (c[i] == 'T') am++;
  }
  for (int i = 0; i < n; i++) {
    t = 0;
    for (int j = i; j < i + am; j++)
      if (c[j] == 'T') t++;
    if (t > ans) ans = t;
  }
  cout << am - ans;
  return 0;
}
