#include <bits/stdc++.h>
using namespace std;
const int inf = (int)2 * 1e9;
const int MOD = (int)1e9 + 7;
const int p = 239;
const int MAX_N = 1000000;
const long double pi = 3.1415926;
const long double eps = 1e-6;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt1 = 0;
  for (int i = 0; i < n; i++)
    if (s[i] == 'H') cnt1++;
  int ans1 = inf;
  for (int i = 0; i <= cnt1; i++) {
    int curr = 0;
    for (int j = 0; j < i; j++)
      if (s[j] == 'T') curr++;
    for (int j = i; j < n - cnt1 + i; j++)
      if (s[j] == 'H') curr++;
    for (int j = n - cnt1 + i; j < n; j++)
      if (s[j] == 'T') curr++;
    ans1 = min(ans1, curr / 2);
  }
  int cnt2 = 0;
  for (int i = 0; i < n; i++)
    if (s[i] == 'T') cnt2++;
  int ans2 = inf;
  for (int i = 0; i <= cnt2; i++) {
    int curr = 0;
    for (int j = 0; j < i; j++)
      if (s[j] == 'H') curr++;
    for (int j = i; j < n - cnt2 + i; j++)
      if (s[j] == 'T') curr++;
    for (int j = n - cnt2 + i; j < n; j++)
      if (s[j] == 'H') curr++;
    ans2 = min(ans2, curr / 2);
  }
  cout << min(ans1, ans2);
  return 0;
}
