#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-11;
char a[2500];
int n;
int h = 0;
int main() {
  cout << setiosflags(ios::fixed) << setprecision(10);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 'H') h++;
  }
  int mm = 99999999;
  for (int i = 0; i < n; i++) {
    int kol = 0;
    for (int j = i; j < i + h; j++)
      if (a[j % n] != 'H') kol++;
    mm = min(mm, kol);
  }
  cout << mm;
}
