#include <bits/stdc++.h>
using namespace std;
int n;
int h;
string s;
int a[2010];
int main() {
  cin >> n >> s;
  h = count(s.begin(), s.end(), 'H');
  s += s;
  a[0] = (s[0] == 'H');
  for (int i = 1; i != 2 * n; ++i) a[i] = (a[i - 1] + (s[i] == 'H'));
  int rv = 1 << 20;
  for (int i = 0; i != n; ++i) rv = min(rv, h - (a[i + h] - a[i]));
  cout << rv << endl;
  return 0;
}
