#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int main() {
  int i, j, n;
  string a;
  while (~scanf("%d", &n)) {
    int ans = 1 << 30;
    cin >> a;
    a = a + a;
    int sum[N] = {0};
    int sumT = 0;
    for (i = 0; i < a.length(); i++) {
      if (i == 0)
        sum[i] = (a[i] == 'T' ? 1 : 0);
      else
        sum[i] = (sum[i - 1] + (a[i] == 'T' ? 1 : 0));
      sumT += (a[i] == 'T' ? 1 : 0);
    }
    sumT /= 2;
    for (i = 0; i < a.length() / 2; i++) {
      j = i + sumT - 1;
      int res = sum[j];
      if (i > 0) res -= sum[i - 1];
      ans = min(ans, sumT - res);
    }
    printf("%d\n", ans);
  }
}
