#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int p = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'H') p++;
  }
  int ans = INT_MAX;
  for (int i = 0; i < n; i++) {
    int co = 0;
    int k = i;
    for (int j = 0; j < p; j++) {
      k = k % n;
      if (s[k] == 'T') {
        co++;
      }
      k = (k + 1) % n;
    }
    ans = min(co, ans);
  }
  cout << ans << "\n";
}
