#include <bits/stdc++.h>
using namespace std;
char a[2021];
int main() {
  int n, xom = 0, maxi = -1 << 30;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i + n] = a[i];
    if (a[i] == 'H') xom++;
  }
  int kol;
  for (int i = 0; i < 2 * n; i++) {
    kol = 0;
    for (int j = i; j < i + xom; j++)
      if (a[j] == 'H') kol++;
    maxi = max(maxi, kol);
  }
  cout << xom - maxi;
  return 0;
}
