#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e3 + 1;
int n, tot, A, B;
string b[MAX];
int main() {
  scanf("%d", &n);
  cin >> b[++tot];
  if (b[1][0] == 'H')
    ++A;
  else
    ++B;
  for (int i = 1; i < n; ++i, ++tot) {
    if (b[1][i] == 'H')
      ++A;
    else
      ++B;
    for (int j = i; j < n; ++j) b[tot + 1] += b[1][j];
    for (int j = 0; j < i; ++j) b[tot + 1] += b[1][j];
  }
  int ans = 1e9;
  for (int i = 1; i <= n; ++i) {
    int sum = 0;
    for (int j = 0; j < A; ++j)
      if (b[i][j] == 'T') ++sum;
    ans = min(ans, sum);
  }
  printf("%d", ans);
  return 0;
}
