#include <bits/stdc++.h>
using namespace std;
int main() {
  char str[2020];
  long l;
  cin >> l;
  cin >> str;
  int i, j, hs = 0, ts = 0;
  for (i = 0; i < l; i++) {
    if (str[i] == 'H')
      hs++;
    else
      ts++;
    str[l + i] = str[i];
  }
  int res = 1000000000;
  int t;
  for (i = 0; i < l; i++) {
    t = 0;
    for (j = 0; j < hs; j++) {
      if (str[i + j] == 'T') t++;
    }
    if (t < res) res = t;
    t = 0;
    for (j = 0; j < ts; j++) {
      if (str[i + j] == 'H') t++;
    }
    if (t < res) res = t;
  }
  cout << res;
  return 0;
}
