#include <bits/stdc++.h>
using namespace std;
int N;
string s;
int dp[1010];
int main(void) {
  int i, j;
  cin >> N >> s;
  s += s;
  int H = 0;
  for ((i) = 0; (i) < (int)(N); (i)++)
    if (s[i] == 'H') H++;
  int big = 0, cur = 0;
  for ((i) = 0; (i) < (int)(H); (i)++)
    if (s[i] == 'H') cur++;
  for ((i) = 0; (i) < (int)(N); (i)++) {
    big = max(big, cur);
    if (s[i] == 'H') cur--;
    if (s[i + H] == 'H') cur++;
  }
  cout << H - big << endl;
  return 0;
}
