#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, kolt = 0, kolh = 0;
  cin >> n;
  vector<char> V(n);
  for (int i = 0; i < n; ++i) {
    cin >> V[i];
    if (V[i] == 'H')
      kolh++;
    else
      kolt++;
  }
  int t, h, minres = 1234567;
  for (int i = 0; i < n; ++i) {
    t = 0;
    h = 0;
    for (int j = 0; j < n; ++j) {
      if (t + h == kolh) {
        if (t < minres) minres = t;
        break;
      }
      if (V[(i + j) % n] == 'T')
        t++;
      else
        h++;
    }
  }
  cout << minres << endl;
  return 0;
}
