#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int hc = 0;
  for (auto c : s)
    if (c == 'H') hc++;
  int ans = INT_MAX, curr;
  for (int i = 0; i <= hc; i++) {
    curr = 0;
    for (int j = 0; j < n; j++) {
      if (j < i) {
        if (s[j] == 'T') curr++;
      } else if (j >= n - (hc - i)) {
        if (s[j] == 'T') curr++;
      }
    }
    ans = min(ans, curr);
  }
  int tc = n - hc;
  for (int i = 0; i <= tc; i++) {
    curr = 0;
    for (int j = 0; j < n; j++) {
      if (j < i) {
        if (s[j] == 'H') curr++;
      } else if (j >= n - (tc - i)) {
        if (s[j] == 'H') curr++;
      }
    }
    ans = min(ans, curr);
  }
  cout << ans;
}
