#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  string s;
  cin >> s;
  long long total = 0;
  for (long long i = 0; i < n; i++) {
    if (s[i] == 'H') total++;
  }
  s += s;
  long long i = 0, ans = n, cnt = 0;
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] == 'H') cnt++;
    if (i >= (total)) {
      if (s[i - total] == 'H') cnt--;
    }
    if (i >= (cnt - 1)) {
      ans = min(ans, total - cnt);
    }
  }
  cout << ans;
}
