#include <bits/stdc++.h>
int main() {
  int n;
  scanf("%d", &n);
  char s[1001];
  scanf("%s", s);
  int tc = 0, hc = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'T')
      tc++;
    else
      hc++;
  }
  char t1[1001];
  t1[n] = '\0';
  int ans = n;
  for (int i = 0; i <= n - tc; i++) {
    memset(t1 + i, (int)'T', tc);
    memset(t1 + i + tc, (int)'H', hc - i);
    memset(t1, (int)'H', i);
    int ds = 0;
    for (int j = 0; j < n; j++)
      if (t1[j] != s[j]) ds++;
    ds >>= 1;
    if (ds < ans) ans = ds;
  }
  for (int i = 0; i <= n - hc; i++) {
    memset(t1 + i, (int)'H', hc);
    memset(t1 + i + hc, (int)'T', tc - i);
    memset(t1, (int)'T', i);
    int ds = 0;
    for (int j = 0; j < n; j++)
      if (t1[j] != s[j]) ds++;
    ds >>= 1;
    if (ds < ans) ans = ds;
  }
  printf("%d\n", ans);
  return 0;
}
