#include <bits/stdc++.h>
using namespace std;
int main() {
  int out = 10000, t = 0, i, j, n;
  string s;
  cin >> n;
  cin >> s;
  for (i = 0; i < n; i++) {
    if (s[i] == 'T') t++;
  }
  for (i = 0; i < n; i++) {
    int f = 0;
    for (j = 0; j < t; j++) {
      if (s[(i + j) % n] == 'H') f++;
    }
    out = min(out, f);
  }
  cout << out << endl;
  return 0;
}
