#include <bits/stdc++.h>
using namespace std;
int n, k;
char arr[2 * 1000 + 5];
int cum[2 * 1000 + 5];
void read_input() {
  cin >> n;
  cum[0] = 0, k = 0;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    arr[i + n] = arr[i];
    cum[i] = cum[i - 1];
    if (arr[i] == 'T')
      cum[i] += 1;
    else
      k++;
  }
  for (int i = n + 1; i < n + k; i++) {
    cum[i] = cum[i - 1];
    if (arr[i] == 'T') cum[i] += 1;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cerr.tie(0);
  read_input();
  int min_swaps = INT_MAX;
  for (int i = k; i < n + k; i++) {
    min_swaps = min(min_swaps, cum[i] - cum[i - k]);
  }
  cout << min_swaps << "\n";
  return 0;
}
