#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL * 1000 * 1000 * 1000 * 1000 * 1000;
const long long MOD = 1e9 + 7;
void solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  long long x = 0;
  for (long long i = 0; i < n; i++) {
    if (s[i] == 'H') x++;
  }
  long long ans = x == 0 ? 0 : INF;
  for (long long i = 0; i < n; i++) {
    long long res = 0;
    for (long long j = i, c = 0; c < x; j = (j + 1) % n, c++) {
      if (s[j] == 'T') res++;
    }
    ans = min(res, ans);
  }
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.precision(12);
  solve();
}
