#include <bits/stdc++.h>
using namespace std;
int n;
char c[1005];
int main() {
  scanf("%d%s", &n, c);
  int i, H = 0, T = 0;
  for (i = 0; i < n; i++) {
    if (c[i] == 'H') H++;
  }
  T = n - H;
  int cntH = 0, mxH = 0;
  for (i = 0; i < H - 1; i++) {
    if (c[i] == 'H') cntH++;
  }
  for (i = H - 1; i < n; i++) {
    if (c[i] == 'H') cntH++;
    if (c[i - H] == 'H') cntH--;
    if (cntH > mxH) mxH = cntH;
  }
  int cntT = 0, mxT = 0;
  for (i = 0; i < T - 1; i++) {
    if (c[i] == 'T') cntT++;
  }
  for (i = T - 1; i < n; i++) {
    if (c[i] == 'T') cntT++;
    if (c[i - T] == 'T') cntT--;
    if (cntT > mxT) mxT = cntT;
  }
  int ans = 1 << 30;
  if (T - mxT < ans) ans = T - mxT;
  if (H - mxH < ans) ans = H - mxH;
  printf("%d\n", ans);
  return 0;
}
