#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string str;
  cin >> str;
  int hc = 0, tc = 0;
  for (int i = 0; i < n; i++) {
    if (str[i] == 'H')
      hc++;
    else
      tc++;
  }
  int res = n;
  for (int i = 0; i < n; i++) {
    vector<int> v1(n), v2;
    for (int j = 0; j < n; j++) {
      if (str[j] == 'H')
        v1[(i + j) % n] = 1;
      else
        v1[(i + j) % n] = 0;
    }
    v2 = v1;
    int ires = 0;
    int x = 0, y = n - 1;
    while (1) {
      while (v1[x] == 0) x++;
      while (v1[y] == 1) y--;
      if (x < y) {
        swap(v1[x++], v1[y--]);
        ires++;
      } else
        break;
    }
    res = min(res, ires);
    ires = 0;
    x = 0, y = n - 1;
    while (1) {
      while (v2[x] == 1) x++;
      while (v2[y] == 0) y--;
      if (x < y) {
        swap(v2[x++], v2[y--]);
        ires++;
      } else
        break;
    }
    res = min(res, ires);
  }
  cout << res;
}
