#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.14159265358979323846;
long long MOD = 1e9 + 7;
const char nl = '\n';
const long long inf = pow(2, 10);
long long power(long long x, long long y) {
  long long z = 1;
  while (y > 0) {
    if (y % 2) z = z * x;
    x = x * x;
    y /= 2;
  }
  return z;
}
long long gcd(long long a, long long b) {
  if (a < b) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long sq(long long a) {
  long long ans = (1ll * a * a);
  return ans;
}
bool isprime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long digitsum(long long x) {
  long long ans = 0;
  while (x > 0) {
    ans += (x % 10);
    x /= 10;
  }
  return ans;
}
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int i, j;
  int num = 0;
  for (i = 0; i < s.size(); i++) {
    if (s[i] == 'H') {
      num++;
    }
  }
  int m = 0;
  for (i = 0; i < num; i++) {
    if (s[i] == 'H') {
      m++;
    }
  }
  j = num;
  int temp = m;
  for (i = 1; i < n; i++) {
    j = j % n;
    if (s[i - 1] == 'H') {
      temp--;
    }
    if (s[j] == 'H') {
      temp++;
    }
    j++;
    m = max(m, temp);
  }
  cout << num - m << nl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  long long TC = 1;
  while (TC--) {
    solve();
  }
}
