#include <bits/stdc++.h>
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
constexpr int MOD = 1000000007;
void print(const std::vector<int>& v) {
  std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
  std::cout << std::endl;
}
int main() {
  long long N;
  cin >> N;
  vector<char> S(N);
  for (long long i = 0; i < (long long)N; i++) cin >> S[i];
  vector<int> index;
  index.push_back(0);
  char tmp = '.';
  for (long long i = 0; i < (long long)N; i++) {
    if (tmp != S[i]) {
      index.push_back(i + 1);
      tmp = S[i];
    }
  }
  long long a = 0;
  for (long long i = 0; i < index.size(); i++) {
    if (i % 2 == 0 and i > 0) {
      a += index[i] - index[i - 1];
    }
  }
  long long b = 0;
  for (long long i = 0; i < index.size(); i++) {
    if (i % 2 == 1 and i > 0) {
      b += index[i] - index[i - 1];
    }
  }
  if (index.size() == 1) {
    cout << 0 << endl;
    return 0;
  }
  long long csize = index.size() / 2;
  vector<long long> c(csize);
  for (long long i = 0; i < (long long)index.size(); i++) {
    for (long long j = 0; j < csize; j++) {
      long long k = 2 * j + 1;
      if (i < k and i % 2 == 0 and i > 0) c[j] += index[i] - index[i - 1];
      if (i >= k and i % 2 == 1 and i > 0) c[j] += index[i] - index[i - 1];
    }
  }
  long long ans = min(a, b);
  long long ltmp = *min_element((c).begin(), (c).end());
  ans = min(ans, ltmp);
  cout << ans << endl;
}
