#include <bits/stdc++.h>
using namespace std;
void sdvig(char *c, int n) {
  int i;
  char s = c[0];
  for (i = 0; i < n - 1; i++) {
    c[i] = c[i + 1];
  }
  c[n - 1] = s;
}
int main() {
  int n;
  scanf("%d\n", &n);
  char c[1010], cc[1010];
  cin >> cc;
  int i, g, f, l = n - 1;
  int mmin = 1000000000, kol;
  bool fl;
  for (f = 0; f < n; f++) {
    kol = 0;
    for (i = 0; i < n; i++) {
      c[i] = cc[i];
    }
    while (true) {
      i = 0;
      g = l;
      while (c[i] == 'H') i++;
      while (c[g] == 'T') g--;
      if (i < g) {
        swap(c[i], c[g]);
        kol++;
      } else {
        break;
      }
    }
    if (kol < mmin) mmin = kol;
    sdvig(cc, n);
  }
  cout << mmin;
  return 0;
}
