#include <bits/stdc++.h>
using namespace std;
int N;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> N;
  string str;
  cin >> str;
  int totalH = 0;
  for (int i = 0; i < N; i++) {
    if (str[i] == 'H') totalH++;
  }
  int cntH = 0;
  for (int i = 0; i < totalH - 1; i++) {
    if (str[i] == 'H') cntH++;
  }
  str = str + str;
  N *= 2;
  int ans = N;
  for (int i = totalH - 1; i < N; i++) {
    if (str[i] == 'H') cntH++;
    ans = min(ans, totalH - cntH);
    if (str[i - (totalH - 1)] == 'H') cntH--;
  }
  cout << ans << "\n";
}
