#include <bits/stdc++.h>
int main() {
  int n;
  char xx[1005];
  char yy[1005];
  while (~scanf("%d", &n)) {
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    memset(xx, 0, sizeof(xx));
    memset(yy, 0, sizeof(yy));
    scanf("%s", xx);
    int s = strlen(xx);
    for (int i = 0; i < s; i++) {
      if (xx[i] == 'H') {
        a++;
      } else {
        b++;
      }
    }
    if (s < 4) {
      d = 0;
    } else {
      d = s;
      for (int i = 0; i < s; i++) {
        c = 0;
        for (int j = 0; j < s; j++) {
          if (i + a <= s) {
            if (j >= i && j < i + a) {
              yy[j] = 'H';
            } else {
              yy[j] = 'T';
            }
          }
          if (i + a > s) {
            if (j >= i && j <= s) {
              yy[j] = 'H';
            } else if (j < a + i - s) {
              yy[j] = 'H';
            } else {
              yy[j] = 'T';
            }
          }
        }
        for (int k = 0; k < s; k++) {
          if (xx[k] != yy[k]) {
            c++;
          }
        }
        if (c < d) {
          d = c;
        }
      }
    }
    printf("%d\n", d / 2);
  }
  return 0;
}
