#include <bits/stdc++.h>
using namespace std;
string itoa(int i) {
  stringstream ss;
  ss << i;
  return ss.str();
}
int getSol(string s, char t, int num) {
  int res = num + 1;
  for (int i = (0); i < (s.length()); ++i) {
    string subs = s.substr(i, num);
    if (subs.length() < num) {
      subs = subs + s.substr(0, num - subs.length());
    }
    int cnt = count(subs.begin(), subs.end(), t);
    res = min(res, num - cnt);
  }
  return res;
}
int main() {
  int length;
  string input;
  int res;
  cin >> length;
  cin >> input;
  int hnum = count(input.begin(), input.end(), 'H');
  int tnum = length - hnum;
  if (hnum < tnum)
    res = getSol(input, 'H', hnum);
  else
    res = getSol(input, 'T', tnum);
  cout << res << endl;
  return 0;
}
