#include <bits/stdc++.h>
using namespace std;
template <typename T>
T sqr(T a) {
  return a * a;
}
template <typename T>
int size(T& a) {
  return (int)a.size();
}
void initf() {}
char s[1100];
int sum[2100];
int main() {
  initf();
  int n;
  scanf("%d\n", &n);
  gets(s);
  memset((sum), (0), sizeof(sum));
  for (int i = 0; i < n; ++i) {
    if (i) sum[i] += sum[i - 1];
    if (s[i] == 'H') ++sum[i];
  }
  for (int i = 0; i < n; ++i) {
    sum[i + n] += sum[i + n - 1];
    if (s[i] == 'H') ++sum[i + n];
  }
  int ans = 2000000000;
  int c = sum[n - 1];
  for (int i = 0; i < n + n; ++i) {
    if (i + c - 1 >= n + n) continue;
    int sm = sum[i + c - 1] - (i - 1 < 0 ? 0 : sum[i - 1]);
    ans = min(ans, c - sm);
  }
  printf("%d", ans);
  return 0;
}
