#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int h_count = 0;
  char c;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    cin >> c;
    if (c == 'H') {
      v.push_back(1);
      h_count++;
    } else {
      v.push_back(0);
    }
  }
  for (int i = 1; i < n; i++) {
    v[i] += v[i - 1];
  }
  int answer = n;
  for (int i = 0; i < n; i++) {
    int count = v[min(n - 1, i + h_count - 1)];
    if (i > 0) {
      count -= v[i - 1];
    }
    if (i + h_count > n) {
      count += v[i + h_count - n - 1];
    }
    count = h_count - count;
    answer = min(answer, count);
  }
  cout << answer;
  return 0;
}
