#include<iostream>
#include<sstream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<numeric>
#include<queue>


#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long
#define MOD 1000000007

using namespace std;

int main(){

ll int N;
string S;
cin >> N;
cin >> S;

if(S.size()==1){
	if(S[0]=='0'){
		cout << 10000000000;
		return 0;
	}
	else{
		cout << 2*10000000000;
		return 0;
	}
}

if(S.size()==2){
	if(S=="11"||S=="10"){
		cout << 10000000000;
		return 0;
	}
	else if(S=="01"){
		cout << 10000000000-1;
		return 0;
	}
	else{
	        cout << 0;
		return 0;
		}

}
int flag=0;
if(S[0]=='1' && S[1]=='1' && S[2] == '0'){
	flag=0;
}
else if(S[0]=='1' && S[1]=='0' && S[2] == '1'){
	flag=1;
}
else if(S[0]=='0' && S[1]=='1' && S[2] == '1'){
	flag=2;
}
else{
	cout << 0;
	return 0;
}
ll int si=S.size();
ll int co0=0;
for(ll int i=0;i<si;i++){
	if(S[i]=='0'){
		co0+=1;
	}
	if(flag==0){
		if(S[i]=='0'){
			cout << 0;
			return 0;
		}
		flag=1;
	}
	else if(flag==1){
		if(S[i]=='0'){
			cout << 0;
			return 0;
		}
		flag=2;
	}
	else{
		if(S[i]=='1'){
			cout << 0;
			return 0;
		}
		flag=0;
	}
}
if(S[N-1]=='1'){
	cout << 10000000000-co0;
	return 0;
}
else{
	cout << 10000000000-co0+1;
	return 0;
}


/*
if(S.size()==1 && S[0]=='1'){
	cout << 20000000000;
	return 0;
}
else if(S.size()==1 && S[0]=='0'){
	cout << 10000000000;
	return 0;
}
else if(S.size()==2 &&( (S[0]=='0'&& S[1]=='1')||(S[0]=='1'&& S[1]=='0'))){
	cout << 10000000000;
	return 0;
}
else if(S.size()==2 && S[1]=='1'&& S[1]=='1'){
	cout << 10000000000;
	return 0;
}
else if(S.size()==2){
	cout << 0;
	return 0;
}

int flag=0;
if(S[0]=='1' && S[1]=='1' && S[2] == '0'){
	flag=0;
}
else if(S[0]=='1' && S[1]=='0' && S[2] == '1'){
	flag=1;
}
else if(S[0]=='0' && S[1]=='1' && S[2] == '1'){
	flag=2;
}
else{
	cout << 0;
	return 0;
}
ll int si=S.size();
for(ll int i=0;i<si;i++){
	if(flag==0){
		if(S[i]=='0'){
			cout << 0;
			return 0;
		}
		flag=1;
	}
	else if(flag==1){
		if(S[i]=='0'){
			cout << 0;
			return 0;
		}
		flag=2;
	}
	else{
		if(S[i]=='1'){
			cout << 0;
			return 0;
		}
		flag=0;
	}
}
if(si==1){
	cout << 20000000000;
}
else if(si%3==0&&S[0]=='1'){
	cout << 10000000000 - (si/3)+1;
}
else if(si%3==0&&S[0]=='0'){
	cout << 10000000000 - (si/3);
}
else if(S[0]=='0'){
	cout << 10000000000 - (si/3)-1;
}
else{
	cout << 10000000000 - (si/3);
}


*/








	return 0;

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define Pint pair<int,int>
#define Pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000;
constexpr ll llINF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
ll modpow(ll a,ll b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    ll memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<ll>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(ll i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
vector<vector<ll>>C,sC;
void init_comb(int n,int m){
    C.resize(n+1,vector<ll>(m+1,0));
    sC.resize(n+1,vector<ll>(m+1,0));
    C[0][0]=1;
    for(int i=1;i<=n;i++){
        C[i][0]=1;
        for(int j=1;j<=m;j++){
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
    rep(i,n+1){
        rep(j,m){
            sC[i][j+1]=(sC[i][j]+C[i][j])%mod;
        }
    }
}
ll comb(int a,int b){
    if(a<b)return 0;
    if(a<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
ll inv(ll x){
    x=modpow(x,mod-2);
    return x;
}

int main(){
    int n;
    string t;
    string a="110";
    cin>>n>>t;
    if(n==1){
        if(t=="0")cout<<10000000000<<endl;
        else cout<<20000000000<<endl;
    }
    else{
        int s=0;
        if(t[0]=='0'){
            if(t[1]=='0'){
                cout<<0<<endl;
                return 0;
            }
            else{
                //01
                s=2;
            }
        }
        else{
            if(t[1]=='0'){
                //10
                s=1;
            }
            else{
                //11
                s=0;
            }
        }
        rep(i,n){
            if(a[(s+i)%3]!=t[i]){
                cout<<0<<endl;
                return 0;
            }
        }
        int p=s+n-1;
        p/=3;
        cout<<10000000000ll-p<<endl;
    }
    return 0;
}