#include using namespace std; const int INF = 1001001001; template bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; } template bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } #ifdef _DEBUG #define show(x) \ cerr << #x << " : "; \ showVal(x) template void showVal(const T &a) { cerr << a << endl; } template void showVal(const pair &a) { cerr << a.first << " " << a.second << endl; } template void showVal(const vector &a) { for (const T &v : a) cerr << v << " "; cerr << endl; } template void showVal(const vector> &a) { cerr << endl; for (const pair &v : a) cerr << v.first << " " << v.second << endl; } template void showVal(const map &a) { cerr << endl; for (const auto &v : a) cerr << "[" << v.first << "] " << v.second << endl; } template void showVal(const vector> &a) { cerr << endl; for (const vector &v : a) showVal(v); } #else #define show(x) #endif int main() { int n; cin >> n; string s; cin >> s; vector> dp(n + 1, vector(1 << 2, INF)); dp[0][0b11] = 0; for (int i = 0; i < n; i++) { for (int b = 0; b < (1 << 2); b++) { for (int v = 0; v < 2; v++) { if (v == 0 && ((b >> 1) == 0 || (b & 1) == 0)) continue; chmin(dp[i + 1][((b << 1) | v) & 0b11], dp[i][b] + ((v == (s[i] - '0')) ? 0 : 1)); } } } show(dp); int ans = INF; for (int b = 0; b < (1 << 2); b++) { chmin(ans, dp[n][b]); } cout << ans << endl; return 0; }