#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 10;
int n, ans, t;
bool animal[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    char a;
    cin >> a;
    if (a == 'H') t++;
    animal[i] = (a == 'H' ? 0 : 1);
  }
  int cnt = 0;
  for (int i = 0; i < t; i++) cnt += animal[i];
  ans = cnt;
  for (int i = 1; i < n; i++) {
    cnt -= animal[i - 1];
    cnt += animal[(i + t - 1) % n];
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}
