#include #include #include using namespace std; int main() { int n; cin >> n; string s; cin >> s; if (n == 1) { cout << 0 << endl; return 0; } vector dp(4); if (s[0] == '0') { ++dp[2]; ++dp[3]; } if (s[1] == '0') { ++dp[1]; ++dp[3]; } for (int i = 2; i < n; ++i) { vector ndp(4); ndp[1] = dp[2] + (s[i] == '0'); ndp[2] = dp[3]; ndp[3] = min(dp[1], dp[3]) + (s[i] == '0'); swap(ndp, dp); } int ans = 1e9; for (int i = 1; i < 4; ++i) ans = min(ans, dp[i]); cout << ans << endl; }