#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int h = 0, t = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'H')
      h++;
    else
      t++;
  }
  int ans = n;
  for (int i = 0; i < n; i++) {
    int st = i;
    int tc = 0, hc = 0;
    int sw1 = 0, sw2 = 0;
    int maxi = i + h - 1;
    for (int j = i; j < n + i; j++) {
      if (s[j % n] == 'H' && j > maxi) sw1++;
    }
    maxi = i + t - 1;
    for (int j = i; j < i + n; j++) {
      if (s[j % n] == 'T' && j > maxi) sw2++;
    }
    ans = min(ans, min(sw1, sw2));
  }
  cout << ans << endl;
}
