#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define ull unsigned long long
#define mp make_pair
const int maxn=4e5+5;
const ll inf=2e5+7;
const ll mod=1e9+7;

ll n,m,k;

char s1[maxn],s2[maxn];
string a,b;
vector<int>num[26];
ll ans=0;
int len1,len2;

int l[maxn],r[maxn];
int main(){

    scanf("%s%s",s1,s2);
    a=s1;b=s2;
    len1=a.size(),len2=b.size();
    for(int i=0;i<len1;i++){
        num[a[i]-'a'].pb(i);
    }

    memset(l,-1,sizeof(l));
    memset(r,-1,sizeof(r));

    int j=len2-1;
    for(int i=len1-1;i>=0;i--){
        if(j<0)break;
        if(a[i]==b[j]&&r[j]==-1){
            r[j]=i;
            j--;
        }
    }

    j=0;
    for(int i=0;i<len1;i++){
        if(j>=len2)break;
        if(a[i]==b[j]&&l[j]==-1){
            l[j]=i;
            j++;
        }
    }

    ans=max(ans,max((ll)r[0],len1-l[len2-1]-1LL));

    for(int i=1;i<len2;i++){
        ans=max(ans,r[i]-l[i-1]-1LL);
    }

    printf("%I64d\n",ans);

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ldob;
typedef pair<int,int> ii;
typedef vector<int> vi;

// OST
template <typename T>
using ordered_set = __gnu_pbds::tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// from: https://codeforces.com/blog/entry/62393
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

const int N = 300005;
const int NN = 1000007;
const int MOD = 998244353; // 1e9+7;
const int IMAX = 1e9+7;
const ll IAMAX = (1LL << 32);
const ll LLMAX = (1LL << 60);

int main () {
	ios_base::sync_with_stdio(false); cin.tie(0);
	// cout.precision(9); cout << fixed;

	int n, k, x; cin >> n >> k >> x;
	vector<int> c(n);
	for (int i = 0; i < n; ++i)
		cin >> c[i];

	int ans = 0;
	for (int _i = 1; _i < n; ++_i) {
		if (c[_i-1] == c[_i] and c[_i] == x) {
			int running = 2;
			vector<int> t = c;
			t.erase(t.begin()+_i-1,t.begin()+_i+1);
			for (int j = 0; j < n; ++j) {
				// for (int i = 0; i < t.size(); ++i) {
				// 	cout << t[i] << ' ';
				// }
				// cout << endl;
				for (int i = 2; i < t.size(); ++i) {
					if (t[i-2] == t[i-1] and t[i-1] == t[i]) {
						while (i < t.size() and t[i-2] == t[i-1] and t[i-1] == t[i]) {
							t.erase(t.begin()+i);
							running++;
						}
						t.erase(t.begin()+i-2,t.begin()+i);
						running += 2;
					}
				}
			}
			ans = max(ans, running);
		}
	}
	cout << ans << endl;

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
	int n;
	cin>>n;
	vector<long long >a(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a.begin(), a.end());
	if(a[n-1]==1)
	{
		cout<<1<<endl;
	}
	else
	{
	long long sum=a[n-1], g=INT_MAX;
	long long x=a[n-1];
	long long y=x;
	for(int i=n-2;i>=0;i--)
	{

		x=min(x-1,a[i]);
		if(x>=y || x<0)
		{
			break;
		}
		else
		{
			sum+=x;
		}
		y=x;
	}
	// for(int i=n-1;i>=0;i--)
	// {
	// 	if(a[i]<g)
	// 	{
	// 		long long x=a[i];
	// 		int f=0;
	// 		while(a[i]==x)
	// 		{
	// 			sum+=a[i]-f;
	// 			f++;
	// 			i--;
	// 		}
	// 		long long g=a[i]-f;
	// 		i++;
	// 	}
	// 	else
	// 	{
	// 		continue;
	// 	}
	// }
	cout<<sum<<endl;
}
}


#include <bits/stdc++.h>
using namespace std;
int dp[200010];
const int mod = 1000000007;
int r,g;
int h;
int ans = 0;
int sum;
int main() {
	memset (dp,0,sizeof(dp));
	cin>>r>>g;
	h=sqrt(r+g+r+g);
	while(h*(h+1)<=r+g+r+g) h++;
	dp[0]= 1;
	for(int i=1; i<h; i++) {
		for(int j=r; j>=i; j--) {
			dp[j] += dp[j-i];
			dp[j]%=mod;
		}
	}
	sum=h*(h-1)/2;
	for(int i=r; ~i; i--) {
		if(sum-i>g) break;
		ans+=dp[i];
		ans%=mod;
	}
	cout<<ans;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#define il inline
#define vd void
#define rep(i,x,y) for(register int i=x;i<=y;++i)
#define drp(i,x,y) for(register int i=x;i>=y;--i)
using namespace std;
const int Len=2333333;
char buf[Len],*p1=buf,*p2=buf,duf[Len],*q1=duf;
il char gc(); il int rd(); il vd pc(char c); il vd rt(int x); il vd flush();
int n,s;
int main(){//sjn AK IOI
	cin>>n>>s;
	int ans=s/n;
	if(s%n) ++ans;
	cout<<ans;
	return flush(),0;
}

il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;}
il int rd(){char c;
	while(!isdigit(c=gc())&&c!='-');
	int f=c=='-'?c=gc(),1:0,x=c^48;
	while(isdigit(c=gc())) x=((x+(x<<2))<<1)+(c^48);
	return f?-x:x;
}
il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;}
il vd rt(int x){x<0?pc('-'),x=-x:0,pc((x>=10?rt(x/10),x%10:x)+48);}
il vd flush(){fwrite(duf,1,q1-duf,stdout);}


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

