#include <cmath>
#include <queue>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N1 200500
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;

ll maxn=1e10;

int n;
char a[N1];

int main() 
{
//	freopen("a.txt","r",stdin);
    scanf("%d",&n);
    scanf("%s",a);
    if(n==1)
    {
        if(a[0]=='0') printf("%lld\n",maxn);
        if(a[0]=='1') printf("%lld\n",maxn*2);
        return 0;
    }
    if(n==2)
    {
        if(a[0]=='0' && a[1]=='0') printf("0\n");
        if(a[0]=='0' && a[1]=='1') printf("%lld\n",maxn-1);
        if(a[0]=='1' && a[1]=='0') printf("%lld\n",maxn);
        if(a[0]=='1' && a[1]=='1') printf("%lld\n",maxn);
        return 0;
    }
    for(int i=3;i<n;i++) // check
    {
        if(a[i]!=a[i%3]){ puts("0"); return 0; }
    }
    ll ans=0; 
    if(a[0]=='1' && a[1]=='1' && a[2]=='0') ;
    else if(a[0]=='1' && a[1]=='0' && a[2]=='1') n++; 
    else if(a[0]=='0' && a[1]=='1' && a[2]=='1') n+=2;
    else{ puts("0"); return 0; }
    ll num=(n-1)/3+1;
    printf("%lld\n",maxn-num+1);
	return 0;
}

#include<bits/stdc++.h>
 #define ll long long
#define pb push_back
 #define f(i, b) for (int i = 0; i < b; i++)
 #define fr(i, a, b) for (int i = a; i >= b; i--)
#define vt vector
 #define all(v) v.begin(), v.end()
 const ll M = 998244353;
using namespace std;
ll s(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (int j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
        ll n;cin>>n;
        if(n==12)
        {
            cout<<"1";return 0;
        }
        cout<<s(n,12)-s(n-1,12);
        
        
    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
    #endif
    return 0;
}