#include <bits/stdc++.h>
char str[1001];
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", str);
  int h = 0, t = 0;
  for (int i = 0; i < n; i++) {
    if (str[i] == 'H')
      h++;
    else
      t++;
  }
  int min = n;
  int sum = 0;
  for (int first = 0; first < n; first++) {
    int last = first + h - 1;
    if (last == n) break;
    if (sum == 0) {
      for (int c = first; c <= last; c++)
        if (str[c] != 'H') sum++;
    } else {
      if (str[first - 1] != 'H') sum--;
      if (str[last] != 'H') sum++;
    }
    if (min > sum) min = sum;
  }
  sum = 0;
  for (int first = 0; first < n; first++) {
    int last = first + t - 1;
    if (last == n) break;
    if (sum == 0) {
      for (int c = first; c <= last; c++)
        if (str[c] != 'T') sum++;
    } else {
      if (str[first - 1] != 'T') sum--;
      if (str[last] != 'T') sum++;
    }
    if (min > sum) min = sum;
  }
  printf("%d\n", min);
  return 0;
}