int main(){
	char a, b;
	int h1, h2, m1, m2;
	cin >> h1 >> a >> m1 >> h2 >> b >> m2;
	int t1 = h1*60 + m1;
	int t2 = h2*60 + m2;
	int mid = (t1+t2)/2;
	int hAns = mid/60;
	int mAns = mid%60;
	if(hAns < 10) cout << "0" << hAns << ":";
	else cout << hAns << ":";
	if(mAns < 10) cout << "0" << mAns << endl;
	else cout << mAns << endl;
	return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main ()
{int n=0;
string x,s;
cin>>x>>s;
for (int i=0 ; i<x.length();i++)
{if (x[i]<'a')
{x[i]+=32;}
if (s[i]<'a')
{s[i]+=32;}
	if (x[i]==s[i])
{n++;}
else
{if (x[i]<s[i] )
{cout<<-1<<endl;
break;}
else
{cout<<1<<endl;
break;}
}
}
if (n==x.length())
cout<<0<<endl;
	return 0;
}


//space optimisation using bit set
//checking if a number is prime or not ~10^14
//bitset sieve is only for a number less than 10^7 but if we have to check after it
#include<bits/stdc++.h>
using namespace std;
const int n = 10000005;
bitset<10000005>b;
vector<int>prime;
void sieve()
{
    //set all the bits
    b.set();//1,1,1,1,

    b[0]=b[1]=0;

    for(long long int i=2;i<=3000;i++)
    {
        if(b[i])
        {
            prime.push_back(i);
           for(long long int j =i*i;j<=3000;j = j+i)
           {
                    b[j]=0;
           }
        }
    }
}
//if the numvber is less than 10^7 ,then we check sieve O(1) if larger than that then we check
//O(sqrt(N)) of than number
// bool Isprime(long long int No)
// {
//     if(No <= n) return b[No] ==1 ? true:false;
//     for(long long int i =0; prime[i] * prime[i] <=No ;i++)
//     {
//         if(No%prime[i] ==0 ) return false;
//     }
//     return true;
// }
int main()
{
    sieve();
//    if(Isprime(2131234113)) cout<<"yes it is";
//    else cout<<"its not ";
int No;
cin>>No;
int count =0,num=0;
for(int j=2;j<=No;j++)
{  count =0;
       for(int i =0;i<prime.size();i++)
       {
          if(j%prime[i]==0)
         {
            count+=1;
         }
         if(count>2) break;

      }
      if(count==2)num+=1;
}
cout<<num;
   return 0;
}


//
//  main.cpp
//  CF Testing Round #8 B
//
//  Created by luras on 16/5/13.
//  Copyright (c) 2016年 luras. All rights reserved.
//

#define ms(x, y) memset(x, y, sizeof(x))
#define mc(x, y) memcpy(x, y, sizeof(x))
#define lson o << 1, l, mid
#define rson o << 1 | 1, mid + 1, r
#define ls o << 1
#define rs o << 1 | 1
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<queue>
#include<map>
#include<stack>
#include<vector>
#include<list>
#include<set>
#include<string>
#include<algorithm>
#pragma comment(linker,"/STACK:102400000,102400000")
template <class T> inline void gmax(T &a, T b){if(b > a) a = b;}
template <class T> inline void gmin(T &a, T b){if(b < a) a = b;}
using namespace std;
const int N = 1e3 + 10, M = 2e6 + 10, Z = 1e9 + 7, maxint = 2147483647, ms1 = 16843009, ms31 = 522133279, ms63 = 1061109567, ms127 = 2139062143;
const double PI = acos(-1.0), eps = 1e-8;
typedef long long LL;
void fre()
{
    freopen("/Users/luras/Desktop/in.txt", "r", stdin);
    freopen("/Users/luras/Desktop/out.txt", "w", stdout);
}
const double INF = 1e9;
int casenum, casei;

int a[30], b[30], ans;
int len1, len2;
char s1[300], s2[300];

int main()
{
    while(~ scanf("%s%s", s1, s2)){
        ms(a, 0); ms(b, 0);
        len1 = strlen(s1);
        len2 = strlen(s2);
        for(int i = 0; i < len1; i ++){
            a[s1[i] - '0'] ++;
        }
        a[2] += a[5]; a[6] += a[9];
        a[5] = a[9] = 0;
        for(int i = 0; i < len2; i ++){
            b[s2[i] - '0'] ++;
        }
        b[2] += b[5]; b[6] += b[9];
        b[5] = b[9] = 0;
        ans = INF;
        for(int i = 0; i <= 9; i ++){
            if(a[i])gmin(ans, b[i] / a[i]);
        }
        printf("%d\n", ans);

    }
    return 0;
}

/*

 题意:

 类型:

 分析:

 优化:

 trick:

 数据:

 Sample Input

 Sample Output

 */


#include <iostream>
#include <cstdio>

using namespace std;

typedef long long int LL;

const LL MOD = 1e9+7;

LL qp(LL p,LL x) { LL ans = 1; for(int i=0;i<x;++i) ans = (ans*p)%MOD; return ans; }

LL solve(LL p,LL k)
{
    if(k<=1) return qp(p,p-1+k);
    int ord = 1;
    for(LL now=k;now!=1;++ord) now = (now*k)%p;
    return qp(p,(p-1)/ord);
}

int main(void)
{
    LL p,k;
    cin >> p >> k;
    cout << solve(p,k) << endl;
    return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int N = 205;

int k;
char s[N];

int main() {
    scanf(" %s %d", s, &k);
    int len = strlen(s);
    for (int i = len; i < len + k; i++)
        s[i] = '?';
    int ans = 0;
    for (int i = 0; i < len + k; i++) {
        for (int j = 0; j < len + k; j++) {
            int sz = (j - i + 1) / 2;
            bool ok = true;
            for (int l = i; ok && l < i + sz; l++)
                if (s[l + sz] != '?' && s[l] != s[l + sz])
                    ok = false;
            if (ok)
                ans = max(ans, 2 * sz);
        }
    }
    printf("%d\n", ans);
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<vector>
#include<ctime>
#include<cstring>
#include<map>
#include<cmath>
#include<queue>
#define mp make_pair
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
using namespace std;
inline int read(){
	int x=0,f=1;char c=getchar();while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	return f==-1?~x+1:x;
}
int n,k;
int ans=0;
int p[200010];
bool vis[200010];
int mu[200010];
const int mod=998244353;
inline int qpow(int x,int k=mod-2){
	int res=1;
	while(k){ if(k&1) res=1ll*res*x%mod; x=1ll*x*x%mod; k>>=1;}
	return res;
}
int fac[200010],ifac[200010];
int xs[200010];
void prework(int x){
	fac[0]=1;
	mu[1]=1;
	for(int i=1;i<=x;++i) fac[i]=1ll*fac[i-1]*i%mod;
	ifac[x]=qpow(fac[x]);
	for(int i=x-1;i>=0;--i) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
	int tot=0;
	for(int i=2;i<=x;++i){
		if(!vis[i]) p[++tot]=i,mu[i]=-1;
		for(int j=1;j<=tot&&i*p[j]<=x;++j){
			vis[i*p[j]]=1;
			if(i%p[j]==0){
				mu[i*p[j]]=0;break ;
			}
			mu[i*p[j]]=-mu[i];
		}
	}
	for(int i=1;i<=n;++i) xs[n/i+(n%i!=0)]+=mu[i];
	xs[1]=0;
	for(int i=1;i<=n;++i) xs[1]-=xs[i];
}
typedef vector<int>poly;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x<y?x+mod-y:x-y;}
int x,len,R[1<<20|1];
void init(int sz){
	x=1,len=0;
	while(x<=sz) x<<=1,++len;
	for(int i=0;i<x;++i) R[i]=(R[i>>1]>>1)|((i&1)<<len-1);
}
void NTT(poly &s,int f){
	for(int i=0;i<x;++i) if(R[i]>i) swap(s[i],s[R[i]]);
	for(int l=1;l<x;l<<=1){
		int w;if(f==1) w=qpow(3,(mod-1)/(l<<1));
		else w=qpow(qpow(3),(mod-1)/(l<<1));
		for(int j=0;j<x;j+=(l<<1)){
			int sum=1;
			for(int k=0;k<l;++k){
				int a1=s[j+k],a2=1ll*sum*s[j+k+l]%mod;
				s[j+k]=add(a1,a2);s[j+k+l]=sub(a1,a2);sum=1ll*sum*w%mod;
			}
		}
	}
	if(f==-1){
		int t=qpow(x);
		for(int i=0;i<x;++i) s[i]=1ll*s[i]*t%mod;
	}
}
poly operator *(poly A,poly B){
	int n=A.size(),m=B.size();
	if(n<=8||m<=8||(n+m<=100)){
		poly res(n+m-1,0);
		for(int i=0;i<n;++i){
			for(int j=0;j<m;++j){
				(res[i+j]+=1ll*A[i]*B[j]%mod)%=mod;
			}
		}
		return res;
	}
	init(n+m-1);
	A.resize(x);B.resize(x);NTT(A,1);NTT(B,1);
	for(int i=0;i<x;++i) A[i]=1ll*A[i]*B[i]%mod;
	NTT(A,-1);
	A.resize(n+m-1);
	return A;
}
int val[200010];
bool used[200010];
int get(int x){
	if(used[x]) return val[x];
	poly f(x+1,0),g(x+1,0);
	for(int i=0;i<=x;++i) f[i]=1ll*((i&1)?mod-1:1)*ifac[i]%mod,g[i]=1ll*ifac[i]*qpow(i,x)%mod;
	f=f*g;
	// printf("x:%d\n",x);
	// for(int i=0;i<f.size();++i) printf("%d ",f[i]);printf("\n");
	for(int i=0;i<=k&&i<f.size()&&i<=x;++i) (val[x]+=f[i])%=mod;used[x]=1;
	// printf("x:%d,%d\n",x,val[x]);
	return val[x];
}
int main(){
	n=read(),k=read();
	if(n==1||k==1) {
		printf("1\n");return 0;
	}
	prework(n);
	for(int i=1;i<=n;++i) if(xs[i]) (ans+=1ll*get(i)*xs[i]%mod)%=mod;
	printf("%d\n",(ans+mod)%mod);
}


// In the name of Allah.
// We're nothing and you're everything.
// Ya Ali!

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn = 1e7 + 14;
int n, phi[maxn], suf[maxn];
vector<int> all[maxn];
bool mark[maxn];
ll c1, c2;
int bads = 1;
int mults(int p, int l, int r){
	return r / p - l / p;
}
int main(){
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++){
		phi[i] += i;
		c1 += max(0, i - 1 - phi[i]);
		for(int j = i * 2; j <= n; j += i)
			phi[j] -= phi[i];
	}
	//cerr << ans << '\n';
	vector<int> pr;
	for(int i = 2; i <= n; i++)
		if(!mark[i]){
			pr.push_back(i);
			if(i * 2 > n)
				bads++;
			for(int j = i; j <= n; j += i)
				if(!mark[j]){
					mark[j] = 1;
					all[i].push_back(j);
				}
			if(i * 2 <= n)
				suf[i] = all[i].size();
		}
	for(int i = n; i >= 0; i--)
		suf[i] += suf[i + 1];
	int goods = n - bads;
	ll allp = (ll) goods * (goods - 1) / 2;
	c2 = allp - c1;
	int ptr = n;
	while(!pr.empty() && pr.back() * 2 > n)
		pr.pop_back();
	for(int i = 0; i < pr.size(); i++){
		if(2 * pr[i] > n)
			break;
		while(ptr && (ll) ptr * pr[i] > n)
			ptr--;
		cerr << suf[ptr + 1] << '\n';
		c2 -= suf[ptr + 1];
	}
	ptr = (int) pr.size() - 1;
	for(int i = 0; i < pr.size(); i++){
		if(2 * pr[i] > n)
			break;
		if(ptr < i)
			ptr = i;
		while(ptr >= i && (ll) pr[ptr] * pr[i] > n)
			ptr--;
		//cerr << suf[ptr + 1] << '\n';
		c2 += pr.size() - ptr - 1;
	}
	cerr << (allp - c1 - c2) << '\n';
	cout << c1 + c2 * 2 + (allp - c1 - c2) * 3 << '\n';
}


#include <bits/stdc++.h>

using namespace std;

bool good(int x0, int y0, int x1, int y1)
{
    if(x0==0 && y0==0)
        return true;
    if(y1==0 && y1==0)
        return false;
    while(1)
    {
        if(x0)
            x0--;
        else
            y0--;
        if((x0==0 && y0==0) || (x0-y0==x1-y1 && min(x0, y0)<min(x1, y1)))
            return true;
        x1=max(0, x1-1);
        y1=max(0, y1-1);
        if(x1==0 && y1==0)
            return false;
    }
    return false;
}

int main()
{
    int x0, y0, x1, y1;
    scanf("%d%d%d%d", &x0, &y0, &x1, &y1);
    if(good(x0, y0, x1, y1) || good(y0, x0, y1, x1))
        printf("Polycarp\n");
    else
        printf("Vasiliy\n");
    return 0;
}


#include <iostream>
#include<stdio.h>
#include<set>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
long long v1=1000000009,ans=1;
int vis[1000],len=0;
vector<int>ed[1000];
long long fact[1000005],invfact[1000005];

int main()
{
   long long i,j,k=0,n,m,a,b,c,d;
   cin>>n>>m>>k;
   if(m<k)
   {
   	cout<<m<<endl;
   	return 0;
   }
   a=n-m;
   c=m;
   m=m-a*(k-1),j=1;
   if(m<=0)
   {
   	cout<<c<<endl;
   	return 0;
   }
   n=m/k;
   d=2;
   for(i=1;i<=n;i=(i<<1))
     {
	 if((i&n)>0)
     {
       j=(j*d)%v1;
     }
     d=(d*d)%v1;
     }
   j=(2*k*j-2*k)%v1;
   j=(j+m%k)%v1;
   j=(j+a*(k-1))%v1;
   cout<<j<<endl;
   return 0;
}


/*
 * main.cpp
 *
 *  Created on: Jun 5, 2017
 *      Author: kagy
 */
#include <iostream>
#include <set>
#include <vector>

using namespace std;

void collect(vector<unsigned long long> & v, unsigned long long z, unsigned long long r)
{
	unsigned long long t=1;

	v.push_back(t);
	while (t*(double)z<=r)
	{
		t*=z;
		v.push_back(t);
	}
}

int main(void)
{
	vector<unsigned long long> vx, vy;
	set<unsigned long long> unlucky;
	set<unsigned long long>::const_iterator it;
	unsigned long long x, y, l, r, o, dMax, last, d;
	unsigned int i, j;

	cin >> x >> y >> l >> r;
	collect(vx, x, r);
	collect(vy, y, r);
	for (i=0; i<vx.size(); i++)
		for (j=0; j<vy.size(); j++)
		{
			o=vx[i]+vy[j];
			if (l<=o && o<=r)
				unlucky.insert(o);
		}
	unlucky.insert(r+1);
	last=l-1;
	dMax=0;
	for (it=unlucky.begin(); it!=unlucky.end(); it++)
	{
		d=(*it)-last;
		if (d>0)
			d--;
		if (d>dMax)
			dMax=d;
		last=(*it);
	}
	cout << dMax << '\n';

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c=0,cc=0,dd=0,ee=0,ff=0;
    cin>>n;
    string s,t;
    t="4";
    cin>>s;
   // cout<<s.length();
    for(int i=0;i<s.length();i++){
        if(s[i]=='4')c++;
        else if(s[i]=='7')c++;
    }
    int d=n/2;
    int l=s.length();
    int q=(l/2);
    if(c==s.length()){
        for(int i=0;i<l/2;i++){

                if(s[i]=='4')cc++;
                else if(s[i]=='7')dd++;
            }
        for(int j=q;j<l;j++){
            if(s[j]=='4')ee++;
            if(s[j]=='7')ff++;
        }
        if(cc==ee&&dd==ff)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    else cout<<"NO"<<endl;

}


#include<iostream>
using namespace std;
int a[100],n,k,i;
int main()
{
    cin>>n>>k;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=1;a[i]>0&&a[i]>=a[k];i++);
    cout<<i-1;
    return 0;

}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<set>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
const ll p = 1e9 + 7;
ll n,m,ans;
ll qp(ll a,ll b){
	ll ans = 1,base = a;
	while(b != 0){
		if(b & 1)ans = ans * base % p;
		base = base * base % p;
		b >>= 1;
	}
	return ans;
}
int main()
{
	scanf("%lld%lld",&n,&m);
	ans = qp((qp(2,m)%p - 1 + p)%p,n)%p;
	cout<<ans<<endl;
	return 0;
}
/*
long long
线段树四倍
写代码时请注意:
	1.是否要开Long Long?数组边界处理好了么?
	2.实数精度有没有处理?
	3.特殊情况处理好了么?
	4.做一些总比不做好.
思考提醒:
	1.最大值和最小值问题可不可以用二分答案?
	2.有没有贪心策略?否则能不能dp?
*/


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n; cin >> n;
  vector<int> ts(n);
  for (int i = 0; i < n; i++) {
    cin >> ts[i];
  }
  int T; cin >> T;

  sort(ts.begin(), ts.end());
  int count = 1;
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      if (ts[j] - ts[i] > T) {
	break;
      }
      count = max(count, j-i+1);
    }
  }
  cout << count << endl;
  return 0;
}


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

#define DEBUG if(1)
#define MAXN 100
#define MAX INT_MAX
#define MAXLL INT_MAX
#define MAXU ULLONG_MAX
#define MIN -2000000
#define endl "\n"
#define INF 99999999
#define MOD 1000000007
#define s(n) scanf("%d", &n)
#define ss(a,b) scanf("%d %d",&a,&b)
#define pb push_back
#define mp make_pair
#define M_PI 3.14159265358979323846
#define sz(a) int(a.size())
#define lli long long int
#define rep(i,a,n) for (int i=a;i<n;i++)
#define ler(a,n,vec) for(int i=0;i<n;i++)s(a), vec.pb(a)
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<string, pair<int, char> > ps;
#define DEBUG if(1)
#define F first
#define S second
// #define d 256
// int dx[] = {0, 1, 0, -1};
// int dy[] = {1, 0, -1, 0};
int ddx[] = {1, 0};
int ddy[] = {0, 1};

lli k;

bool test(lli aux){
	lli kk = k;
	lli aa = 0, bb = 0;

	while(kk > 0){
		lli atual = min(aux, kk);
		kk -= atual, aa += atual;
		if(kk == 0) break;
		lli atual2 = kk/10;
		kk -= atual2;
	}
	// cout << aa << " - " << bb << endl;
	// cout << aa << " - " << aux << endl;
	if(aa*2 >= k) return true;
	return false;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> k;

	lli ans = k;

	lli com = 0, fim = ans;
	while(com < fim){
		lli mid = (com + fim) >> 1;
		if(mid == 0) break;
		if(test(mid)) fim = mid, ans = mid;
		else com = mid + 1;
	}

	// while(test(ans)) ans--;

	cout << fim << endl;

	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <string>
#include <ctime>

using namespace std;

#define rep(x, y, z) for(int x = (y), end##x = (z); x < end##x; x++)
#define all(x) (x).begin(),(x).end()

#ifdef LOCAL_DEBUG

#define DebugPrint(...) fprintf(stderr, __VA_ARGS__);

#else

#define DebugPrint(...)

#endif

typedef long long ll;
typedef pair<int, int> pii;

int main()
{
    //
#ifdef LOCAL_DEBUG

    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);

#else

//    freopen("fibsubseq.in", "r", stdin);
//    freopen("fibsubseq.out", "w", stdout);

#endif

    clock_t cl = clock();

    ll num;
    cin >> num;

    ll t = 1;

    while (num % t == 0)
        t *= 3;

    ll res = num / t + 1;

    cout << res << endl;

    //int num;

#ifdef LOCAL_DEBUG

    fprintf(stderr, "\nTime used: %lf\n", (clock() - cl) / (double)CLOCKS_PER_SEC);

#endif

    return 0;
}


///	B : Coded by Choe Kwang

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

int n, m, x;

int calc(int x) {
	return (max(0, n - 2 * x) * max(0, m - 2 * x) + 1) / 2;
}

int main() {
	scanf("%d %d %d", &n, &m, &x);
	printf("%d\n", calc(x - 1) - calc(x));
	return 0;
}


#include <iostream>
#define int long long
using namespace std;

int cnt[9];
int curcnt[9];

int res = 1e18;
void check(int sum, int mini) {
    if (sum < 0) return;
    res = min(res, sum);
    for (int i = mini; i <= 8; i++) {
        for (int j = 1; j <= cnt[i] - curcnt[i]; j++) {
            if (sum - i * j < 0) break;
            check(sum - i * j, i + 1);
        }
    }
}

signed main() {
    int w;
    cin >> w;
    for (int i = 1; i <= 8; i++) {
        cin >> cnt[i];
    }
    int x = 0;
    for (int i = 8; i >= 1; i--) {
        curcnt[i] = min(max(0ll, w - 20 - x) / i, max(0ll, cnt[i] - 9) );
        x += i * curcnt[i];
    }
    /*cout << x << endl;
    for (int i = 1; i <= 8; i++) {
        cout << curcnt[i] << " ";
    }
    cout << endl;*/
    check(w - x, 1);
    cout << w - res;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
long int n,i,ks,kf;
char s,e;
cin>>s>>e;
char p[4]={'v','<','^','>'};
for(i=0;i<4;i++)
{ if(s==p[i])
{ ks=i;
}
if(e==p[i])
{
kf=i;
}}
cin>>n;
n=n%4;
int ans=2,q=ks;
for(i=1;i<=n;i++)
{

q=q+1;
if(q==4)
  q=0;
}
if(p[q]==p[kf])
{

    ans=0;
}

    q=ks;
for(i=1;i<=n;i++)
{

q=q-1;
if(q<0)
q=3;
}
if(p[q]==p[kf])
{
    if(ans!=0)
    ans=1;
    else
        ans=2;
}

if(ans==0)
printf("cw\n");
else if(ans==1)
printf("ccw\n");
else if(ans==2)
printf("undefined\n");

return 0;
}


