#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int h = 0, t = 0;
  for (int i = 0; i < s.length(); i++)
    if (s[i] == 'H')
      h++;
    else
      t++;
  int min = s.length();
  for (int i = 0; i <= h; i++) {
    int tempmin = 0;
    for (int j = 0; j < i; j++)
      if (s[j] != 'H') tempmin++;
    for (int j = s.length() - (h - i); j < s.length(); j++)
      if (s[j] != 'H') tempmin++;
    if (tempmin < min) min = tempmin;
  }
  for (int i = 0; i <= t; i++) {
    int tempmin = 0;
    for (int j = 0; j < i; j++)
      if (s[j] != 'T') tempmin++;
    for (int j = s.length() - (t - i); j < s.length(); j++)
      if (s[j] != 'T') tempmin++;
    if (tempmin < min) min = tempmin;
  }
  cout << min;
}
