#include <bits/stdc++.h>
using namespace std;
string str;
int n;
int func(int idx, char ch, int freq) {
  int cnt = 0;
  for (int i = 0; i < freq; i++)
    if (str[(i + idx) % n] == ch) ++cnt;
  return (freq - cnt);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n;
  cin >> str;
  int hc, tc;
  hc = 0;
  for (int i = 0; i < n; i++)
    if (str[i] == 'H') ++hc;
  tc = n - hc;
  char element_to_search = 'H';
  int freq = hc;
  if (tc <= hc) {
    element_to_search = 'T';
    freq = tc;
  }
  int minn = 0x3f3f3f3f;
  for (int i = 0; i < (int)str.size(); i++)
    minn = min(minn, func(i, element_to_search, freq));
  cout << minn;
  return 0;
}
