#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:64000000")
const int MAXN = 2000000;
int main() {
  string in;
  int n = 0;
  cin >> n;
  n = 0;
  cin >> in;
  for (int i = 0; i < in.size(); ++i) {
    if (in[i] == 'H') ++n;
  }
  int best = 10000;
  for (int i = 0; i < in.size(); ++i) {
    int cnt = 0;
    if (in[i] == 'H') {
      for (int j = i; j != (i + n) % in.size(); j = (j + 1) % in.size()) {
        if (in[j] == 'T') ++cnt;
      }
      best = min(best, cnt);
    }
  }
  for (int i = 0; i < in.size(); ++i) {
    int cnt = 0;
    if (in[i] == 'H') {
      for (int j = i; j != (i + in.size() - n) % in.size();
           j = (j + 1) % in.size()) {
        if (in[j] == 'H') ++cnt;
      }
      best = min(best, cnt);
    }
  }
  cout << best << endl;
  return 0;
}
