#include <bits/stdc++.h>
using namespace std;
char s[1010];
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", s);
  int h = 0, t = 0;
  for (int i = 0; i < n; i++)
    if (s[i] == 'H')
      h++;
    else
      t++;
  int curt = 0;
  int sol = 9999;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'T') curt++;
    if (i - h >= 0 && s[i - h] == 'T') curt--;
    if (i - h >= 0) sol = min(curt, sol);
  }
  int curh = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'H') curh++;
    if (i - t >= 0 && s[i - t] == 'H') curh--;
    if (i - t >= 0) sol = min(curh, sol);
  }
  printf("%d\n", sol);
  return 0;
}
