#include <bits/stdc++.h>
using namespace std;
void fix() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const long long inf = 1e9 + 1;
void solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  long long H = 0, T = 0;
  for (auto& now : s) {
    if (now == 'H') H++;
    if (now == 'T') T++;
  }
  long long cnt = 0;
  long long ans = inf;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < H; j++) {
      long long cur = (j + i) % n;
      if (s[cur] == 'T') cnt++;
    }
    ans = min(ans, cnt);
    cnt = 0;
  }
  cout << ans << endl;
}
signed main() { solve(); }
