#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ans = 100000000;
  cin >> n;
  string s, ss;
  cin >> s;
  for (int i = 0; i < s.length(); ++i) {
    ss = s.substr(i, n - i) + s.substr(0, i);
    int l = 0, r = n - 1, sum = 0;
    while (l < r) {
      while (ss[l] == 'H') ++l;
      while (ss[r] == 'T') --r;
      if (l < r) {
        swap(ss[l], ss[r]);
        ++l;
        --r;
        ++sum;
      }
    }
    ans = min(ans, sum);
  }
  cout << max(ans, 0);
  return 0;
}
