#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  string s;
  cin >> s;
  long long cnt = 0;
  for (long long i = 0; i <= n - 1; i++) {
    if (s[i] == 'T') cnt++;
  }
  long long ma = LLONG_MAX;
  for (long long i = 0; i <= n - 1; i++) {
    long long c = 0;
    for (long long j = 0; j <= cnt - 1; j++) {
      if (s[(i + j) % n] == 'H') c++;
    }
    ma = min(ma, c);
  }
  cout << ma;
  return 0;
}
