#include <bits/stdc++.h>
using namespace std;
string s;
int n, h, a[6666], b, c, d, m;
int main() {
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'H') h++;
    a[i + 1] = h;
  }
  d = a[h];
  for (int i = h + 1; i < n; i++) {
    b = a[i] - a[i - h];
    if (b > d) d = b;
  }
  m = a[n - h];
  for (int i = n - h + 1; i < n; i++) {
    c = a[i] - a[i - n + h];
    if (c < m) m = c;
  }
  cout << min(h - d, m);
}
