#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[1001];
  char c;
  cin >> c;
  if (c == 'H')
    a[0] = 1;
  else
    a[0] = 0;
  for (int i = 1; i < n; i++) {
    char c;
    cin >> c;
    if (c == 'H')
      a[i] = a[i - 1] + 1;
    else
      a[i] = a[i - 1];
  }
  int total = a[n - 1] - 1;
  int min = a[total];
  min = total - min + 1;
  for (int i = 1; i < n; i++) {
    int current;
    if (i + total >= n) {
      current = a[n - 1] - a[i - 1] + a[(i + total) % n];
    } else
      current = a[i + total] - a[i - 1];
    current = total - current + 1;
    if (current < min) min = current;
  }
  cout << min;
  return 0;
}
