#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
void dummy_func() {}
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  s += s;
  int m = 0;
  for (int i = 0; i < n; ++i)
    if (s[i] == 'H') m++;
  int ans = (int)1e9;
  for (int i = 0; i < n; ++i) {
    int cur = 0;
    for (int j = 0; j < m; ++j)
      if (s[i + j] != 'H') ++cur;
    if (cur < ans) ans = cur;
  }
  cout << ans << '\n';
  return 0;
}
