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