#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 777;
const int inf = 0x3f3f3f3f;
char s[N];
int sum[N];
int main() {
  int n;
  scanf("%d%s", &n, s + 1);
  sum[0] = 0;
  for (int i = 1; i <= n; ++i) {
    sum[i] = sum[i - 1];
    if (s[i] == 'T') ++sum[i];
  }
  int ans = inf;
  int num = sum[n];
  for (int i = 0; i <= num; ++i) {
    ans = min(ans, sum[n - num + i] - sum[i]);
  }
  for (int i = 0; i <= n - num; ++i) {
    ans = min(ans, num - (sum[num + i] - sum[i]));
  }
  cout << ans << '\n';
  return 0;
}
