#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
const int N = 1e3 + 10;
const int MOD = 1e9 + 7;
const long double eps = 1e-12;
int n, h, t, ans;
string s;
void solve() {
  for (int i = 0; i < n; i++) {
    if (s[i] == 'T') continue;
    if (i + h > n) continue;
    int c = 0;
    for (int j = i; j < i + h; j++)
      if (s[j] == 'T') c++;
    ans = min(ans, c);
  }
}
int main() {
  ans = N;
  n = in();
  cin >> s;
  for (int i = 0; i < n; i++)
    if (s[i] == 'H')
      h++;
    else
      t++;
  solve();
  for (int i = 0; i < n; i++)
    if (s[i] == 'H')
      s[i] = 'T';
    else
      s[i] = 'H';
  swap(t, h);
  solve();
  cout << ans;
  return 0;
}
