#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979323846;
const int V = 1111;
const int E = 4 * V;
const int N = 3010;
const int MOD = 1e9 + 7;
void sdvig(string &s, int n) {
  char c = s[n - 1];
  for (int i = n - 1; i >= 1; i--) s[i] = s[i - 1];
  s[0] = c;
}
int kol1, kol2;
int hom, tig;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i <= n - 1; i++)
    if (s[i] == 'H') hom++;
  int kol = MOD;
  for (int i = 0; i <= n - 1; i++) {
    if (s[i] == 'H') {
      int j = i + 1;
      int t = 1;
      int kol1 = 0;
      while (t != hom) {
        t++;
        j %= n;
        if (s[j] == 'T') kol1++;
        j++;
      }
      kol = min(kol, kol1);
    }
  }
  cout << kol << endl;
  return 0;
}
