#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int H = 0, cur_H = 0;
  for (int i = 0; i < n; i++)
    if (s[i] == 'H') H++;
  for (int i = 0; i < H; i++)
    if (s[i] == 'H') cur_H++;
  int min_oper = H - cur_H;
  for (int i = 1; i < n; i++) {
    if (s[i - 1] == 'H') cur_H--;
    if (s[(i + H - 1) % n] == 'H') cur_H++;
    min_oper = min(H - cur_H, min_oper);
  }
  cout << min_oper;
}
