#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
template <class _T>
inline string tostr(const _T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-9;
string s;
int test() {
  int z = 0;
  for (int i = 0; i < s.size(); i++)
    if (s[i] == 'H') z++;
  int res = 2000000000;
  for (int i = 0; i < s.size(); i++) {
    int now = 0;
    for (int j = 0; j < z; j++) {
      if (s[(i + j) % s.size()] == 'T') now++;
    }
    res = min(res, now);
  }
  return res;
}
int main() {
  cout.flags(ios::fixed);
  cout.precision(2);
  cin >> s >> s;
  int ans = test();
  for (int i = 0; i < s.size(); i++)
    if (s[i] == 'H')
      s[i] = 'T';
    else
      s[i] = 'H';
  cout << min(ans, test());
  return 0;
}
