#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int main() {
  int n;
  cin >> n >> ws;
  char s[1001];
  scanf("%s", &s);
  int h = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'H') h++;
  }
  int _min = INF;
  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = 0; j < h; j++) {
      if (s[(i + j) % n] == 'T') ans++;
    }
    _min = min(ans, _min);
  }
  cout << _min;
  return 0;
}
