main = do
    n_ <- readLn::IO Int
    bistr_ <- getLine
    let
	proc v _ []	= v
	proc v _ [_]	= v
	proc v _ [_,_]	= v
	proc v [] ('1':'0':'1':bs) = proc (v+1) [] ('1':'0':bs)
	proc v stack ('1':'0':'1':bs)
	  = let
	    candi1 = (proc 0 [] ('1':'0':stack)) +
			(proc (v+1) [] ('0':bs))
	    candi2 = (proc 0 [] ('0':stack)) +
			(proc (v+1) [] ('1':'0':bs))

	  in
	    max candi1 candi2
		
	proc v stack (b:bs) = proc v (b:stack) bs

    print $ proc 0 [] bistr_