#include <bits/stdc++.h>
using namespace std;
char s[1001];
int main() {
  int ls;
  scanf("%d", &ls);
  scanf(" %s", s);
  int ch = 0, ct = 0;
  for (int i = 0; i < ls; ++i)
    if (s[i] == 'H')
      ++ch;
    else
      ++ct;
  int ans = INT_MAX, tans;
  for (int i = 0; i < ls; ++i) {
    tans = 0;
    for (int j = 0; j < ch; ++j) tans += s[(i + j) % ls] == 'H' ? 0 : 1;
    ans = min(ans, tans);
  }
  printf("%d\n", ans);
}
