#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int maxn = 2e5+10;
char s[maxn];

int main() {
    int n;
    cin>>n>>(s+1);
    int f=0;
    ll tans=1e10;
    for(int i=4;i<=n;i++){
        if(s[i]!=s[i-3])f=1;
    }
    if(f)return puts("0"),0;
    if(n==1){
        if(s[1]=='1')return puts("20000000000"),0;
        return puts("10000000000"),0;
    }else if(n==2){
        if(s[1]=='0'&&s[2]=='1')return puts("9999999999"),0;
        if(s[1]=='0'&&s[2]=='0')return puts("0"),0;
        return puts("10000000000"),0;
    }
    if(s[1]==s[2]&&s[1]=='1'&&s[3]=='0')
        cout<<tans-(n+2)/3+1;
    else if(s[1]==s[3]&&s[1]=='1'&&s[2]=='0')
        cout<<tans-(n)/3;
    else if(s[1]=='0'&&s[2]==s[3]&&s[2]=='1')
        cout<<tans-(n+1)/3;
    else cout<<0<<endl;
    return 0;
}

#include<bits/stdc++.h>
 
using namespace std;
 
#define D(x) cout << (#x) << " is " << x << endl;
#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;


int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    lli ans = 1e10;
    if(s == "1"){
		cout << ans*2 << endl;
		return 0;
	}
	if(s == "0"){
		cout << ans << endl;
		return 0;
	}
	if(s[0] == '0'){
		s = "11"+s;
	}
	else{
		if(s[1] == '0'){
			s = "1"+s;
		}
	}
	n = s.size();
	if(s[n-1] == '1'){
		if(s[n-2] == '0'){
			s += "10";
		}
		else{
			s += "0";
		}
	}
	string t = "110", tmp;
	n = s.size();
	for(int i=0; i<n; i++){
		tmp += s[i];
		if(i%3 == 2){
			if(tmp != t){
				cout << 0 << "\n";
				return  0;
			}
			tmp.clear();
		}
	}
	if(n%3 != 0){
		cout << "0\n";
	}
	else{
		cout << ans-(n/3)+1 << endl;
	}
 
    return 0;
}
