#include <bits/stdc++.h>
using namespace std;
void open() {
  freopen("D:/Code/in.txt", "r", stdin);
  freopen("D:/Code/out.txt", "w", stdout);
}
int main(void) {
  int n;
  scanf("%d", &n);
  string str;
  cin >> str;
  int h = 0;
  int t;
  for (int i = 0; i < n; i++) {
    if (str[i] == 'H') h++;
  }
  t = n - h;
  int ans = 1000000000;
  int perlu;
  for (int i = 0; i < n; i++) {
    perlu = 0;
    for (int j = 0; j < t; j++) {
      if (str[(i + j) % n] == 'H') perlu++;
    }
    ans = min(ans, perlu);
  }
  cout << ans;
  return 0;
}
