#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t, r, aux, aux2, c1, c2;
  string s;
  char obj;
  cin >> n;
  cin >> s;
  t = s.size();
  s = s + s;
  r = 10000;
  c1 = 0;
  c2 = 0;
  for (int i = 0; i < t; i++) {
    if (s[i] == 'H')
      c1++;
    else
      c2++;
  }
  if (c1 > c2)
    obj = 'T';
  else
    obj = 'H';
  aux2 = min(c1, c2);
  for (int i = 0; i < t; i++) {
    aux = 0;
    for (int j = i; j < aux2 + i; j++) {
      if (s[j] != obj) aux++;
    }
    r = min(aux, r);
  }
  cout << r;
  return 0;
}
