#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n, t, mxt, mxh, mnt = N, mnh = N;
string s;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> s;
  for (int i = 0; i < n; i++) t += (s[i] == 'T');
  int tn = 0;
  for (int i = 0; i < n - t + 1; i++) {
    for (int j = i; j < i + t; j++) tn += (s[j] == 'T');
    mxt = max(mxt, tn);
    mnt = min(mnt, tn);
    tn = 0;
  }
  int ans = t - mxt;
  t = n - t;
  for (int i = 0; i < n - t + 1; i++) {
    for (int j = i; j < i + t; j++) tn += (s[j] == 'H');
    mxh = max(mxh, tn);
    mnh = min(mnh, tn);
    tn = 0;
  }
  cout << min(ans, t - mxh);
}
