#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:134217728")
using namespace std;
int n;
string s;
int main() {
  cin >> n;
  cin >> s;
  int res = (int)1e9;
  int H = 0, T = 0;
  for (int i = 0; i < n; ++i)
    if (s[i] == 'H')
      ++H;
    else
      ++T;
  for (int i = 0; i < n; ++i) {
    s = s.substr(1) + s[0];
    int a = 0, b = 0;
    for (int j = 0; j < H; ++j) a += s[j] == 'T';
    for (int j = 0; j < T; ++j) b += s[j] == 'H';
    res = min(res, a);
    res = min(res, b);
  }
  cout << res << endl;
  return 0;
}
