#include <bits/stdc++.h>
char s[1 << 10];
int main() {
  int i, j, k, n;
  int a = 0, b;
  scanf("%d%s", &n, s);
  for (i = 0; i < n; i++)
    if (s[i] == 'H') a++;
  b = n - a;
  int ans = 0;
  for (i = 0; i < n; i++) {
    if (s[i] != 'H') continue;
    int t = 1;
    for (k = 1; k < a; k++) {
      if (s[(k + i) % n] == 'H') t++;
    }
    if (ans < t) ans = t;
  }
  printf("%d\n", a - ans);
  return 0;
}
