#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<char> animals(n);
  int tigers = 0;
  for (int i = 0; i < n; i++) {
    cin >> animals[i];
    if (animals[i] == 'T') tigers++;
  }
  int l = 0;
  int r = tigers;
  int max = 0;
  for (l = 0; l < n; l++) {
    int inzone = 0;
    for (int i = l; i < r; i++) {
      if (animals[i % n] == 'T') inzone++;
    }
    if (inzone > max) max = inzone;
    r++;
  }
  cout << tigers - max << endl;
}
