#include <bits/stdc++.h>
using namespace std;
int dp[1005][1005][2][2];
char a[1005];
int dfs(int l, int r, int x, int y) {
  if (l > r) return 0;
  if (dp[l][r][x][y] != -1) return dp[l][r][x][y];
  if (r - l + 1 == 2) {
    if (a[l] != x && a[r] != a[l] && y != a[r]) return 0;
    if (a[l] ^ 1 != x && a[r] != a[l] ^ 1 && y != a[r]) return 1;
    if (a[l] != x && a[r] ^ 1 != a[l] && y != a[r] ^ 1) return 1;
    return 999999999;
  }
  int ans = 999999999;
  if (a[l] == x) ans = min(ans, dfs(l + 1, r, a[l] ^ 1, y) + 1);
  if (a[l] != x) ans = min(ans, dfs(l + 1, r, a[l], y));
  if (a[r] == y) ans = min(ans, dfs(l, r - 1, x, a[r] ^ 1) + 1);
  if (a[r] != y) ans = min(ans, dfs(l, r - 1, x, a[r]));
  return dp[l][r][x][y] = ans;
}
int main() {
  long long m, n, i, j, k;
  cin >> m;
  for (i = 1; i <= m; i++) {
    char c;
    cin >> c;
    a[i] = c - '0';
  }
  memset(dp, -1, sizeof(dp));
  int ans = 999999999;
  ans = min(ans, dfs(1, m, 1, 1));
  ans = min(ans, dfs(1, m, 1, 0));
  ans = min(ans, dfs(1, m, 0, 1));
  ans = min(ans, dfs(1, m, 0, 0));
  cout << ans << endl;
}
