#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t = 0, h = 0, i, l, j;
  string s, t1 = "", t2 = "", t3 = "";
  scanf("%d", &n);
  cin >> s;
  l = s.length();
  for (i = 0; i < l; i++) s[i] == 'T' ? t++ : h++;
  int swaps = 0;
  int ret = 1000000000;
  for (i = 0; i < l - t + 1; i++) {
    swaps = 0;
    t1 = "";
    for (j = 0; j < i; j++) t1 += 'H';
    for (j = i; j < i + t; j++) t1 += 'T';
    for (j = i + t; j < l; j++) t1 += 'H';
    for (j = 0; j < l; j++) t1[j] != s[j] ? (swaps++) : swaps;
    ret = min(ret, swaps / 2);
  }
  for (i = 1; i <= t - 1; i++) {
    swaps = 0;
    t1 = "";
    for (j = 0; j < i; j++) t1 += 'T';
    for (j = i; j < i + h; j++) t1 += 'H';
    for (j = i + h; j < l; j++) t1 += 'T';
    for (j = 0; j < l; j++) t1[j] != s[j] ? (swaps++) : swaps;
    ret = min(ret, swaps / 2);
  }
  cout << ret << endl;
  return 0;
}
