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