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