#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  int hom = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'H') hom++;
  }
  s += s;
  int minans = 2000;
  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = i; j < i + hom; j++) {
      ans += (s[j] == 'T');
    }
    if (ans < minans) minans = ans;
  }
  cout << minans;
  return 0;
}
