#include <bits/stdc++.h>
char S[1010];
int A[1010];
int i, j, N, Ans, Act, sum;
int main() {
  scanf("%d\n", &N);
  gets(S);
  Ans = 1000000000;
  for (i = 1; i <= N; ++i) {
    sum = 0;
    for (j = 1; j <= N; ++j) {
      A[j] = (S[(i + j - 2) % N] == 'H');
      sum += A[j];
    }
    Act = 0;
    for (j = 1; j <= sum; ++j)
      if (A[j] != 1) ++Act;
    if (Ans > Act) Ans = Act;
  }
  printf("%d\n", Ans);
  return 0;
}
