#include <bits/stdc++.h>
using namespace std;
template <class T>
inline int countbit(T n) {
  return (n == 0) ? 0 : (1 + countbit(n & (n - 1)));
}
template <class T>
inline T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
const double EPS = 1e-9;
const double PI = acos(-1.0);
int main() {
  int n;
  cin >> n;
  string round;
  cin >> round;
  int h = 0, best = n + 100;
  for (int i = 0; i < int(n); i++)
    if (round[i] == 'H') h++;
  for (int i = 0; i < int(n); i++) {
    int swaps = 0;
    for (int j = 0; j < int(h); j++) {
      if (round[(i + j) % n] == 'T') swaps++;
    }
    best = min(swaps, best);
  }
  cout << best << endl;
  return 0;
}
