#include<bits/stdc++.h>
using namespace std;
#define int long long

bool chk(string &s,string t){
    int n=(int)(s.length());
    for(int i=0;i<n;i++){
        if(s[i]!=t[i%3]) return false;
    }
    return true;
}
signed main()
{
    
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    cin>>n;
    string s;
    cin>>s;
    int tot=1e10;
    int tms=0;
    if(n==1){
        if(s[0]=='0') tms=tot;
        else tms=2*tot;
    }
    else if(n==2){
        if(s=="11"||s=="10") tms=tot;
        else if(s=="01") tms=tot-1;
    }
    else{
        if(s.substr(0,3)=="110"){
            if(chk(s,"110")){
                int toen=(n-1)/3;
                tms=tot-toen;
            }
        }
        else if(s.substr(0,3)=="101"||s.substr(0,3)=="011"){
            if(chk(s,s.substr(0,3))){
                int toadd=0;
                if(s.substr(0,3)=="011") toadd=1;
                int toen=(n+toadd)/3;
                tms=tot-toen;
            }
        }
    }
    cout<<tms;
    return 0;
}
#include <bits/stdc++.h>
 
 
#define se second
#define sz(x) (int)(x.size())
#define ll long long
#define rep(i,x,y) for(int i = x; i <= y; ++i)
#define repr(i,x,y) for(int i = x; i >= y; --i)
#define pb push_back
#define mp make_pair
#define fi first
#define ull unsigned ll
 
#define pi 3.14159265358979
 
 
using namespace std;
 
const int N = (int)(1e6) + 322;
const ll INF = 2e18 + 17;
const int inf = 2e9;
const int mod = 1000000007;
const double eps = 1e-9;


template<typename T>
void pop_front(vector<T>& vec)
{
    assert(!vec.empty());
    vec.erase(vec.begin());
}
 
int gcd(int a, int b) { return b ? gcd (b, a % b) : a; }
 
int nbr_bits(int a){
	return log2(a)+1;
} 
 
int fastpow(int a, int n, int mod) {
    if(n==0)
    	return 1;
    if(n%2==0){
    	int res = fastpow(a,n/2,mod);
    	res*=res;
    	res%=mod;
    	return res;
	}
	int res = (fastpow(a,n-1,mod)*a)%mod;
	return res;
    
}
 
// ---------------------------------------------------
int p[N];
stack<string> answers;
 
int find(int u){
	if(p[u]==u) return u;
	return p[u] = find(p[u]);
}

bool bubleSort(vector<int> v, int n){

  int ans = 0;
  int m = (n * (n -1)) / 2;
  rep(i, 0, n-1){
  
    rep(j, 0, n-2){
    
      if(v[j] > v[j + 1]){
		  
		  swap(v[j], v[j + 1]);
		  ans++;
		  
		}
     
	 }
    
  }
  if(ans < m) return true;
  else return false;
  
}
 
signed main()
{
 
//	int t;
//	cin >> t;
//	
//	while(t--){
//	
	  int x, y;
	  cin >> x >> y;
	  int k = max(x,y);
	  int l = min(x,y);
	  int rest = k - l ;
	  if(rest >= 3) cout << "No" << endl;
	  else cout << "Yes" << endl;
	   
//	}  
	
	return 0;
}