#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cou = 0;
  cin >> n;
  string s;
  cin >> s;
  int res = n + 1;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'H') cou++;
  }
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    for (int j = 0; j < cou; j++) {
      if (s[(i + j) % n] == 'T') cnt++;
    }
    res = min(res, cnt);
  }
  cout << res << endl;
}
