#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 500111;
const long long mod = 1e9 + 7;
int n;
char v[20011];
char a[20011];
int solve(char* v) {
  for (int i = 0, __ = n; i < __; i++) {
    a[i] = v[i];
  }
  int i = 0;
  int j = n - 1;
  int ans = 0;
  while (i < j) {
    while (i < j && a[i] == 'H') i++;
    while (i < j && a[j] == 'T') j--;
    if (i != j) {
      swap(a[i], a[j]);
      ans++;
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  while (cin >> n) {
    for (int i = 0, __ = n; i < __; i++) {
      cin >> v[i];
      v[i + n] = v[i];
    }
    int ans = inf;
    for (int i = 0, __ = n; i < __; i++) {
      ans = min(ans, solve(v + i));
      reverse(v + i, v + i + n);
      ans = min(ans, solve(v + i));
      reverse(v + i, v + i + n);
    }
    printf("%d\n", ans);
  }
}
