#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  char end, changed;
  int planA, planB, ans;
  cin >> n >> s;
  end = s[n - 1];
  changed = end;
  for (int i = 0; i < n; i++) {
    if (s[n - i - 1] != end) {
      changed = n - i - 1;
      break;
    }
    break;
  }
  planA = 0;
  for (int j = 0; j < n; j++) {
    if ((j <= changed && s[j] != changed) || (j > changed && s[j] != end)) {
      planA++;
    }
  }
  planB = 0;
  for (int j = 0; j < n; j++) {
    if (s[j] != end) {
      planB++;
    }
    ans = min({planA, planB, n - planA, n - planB});
  }
  cout << ans << endl;
  cin >> n;
  return 0;
}
