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