#include <bits/stdc++.h>
using namespace std;
string in;
int N;
int main() {
  int i, j, k;
  scanf("%d", &N);
  cin >> in;
  int t, h;
  int ans = (1 << 28);
  t = h = 0;
  int n = in.size();
  for (i = 0; i < n; i++) {
    if (in[i] == 'H')
      h++;
    else
      t++;
  }
  for (i = 0; i < n; i++) {
    int c = 0;
    for (j = i, k = 0; k < t; k++, j = (j + 1) % n) {
      if (in[j] == 'H') c++;
    }
    if (c < ans) ans = c;
  }
  printf("%d\n", ans);
  return 0;
}
