#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
const int INF = 0x7fffffff;
int n, h[N], t[N], ans = INF;
string s;
int main() {
  scanf("%d", &n);
  cin >> s;
  for (int i = 1; i <= n; ++i) {
    h[i] = h[i - 1];
    t[i] = t[i - 1];
    if (s[i - 1] == 'H') ++h[i];
    if (s[i - 1] == 'T') ++t[i];
  }
  for (int i = 1; i <= n - h[n] + 1; ++i)
    ans = min(ans, t[i + h[n] - 1] - t[i - 1]);
  for (int i = 1; i <= n - t[n] + 1; ++i)
    ans = min(ans, h[i + t[n] - 1] - h[i - 1]);
  printf("%d\n", ans);
}
