#include<bits/stdc++.h>

using namespace std;

#define N 600000

int n,a[N],f[N];
char s[N];

void upd(int &x,int y){
	x=max(x,y);
}

int main(){
	scanf("%d%s",&n,s+1);
	for (int i=1;i<=n;++i) a[i]=s[i]-'0';
	for (int i=1;i<=n;++i){
		upd(f[i],f[i-1]);
		if (i>1&&a[i]&&!a[i-1]){
			int j=i-2;
			for (;a[j];--j);
			upd(f[i],f[j]+(i-j-2));
			upd(f[i],f[j+1]+(i-j-3));
		}
		if (i<n&&a[i]&&!a[i+1]){
			int j=i+2;
			for (;a[j];++j);
			upd(f[j-1],f[i-1]+(j-i-2));
			upd(f[j-2],f[i-1]+(j-i-3));
		}
	}
	printf("%d\n",f[n]);
	
	return 0;
}
			