#include <bits/stdc++.h>
using namespace std;
const int MXN = (int)4e6 + 100;
const int INF = (int)1e9 + 7;
const long long LINF = (long long)1e18;
const double EPS = (double)1e-9;
int n;
string s;
int c1, c2;
int ans = INF;
int main() {
  cin >> n >> s;
  for (int i = 0; i < n; ++i) {
    (s[i] == 'T' ? c1++ : c2++);
  }
  for (int i = 0; i + c1 - 1 < n; ++i) {
    int cnt = 0;
    for (int j = 0; j < c1; ++j) {
      if (s[i + j] != 'T') ++cnt;
    }
    ans = min(cnt, ans);
  }
  for (int i = 0; i + c2 - 1 < n; ++i) {
    int cnt = 0;
    for (int j = 0; j < c2; ++j) {
      if (s[i + j] != 'H') ++cnt;
    }
    ans = min(cnt, ans);
  }
  cout << ans;
  return 0;
}
