#include using namespace std; int ans = 0; int n; string s; void mark(int i) { s[i] = '1'; ans++; } int main() { cin >> n >> s; if (n == 1) { cout << 0 << endl; return 0; } else if (n == 2) { if (s == "11") cout << 1 << endl; else cout << 0 << endl; return 0; } else { for (int i = 0; i < (int)s.length() - 2; i++) { string t = s.substr(i,3); // cerr << t << endl; if (t == "000") { mark(i+1); mark(i+2); } else if (t == "001") { mark(i+1); } else if (t == "010") { mark(i+2); } else if (t == "100") { mark(i+2); } else { // more than 2 1s, fine } } cout << ans << endl; } }