#include <bits/stdc++.h>
using namespace std;
int Solution() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < n; ++i) cnt += (s[i] == 'H');
  s += s;
  int ans = 0x7fffffff;
  for (int i = 0; i < n; ++i) {
    int dif = 0;
    for (int j = 0; j < cnt; ++j)
      if (s[i + j] != 'H') ++dif;
    if (dif < ans) ans = dif;
  }
  cout << ans << endl;
  return 0;
}
int main() {
  Solution();
  return 0;
}
