#include <bits/stdc++.h>
using namespace std;
int n;
char str[1024];
int main() {
  scanf("%d %s", &n, str);
  int h = 0, t = 0;
  for (int i = 0; i < n; i++) {
    if (str[i] == 'H')
      h++;
    else
      t++;
  }
  int res = n;
  for (int i = 0; i < n; i++) {
    int cc = 0;
    for (int j = 0, k = i; j < h; j++, k = (k + 1) % n)
      if (str[k] != 'H') cc++;
    res = min(res, cc);
  }
  printf("%d\n", res);
  return 0;
}
