#include <bits/stdc++.h>
using namespace std;
int n;
char p[5000];
int main() {
  scanf("%d%s", &n, p);
  int ans = n * 2;
  int h = 0;
  for (int i = 0; i < (int)(n); i++)
    if (p[i] == 'H') h++;
  for (int i = 0; i < (int)(n); i++) {
    int c = 0;
    for (int j = 0; j < (int)(h); j++)
      if (p[(i + j) % n] != 'H') c++;
    ans = min(ans, c);
  }
  printf("%d\n", ans);
  return 0;
}
