#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int N = 1e5 + 5;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  string x;
  cin >> x;
  int H = 0;
  for (char &c : x)
    if (c == 'H') H++;
  int result = n;
  for (int i = 0; i < n; i++) {
    int now = 0;
    for (int j = 0; j < H; j++) {
      if (x[(i + j) % n] != 'H') now++;
    }
    result = min(result, now);
  }
  cout << result << endl;
}
