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