#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  int k = 0;
  for (int i = 0; i < n; i++)
    if (s[i] == 'T') k++;
  int ans = n + 2;
  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = i, x = 0; x < k; x++, j++, j %= n) {
      if (s[j] != 'T') sum++;
    }
    ans = min(ans, sum);
  }
  cout << ans;
  return 0;
}
