#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  char c;
  for (int i = 0; i < n; i++) {
    cin >> c;
    a[i] = (c == 'H' ? 0 : 1);
  }
  int k = 0;
  int i, j;
  int mm = 1000000000;
  vector<int> t;
  for (int g = 0; g < n; g++) {
    rotate(a.begin(), a.begin() + 1, a.end());
    k = 0;
    t.assign(a.begin(), a.end());
    while (true) {
      i = 0;
      j = n - 1;
      while (t[i] == 1) i++;
      while (t[j] == 0) j--;
      if (j < i) break;
      swap(t[i], t[j]);
      k++;
    }
    mm = min(mm, k);
  }
  cout << mm;
  return 0;
}
