#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, i, j, counth = 0, countt = 0, min1 = 1e5;
  cin >> n;
  string s;
  map<char, long long> m;
  cin >> s;
  for (i = 0; i < n; i++) {
    m[s[i]]++;
  }
  for (j = 0; j < m['H']; j++) {
    if (s[j] == 'T')
      countt++;
    else
      counth++;
  }
  min1 = min(min1, countt);
  for (i = 1; i < n; i++) {
    if (s[i - 1] == 'H')
      counth--;
    else if (s[i - 1] == 'T')
      countt--;
    if (s[j % n] == 'H')
      counth++;
    else if (s[j % n] == 'T')
      countt++;
    min1 = min(min1, countt);
    j++;
  }
  cout << min1;
}
