#include <bits/stdc++.h>
using namespace std;
const int INFint = 2147483647;
const long long INF = 9223372036854775807ll;
const long long MOD = 1000000007ll;
const long double EPS = 1e-9;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cntt = 0, cnth = 0;
  int ans = INFint;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'H') cnth++;
  }
  for (int i = 0; i < n; i++) {
    cntt = 0;
    for (int j = 0; j < cnth; j++)
      if (s[(i + j) % n] == 'T') cntt++;
    ans = min(cntt, ans);
  }
  cout << ans;
  fprintf(stderr, "\nTIME = %lf\n", 1.0 * clock() / CLOCKS_PER_SEC);
  return 0;
}
