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