#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  int mark = 0;
  for (int i = 0; i < n; i++)
    if (s[i] == 'H') mark++;
  if (mark == 0 || mark == n) {
    cout << 0 << endl;
    return 0;
  }
  int max;
  max = 0;
  for (int i = 0; i < n; i++) {
    int hash = 0;
    for (int j = 0; j < mark; j++) {
      int k;
      k = (i + j) % n;
      if (s[k] == 'H') hash++;
    }
    if (max < hash) max = hash;
  }
  int ans = 999999;
  if (mark - max < ans) ans = mark - max;
  cout << ans << endl;
  return 0;
}
