#include <bits/stdc++.h>
int N;
bool anim[1000];
int H;
int now, min;
int main() {
  int i, j;
  char c;
  scanf("%d\n", &N);
  for (i = 0; i < N; i++) {
    scanf("%c", &c);
    if (c == 'H') {
      H++;
      anim[i] = 1;
    } else
      anim[i] = 0;
  }
  now = 0;
  for (i = 0; i < H; i++) {
    if (!anim[i]) now++;
  }
  min = now;
  j = H;
  for (i = 0; i < N; i++) {
    now -= anim[j] - anim[i];
    if (now < min) min = now;
    j = (j + 1) % N;
  }
  printf("%d\n", min);
  return 0;
}
