#include <bits/stdc++.h>
using namespace std;
long long n, ans;
string str;
int main() {
  cin >> n >> str;
  long long cnt_H = 0, cnt_T = 0;
  long long len = str.length();
  for (long long i = 0; i < len; i++)
    if (str[i] == 'H') cnt_H++;
  long long s = 0, e = cnt_H - 1;
  long long x = s, y = e;
  for (long long i = 0; i <= e; i++)
    if (str[i] == 'T') cnt_T++;
  ans = cnt_T;
  while (1) {
    if (str[s] == 'T') cnt_T--;
    s++;
    e++;
    if (s == len) s = 0;
    if (e == len) e = 0;
    if (str[e] == 'T') cnt_T++;
    ans = min(ans, cnt_T);
    if (s == x && e == y) break;
  }
  cout << ans << endl;
  return 0;
}
