#include <bits/stdc++.h>
using namespace std;
int ans[2000], now, k, n, hh = 0, nowhh = 0, maxhh = 0;
string ste;
int main() {
  cin >> n >> ste;
  for (int i = 0; i < ste.size(); i++) {
    if (ste[i] == 'H') hh++;
  }
  for (int i = 0; i < hh; i++) {
    if (ste[i] == 'H') nowhh++;
  }
  maxhh = nowhh;
  int frontt = 0, endd = hh - 1;
  do {
    if (ste[frontt] == 'H') nowhh--;
    frontt++;
    endd++;
    if (frontt == ste.size()) frontt = 0;
    if (endd == ste.size()) endd = 0;
    if (ste[endd] == 'H') nowhh++;
    maxhh = max(maxhh, nowhh);
  } while (frontt != 0);
  cout << hh - maxhh << endl;
}
