import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    int n;
    string s;
    scan(n);
    scan(s);
    s = "0" ~ s ~ "0";

    auto dp = new int[](n + 1);

    foreach (i ; 3 .. n + 1) {
        dp[i] = max(dp[i], dp[i - 1]);

        if (s[i - 2] == '1' && s[i - 1] == '0' && s[i] == '1') {
            foreach_reverse (j ; 0 .. i - 2) {
                if (s[j] == '0') {
                    dp[i] = max(dp[i], dp[j] + i - j - 2);
                    break;
                }
            }

            foreach (j ; i .. n + 2) {
                if (s[j] == '0') {
                    dp[j - 1] = max(dp[j - 1], dp[i - 3] + j - i);
                    break;
                }
            }
        }
    }

    debug {
        writeln(dp);
    }

    writeln(dp[n]);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}