#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>
#include<math.h>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,n) for(ll i=1;i<=n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=1e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


   
int main(void){
    ll N;
    string T;
    cin>>N>>T;
    if(T=="1"){
        cout<<20000000000<<endl;
        return 0;
    }
    if(T=="11" || T=="0"){
        cout<<10000000000<<endl;
        return 0;
    }
    if(T.at(0)=='0') T="11"+T;
    if(T.at(0)=='1' && T.at(1)=='0') T="1"+T;
    if(T.at(T.size()-3)=='0' && T.at(T.size()-2)=='1' && T.at(T.size()-1)=='1') T+="0";
    if(T.at(T.size()-2)=='0' && T.at(T.size()-1)=='1') T+="10";

    if(T.size()%3){
        cout<<0<<endl;
        return 0;
    }
    rep(i,T.size()/3){
        if(T.at(3*i)=='1' && T.at(3*i+1)=='1' && T.at(3*i+2)=='0') continue;;
        cout<<0<<endl;
        return 0;
    }
    cout<<10000000000-T.size()/3+1<<endl;
    return 0;
}
//#include<atcoder/all>
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
using ll = long long;
//using mint = modint1000000007;
using vi = vector<ll>;
using vi2 = vector<vector<ll>>;
using vl = vector<ll>;
using vl2 = vector<vector<ll>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<ll>;
using vs2 = vector<vector<string>>;
using pii = pair<ll, ll>;
using mii = map<ll, ll>;
const int INF = 1e9+1;
const ll LINF = 1e18+1;
const long double LPI = acos(-1.0);
const  double PI = acos(-1.0);
const ll mod = 998244353;

 
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,x) for(ll i=0;i<(int)(x);i++)
#define REPS(i,x) for(ll i=1;i<=(int)(x);i++)
#define RREP(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(ll i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SORT(v) sort(ALL(v));
#define RSORT(v) sort(RALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}
template<typename T> T lcm(T a,T b){return a*b/gcd(a, b);}
template<typename T> bool isPrime(T a){if(a<=1){return false;}
    for(T i=2;i*i<=a;i++){if (a%i==0) {return false;}}return true;}
template<typename T> T ord(T p,T n){T ans=0;while(true){if(n%p==0){n/=p;ans++;}else{break;}}return ans;}
 
char janken(char a,char b){
    if (a==b) {
        return a;
    }
    if (a=='R') {
        if (b=='P') {
            return b;
        }
        if (b=='S') {
            return a;
        }
    }
    if (a=='P') {
        if (b=='R') {
            return a;
        }
        if (b=='S') {
            return b;
        }
    }
    if (a=='S') {
        if (b=='P') {
            return a;
        }
        if (b=='R') {
            return b;
        }
    }
    return 'k';
    
}

int main() {
    IN(ll, n);
    IN(string, s);
    reverse(ALL(s));
    ll start = -1;
    REP(i, n){
        if (s[i]=='0') {
            start = i;
            break;
        }
    }
    if (start==-1) {
        if (s=="1") {
            COUT(20000000000);
            return 0;
        }else if (s=="11"){
            COUT(10000000000);
            return 0;
        }else{
            COUT(0);
            return 0;
        }
    }
    if (start>=3) {
        COUT(0);
        return 0;
    }
    ll count = 0;
    for (ll i = start; i < n; i++) {
        if ((i-start)%3==0) {
            if (s[i]=='0') {
                count++;
            }else{
                COUT(0);
                return 0;
            }
        }else{
            if (s[i]=='1') {
                
            }else{
                COUT(0);
                return 0;
            }
        }
    }
    if (start==0) {
        COUT(10000000000-count+1);
    }else{
        COUT(10000000000-count);
    }
    
}




