#include <bits/stdc++.h>
using namespace std;
const long long N = 1e3 + 9;
string s;
long long t, h, ans = 1e10;
long long n;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  cin >> s;
  for (int i = 0; i < (n); i++) {
    if (s[i] == 'T')
      t++;
    else
      h++;
  }
  for (int i = 0; i < (n); i++) {
    long long cur = i, res = 0;
    for (int j = 0; j < (t); j++) {
      if (s[cur] != 'T') res++;
      cur = (cur + 1) % n;
    }
    ans = min(ans, res);
  }
  cout << ans << endl;
}
