#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int t = 0, ans = 100000, a;
  for (int i = (0); i < (n); ++i)
    if (s[i] == 'T') t++;
  for (int i = (0); i < (n); ++i) {
    a = 0;
    for (int j = (i); j < (i + t); ++j) {
      if (s[j % n] == 'H') a++;
    }
    ans = min(ans, a);
  }
  cout << ans << endl;
  return 0;
}
