#include <bits/stdc++.h>
using namespace std;
const long maxn = 1000 + 1;
long ans = 1000000000, now = 0, n;
char s[maxn];
int main() {
  cin >> n;
  long l = 1, r = 0;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    if (s[i] == 'H') r++;
  }
  for (int i = l; i <= r; i++) {
    if (s[i] == 'T') now++;
  }
  ans = now;
  for (int i = 1; i <= n - 1; i++) {
    if (s[l] == 'T') now--;
    l++;
    r++;
    l = (l > n) ? 1 : l;
    r = (r > n) ? 1 : r;
    if (s[r] == 'T') now++;
    if (now < ans) ans = now;
  }
  cout << ans;
}
