#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  ios::sync_with_stdio(0);
  solve();
  return 0;
}
int N;
string s;
int go(char ch, int l) {
  int i = 0;
  int cnt = 0;
  for (int j = i; j < i + l; j++) {
    if (s[j] == ch) cnt++;
  }
  int mcnt = cnt;
  for (; i < N; i++) {
    int ni = (i + l) % N;
    if (s[i] == ch) {
      cnt--;
    }
    if (s[ni] == ch) {
      cnt++;
    }
    mcnt = max(mcnt, cnt);
  }
  return l - mcnt;
}
void solve() {
  cin >> N;
  cin >> s;
  int ch = count(s.begin(), s.end(), 'H');
  int ct = N - ch;
  int ans = min(go('H', ch), go('T', ct));
  cout << ans << '\n';
}
