#include <bits/stdc++.h>
using namespace std;
template <class T>
T checkmin(T &a, T b) {
  return a = min(a, b);
}
template <class T>
T checkmax(T &a, T b) {
  return a = max(a, b);
}
bool inside(int a, int n) { return a >= 0 && a < n; }
const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 0x3F3F3F3F;
int main(int argc, char *argv[]) {
  int n;
  char s[2048];
  scanf("%d%s", &n, s);
  int nh = 0, nt = 0;
  for (int i = 0; i < (n); ++i)
    if (s[i] == 'H')
      ++nh;
    else
      ++nt;
  int ch = 0, best = nh;
  for (int i = 0; i < (nh); ++i)
    if (s[i] == 'H') ++ch;
  for (int i = 0, j = nh; i < n; ++i, ++j) {
    checkmin(best, nh - ch);
    if (j == n) j = 0;
    if (s[j] == 'H') ++ch;
    if (s[i] == 'H') --ch;
  }
  printf("%d\n", best);
}
