#include <bits/stdc++.h>
using namespace std;
int n, ans = int(1e9), cur = 0, t = 0;
char ch[2001];
void solve() {
  int l = 0, r = 0;
  while (r < t) {
    if (ch[r] == 'T') {
      cur++;
    }
    r++;
  }
  r--;
  for (; r < 2 * n; ++r, ++l) {
    ans = min(ans, t - cur);
    if (ch[l] == 'T') {
      cur--;
    }
    if (r + 1 < 2 * n) {
      if (ch[r + 1] == 'T') {
        cur++;
      }
    }
  }
}
int main(int argc, char *argv[]) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf(" %c", &ch[i]);
    if (ch[i] == 'T') {
      t++;
    }
  }
  for (int i = n; i < 2 * n; ++i) {
    ch[i] = ch[i - n];
  }
  solve();
  printf("%d", ans);
  return 0;
}
