#include <bits/stdc++.h>
using namespace std;
char c[1010];
int rs, s, k, n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
    if (c[i] == 'H') k++;
  }
  for (int i = 1; i <= k; i++)
    if (c[i] != 'H') s++;
  rs = s;
  for (int i = k + 1; i <= n + k; i++) {
    int x;
    if (i > n)
      x = 1;
    else
      x = 0;
    if (c[i - k] != 'H') s--;
    if (c[i % (n + 1) + x] != 'H') s++;
    rs = min(rs, s);
  }
  cout << rs;
  return 0;
}
