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