#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int h = 0, t = 0;
  for (int i = 0; i < n; ++i)
    if (s[i] == 'T')
      t++;
    else
      h++;
  int ans = n * 2;
  for (int i = 0; i < n; ++i) {
    int ch = 0, ct = 0;
    for (int j = i, k = 0; k < h; ++k, j = (j + 1) % n)
      if (s[j] == 'T') ch++;
    for (int j = i, k = 0; k < t; ++k, j = (j + 1) % n)
      if (s[j] == 'H') ct++;
    ans = min(ans, min(ch, ct));
  }
  cout << ans << endl;
  return 0;
}
