#include <bits/stdc++.h>
template <class T>
inline int __builtin_popcount(T n) {
  return (n == 0) ? 0 : (1 + __builtin_popcount(n & (n - 1)));
}
using namespace std;
int main() {
  int N;
  string input;
  cin >> N >> input;
  int numH = 0, numT = 0;
  for (int i = 0; i < (int)(N); i++) {
    if (input[i] == 'H')
      numH++;
    else
      numT++;
  }
  int res = 1 << 30;
  for (int i = 0; i < (int)(N); i++) {
    int tmp = 0;
    for (int j = 0; j < (int)(numT); j++) {
      int index = (i + j) % N;
      if (input[index] == 'H') tmp++;
    }
    res = min(tmp, res);
  }
  cout << res << endl;
}
