#include <bits/stdc++.h>
using namespace std;
template <class _T>
inline _T sqr(const _T& x) {
  return x * x;
}
template <class _T>
inline string tostr(const _T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
template <class _T>
inline istream& operator<<(istream& is, const _T& a) {
  is.putback(a);
  return is;
}
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-11;
string st;
int n;
int main() {
  cin >> n;
  cin >> st;
  st += st;
  int ans = 10050000;
  for (int i = 0; i < n; i++) {
    int s = 0;
    for (int j = 0; j < n; j++) {
      s += (st[i + j] == 'H');
    }
    int k = 0;
    for (int j = 0; j < n; j++) {
      if (st[i + j] == 'H' && j >= s) k++;
    }
    ans = min(ans, k);
  }
  cout << ans;
  return 0;
}
