#include <bits/stdc++.h>
using namespace std;
char s[1001];
int n, l, r, M, m;
int main() {
  cin >> n;
  r = n;
  cin >> s;
  for (int i = 0; i < n; i++)
    if (s[i] == 'H') {
      l++;
      r--;
    }
  for (int i = 0; i < l; i++)
    if (s[i] == 'H') m++;
  M = m;
  for (int i = l; i < n + l - 1; i++) {
    if (s[i % n] == 'H') m++;
    if (s[i - l] == 'H') m--;
    if (m > M) M = m;
  }
  cout << l - M;
}
