#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::string s;
    std::cin >> n >> s;
    std::vector<int> dp(n + 1);
    for (int i = 0; i < n; i++) {
        dp[i + 1] = std::max(dp[i + 1], dp[i]);
        if (s[i] == '1') continue;
        if (!(i > 0 && i + 1 < n && s[i - 1] == '1' && s[i + 1] == '1')) continue;
        for (int j = i - 1; j >= 0 && s[j] == '1'; j--) {
            dp[i + 2] = std::max(dp[i + 2], dp[j] + i - j);
        }
        for (int j = i + 1; j < n && s[j] == '1'; j++) {
            dp[j + 1] = std::max(dp[j + 1], dp[i - 1] + j - i);
        }
    }
    std::cout << dp[n] << std::endl;

    return 0;
}
