#include <bits/stdc++.h>
using namespace std;
const int inf = 1999999999;
const double pi = acos(-1.0);
const double eps = 1e-10;
char gc() {
  char c;
  while (isspace(c = getchar()))
    ;
  return c;
}
int gs(char* s) {
  gets(s);
  int l = strlen(s);
  while (l && isspace(s[l - 1])) s[--l] = 0;
  return l;
}
int getd(string& a, string& b) {
  int c = 0;
  for (int i = 0; i < ((int)(a).size()); i++)
    if (a[i] != b[i]) c++;
  return c;
}
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int hc = 0;
  for (int i = 0; i < n; i++)
    if (s[i] == 'H') hc++;
  string v = "";
  for (int i = 0; i < hc; i++) v += 'H';
  for (int i = hc; i < n; i++) v += 'T';
  int best = inf;
  for (int i = 0; i < n; i++) {
    best = min(best, getd(s, v));
    char c = v[0];
    string s2(v.begin() + 1, v.end());
    v = s2;
    v += c;
  }
  cout << best / 2;
}
