#include <bits/stdc++.h>
using namespace std;
const int MAX = 1020;
char an[MAX];
int n;
int main() {
  scanf("%d", &n);
  scanf("%s", an);
  int hn = 0, tn = 0;
  for (int i = 0; i < n; ++i) {
    if (an[i] == 'H')
      hn++;
    else
      tn++;
  }
  int pos, opt = INT_MAX;
  for (int hs = 0; hs <= n - 1; ++hs) {
    int vio = 0;
    for (int j = 0; j < hn; ++j) {
      pos = (hs + j) % n;
      if (an[pos] != 'H') vio++;
    }
    int ts = (pos + 1) % n;
    for (int j = 0; j < tn; j++) {
      pos = (ts + j) % n;
      if (an[pos] != 'T') vio++;
    }
    opt = std::min(opt, vio / 2);
  }
  printf("%d\n", opt);
  return 0;
}
