#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string a;
  cin >> a;
  int c1 = count(a.begin(), a.end(), 'T');
  int c2 = count(a.begin(), a.end(), 'H');
  char who = 'T';
  if (c2 < c1) {
    swap(c1, c2);
    who = 'H';
  }
  a += a;
  int best = 1e9;
  for (int i = (0); i < ((n)); ++i) {
    int current = 0;
    for (int j = (0); j < ((c1)); ++j) current += a[i + j] == who;
    current = c1 - current;
    best = min(current, best);
  }
  cout << best << endl;
  return 0;
}