//codeforces 401D Roman and Numbers
#include<bits/stdc++.h>
#define ll long long
const int maxs=(1<<18)+5;
const int maxn=110;
using namespace std;
int cnt=-1,w[20],m;
ll f[maxs][maxn],n;
bool vis[10];
int main(){
	for(cin>>n>>m;n;n/=10)
	 w[++cnt]=n%10;
	f[0][0]=1;
	for(int s=1;s<1<<cnt+1;s++){
	  memset(vis,0,sizeof vis);
	  for(int i=0;i<=cnt;i++){
		if(s==(1<<i)&&!w[i]) break;
		if(!(s&(1<<i))||vis[w[i]]) continue;
		vis[w[i]]=1;
		for(int j=0;j<m;j++)
		 f[s][(j*10+w[i])%m]=(f[s][(j*10+w[i])%m]+f[s^(1<<i)][j]);
	  }
	}
	cout<<f[(1<<cnt+1)-1][0];
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n,l,r,js=0,x=1,mn,mx;
	scanf("%d%d%d",&n,&l,&r);
	for(int i=0;i<l;i++,x*=2)
		js+=x;
	mx=mn=js;
	mn+=n-l;
	x/=2;
	for(int i=l;i<n;i++){
		if(i<r)
			x*=2;
		mx+=x;
	}
	printf("%d %d",mn,mx);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define um unordered_map
#define F first
#define S second
#define MOD 1000000007
#define TC int t; cin >> t; while(t--)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define count_bits(val) __builtin_popcount(val)

const int maxn = 105;
int n,k,l;
int a[maxn];
int dp[2*maxn][maxn];
vi dist;

int solve(int curr_time, int i){

	if( i >= n)
		return 1;

	if(a[i] + dist[curr_time % (2*k)] > l)
		return 0;

	if(dp[curr_time % (2*k)][i] != -1)
		return dp[curr_time % (2*k)][i];

	int ans = 0;
	for(int inc = 1; inc <= 2*k;inc++){
		if(a[i] + dist[(curr_time + inc - 1) % (2*k)] <= l)
			ans += solve((curr_time + inc) % (2*k), i+1);
		else break;
	}

	return (dp[curr_time % (2*k)][i] = (ans >= 1));
}

signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
	#endif
	TC{
		cin >> n >> k >> l;
		for(int i=0;i<n;i++) cin >> a[i];
		memset(dp, -1, sizeof(dp));
		for(int i=0;i<=k;i++) dist.pb(i);
		for(int i=k-1;i>=1;i--) dist.pb(i);
		int ans = 0;
		for(int i=1;i<=2*k;i++){
			ans += solve(i % (2*k), 0);
		}
		string sl = (ans >= 1) ? "Yes" : "No";
		cout << sl << endl;
		dist.clear();
	}

	return 0;
}


