#include <bits/stdc++.h>
using namespace std;
char str[1005];
int main() {
  int n, h = 0, ans = 1000000;
  scanf("%d%s", &n, str);
  for (int i = 0; str[i]; i++) {
    if (str[i] == 'H') h++;
  }
  for (int i = 0; str[i]; i++) {
    int j = i, e = h, t = 0;
    while (e--) {
      if (str[j] == 'T') t++;
      (j += 1) %= n;
    }
    ans = min(ans, t);
  }
  cout << ans << endl;
  return 0;
}
