#include <bits/stdc++.h>
using namespace std;
int const NM = 2007;
char v[NM];
int main() {
  int n, i, _begin, secv = 0, _end, best = (1e10);
  cin.tie(0), cout.tie(0);
  ios_base ::sync_with_stdio(0);
  cin >> n >> v + 1;
  for (i = 1; i <= n; ++i) v[n + i] = v[i];
  for (i = 1; i <= n; ++i)
    if (v[i] == 'H') ++secv;
  _begin = 1, _end = 1;
  int a, b;
  a = b = 0;
  for (i = 1; i <= n; ++i) {
    if (v[i] == 'H') {
      b = 0;
      for (int j = i; j <= i + secv - 1; ++j)
        if (v[j] == 'T') ++b;
      best = min(best, b);
    }
  }
  cout << best;
  return 0;
}
