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