#include <bits/stdc++.h>
using namespace std;
const char ltr[2] = {'H', 'T'};
int a[3000], l = 0, r = 0, best = 1000000000, h;
void fwd() {
  a[r] = a[l];
  l++, r++;
}
int main() {
  int n;
  string s;
  cin >> n >> s;
  r = n;
  for (int i = 0; i < n; i++) {
    a[i] = (s[i] == 'H' ? 0 : 1);
    if (s[i] == 'H') h++;
  }
  for (int i = 0; i < n; i++) {
    int loch = h, m = 0;
    for (int j = 0; j < h; j++) {
      if (a[l + j]) m++;
    }
    best = min(best, m);
    fwd();
  }
  cout << best;
  return 0;
}
