#include <bits/stdc++.h>
using namespace std;
template <typename S, typename T>
void fill_(S& buf, const T& x) {
  fill_n(reinterpret_cast<T*>(&buf), sizeof(buf) / sizeof(T), x);
}
template <typename T, int N>
inline int countof(const T (&)[N]) {
  return N;
}
template <typename T>
inline vector<T>& operator+=(vector<T>& ret, const T& x) {
  ret.push_back(x);
  return ret;
}
int N;
int tigers, hamsters;
int target, numberOfTargets;
int xs[3000];
int main(int argc, char* argv[]) {
  cin >> N;
  string s;
  cin >> s;
  for (int i = int(0), CNT_i = int(int((s).size()) * 2); i < CNT_i; ++i)
    xs[i] = (s[i % N] == 'T') ? 1 : 0;
  tigers = accumulate(xs, xs + N, 0);
  hamsters = N - tigers;
  if (tigers < hamsters) {
    target = 1;
    numberOfTargets = tigers;
  } else {
    target = 0;
    numberOfTargets = hamsters;
  }
  int best = INT_MAX;
  for (int i = int(0), CNT_i = int(N); i < CNT_i; ++i) {
    int acc = 0;
    for (int j = int(0), CNT_j = int(numberOfTargets); j < CNT_j; ++j) {
      if (xs[i + j] != target) ++acc;
    }
    best = min(best, acc);
    acc = 0;
    for (int j = N - 1, end = N - numberOfTargets; j >= end; --j) {
      if (xs[i + j] != target) ++acc;
    }
    best = min(best, acc);
  }
  cout << best << endl;
  return 0;
}