#include <iostream>
#include <string>
#include <sstream>
using namespace std;
double todouble (string s)
{
    stringstream m;
    int n;
    m<<s;
    m>>n;
    return n;
}
int main ()
{
    string num , temp1,temp2,temp3;
    cin>>num;
    int res=-1 , temp , temp4 , temp5 , mom;
     int siz=num.size();
    for (int i=siz-3;i>=0;i--)
    {
        temp1=num.substr(0,i+1);
        temp=todouble (temp1);
        if (temp > 1000000)
            continue;
        else if (temp1.size()>1 && temp1[0]=='0')
                continue;
        for (int j=siz-2;j>=i+1;j--)
        {
            temp2=num.substr(i+1,j-i);
            temp3=num.substr(j+1,siz-j+1);
            temp4=todouble (temp2);
            temp5=todouble(temp3);
            if (temp4>1000000 || temp5>1000000)
                continue;
            else if (temp2.size()>1 && temp2[0]=='0')
                continue;
            else if (temp3.size()>1 && temp3[0]=='0')
                continue;
            mom=temp+temp4+temp5;
            if (mom>res)
                res=mom;
        }
    }
    cout<<res;
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n, posM=0, posm=0;
	cin>>n;
	int* arr = new int[n];
	for(int i=0; i<n; i++)
	{
		cin>>arr[i];
		if(arr[i]==n) {posM=i;}
		if(arr[i]==1) {posm=i;}
	}
	int a, b;
	a=min(abs(n-1-posM), abs(posM));
	b=min(abs(n-posm-1), abs(posm));
	cout<<n-1-min(a, b);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{	ios::sync_with_stdio(0);
    int n,a,b;
    cin>>n>>a>>b;
    cout<<((a+b)%n+n-1)%n+1;
}


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

int main()
{
    int ya,wa,dot,count,sub;
    cin>>ya>>wa;
    if(ya>wa)
    {
        count=ya;
    }
    else if(wa==ya)
    {
        count=wa;
    }
    else
    {
        count=wa;
    }
    sub=6-(count-1);
    if(sub==6)
    {
        cout<<"1/1";
    }
    else if(sub==5)
    {
        cout<<"5/6";
    }
    else if(sub==1)
    {
        cout<<"1/6";
    }
    else if(sub==2)
    {
        cout<<"1/3";

    }
    else if(sub==3)
    {
        cout<<"1/2";
    }
    else
    {
        cout<<"2/3";
    }
    return 0;
}


//How can I pass?

#include <cstdio>
#include <algorithm>
#include <cmath>

typedef long long LL;

using namespace std;

int main(){
	LL n, m, k;
	scanf("%lld%lld",&n,&m);
	for(k = 0; k * (k - 1) / 2 < m; k++);
	printf("%lld %lld\n", max(0LL, n - 2 * m), n - k);
	return 0;
}


#include <iostream>
#include <string>
using namespace std;
int dir;
int n,m,k;

int go(int pos)
{
	if(pos==1)
	{
		dir=1;
		return pos+1;
	}
	if(pos==n)
	{
		dir=0;
		return pos-1;
	}
	if(dir)
		return pos+1;
	return pos-1;
}

int main()
{
	//freopen("input.txt","r",stdin);
	cin>>n>>m>>k;
	string napr,isstop;
	cin>>napr>>napr;
	cin>>isstop;

	if(napr=="head")
		dir=0;
	else
		dir=1;

	for(int i=0;i<isstop.size();i++)
	{
		if(isstop[i]=='1')
		{
			k=go(k);
			if(dir==0)
			{
				if(k==n)
					m=1;
				else
					m=n;
			}
			else
			{
				if(k==1)
					m=n;
				else
					m=1;
			}
		}
		else
		{
			if(dir==0)
			{
				if(m<k)
				{
					m--;
					m=max(1,m);
				}
				else
				{
					m++;
					m=min(m,n);
				}
			}
			else
			{
				if(m>k)
				{
					m++;
					m=min(m,n);
				}
				else
				{
					m--;
					m=max(1,m);
				}
			}
			k=go(k);
		}
		if(m==k)
		{
			cout<<"Controller "<<i+1;
			return 0;
		}
	}
	cout<<"Stowaway";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n, x, y, c;

bool ok(ll t) {
	ll res = 0;
	ll rowl = max(1ll, y - t), rowh = min(n, y + t);
	for (ll row = rowl; row <= rowh; row++) {
		ll tt = t - abs(y - row);
		ll coll = max(1ll, x - tt), colh = min(n, x + tt);
		res += colh - coll + 1;
		if (res >= c) return 1;
	}
	return 0;
}

int main() {
	cin >> n >> x >> y >> c;
	ll lo = 0, hi = 2 * n, mid;
	while (lo <= hi) {
		mid = (lo + hi) / 2;
		if (ok(mid)) hi = mid - 1;
		else lo = mid + 1;
	}
	cout << lo << endl;
	return 0;
}


#include <bits/stdc++.h>
#define fr first
#define r_0 return 0
#define sc scanf
#define pf printf
#define se second
#define ll long long
#define pb push_back
#define puf push_front
#define mk make_pair
#define ld long double
#define pr pair<int,int>
#define piip pair< pair<ll,ll>,ll >
#define fin(s) freopen( s, "r",stdin )
#define fout(s) freopen( s, "w", stdout )
#define TIME ios_base::sync_with_stdio(0)
using namespace std;
vector<int>V,B;
set<int>S;
map<string,int>M;
queue<int>Q;
deque<int>D;
vector<pair<int,int>>P;
ll n ,x,ans,a,b;
int  arr[101],ar[101];
string s;
ll m;
int main ()
{
   TIME;
   while (cin>>s)
   { for (int i =0; i <s.size(); i ++ )
       if (s[i]<'a' and s[i]>='A')
        ans++;
       b=max(ans,b);
       ans=0;
   }

       cout<<b;
}


    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    using namespace std;
    const int N=1e5+1,MOD=998244353;
    int lim[N][2][2],p[N<<2][2][2],psb[N][2];
    inline int qpow(int base,int expo)
    {
    	int ret=1;
    	while(expo)
    	{
    		if(expo&1) ret=1ll*ret*base%MOD;
    		base=1ll*base*base%MOD;
    		expo>>=1;
    	}
    	return ret;
    }
    inline void up(int now,int mid)
    {
    	int i,j,k,l;
    	for(i=0;i<2;i++)
    	{
    		for(j=0;j<2;j++)
    		{
    			p[now][i][j]=0;
    			for(k=0;k<2;k++)
    				for(l=0;l<2;l++)
    					if(!lim[mid][k][l])
    						p[now][i][j]=(0ll+p[now][i][j]+1ll*p[now<<1][i][k]*p[now<<1|1][l][j]%MOD)%MOD;
    		}
    	}
    }
    void build(int now,int l,int r)
    {
    	if(l==r)
    	{
    		p[now][0][0]=psb[l][0];
    		p[now][1][1]=psb[l][1];
    		return;
    	}
    	int mid=(l+r)>>1;
    	build(now<<1,l,mid);
    	build(now<<1|1,mid+1,r);
    	up(now,mid);
    }
    void update(int now,int l,int r,int qp)
    {
    	if(l==r) return;
    	int mid=(l+r)>>1;
    	if(qp<=mid) update(now<<1,l,mid,qp);
    	else update(now<<1|1,mid+1,r,qp);
    	up(now,mid);
    }
    struct chase
    {
    	int x,xp,yp;
    	double tim;
    	int rtim;
    	chase(int x=0,int xp=0,int yp=0,double tim=0,int rtim=0):
    		x(x),xp(xp),yp(yp),tim(tim),rtim(rtim){}
    } cs[N*2];
    int csc;
    inline int cmp(chase a,chase b){return a.tim<b.tim;}
    int main()
    {
    	int n,i,lasp,lasv,inv=qpow(100,MOD-2);
    	scanf("%d",&n);
    	for(i=1;i<=n;i++)
    	{
    		int tpos,tv;
    		scanf("%d%d%d",&tpos,&tv,&psb[i][1]);
    		if(i>1)
    		{
    			int dis=tpos-lasp;
    			cs[++csc]=chase(i-1,1,0,dis/1.0/(tv+lasv),1ll*dis*qpow(tv+lasv,MOD-2)%MOD);
    			if(tv<lasv) cs[++csc]=chase(i-1,1,1,dis/1.0/(lasv-tv),1ll*dis*qpow(lasv-tv,MOD-2)%MOD);
    			else if(tv>lasv) cs[++csc]=chase(i-1,0,0,dis/1.0/(tv-lasv),1ll*dis*qpow(tv-lasv,MOD-2)%MOD);
    		}
    		psb[i][0]=1ll*(100-psb[i][1])*inv%MOD;
    		psb[i][1]=1ll*psb[i][1]*inv%MOD;
    		lasp=tpos,lasv=tv;
    	}
    	build(1,1,n);
    	sort(cs+1,cs+csc+1,cmp);
    	int ans=0,lpsb=1;
    	for(i=1;i<=csc;i++)
    	{
    		lim[cs[i].x][cs[i].xp][cs[i].yp]=1;
    		update(1,1,n,cs[i].x);
    		int tpsb=(0ll+p[1][0][0]+p[1][0][1]+p[1][1][0]+p[1][1][1])%MOD;
    		ans=(0ll+ans+1ll*cs[i].rtim*(lpsb-tpsb+MOD)%MOD)%MOD;
    		lpsb=tpsb;
    	}
    	printf("%d",ans);
    	return 0;
    }


/**
 *  iN thE namE oF AllaH
 *  |__________________|
 *  Author : Asfaq,CSE'25,JU!
 *  Code the Time :)
**/

#include "bits/stdc++.h"
using namespace std;

#define    FasterIO      ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
typedef    long long int ll;
typedef    double        dd;
typedef    pair<ll,ll>   PLL;
typedef    vector<ll>    VL;
typedef    vector<string>VS;
typedef    vector<PLL>   VP;
typedef    map<ll,ll>    MP;
typedef    set<ll>       ST;
typedef    multiset<ll>  MST;
#define    L             2*node
#define    R             2*node+1
#define    mp            make_pair
#define    pb            push_back
#define    fi            first
#define    se            second
#define    PI            3.14159265358979
#define    pi            2*acos(0.0)
#define    INF           1e18
#define    EPS           1e-9
#define    sz(x)         (ll)(x.size())
#define    MEM(x,y)      memset(x,y,sizeof x)
#define    all(x)        (x).begin(),(x).end()
#define    sc1(x)        scanf("%lld",&x);
#define    sc2(x,y)      scanf("%lld%lld",&x,&y);
#define    sc3(x,y,z)    scanf("%lld%lld%lld",&x,&y,&z);
#define    sc4(x,y,z,w)  scanf("%lld%lld%lld%lld",&x,&y,&z,&w);
#define    scl1(x)       scanf("%lf",&x);
#define    scl2(x,y)     scanf("%lf%lf",&x,&y);
#define    cn1(x)        cin>>x;
#define    cn2(x,y)      cin>>x>>y;
#define    cn3(x,y,z)    cin>>x>>y>>z;
#define    cn4(x,y,z,w)  cin>>x>>y>>z>>w;
#define    co1(x)        cout<<x<<"\n";
#define    co2(x,y)      cout<<x<<" "<<y<<"\n";
#define    co3(x,y,z)    cout<<x<<" "<<y<<" "<<z<<"\n";
#define    TC(x)         sc1(x);    while(x--)
#define    dbg(x)        { cerr << #x << " = " << x << "\n"; }
#define    FOR(i,x,y)    for (int i = x; i <= y; i ++ )
#define    FORr(i,x,y)   for (int i = x; i >= y; i -- )

const ll  N1   = 1000010;
const ll  N2   = 2000010;
const ll  mod1 = 1e2 + 7;
const ll  mod2 = 1e9 + 7;

/*
///Geometry###
dd pw(dd x){return (x*x);}
dd dis(dd x1,dd y1,dd x2,dd y2){return sqrt(pw(x1-x2)+pw(y1-y2));}
dd Circle_line(dd a,dd b,dd c,dd x,dd y){return (abs(a*x+b*y+c)/sqrt(pw(a)+pw(b)));}
dd Co_linear(dd x1,dd y1,dd x2,dd y2,dd x3,dd y3){return x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2);}//Triangle area formula
bool Rotate_page(dd x1,dd y1,dd x2,dd y2,dd x3,dd y3){dd d1=dis(x1,y1,x2,y2),d2=dis(x2,y2,x3,y3);if(d1!=d2)return 0;if(!Co_linear(x1,y1,x2,y2,x3,y3))return 0;return 1;}
dd Polgn_area(dd x[],dd y[],ll n){dd a=0;int j=n;for(int i=1;i<=n;i++){a+=(x[j]+x[i])*(y[j]-y[i]);j=i;}return abs(a/2.0);}
dd angle(dd a,dd b,dd c){return acos((pw(b)+pw(c)-pw(a))/(2.0*b*c));}
*/

ll BS(ll a,ll b,ll aa[],ll x){while(a<=b){ll mid=(a+b)/2;if(aa[mid]==x) return 1;else if(aa[mid] > x) b=mid-1;else a=mid+1;}return -1;}
ll GCD(ll a,ll b){if(a==0) return b;else return GCD(b%a,a);}
ll prime(ll x){for (ll i=2;i*i<=x;i++){if(x%i==0) return 0;}return 1;}
void swap(char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
ll Bigmod(ll b,ll p,ll m){ll ret=1;while(p){if(p&1)ret=(ret*b)%m;b=(b*b)%m;p>>=1LL;}return ret;}
ll Joss(ll n,ll k){if(n==1) return 1;return (Joss(n-1,k)+k-1)%n+1;}
ll XtndGCD(ll a,ll b,ll *x,ll *y){if(a==0){*x=0;*y=1;return b;}ll x1,y1;ll gcd=XtndGCD(b%a,a,&x1,&y1);*x=y1-(b/a)*x1;*y=x1;return gcd;}

/*
bool vis[N1]; ll primF[N1],idx;
void SV()
{
    vis[0]=vis[1]=1;for(int i=4;i<=N1;i+=2)vis[i]=1;primF[++idx]=2;
    for(int i=3;i*i<=N1;i+=2){
        if(!vis[i])for(int j=(i*i);j<=N1;j+=(i+i))vis[j]=1;
    }
    for(int i=3;i<=N1;i+=2)if(!vis[i])primF[++idx]=i;
}
*/

int main()
{
    string s; cin>>s;
    ll n = s.size();
    ll x = 0;
    reverse(all(s));
    FOR(i,0,n-1)
    {
        x += ( s[i]-'0' ) * Bigmod(2,i,mod2);
        x %= mod2;
    }
    x = (x * Bigmod(2,n-1,mod2)) % mod2;
    co1(x);

    //main();

    return 0;
}


#include <bits/stdc++.h>

#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
using ll = long long;
using pii = pair <int, int>;
using pll = pair <ll, ll>;
using ld = long double;
// mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
const ll inf = 1e9;
const ll INF = 2e18;
const int N = 2e6 + 66;
const int M = 5005;

void solve () {
	ll x, y;
	cin >> x >> y;
	vector <ll> px, cnt;
	ll trash = x;
	for (ll i = 2 ; i * i <= x ; ++ i) {
		if (x % i == 0) {
			px.push_back (i);
			cnt.push_back (0);
			while (x % i == 0) x /= i, cnt.back()++;
		}
	}
	if (x > 1) px.push_back (x), cnt.push_back (1);
	ll now = 1;
	ll ans = 0;
	x = trash;
	// int times = 0;
	while (now != x && y) {
		// cout << now << " " << y << "\n";
		// if (times++ > 10) return;
		ll mx = -1, id = -1;
		for (int i = 0 ; i < (int)px.size() ; ++ i) if (cnt[i]) {
			ll p = px[i];
			ll cur = (y / (now * p)) * (now * p);
			if (mx <= cur) mx = cur, id = i;
		}
		assert (id != -1);
		cnt[id]--;
		ans += (y - mx) / now;
		y = mx;
		now = gcd (x, y);
	}
	ans += y / now;
	cout << ans;
}

int main (/*UwU*/) {
	ios;
	int tt = 1;
	// cin >> tt;
	while (tt--) {
		solve();
		cout << "\n";
	}
}


#include <iostream>
#include<cstdio>

using namespace std;

int main()
{
    long long n;
    while(scanf("%lld",&n)!=EOF)
    {
        if(n<=4||(long long)n%2)printf("0\n");
        else
        {
            n=(long long)n/2;
            printf("%lld\n",(long long)(n-1)/2);
        }
    }
    return 0;
}


#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k, n;
    cin >> n >> k;
    int min_numb = (int)1e9;
    for (int i = 1; i * i <= n && i < k; i++){
        if (n % i == 0) {
            int numb = (n / i) * k + i;
            if (numb < min_numb && n % k != 0) min_numb = numb;
            if (n / i < k && ((n / i) % k) != 0) numb = i * k + (n / i);
            if (numb < min_numb) min_numb = numb;
        }
    }
    cout << min_numb;
    return 0;
}


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

int main(void){

    long long int n,nn,d,x,y;

	scanf("%lld", &n);
	nn = n;
	d=0;
	while(n != 0){
		x = n;
		n /= 10;
		d++;
	}
	if(d == 1) printf("1\n");
	else if(d > 1){
		y = (x+1)*(long long)(pow(10,d-1)+1e-9);
//		for(int i = 0; i < d-1; i++) y*=10;
		printf("%lld\n", y-nn);
	}
//	printf("\nd = %lld\ny = %lld\nx = %lld\np = %lld\n",d,y,x,p);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
const int N=2e6+10;
const int mod=998244353;
int power(int x, int y){ x = x%mod, y=y%(mod-1);int ans = 1;while(y>0){if (y&1){ans = (1ll * x * ans)%mod;}y>>=1;x = (1ll * x * x)%mod;}return ans;}
int add(int a,int b) {  return (a%mod+b%mod)%mod;      }
int mul(int a,int b) {  return (a%mod*b%mod)%mod;    }
int n,k;
const int K=210;
vector<int>a(N);
vector<int>b(N);
struct cmp
{
	 bool operator()(const string &s,const  string &t) const
	 {
         if(t.size()>s.size()) return 1;
         else if(s.size()==t.size() and t>s) return 1;
         else return 0;
	 }
};

int32_t main()
{
   int n,k; cin>>n>>k; string s; cin>>s;
   set<string,cmp>st,temp; int ans=0;
   st.insert("");
   for(int j=0;j<n;j++)
   {
   	  temp=st;
   	  for(string i : st) temp.insert(i+s[j]);
   	  st=temp;
   	  while(st.size()>k) st.erase(st.begin());
   }
   if(st.size()<k) { cout<<-1; exit(0); }
   else { for(auto i : st) ans+=n-i.size(); }
   cout<<ans;
   return 0;

}


#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define oo 2000000000
#define inf 1000000000000000000
#define M  1000000007
#define M2 1000000009
#define M3 998244353
typedef long long ll;
using namespace std;
const int N = 255001;
const long double PI = acos(-1);

int n , m , freq[N],a[N],k[N];

signed main(){
    #ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
    #endif
    cin >> n >> m;
    for(int i = 0  ; i < n ; i++){
        scanf("%d",&a[i]);
    }
    int s=0,ss=0;
    for(int i = 1; i <= m ; i++){
        scanf("%d",&k[i]);
        s+=k[i];
    }
    for(int i = 0 ; i < n ; i++){
        ss=0;
        for(int ii = 0 ; ii <=100 ; ii++)freq[ii]=0;
        for(int j = i ; j < n ; j++){
            freq[a[j]]++;
            ss++;
            if(freq[a[j]]>k[a[j]])break;
            if(ss==s)return puts("YES"),0;
        }
    }
    puts("NO");

}


#pragma region
#include <bits/stdc++.h>
#define endl '\n'
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define prec fixed<<setprecision(9)
#define all(x) x.begin(),x.end()
using ll = long long;
using namespace std;
int mod = 998244353;

string to_string(string& s) {return '"'+s+'"';}
string to_string(bool& b) {return b?"true":"false";}
string to_string(const char* s) {string t; return to_string(t=s);}
template <class A, class B> string to_string(pair<A, B>& p) {return "("+to_string(p.first)+", "+to_string(p.second)+")";}
template <class A> string to_string(A& v) {string s; for (auto &x : v) s+=(s.empty()?"":", ")+to_string(x); return "{"+s+"}";}
template<class... Ts> void _debug(Ts&... args){(..., (cerr<<" "<<to_string(args))); cerr<<endl;}
#ifdef apurv
#define debug(args...) cerr<<__LINE__<<" ["<<#args<<"]:", _debug(args)
#else
#define debug(...) 42
#endif
#pragma endregion
// https://www.geeksforgeeks.org/prime-factorization-using-sieve-olog-n-multiple-queries/
#define MAXN  2000001

auto get_spf (int n) {
    vector<int> spf(n + 1, INT_MAX), primes;
    spf[0] = spf[1] = -1;
    for (int i = 0; i < n + 1; i++) {
        spf[i] = min(i, spf[i]);
        if (spf[i] != i) continue;
        for (ll j = i * (ll) i; j < n + 1; j += i)
            spf[j] = min(spf[j], i);
    }
    return spf;
}

struct hash_int {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

// A O(log n) function returning primefactorization
// by dividing by smallest prime factor at every step
ll getFactorization(int x, vector<int>& spf)
{
    unordered_map<int,ll,hash_int> mp;
    while (x != 1) {mp[spf[x]]++;x/=spf[x];}
    ll val = 1;
    for(auto& p:mp) {val*=(p.second+1); if(val>=mod) val%=mod;}
    return val;
}

int main()
{
    fastIO
    auto spf = get_spf(2000000);
    int t=1;
    while (t--) {
        int n; cin>>n;
        ll ans = 0;
        for(int i=2;i<(2*n);i+=2){
            ans*=2; if(ans>=mod) ans%=mod;
            // debug(i,getFactorization(i/2));
            ans+=getFactorization(i/2, spf);
            // cout<<"after including i="<<i<<",ans="<<ans<<endl;
            if(ans>=mod) ans%=mod;
        }
        cout<<(ans+getFactorization(n, spf))%mod<<endl;
    }
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <chrono>
#include <thread>

using namespace std;

const bool debug = false;

#ifndef M_PI
    const double M_PI = acos(-1.0);
#endif // M_PI

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
//#define ll long long
const int mod = int(1e9) + 7;
//const int inf = 1e9;
//const long long infLL = 1e11;
//const int MX2 = 10100500; //  e7
//const long long INF = 1e18 + 0.5;
const int MX = 200500; //       e5
//const int SZ = 1100;
//const int delta = 1 << 19;

int b[MX];
long long st[MX];

int main()
{
    st[0] = 1;
    for(int i = 1; i < 60; i++){
        st[i] = st[i - 1] * 2;
    }/*
    for(int i = 0; i < 50; i++){
        cout << st[i] << ' ';
    }
    return 0;*/
    ios_base::sync_with_stdio(false);
    //if(debug)
    //freopen("/Users/ozzy/Documents/in.txt","r", stdin);
    int n;
    cin >> n;
    vector<long long> trash;
    for(int i = 0; i < n; i++){
        long long a;
        cin >> a;
        long long t = a;
        int cnt = 0;
        while(true){
            if(t & 1) break;
            cnt++;
            t >>= 1;
        }
        if(t == 1){
            b[cnt]++;
        }else trash.push_back(a);
    }
    int r = b[0];
    for(int i = 1; i < 60; i++){
        while(b[i] > b[i - 1]){
            trash.push_back(st[i]);
            b[i]--;
        }
    }
    sort(trash.begin(), trash.end());
    vector<pair<long long, long long>> ans;
    for(int i = 0; i < 60; i++){
        b[i] -= b[i + 1];
        while(b[i]--){
            ans.push_back({i, 0});
        }
    }
    int pos = 0;
    for(int i = 0; i < trash.size(); i++){
        while(pos < ans.size() && st[ ans[pos].first + 1 ] < trash[i]) pos++;
        if(pos == ans.size()){cout << -1 << endl; return 0;}
        ans[pos].second = trash[i];
        pos++;
    }
    sort(ans.begin(), ans.end());
    int l = r;
    int vacant = ans.size() - trash.size();
    for(int i = 0; i < ans.size(); i++){
        vacant--;
        vacant -= ans[i].first + 1;
        if(vacant >= 0) l--; else break;
    }
    for(int i = l; i <= r; i++){
        cout << i <<  ' ';
    }
    cout << endl;
    return 0;
}


#include<bits/stdc++.h>
#define maxi 100005
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define ll long long
#define si(n) scanf("%d",&n)
#define sll(n) scanf("%lld",&n)
#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#else
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
#endif
int dbg=1;
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=0;i<=c/a;i++)
		if((c-i*a)%b==0){
			cout<<"Yes\n";
			return 0;
		}
	cout<<"No\n";
	return 0;
}


#include <iostream>
#include <time.h>
#include <vector>
#include <stdio.h>
#include <memory.h>
#include <string>
#include <map>
#include <algorithm>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_map>
#if !ONLINE_JUDGE
#include "inc.h"
#endif
using namespace std;
typedef long long ll;

vector<string>v;
int n,q;
pair<string,string>a[40];
void init(string s,int at){
	if(at==n){
		v.push_back(s);
		return;
	}
	for(int i=0;i<6;++i){
		s+=i+'a';
		init(s,at+1);
		s.resize(s.size()-1);
	}
}
unordered_map<string,bool>dp;
bool tr(string s){
	if(s.size()==1 && s[0]=='a')
		return dp[s]=1;
	if(dp.find(s)!=dp.end())
		return dp[s];
	for(int i=0;i<q;++i){
		if(s[0]==a[i].first[0] && s[1]==a[i].first[1]){
			if(tr(a[i].second+s.substr(2)))
				return dp[s]=1;
		}
	}
	return dp[s]=0;
}

int main() {
#if !ONLINE_JUDGE
	freopen("aa.txt", "r", stdin);
//	freopen("aa.txt", "w", stdout);
	decTime;
#endif

	scanf("%d%d",&n,&q);
	init("",0);
	for(int i=0;i<q;++i)
		cin>>a[i].first>>a[i].second;
	int ans=0;
	for(int i=0;i<v.size();++i)
		ans+=tr(v[i]);
	printf("%d",ans);

#if !ONLINE_JUDGE
	printTime;
#endif
	return 0;
}


#include<stdio.h>

int n,i;
int a[100];

void docfile()
{

  scanf("%d",&n);
  for (i=0;i<=n-1;i++)
      scanf("%d",&a[i]);

}

int UCLN(int x,int y)
  {
 if (y%x==0)
 return x;
 else
 return UCLN(y%x,x);
 }

int main ()
    {
    int t;
    docfile();
    t=a[0];
    for (i=1;i<=n-1;i++)
    {
    if (t<a[i])
        t=UCLN(t,a[i]);
    else
        t=UCLN(a[i],t);
    }
    printf ("%d",t*n);

    return 0;
    }


#include <iostream>
using namespace std;
int n, m;
long double mem[1005][1005];
long double dp(int x, int y) {
  if (mem[x][y] > 0) return mem[x][y];
  if (!x) return mem[0][y] = 1.0 / (y + 1);
  if (!y) return mem[x][0] = 1;
  long double mn = dp(y, x - 1) / (dp(y, x - 1) + 1.0 / (y + 1));
  return mem[x][y] = mn * y / (y + 1) * (1 - dp(y - 1, x)) + 1 - mn;
}
int main() {
  scanf("%d%d", &n, &m), printf("%.9Lf %.9Lf", dp(n, m), 1 - dp(n, m));
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define lld long double
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define PI 3.1415926535897932384626
#define mod 1000000007
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define bct(x) __builtin_popcountll(x)
#define all(v) (v).begin(),(v).end()
#define mk(arr,n,type)  type *arr=new type[n];
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// cout << s.order_of_key(2) << endl; // the number of elements in the s less than 2
// cout << *s.find_by_order(0) << endl; // print the 0-th smallest number in s(0-based)

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template<class T> void _print(priority_queue<T> pq);
template<class T> void _print(priority_queue<T, vector<T>, greater<T>> pq);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
template<typename A> void _print(priority_queue<A> pq) { if (!pq.empty()) { queue<A> t; cerr << "T["; while (pq.size() != 1) { _print(pq.top()); cerr << ","; t.push(pq.top()); pq.pop(); } _print(pq.top()); cerr << "]B"; t.push(pq.top()); pq.pop(); while (!t.empty()) { pq.push(t.front()); t.pop(); } } else { cerr << "F[]B"; } }
template<typename A> void _print(priority_queue<A, vector<A>, greater<A>> pq) { if (!pq.empty()) { queue<A> t; cerr << "T["; while (pq.size() != 1) { _print(pq.top()); cerr << ","; t.push(pq.top()); pq.pop(); } _print(pq.top()); cerr << "]B"; t.push(pq.top()); pq.pop(); while (!t.empty()) { pq.push(t.front()); t.pop(); } } else { cerr << "F[]B"; } }

/*-------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll expo(ll a, ll b, ll m) {ll res = 1; while (b > 0) {if (b & 1)res = ((res % m) * (a % m)) % m; a = ((a % m) * (a % m)) % m; b = b >> 1;} return res;}
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
ll mod_add(ll a, ll b, ll m) {a = a % m; b = b % m; return ((((a % m) + (b % m)) % m) + m) % m;}
ll mod_mul(ll a, ll b, ll m) {a = a % m; b = b % m; return ((((a % m) * (b % m)) % m) + m) % m;}
ll mod_sub(ll a, ll b, ll m) {a = a % m; b = b % m; return ((((a % m) - (b % m)) % m) + m) % m;}
ll mod_div(ll a, ll b, ll m) {a = a % m; b = b % m; return (mod_mul(a, mminvprime(b, m), m) + m) % m;}  //only for prime m
/*--------------------------------------------------------------------------------------------*/

const int N = (3e5) + 5;

const ll mod1 = 998244353;

int32_t main() {

#ifndef ONLINE_JUDGE
	freopen("Error.txt", "w", stderr);
#endif
	fastio();

	ll n, m;
	cin >> n >> m;

	vector<int> is_prine(N, 1);

	is_prine[0] = 0, is_prine[1] = 0;

	for (ll i = 2; i * (ll)i < N; i++) {
		if (is_prine[i] == 1) {
			for (ll j = i * i; j * (ll)j < N; j += i) {
				is_prine[j] = 0;
			}
		}
	}

	// Total ambiguous array = (Total number of array)- (Total number of unabiguous array).

	// total= m+(m^2)+(m^3)+(m^4)+.........+(m^n)  ---> Gp

	ll total = 0;

	for (ll i = 1; i <= n; i++) {
		ll val = expo(m, i, (ll)mod1);

		total = mod_add(total, val, (ll)mod1);
	}

	total %= mod1;

	debug(total);

	// To find --> number of unambiguous arrays

	/*
	    _,_,_,_,_,_,_,_,_,x,_,_,_,_,_,_,_,_,_,_
	    1,2,3,4,5,6,7,8,9,10

	    What is the value of x such that if it gets left shifted to any of the positions if an element get deleted such that its
	    gcd with that particular index is always >1.

	    --> This is only possible if x is a multiple of all the indicies left to it and are prime number.
	    --> x has to be a multiple of (2*3*5*7) , so that at any position its gcd with that index is greater than 1.
	*/

	ll unambiguous = 0;

	ll productOfPrimes = 1, ans = 1;

	for (ll i = 1; i <= n; i++) {
		if (is_prine[i] == 1) {
			productOfPrimes *= (ll)i;
		}

		debug(productOfPrimes);

		if (productOfPrimes > m) {  // Numbers have to be in the range from 1 to m .
			break;
		}

		ll canHave = m / productOfPrimes; // Numbers from [1,m] which are multiple of product of primes.

		canHave %= mod1;

		debug(canHave);

		ans *= canHave;
		ans %= mod1;

		unambiguous += ans;
		unambiguous %= mod1;
	}

	ll ambiguous = ((total - unambiguous) + (mod1)) % mod1;

	cout << ambiguous << endl;

	return 0;
}


    #include<algorithm>
    #include<iostream>
    #include<string.h>
    #include<stdlib.h>
    #include<limits.h>
    #include<sstream>
    #include<stdio.h>
    #include<ctype.h>
    #include<math.h>
    #include<vector>
    #include<string>
    #include<queue>
    #include<stack>
    #include<map>

    using namespace std;

    int arr[15],best[20000000];

    int  convert(int n)
    {
        int i=0,maxi;
        for(int c=0;c<10;c++)
            arr[c]=-10000000;
        while(n!=0)
        {
            arr[i]=n%10;
            n/=10;
            i++;
        }
        maxi=arr[0];
        for(int c=1;c<i;c++)
            maxi=max(maxi,arr[c]);
       return maxi;
    }

    int solve(int n)
    {
        if(n<0)return -10000000;
        if(n==0)
            return 0;
        if(best[n]!=-1)return best[n];
        //int a=-1,b=-1,c=-1,d=-1,e=-1,f=-1,g=-1;
        /*if(arr[0]>0)
        a=solve(n-arr[0])+1;
        if(arr[1]>0)
        b=solve(n-arr[1])+1;
        if(arr[2]>0)
        c=solve(n-arr[2])+1;
        if(arr[3]>0)
        d=solve(n-arr[3])+1;
        if(arr[4]>0)
        e=solve(n-arr[4])+1;
        if(arr[5]>0)
        f=solve(n-arr[5])+1;
        if(arr[6]>0)
        g=solve(n-arr[6])+1;
        */
        int maxi=convert(n);
        return best[n]=solve(n-maxi)+1;
    }

    int  main()
    {
        int n;
        scanf("%d",&n);
        memset(best,-1,sizeof best);
        int ans=solve(n);
        printf("%d\n",ans);
        return 0;
    }


#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <map>
using namespace std;
int h,m;
void theTime(int a)
{
    m+=a;
    for(;m>=60;)
    {
        m-=60;
        h++;
        if(h==24)
            h=0;
    }
}
int main()
{
    while(~scanf("%d:%d",&h,&m))
    {
        int a;
        cin>>a;
        theTime(a);
        char H[2],M[2];
        H[0]=h/10+'0';
        H[1]=h%10+'0';
        M[0]=m/10+'0';
        M[1]=m%10+'0';
        for(int i(0);i<2;i++)
            cout<<H[i];
        cout<<":";
        for(int i(0);i<2;i++)
            cout<<M[i];
        cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define lli long long
lli M=1e9;

#define PI 3.14159265

lli const MAX = 500005;
vector<int> e[MAX];

lli power(lli x, unsigned lli y, lli p)
{
    lli res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

lli modInverse(lli a, lli m)
{
    return power(a, m-2, m);
}

int main()
{
    lli q=1;
    //cin>>q;
    for(lli tc=1;tc<=q;tc++)
    {
        lli M = 998244353 ;
        lli n,k,c=0;
        cin>>n>>k;
        if(n<k)
        {
            cout<<0<<endl;
            return 0;
        }
        lli nck[n+1]={0};
        nck[k-1]=1;
        for(lli i=k;i<=n;i++)
        {
            nck[i]=(((nck[i-1]*(i))%M)*modInverse(i-k+1,M))%M;
            // cout<<i<<' '<<nck[i]<<endl;
        }
        for(int i=1;i<=n;i++)
        {
            c=(c+nck[n/i-1])%M;
        }
        cout<<c<<endl;
    }
    return 0;
}


//+-------------------------------------+
//|     By   qwer_zcc                   |
//|     Date 12/10/2014                 |
//+-------------------------------------+
#include <bits/stdc++.h>
#define INF (~0U>>1)-3
#define LLINF ~0ULL>>1
#define LL long long
#define uLL unsigned long long
#define uint unsigned int
#define D double
#define LD long double
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define drep(i,a,b) for (int i=a;i>=b;i--)
#define M(a) memset(a,0,sizeof(a));
#define pb push_back
#define mp make_pair
#define Pi M_PI
using namespace std;
template<class T> inline T min(T &a,T &b) {return a<b?a:b;}
template<class T> inline T max(T &a,T &b) {return a>b?a:b;}
template<class T> void read(T &x)
{
    char ch;
    while ((ch=getchar()) && !isdigit(ch));x=ch-'0';
    while ((ch=getchar()) && isdigit(ch)) x=x*10+ch-'0';
}
struct point
{
    int x,y;
    point() {}
    point(int _x,int _y) : x(_x),y(_y) {}
} ;
int n,m,l;
LL ans;
int main()
{
	read(n),read(m);l=n+1;
	int c;
	rep(j,m+1,n-m)
	{
		rep(i,m+1,n-m)
		{
			int x=j*(j*2-l*3)+l*l,y=l-j,z=l+j;
			if (i==m+1) c=max((x+z*i)/(i+y),m);
			else while ((c+1)*(i+y)<=x+z*i) c++;
			if (c+1<=n-m) ans+=(LL)(n-m-c);
			else break;
		}
	}
	printf("%lld\n",ans*3LL);
}


# include <iostream>
# include <map>
# include <vector>
  using namespace std;
  struct krug{
      long long x, y, r, R;
      krug()
      {
          x = 0;
          y = 0;
          r = 0;
          R = 0;
      }
      int check(krug a, long long r1)
      {
          if(((((x - a.x) * (x - a.x)) + ((y - a.y) * (y - a.y))) <= ((r - r1) * (r - r1))) && (r >= r1)) return 1;
          if((((x - a.x) * (x - a.x)) + ((y - a.y) * (y - a.y))) >= ((r1 + R) * (r1 + R))) return 1;
          if(((((x - a.x) * (x - a.x)) + ((y - a.y) * (y - a.y))) <= ((r1 - R) * (r1 - R))) && (r1 >= R)) return 1;
          return 0;
      }
  };
  int main()
  {
      long long ans;
      krug a, b;
      cin >> a.x >> a.y >> a.r >> a.R;
      cin >> b.x >> b.y >> b.r >> b.R;
      ans = 0;
      ans += a.check(b, b.r);
      ans += a.check(b, b.R);
      ans += b.check(a, a.r);
      ans += b.check(a, a.R);
      cout << ans;
      return 0;
  }


#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<": "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

ll fpow(ll x, ll y)
{
    ll res = 1;
    while(y > 0)
    {
        if(y & 1)
            res = (res % mod * x % mod) % mod;
        x = (x % mod * x % mod) % mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll a)
{
    return fpow(a, mod - 2);
}

void cp()
{
    ll n;
    cin >> n;
    ll ans = (fpow(2, n) + fpow(4, n)) % mod;
    ans = (ans * inv(2)) % mod;
    cout << ans;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MOD = 1000000007;
const int kMax = 20;
const int N = 75;

int memo[N][1 << kMax];
int first_one[N];

string poke;
int n;

bool ValidMask(int mask) {
  return mask != 0 && (mask & (mask + 1)) == 0;
}

int Solve(int ind, int mask) {
  if (ind == n) {
    return ValidMask(mask);
  }

  if (poke[ind] != 1) {
    return Solve(first_one[ind], mask);
  }

  int& res = memo[ind][mask];
  if (res != -1) {
    return res;
  }

  res = ValidMask(mask);

  int curr = 0;

  for (int i = ind; i < min(n, ind + 5); ++i) {
    curr = curr * 2 + poke[i];
    if (curr > kMax) break;
    res = (res + Solve(i + 1, mask | (1 << (curr - 1)))) % MOD;
  }

  return res;
}

void BuildFirstOne() {
  for (int i = 0; i < n; ++i) {
    first_one[i] = n;
    for (int j = i; j < n; ++j) {
      if (poke[j] == 1) {
        first_one[i] = j;
        break;
      }
    }
  }
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("test.in", "r", stdin);
//  freopen("wa.txt", "w", stdout);
#endif

  memset(memo, -1, sizeof memo);

  cin >> n >> poke;
  for (char& c : poke) {
    c -= '0';
  }
  BuildFirstOne();

  int res = 0;

  for (int i = 0; i < n; ++i) {
    res = (res + Solve(i, 0)) % MOD;
  }

  cout << res;

}


#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll long long int
#define endl "\n"
#define db(x) cout<<#x<<" ->"<<x<<endl
#define db2(x,y) cout<<#x<<"->"<<x<<", "<<#y<<" -> "<<y<<endl
#define db3(x,y,z) cout<<#x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define db4(w,x,y,z) cout<<#w <<" -> " << w << " , " << #x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define prt(x) for(auto it = x.begin(); it!=x.end(); it++) { cout<<*it<<" "; } cout<< endl
#define IN freopen("input.txt","r",stdin)

//template<typename T>
//using ordered_set =
//tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = (int)1.5e7;

namespace NumberTheory{

    #define maxn 700005

    const ll mod = (ll)1e6+3;
    ll fact[maxn+5];
    ll inverseFact[maxn+5];
    vector< int > Prime;
    bool vis[maxn+5];

    void seive(){
        for(int i=2; i*i<=maxn; i++){
            if(vis[i]==0){
                for(int j=(2*i); j<=maxn; j+=i){
                    vis[j] = true;
                }
            }
        }
        Prime.push_back(2);
        for(int i=3; i<=maxn; i+=2){
            if(vis[i]==0){
                Prime.push_back(i);
            }
        }
    }

    ll bigmod(ll a, ll n){
        if( n==0 ) { return 1LL; }
        if( n%2==0 ){
            ll ret = bigmod(a,n/2);
            return ( (ret%mod) * (ret%mod) ) % mod;
        }
        else { return ( ( a % mod ) * ( bigmod(a,n-1) % mod ) ) % mod ; }
    }

    ll modInverse(ll a){
        return bigmod(a,mod-2)%mod;
    }

    ll nCr(int n, int r){
        ll ans = (1LL*(fact[n] * inverseFact[r])%mod * inverseFact[n-r]) % mod ;
        return (ans%mod);
    }

    void PreProcess(){
        fact[0] = 1LL;
        for(int i=1; i<=maxn; i++){ fact[i] = (  1LL * fact[i-1] *  i )  % mod ; }
        inverseFact[maxn] = modInverse(fact[maxn]) ;
        for(int x=maxn-1 ; x>=0 ; x--) inverseFact[x] = ( 1LL * inverseFact[x+1] * (x+1) ) % mod ;
    }

    vector< pair< int , int >  > f(int x){
        vector< pair< int , int > > temp;
        for(int i=0; Prime[i]*Prime[i]<=x; i++){
            if(x%Prime[i]==0){
                int cnt = 0;
                while(x%Prime[i]==0){
                    cnt++;
                    x/=Prime[i];
                }
                temp.push_back( make_pair(Prime[i],cnt) );
            }
        }
        if(x>1){
            temp.push_back(make_pair(x,1));
        }
        return temp;
    }
}

using namespace NumberTheory;
int n , c;

ll NoOfSolutions(int res){
    ll cur = nCr(res + c - 1 , c - 1) % mod;
    return cur % mod;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
//    IN;
    PreProcess();
    cin >> n >> c;
    ll ans = 0LL;
    for(int i = 1 ; i <= n; i++){
        ans+=NoOfSolutions(i);
        ans%=mod;
    }
    ans+=mod;
    ans%=mod;
    cout << ans << endl;
    return 0;
}


#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;

#define NN 202
#define F first
#define S second
#define mp make_pair
#define INF 0x3f3f3f3f // infinito da distancia

int flow[NN][NN]; // zerar antes (para 0..)
int cap[NN][NN]; // preencher com as capacidades, deixar 0 se nao tiver ligacao
int pre[NN], que[NN], d[NN]; // anteriores, fila, distancia

int edmondsKarp(int n, int source, int sink) // nao testa se source == sink
{
	int p, q, t, i, j;
	while (1)
	{
		memset(pre, -1, sizeof(pre));
		d[source] = INF;
		p = q = 0, que[q++] = source;
		while (p<q && pre[sink] < 0) // bfs
		{
			t = que[p++]; // facil de trocar por uma lista de adjacencia, so arrumar \/
			for (i=0; i<n; i++) if (pre[i]<0 && (j=cap[t][i]-flow[t][i]))
				pre[que[q++]=i]=t, d[i]=min(d[t],j);
		}
		if (pre[sink]<0) break;
		for (i=sink; i!=source; i=pre[i]) flow[pre[i]][i]+=d[sink],flow[i][pre[i]]-=d[sink];
	}
	for (j=i=0; i<n; j+=flow[source][i++]);
	return j;
}

char a[11][11];
char b[11][11];
int bi, bj, dir[][2] = {0,1,0,-1,1,0,-1,0};
int mat[101][101];
int n, t;
vector<int> ca, cb, cc;

void solve(int A, int B, int* vis, bool check)
{
	queue<pair<int, int> > que;
	vis[A*n+B] = 0;
	que.push(mp(A, B));
	while (!que.empty())
	{
		pair<int, int> now = que.front();
		que.pop();
		int p = now.F*n+now.S;
		int dis = vis[p];
		if (check && (mat[bi*n+bj][p] <= dis || t <= dis))
		{
			if (mat[bi*n+bj][p] < dis || t < dis) vis[p] = INF+1;
			continue;
		}
		for (int d = 0; d < 4; ++d)
		{
			int i = dir[d][0]+now.F;
			int j = dir[d][1]+now.S;
			if (i < 0 || j < 0 || i == n || j == n) continue;
			if (b[i][j] < '0' || b[i][j] > '9') continue;
			int q = i*n+j;
			if (vis[q] != INF) continue;
			vis[q] = dis+1;
			que.push(mp(i, j));
		}
	}
}

void build()
{
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			if (b[i][j] <= '0' || b[i][j] > '9') continue;
			ca.push_back(i);
			cb.push_back(j);
			int p = i*n+j;
			cap[p+2+n*n][1] = b[i][j]-'0';
		}
	}
	int z = bi*n+bj;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			if (a[i][j] <= '0' || a[i][j] > '9') continue;
			int p = i*n+j;
			cap[0][p+2] = a[i][j]-'0';
			for (int k = 0; k < ca.size(); ++k)
			{
				int ii = ca[k];
				int jj = cb[k];
				int q = ii*n+jj;
				if (mat[p][q] < INF)
					cap[p+2][q+2+n*n] = INF;
			}
		}
	}
}

int main()
{
	scanf("%d%d", &n, &t);
	memset(mat, 0x3f, sizeof mat);
	for (int i = 0; i < n; ++i)
		scanf("%s", a[i]);
	for (int i = 0; i < n; ++i)
		scanf("%s", b[i]);
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			if (a[i][j] == 'Z') bi = i, bj = j;
		}
	}
	solve(bi, bj, mat[bi*n+bj], false);
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j) if (a[i][j] >= '1' && a[i][j] <= '9')
			solve(i, j, mat[i*n+j], true);
	build();
	/*for (int i = 2; i < n*n+2; ++i)
		for (int j = 2; j < n*n+2; ++j) if (cap[i][j] == INF)
			printf("link %d to %d\n", i-2, j-2);
	for (int i = 2; i < n*n+2; ++i)
		printf("cap from %d is %d\n", i-2, cap[0][i]);
	for (int i = 2; i < n*n+2; ++i)
		printf("cap to %d is %d\n", i-2, cap[i][1]);*/
	printf("%d\n", edmondsKarp(2+n*n+n*n, 0, 1));
}


#include <bits/stdc++.h>

using namespace std;

#define _                   ios::sync_with_stdio(0),cin.tie(0);
#define X                   first
#define Y                   second
#define mp                  make_pair
#define sz(a)               static_cast<int>((a).size())
#define FOR(i, a, b)        for (int i(a), b_(b); i < b_; ++i)
#define REP(i, n)           FOR (i, 0, n)
#define all(c)              (c).begin(), (c).end()
#define rall(c)             (c).rbegin(), (c).rend()
#define allN(c, n)          (c).begin(), (c).begin() + n
#define FORD(i, a, b)       for (int i(a), b_(b); i >= b_; --i)
#define UNIQUE(c)           sort(all(c)), (c).erase(unique(all(c)), (c).end())

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <ldb, ldb> pdd;
template <typename T> using max_queue = priority_queue<T, vector<T>, less<T>>;
template <typename T> using min_queue = priority_queue<T, vector<T>, greater<T>>;

const int       INF     = static_cast<int>(1e9);
const long long INF_LL  = static_cast<long long>(4e18);
const double    PI      = acos(-1.0);

template <typename T> inline T&     smin(T& x, const T& y) { return x > y ? x = y : x; }
template <typename T> inline T&     smax(T& x, const T& y) { return x < y ? x = y : x; }
template <typename T> inline T      sqr(const T& x) { return x * x; }
template <typename T> inline int    sgn(const T& x) { return (T(0) < x) - (x < T(0)); }

template <typename T>
static inline T gcd(T a, T b) {
    for (a = abs(a), b = abs(b); a && b; a >= b ? a %= b : b %= a);
    return a + b;
}

template <typename Iterator>
void print(Iterator first, Iterator last, const char* delimiter = " ", const char* closing = "\n") {
    for (; first != last; ++first)
        cout << *first << delimiter;
    cout << closing;
}

string line;

int n, k;

bool result = 1;

inline void add(int& val, int&delta)    {val+=delta;}

int main() {_
    cin >> n >> k >> line;
    int start = line.find('G');
    int destination = line.find('T');
    if( abs(destination - start) % k)  result = 0;
    else {
        int delta = start<destination?k:-k;
        int position = start;
        while(position!=destination) {
            if(line[position]!='.' && line[position] != 'G') break;
            add(position,delta);
        }
        if(position != destination) result = 0;
    }
    cout << (result?"YES":"NO") << endl;
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#include<sstream>
#include<unordered_map>
using namespace std;
template<typename T> void write(T x) {if (x < 0) putchar('-'), x = -x;if (x > 9) write(x / 10);putchar(x % 10 + '0');}
template <typename T> void inline read(T& x) { T f = 1; x = 0; char s = getchar(); while (s < '0' || s > '9') { if (s == '-') f = -1; s = getchar(); }while (s <= '9' && s >= '0') x = (x << 3) + (x << 1) + (s ^ 48), s = getchar(); x *= f; }
#define INF 0x3f
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 2e3 + 10;
const ll mod = 1e9+7;
const ll logn = 21;
ll f[maxn][maxn],s[maxn][maxn];
ll t, k;
void yhdelta() {
    for (int i = 0; i <= 2000; i++)
    {
        f[i][i] = 1;
        f[i][0] = 1;
    }
    for (int i = 1; i <= 2000; i++)
        for (int j = 1; j < i; j++)
        {
            f[i][j] = (f[i - 1][j - 1] + f[i - 1][j]) % k;
        }
    for (int i = 1; i <= 2000; i++)
        for (int j = 1; j <= 2000; j++)
        {
            s[i][j] = s[i][j - 1] + s[i - 1][j] - s[i - 1][j - 1];
            if (f[i][j] == 0 && j <= i)
                s[i][j]++;
        }
}
void solve()
{
    ll n; read(n);
    ll a[4];
    read(a[1]); read(a[2]); read(a[3]);
    if (a[a[n]] > 0 && a[n] > 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

int main() {
    ll T = 1;
    read(T);
    while (T--)
        solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	char str[510];
	scanf("%s",str);
	int t=0,i;
	for(i=0;i<strlen(str);i++)
	{
		if(str[i]-'a'>t)
		{
		  printf("NO\n");
		  break;
	    }
		if(str[i]-'a'==t)
		t++;
	}
	if(i==strlen(str))
	printf("YES\n");
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<string.h>
#include<map>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<set>
#include<stdio.h>
#include<stack>
#include<fstream>
#include<iomanip>
#include<unordered_map>
#include<random>
#include<time.h>
//#include<bitsdc++.h>
using namespace std;
#define as1 ios::sync_with_stdio(false)
#define as2 cout.tie(0);cin.tie(0);
#define endl '\n'
#define x first
#define y second
#define sqrt sqrtl
typedef long long ll;
typedef double ld;
typedef pair<int, int>pii;
typedef pair<ld, ld>pdd;
typedef pair<ll, ll>pll;
typedef pair<pii, pii>ppp;
const ll maxn = 4e6 + 7, maxd = 1e9 + 8, mod = 1e9 + 7;
ll n, m;
ll dp[maxn];
ll pp[maxn];

void solve() {
	cin >> n >> m;
	dp[1] = 1;
	ll pres = 1, cp = 0;
	for (int i = 2; i <= n; i++) {
		cp += pp[i] + 1;
		cp %= m;
		dp[i] = pres + cp;
		dp[i] %= m;
		for (int j = i * 2; j <= n; j += i) {
			pp[j] += dp[i] - dp[i - 1];
			pp[j] %= m;
		}
		pres += dp[i];
		pres %= m;
		//cout << i << ' ' << cp << ' ' << pres << endl;
	}
	cout << (dp[n] + m) % m;
}
int main() {
	as1; as2;
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) {
		solve();
	}
}


/*29.11.2017*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	long long a,b,c;
	cin>>a>>b>>c;
	if(b<a&&c>=0){
		cout<<"NO";
	}
	else if(c==0&&a!=b){
		cout<<"NO";
	}
	else if(b>a&&c<=0){
		cout<<"NO";
	}
	else if(a==b){
		cout<<"YES";
	}
	else if(a>=0&&b<=0){
		if((abs(a)+abs(b))%c==0){
			cout<<"YES";
		}
		else{
			cout<<"NO";
		}
	}
	else if(a<=0&&b>=0){
		if((abs(a)+abs(b))%c==0){
			cout<<"YES";
		}
		else{
			cout<<"NO";
		}
	}
	else if(a>=0&&b>=0){
		if(abs(a-b)%c==0){
			cout<<"YES";
		}
		else{
			cout<<"NO";
		}
	}
	else if(a<=0&&b<=0){
		if((a+b)%c==0){
			cout<<"YES";
		}
		else{
			cout<<"NO";
		}
	}
	else{
		cout<<"NO";
	}
	return 0;
}


#include<iostream>
#include<cmath>
#include<sstream>
#include<cstdio>
#include<set>
#include<cstring>
#include<algorithm>
#include<ctype.h>
using namespace std;
int main()
{
    long long int n,A,B;
    while(cin>>n)
    {
        long long int i,left,right,mid;
        int f=0;
        for(i=1;i<sqrt(2*n);i++)
        {
            A=i*(i+1)/2;
            left=i;
            right=sqrt(2*n);
            mid=(left+right)/2;
            while(left<=right)
            {
                B=mid*(mid+1)/2;
                if(A+B<n)
                {
                    left=mid+1;
                    mid=(left+right)/2;
                }
                if(A+B>n)
                {
                    right=mid-1;
                    mid=(left+right)/2;
                }
                if(A+B==n)
                {
                    f=1;
                    break;
                }
            }
            if(f==1)
            {
                break;
            }
        }
        if(f)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


#include <vector>=
#include <algorithm>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <limits>
#include <climits>
#include <cstdio>
#include <numeric>
#define ll long long
using namespace std;
const int inf = 0x3f3f3f3f;
const ll mod = 1000000007;
const double pi = acos(1.0*(-1));
typedef pair<int, int> P;
int num[300010];
ll n, l, r, s = 1, ans;
void solve(ll a, ll b, ll l, ll r, ll d)//二分的思想
{
	if (a > b || l > r)    return;
	else
	{
		ll mid = (a + b) / 2;
		if (r < mid)solve(a, mid - 1, l, r, d / 2);
		else if (mid < l)solve(mid + 1, b, l, r, d / 2);
		else {
			ans += d % 2;
			solve(a, mid - 1, l, mid - 1, d / 2);
			solve(mid + 1, b, mid + 1, r, d / 2);
		}
	}
}
int main()
{
	cin >> n >> l >> r;
	long long p = n;
	while (p >= 2)
	{
		p /= 2;
		s = s * 2 + 1;
	}
	solve(1, s, l, r, n);
	cout << ans << endl;
	return 0;
}


#include <iostream>

using namespace std;

int main()
{
int g,c,h=0;int b=0;cin>>g>>c;
while(g>0){
b=g%c+b;
h=h+g;
g=g/c;
}
h=h+b/c+(b/c+b%c)/c+((b/c+b%c)/c+(b/c+b%c)%c)/c;
cout<<h<<endl;

    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,area = 0,minx = 31400,miny = 31400,maxx=0,maxy=0;
    cin >> n;
    int x,y,xx,yy;
    for(int i = 0;i < n;i++){
        cin >> x;cin >> y;cin >> xx;cin >> yy;
        area += (xx-x) * (yy-y);
        if(x < minx) minx=x;
        if(y < miny) miny= y;
        if(xx > maxx) maxx = xx;
         if(yy > maxy) maxy = yy;
    }
    if ( maxx - minx == maxy - miny && area == (maxx-minx)*(maxx-minx))
    cout << "YES"  << endl;
    else cout<<"NO";
    return 0;
}


#include<iostream>
using namespace std;
int main()
{
	long long n; cin >> n;
	if(n%2 && n>3)cout << "1 " << (n-3)/2 << endl;
	else cout << "NO\n";
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size()
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)

/****************************** CODE IS HERE ***********************************/

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int n; cin >> n;
    vector <int> A(n);
    for (int &i: A) cin >> i;

    vector <int> total(n), score(n);

    total[n-1] = A[n-1];
    score[n-1] = A[n-1];

    for (int i = n-2; i >= 0; --i) {
        total[i] = A[i] + total[i+1];
        int first = A[i] + total[i+1] - score[i+1];
        int second = score[i+1];
        score[i] = max(first, second);
    }

    int first = total[0] - score[0];
    int second = score[0];
    cout << min(first, second) << " " << max(first, second);

    return 0;
}

/*

*/


#include <bits/stdc++.h>
using namespace std ;
#define FAST ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long
#define lli long long int
#define ld long double
#define MOD 1000000007
#define endl "\n"
#define all(v) v.begin(),v.end()
#define tc() int t; cin >> t ; while (t--)

#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

ll visted1[6];
ll visted2[6];

vector<long long> trial_division1(long long n) {
    vector<long long> factorization;
    for (long long d = 2; d * d <= n; d++) {
        while (n % d == 0) {
            factorization.push_back(d);
            n /= d;

        }
    }
    if (n > 1)
        factorization.push_back(n);
    return factorization;
}

int main(){
    FAST;

ll a,b;
cin>>a>>b ;

vector<ll>res1=trial_division1(a);
vector<ll>res2=trial_division1(b);

ll x=0,y=0;

for(int i=0;i<res1.size();i++){

    if(res1[i]==2 || res1[i]==3 || res1[i]==5){
        visted1[res1[i]]++;
    }
    else{
        x=res1[i];
    }
}

for(int i=0;i<res2.size();i++){

    if(res2[i]==2 || res2[i]==3 || res2[i]==5){
        visted2[res2[i]]++;

    }
    else{
        y=res2[i];
    }
}

if(x !=y){
cout<<-1;
}
else{

    cout<<abs(visted1[2]-visted2[2]) +  abs(visted1[3]-visted2[3]) +  abs(visted1[5]-visted2[5]) ;

}

}


// i_am_arin

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<long long> vll;
typedef vector<string> vs;

#define f(i, a, n) for(ll i=a; i<(ll)n; i++)
#define f2(i, a, b) for(ll i=a; i<=(ll)b; i++)
#define PB push_back
#define FF first
#define SS second
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;

void solve(){
	int n;
	cin>>n;
	int cnt=1;
	vector<int> ans;
	while(n){
		if(n%2) ans.PB(cnt);
		cnt++;
		n/=2;
	}
	reverse(ans.begin(), ans.end());
	for(auto c: ans) cout<<c<<" ";
}

int main(){
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
using namespace std;

int f[1000010],op[100010],ans=1<<30;
bool b[1000010];

int main()
{
	for (int i=2;i<=1000000;i++)
	{
		if (b[i]==false) op[++op[0]]=i;
		for (int j=1;j<=op[0];j++)
		if (i*op[j]<=1000000) b[i*op[j]]=true;
		else break;
	}

	int x,y,o;
	scanf("%d",&x);
	for (int i=x-1;i>1;i--)
	if (x%i==0 && b[i]==false)
	{
		//printf("%d\n",i);
		y=(x/i-1)*i+1;
		o=0;
		for (int j=y;j<=x;j++)
		if (f[j]==0)
		{
			o++;
			if (o>500) break;
			f[j]=j;
			//if (pd(j)) continue;
			for (int k=j-1;k>1;k--)
			if (j%k==0 && b[k]==false)
			{
				f[j]=min(f[j],(j/k-1)*k+1);
				continue;
			}
			ans=min(ans,f[j]);
		}
		continue;
	}
	printf("%d\n",ans);
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ll n;
    cin>>n;
   cout<<2*n -n/2 <<endl;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int x[20];
int ck()
{
    int i;
    int a,b,c,d;
    for (i=1;i<=6;++i) x[i+6]=x[i];
    for (i=1;i<6;i+=2)
    {
        a=x[i]-x[i+2]; b=x[i+1]-x[i+3];
        if (a==0&&b==0) return 0;
    }
    for (i=1;i<6;i+=2)
    {
        a=x[i]-x[i+2]; b=x[i+1]-x[i+3];
        c=x[i+2]-x[i+4]; d=x[i+3]-x[i+5];
        if (a*c+b*d==0) return 1;
    }
    return 0;
}
int main()
{
    int i;
    for (i=1;i<=6;++i) scanf("%d",&x[i]);
    if (ck()) cout <<"RIGHT"<<endl;
    else
    {
        for (i=1;i<=6;++i)
        {
            x[i]--; if (ck()) {cout <<"ALMOST"<<endl;return 0;}
            x[i]+=2; if (ck()) {cout <<"ALMOST"<<endl;return 0;}
            x[i]--;
        }
        cout <<"NEITHER"<<endl; return 0;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k, n, x;
    int a[10005];
    while(cin>>n>>k>>x){
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        int sum=0;
        for(int i=0;i<n-k;i++){
            sum+=a[i];
        }
        sum+= ( k*x);
        cout<<sum<<endl;
    }
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

int a[8][8];
int n, m, ans = 0x3f3f3f3f;

int main()
{
	scanf ("%d%d", &n, &m);
	for (int i = 1; i <= m; ++ i)
	{
		int u, v;
		scanf ("%d%d", &u, &v);
		a[u][v] = 1, a[v][u] = 1;
	}
	if (n <= 6)
	{
		printf ("%d\n", m);
		return 0;
	}
	for (int i = 1; i <= n; ++ i)
		for (int j = 1; j <= n; ++ j)
		{
			int cur = 0;
			for (int k = 1; k <= n; ++ k)
				if (a[k][i] && a[k][j])
					++ cur;
			ans = min (ans, cur);
		}
	printf ("%d\n", m - ans);
	return 0;
}


// 1027E
// rettangoli con righe adiacenti uguali o opposte e senza sottorettangoli con area >= k

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

#define endl "\n"
#define ll long long
#define INF (ll)1e18

ll i, i1, j, k, k1, t, n, m, res, check1, a, b, mod, dp[510][510];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    //ifstream cin("input.txt");
    //ofstream cout("output.txt");

    mod = 998244353;

    cin >> n >> k;
    for (i = 1; i <= n; i++) {
        for (j = 0; j <= n; j++) {
            if (j == 0 || j == 1) {
                dp[i][j] = 2;
            } else if (j <= i) {
                dp[i][j] = (2 * dp[i][j - 1] + mod) % mod;
            } else {
                dp[i][j] = (2 * dp[i][j - 1] - dp[i][j - i - 1] + mod) % mod;
            }
        }
    }

    dp[0][0] = 0;
    for (i = 1; i <= n; i++) {
        dp[i][0] = 0;
        dp[0][i] = 0;
    }

    /* for (i = 1; i <= n; i++) {
        for (j = 0; j <= n; j++) {
            cout << dp[i][j] << ' ';
        }
        cout << endl;
    } */

    res = 0;
    for (i = 1; i <= n; i++) {
        // cout << i << ' ' << min((k - 1) / i, n) << endl;
        m = (mod + dp[i][n] - dp[i - 1][n]) * dp[min((k - 1) / i, n)][n];
        // cout << m << endl;
        res += m;
        res %= mod;
    }

    if (res % 2 == 1) {
        res += mod;
    }
    res /= 2;
    res %= mod;

    cout << res;

    return 0;
}


#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define mp make_pair
#define pb push_back
#define rep(i,m,n) for(long long i = m; i < n; ++i)
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))

typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

const ll mod = 1000000007;

ll dp[160][160][160][4]={0};
ll sol(int c,int u,int d,int i){
  re (dp[c][u][d-1][i]+dp[c][u+1][d][i]-dp[c][u+1][d-1][i]+mod)%mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  rep(c,1,m+1)
    rep(r,1,n+1)
      rep(u,1,n+2-r) {
        dp[c][u][u+r][0]=(sol(c,u,u+r,0)+1+dp[c-1][u][u+r][0]+10*mod)%mod;
        dp[c][u][u+r][1]=(sol(c,u,u+r,1)+dp[c-1][u][n+1][0]-dp[c-1][u][u+r][0]-dp[c-1][u+r][n+1][0]+
            dp[c-1][u][n+1][1]-dp[c-1][u][u+r-1][1]-dp[c-1][u+r][n+1][1]+10*mod)%mod;
        dp[c][u][u+r][2]=(sol(c,u,u+r,2)+dp[c-1][1][u+r][0]-dp[c-1][1][u][0]-dp[c-1][u][u+r][0]+
            dp[c-1][1][u+r][2]-dp[c-1][1][u][2]-dp[c-1][u+1][u+r][2]+10*mod)%mod;
        dp[c][u][u+r][3]=(sol(c,u,u+r,3)+dp[c-1][1][n+1][3]-dp[c-1][u+1][n+1][3]-dp[c-1][1][u+r-1][3]+
            dp[c-1][u+1][u+r-1][3]+dp[c-1][1][n+1][2]-dp[c-1][u+1][n+1][2]-dp[c-1][1][u+r][2]+
            dp[c-1][u+1][u+r][2]+dp[c-1][1][n+1][1]-dp[c-1][u][n+1][1]-dp[c-1][1][u+r-1][1]+
            dp[c-1][u][u+r-1][1]+dp[c-1][1][n+1][0]-dp[c-1][u][n+1][0]-dp[c-1][1][u+r][0]+
            dp[c-1][u][u+r][0]+10*mod)%mod;
      }
  ll res=0;
  rep(i,1,m+1)
    rep(j,0,4){
      res=(res+dp[i][1][n+1][j])%mod;}
  cout<<res<<endl;
  return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <iostream>
#include <cmath>
#include <math.h>
#include <vector>

using namespace std;

int main()
{

	long long a, b;
	long long c=0, d=0;
	cin >> a >> b;
	if (a == b)
	{
		cout << "infinity";
		return 0;
	}
	if (a < b)
	{
		cout << 0;
		return 0;
	}
	a -= b;

	if (a <= 0)
	{
		cout << "infinity";
		return 0;
	}

	long long limit = a;
	for (int i = 1; i <= limit; i++)
	{
		limit = a / i;
		if (i > limit)break;
		if (a%i != 0) limit++;
		else {
			if (i != limit)
			{
				if (i > b) d++;
			}
			if (limit > b) d++;
		}
	}
	cout << d;
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

int main()
{
    int x, h, m;
    cin >> x >> h >> m;
    int answer = 0;
    while (h%10 != 7 && m%10 != 7)
    {
        m -= x;
        if (m < 0)
        {
            h--;
            if (h < 0)
                h = 23;
            m += 60;
        }
        answer++;
    }
    cout << answer;
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
#define int long long

int a , b , cnt = 1;

void cul ( )
{
	if ( a > b ) swap ( a , b );
	while ( a != 1 ) {
		cnt *= a;
		a--;
	}
}

signed main ( void )
{
	cin >> a >> b;
	cul ( );
	cout << cnt << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long a,b;
int main(void)
{
    scanf("%d%d",&a,&b);
    while(b--)if(a%10)a--;else a/=10;
    printf("%lld",a);
    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<set>
using namespace std;
bool vis[1000001], vvis[20000001];
int cnt[20];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	long long n, m;
	cin >> n >> m;
	for (int i = 1; i <= 19; ++i) {
		cnt[i] = cnt[i - 1];
		int tmp = 0;
		for (int j = 1; j <= m; ++j) {
			tmp += i;
			if (!vvis[tmp]) {
				++cnt[i];
				vvis[tmp] = 1;
			}
		}
	}
	long long ans = 0;
	for (int i = 2; i <= n; ++i) {
		if (!vis[i]) {
			int tot = 0;
			for (long long j = i; j <= n; j *= i)
				vis[j] = 1, ++tot;
			ans += cnt[tot];
		}
	}
	cout << ans + 1 << '\n';
}


#include<bits/stdc++.h>
using namespace std;
string st;
bool pd(int i)
{
    return st[i]=='a'||st[i]=='e'||st[i]=='i'||st[i]=='o'||st[i]=='u';
}
int main()
{
	cin>>st;
	for(int i=0;i<st.size();i++)
	{
		if(!pd(i)&&!pd(i+1)&&st[i]!='n')
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
	string s;

	cin >> s;
	int l = s.size(), cnt = 0;

	for(int i = 0, j = l-1; i <= j; i++, j--){
		if(i == j && cnt == 0) cnt++;
		else if(s[i] != s[j]) cnt++;
	}

	if(cnt == 1) cout << "YES" << endl;
	else cout << "NO" << endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <climits>
#include<cstring>

using namespace std;

int dp[402][402]= {};

int x,y,n,d;

int get(int a,int b){
  if(a < -200 || a > 200) return -1;
  if(b < -200 || b > 200) return -1;
  return dp[a + 200][b+ 200];
}
void set(int a, int b, int val){
  if(a < -200 || a > 200) return;
  if(b < -200 || b > 200) return;
  dp[a + 200][b+200] = val;
  return;
}

int dist2(int a, int b){
  return a * a + b * b;
}

int main(){
  while(cin >> x){
    memset(dp, 0,sizeof(dp));
    cin >> y >> n >> d;

    vector<int > a(n);
    vector<int > b(n);
    for(int i = 0; i < n; i++){
      cin >> a[i] >> b[i];
    }
    for(int i = -200; i <= 200; i++){
      for(int j  = -200; j <= 200; j++){
	if(dist2(i, j) > d * d) {
	  set(i, j, -1);
	}
      }
    }

    for(int rep = 0; rep < 600; rep++){
      for(int i = -200; i <= 200; i++){
	for(int j = -200; j <= 200; j++){
	  if(get(i, j) != 0) continue;
	  for(size_t k = 0; k < n; k++){
	    if(get(i + a[k], j + b[k]) == 1){
	      set(i, j, -1);
	      break;
	    }
	  }
	  bool flag = true;
	  for(size_t k = 0; k < n; k++){
	    if(get(i + a[k], j + b[k]) != -1){
	      flag = false;
	      break;
	    }
	  }
	  if(flag){
	    set(i, j, 1);
	  }

	}
      }
    }

    if(get(x, y) == 1){
      cout << "Dasha" <<endl;
    }else if(get(x, y) == -1) {
      cout << "Anton" <<endl;
    }else{
      cout << "error" << endl;
    }

  }
  return 0;
}


#include <iostream>
#include <set>
#include <vector>
#include <deque>
#include <algorithm>
#include <tuple>

using namespace std;

using ll = long long;

ll up(ll x, ll y) {
	return x / y + (x % y != 0);
}

ll stupid (ll n) {
	ll ans = 0;
	for (int i = 0; i < 60; i++) {
		ans += (up((n - 1) / (1ll << i), 2)) * (1ll << (i));
	}
	return ans;
}

struct DSU {
	vector<int>dsu;
	vector<int>sz;
	DSU(int n) {
		dsu.resize(n + 1);
		sz.resize(n + 1);
		for (int i = 1; i <= n; i++) {
			dsu[i] = i;
			sz[i] = 1;
		}
	}
	int find(int x) {
		if (x == dsu[x])return x;
		return dsu[x] = find(dsu[x]);
	}

	void merge(int a, int b) {
		a = find(a);
		b = find(b);
		if (sz[a] > sz[b]) {
			sz[a] += sz[b];
			dsu[b] = a;
		}
		else {
			sz[b] += sz[a];
			dsu[a] = b;
		}
	}
};

ll clever(ll n) {
	ll ans = 0;
	vector<tuple<int, int, int>> edges;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			edges.emplace_back(i ^ j, i, j);
		}
	}
	DSU d(n + 1);
	sort(edges.begin(), edges.end());
	for (auto edge : edges) {
		int w = get<0>(edge);
		int v = get<1>(edge);
		int u = get<2>(edge);
		if (d.find(u) != d.find(v)) {
			d.merge(v, u);
			ans += w;
			//cout << u << " " << v << endl;
		}
	}
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	/*for (int i = 1; i <= 100; i++) {
		if (clever(i) != stupid(i)) {
			cout << i << endl;
			cout << clever(i) << endl;
			cout << stupid(i) << endl;
			return 0;
		}
	}*/
	ll n;
	cin >> n;
	cout << stupid(n);
	//cout << stupid(4);
	return 0;
}


#include<cstdio>
#include<cstring>

char str[101];

int main()
{
    scanf("%s", str);
    int len = strlen(str);
    for (int i = 0; i < len; ++i)
    {
        if (str[i] < 'a')
            str[i] += 32;
        if (str[i] != 'a' && str[i] != 'e' && str[i] != 'i' && str[i] != 'o' && str[i] != 'u' && str[i] != 'y')
            printf(".%c", str[i]);
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int mx,b,c;
double arr[15000],a;
bool chek;

int main()
{

    for(int i=1; i<=3; i++){
        cin>>a;
        if(a==1)arr[1]+=(1/a);
        if(!((int)a%2))arr[2]+=(2/a);
        if(!((int)a%3))arr[3]+=(3/a);
    }
    if((arr[1]) || (arr[2]>=2) || (arr[3]>=3)){
        cout<<"YES\n";
    }else{
        cout<<"NO\n";
    }
    //chek= ((b*c)+(a*c)+(b*a))/(a*b*c);
    /*if(chek){
        cout<<"YES\n";
    }else{
        cout<<"NO\n";
    }
    cin>>arr[0]>>arr[1]>>arr[2];
    sort(arr,arr+3);
    mx=arr[2]-1;
    if(!mx){
        cout<<"YES\n";
        return 0;
    }
    chek = (mx/arr[0])+(mx/arr[1]);
    if(chek>=mx){
        cout<<"YES\n";
    }else{
        cout<<"NO\n";
    }*/
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;

int main()
{
    int n,s,m,i,sum=0;
	int a[101];
	m=-1;
    scanf("%d%d",&n,&s);
    for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(m<a[i])
		{
			m=a[i];
		}
		sum+=a[i];
	}
    if(sum-m<=s)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[55];
int num[200005];
int main(){
    int n,m,ma=0,num,ans=0,r=0,mi=2000000;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    sort(a+1,a+1+n);
    for(int i=0;i<=a[n];i++){
        r=0;
        ans=0;
        for(int j=1;j<=n;j++){
            if(a[j]==i){
                r++;
            }
            else if(a[j]>i){
                int x=a[j],c=0;
                while(x>i){
                    x=x/2;
                    c++;
                }
                if(x==i){
                    r++;
                    ans+=c;
                }
            }
            if(r==m) break;
        }
        if(r==m) mi=min(ans,mi);
    }
    printf("%d\n",mi);
}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

int main() {

	INT d, k, a, b, t;

	cin >> d >> k >> a >> b >> t;

	if(d<=k) cout << d*a << endl;

	else if(d<=2*k) cout << min(k*a+t+(d-k)*a, k*a+(d-k)*b) << endl;

	else {

		INT ans=d*b;

		smin(ans, d/k*(k*a+t)+d%k*a);

		INT st=1, ed=d/k, mid1, mid2;

		while(ed-st>2){

			mid1=(st*2+ed)/3;

			mid2=(st+ed*2)/3;

			if(mid1*(k*a+t)-t+(d-mid1*k)*b<=mid2*(k*a+t)-t+(d-mid2*k)*b) ed=mid2;

			else st=mid1;

		}

		for(mid1=st; mid1<=ed; mid1++){

			smin(ans, mid1*(k*a+t)-t+(d-mid1*k)*b);

		}

		cout << ans << endl;

	}

	return 0;

}


#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(x, n) for(int x = 0; x < n; ++ x)
long long GCD(long long  n1, long long n2)
{
    if (n2 != 0)
        return GCD(n2, n1 % n2);
    else
        return n1;
}
long long LCM(long long  n1, long long n2)
{
    long long m;
    m=n1*n2/GCD(n1,n2);
    return m;
}
unsigned long long choose(unsigned long long n, unsigned long long k)
{
    if (k > n)
    {
        return 0;
    }
    unsigned long long r = 1;
    for (unsigned long long d = 1; d <= k; ++d)
    {
        r *= n--;
        r /= d;
    }
    return r;
}
bool isprime(int x)
{
    if(x==1)
        return 0;
    for(int i=2; i*i<x; i++)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
int main()
{
    long long  a,b,x,y,d;
    cin>>a>>b;
    x=LCM(a,b);
    if(abs(x/a-x/b)-1==0)
        cout<<"Equal"<<endl;
    else if(x/a>x/b)
        cout<<"Dasha"<<endl;
    else
        cout<<"Masha"<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const char duom[] ="i.txt";
int main()
{
  //  ifstream cin (duom);
    int n;
    cin >> n;
    int ind1=1;
    int ind2=1;
    while(true)
    {
        if(ind1*ind2>=n)
        {
            break;
        }
        if(ind1==ind2)
        {
            ind1++;
            continue;
        }else
        {
            ind2++;
        }
    }
    cout << ind1+ind2;

    return 0;
}