#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define BE(x) x.begin(), x.end()

int main() {
    ll s, p;
    cin >> s >> p;

    for (ll i = 1; i*i <= p; i++) {
        if (p % i > 0) continue;
        ll n = i, m = p / i;
        if (n + m == s) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

const int N = 2e5 + 5;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    string str;
    cin >> str;
    string s = "";
    char ch[3] = {'1','1','0'};
    if(str.size() ==1)
    {
        ll ans = 1e10;
        if(str[0] == '0')
        {
            cout << ans << "\n";
        }
        else
            cout << 2*ans << "\n";
        return 0;
    }
    for(int i=0;i<2*n;i++)
    {
        s += ch[i%3];
    }
    ll cnt = 0;
    int j =0;
    ll add = 0;
    ll fst = 0;
    for(int i=0;i<2*n;i++)
    {
        //cout << i << " " << j << '\n';
        if(str[j] == s[i])
        {
            j++;
            if(j == n)
            {
                fst = i-n+1;
                cnt =  1;
                break;
            }
        }
        else
        {
            j = 0;
            if(str[j] == s[i])
                j++;
        }
    }
    if(cnt == 0)
    {
        cout << 0 << '\n';
    }
    else
    {
        ll curr = 0;
        ll low = 1;
        ll high = 3e10;
        ll best = 1;
        ll lim = 3e10;
        fst++;
        //ll v = fst + 3*(1e10 - 1);
        //v += str.size() - 1;
        //cout << v << "\n";
        while(low <= high)
        {
            ll mid = (low + high)/2;
            ll val = fst + 3*mid;
            ll r = val + str.size() - 1;
            if(r > lim)
            {
                high = mid-1;
            }
            else
            {
                best = mid;
                low = mid+1;
            }
        }
        cout << best+1;
    }
}
