#include <iostream>
using namespace std;
int a[15], b[15];
int main(void)
{
	int n, m, x;
	cin>> n >> m;
	for (int i = 0; i<n; i++)
	{
		cin >> x;
		a[x] = 1;
	}
	for (int i = 0; i<m; i++)
	{
		cin>> x;
		b[x] = 1;
	}
	int ans;
	for (int i = 1; i<100; i++)
	{
		if (i>10)
		{
			int t1 = i / 10, t2 = i % 10;
			if ((a[t1] && b[t2]) || (a[t2] && b[t1]))
			{
				ans = i;
				break;
			}
		}
		else
		{
			if (a[i] && b[i])
			{
				ans = i;
				break;
			}
		}
	}
	cout<< ans;
	return 0;
}


#include<bits/stdc++.h>
#define M 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define mem(x) memset(x,0,sizeof(x))
#define setbits(x)  __builtin_popcount(x)
#define ull unsigned long long int
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep1(i,a,b)  for(int i=a;i<=b;i++)
#define fun(s,e,c) for(int i=s;i<e;i+=c)
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef pair<ll,int> li;
inline void fast()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
const int N=(int)4010;
int dp0[N][N],dps[N][N];
int C[N][N];
// c[n][k]=c[n-1][k-1]+c[n-1][k];
const int mod=998244853;
void ncr(ll n)
{
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
           if(j==0||j==i)
           {
           	C[i][j]=1;
           }
           else
           {
           	C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
           	C[i][j]=C[i][j]%mod;
           }
		}
	}
}
int main()
{
	fast();
	int n,m;
	cin>>n>>m;
	ll mx=max(n,m);
	ncr(2*mx+2LL);

	for(int i=0;i<=n;i++)
	{
    for(int j=i;j<=m;j++)
    {   if(i==0)
    	dp0[i][j]=1;
    	else
    	dp0[i][j]=dp0[i][j-1]+dp0[i-1][j];
    	dp0[i][j]%=mod;
    }
	}
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{   if(i==0)
			dps[i][j]=0;
			else if(j==0)
				dps[i][j]=i;

			else if(i>0&&j>0)
			{int a=(dps[i-1][j]+C[i+j-1][i-1])%mod;
			int b=(dps[i][j-1]+((mod-((mod+(C[i+j-1][j-1]-dp0[i][j-1])%mod)%mod))%mod))%mod;
			dps[i][j]=(a+b)%mod;
			dps[i][j]%=mod;
		   }
		}
	}
	cout<<dps[n][m];

}


#include <iostream>
#include <string>

using namespace std;

int S ( long long n );

int main()
{
    // freopen("in.txt","r",stdin);
    long long w, m, k;
  cin >> w >> m >> k;
  w /= k;

  int sm = S(m);
  long long ans = 0;
  long long cost = w;
  long long next10Pow = 1;
  for (int i = 0; i < sm; ++i) {
    next10Pow *= 10;
  }
  while (cost - (next10Pow - m) * sm >= 0) {
    cost -= (next10Pow - m) * sm;
    ans += next10Pow - m;
    m = next10Pow;
    ++sm;
    next10Pow *= 10;
  }

  ans += cost / sm;
  cout << ans << endl;

    return 0;
}

int S ( long long m )
{
    int ans = 0;
  while (m) {
    ++ans;
    m /= 10;
  }
  return ans;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <ctime>
#include <set>

using namespace std;
#define ll long long
ll mod = 998244353;

ll binpow(ll a, ll p) {
    return p ? binpow(a * a % mod, p >> 1)* (p & 1 ? a : 1) % mod : 1;
}
ll bininv(ll a) { return binpow(a, mod - 2); }
set<int> solved;
map<ll, vector<ll> > mp;
vector<vector<ll> > C;
int k, kk;
ll m, invm;
ll fact[35000];
ll ifact[35000];

struct FFT {
    int n;
    vector<ll> w;
    vector<ll> inv;

    void set(int _n = (1 << 14)) {
        n = _n;
        inv.resize(n);
        inv[0] = 0;
        for (int i = 1, j = 0; i < n; i++) {
            int bit = (n >> 1);
            while (bit & j) {
                j ^= bit;
                bit >>= 1;
            }
            j ^= bit;
            inv[i] = j;
        }

        w.resize(n);
        ll step = binpow(3, (mod - 1) / n);
        w[0] = 1;
        for (int i = 1; i < n; i++) {
            w[i] = w[i - 1] * step % mod;
        }
    }

    void fft(vector<ll>& a) {
        for (int i = 0; i < n; i++) {
            if (i < inv[i]) {
                swap(a[i], a[inv[i]]);
            }
        }

        for (int len = 2; len <= n; len <<= 1) {
            for (int i = 0; i < n; i += len) {
                int i1 = i, i2 = i + (len >> 1);
                int wind = 0, wstep = (n / len);
                for (; i2 < i + len; i1++, i2++, wind += wstep) {
                    ll x = a[i1], y = a[i2] * w[wind] % mod;
                    a[i1] = (x + y) % mod;
                    a[i2] = (x - y + mod) % mod;
                }
            }
        }
    }

    void ifft(vector<ll>& a) {
        fft(a);
        reverse(a.begin() + 1, a.end());
        ll invn = binpow(n, mod - 2);
        for (int i = 0; i < n; i++) {
            a[i] = (a[i] * invn) % mod;
        }
    }

    void do_calculation(vector<ll> a, vector<ll> b, vector<ll>& to) {
        fft(a);
        fft(b);
        for (int i = 0; i < n; i++) {
            to[i] = a[i] * b[i] % mod;
        }
        ifft(to);
        for (int i = k + 1; i < n; i++) {
            to[i] = 0;
        }
    }
}fft;

void prec() {
    fact[0] = ifact[0] = 1;
    for (int i = 1; i < 35000; i++) {
        fact[i] = fact[i - 1] * i % mod;
        ifact[i] = binpow(fact[i], mod - 2);
    }
}

void calc(ll n) {

    // (a+b)^k = SUM_0^k C_k^i a^i b^{k-i}
    if (solved.count(n))
        return;
    if (n == 1) {
        vector<ll> tmp(k + 1, invm);
        tmp[0] = 1;
        for (int i = 0; i < k + 1; i++) {
            tmp[i] = tmp[i] * ifact[i] % mod;
        }
        while (tmp.size() < kk) {
            tmp.push_back(0);
        }
        mp[1] = tmp;
    }
    else if (n & 1) {
        calc(n - 1);
        mp[n] = vector<ll>(kk, 0);
        fft.do_calculation(mp[1], mp[n - 1], mp[n]);
        mp[n][0] = 1;
        //for (int ii = 1; ii <= k; ++ii) {
        //    for (int i = 0; i <= ii; ++i) {
        //        (mp[n][ii] += C[ii][i] * mp[n - 1][i] % mod * mp[1][ii - i] % mod) %= mod;
        //    }
        //}
    }
    else {
        calc(n / 2);
        mp[n] = vector<ll>(kk, 0);
        fft.do_calculation(mp[n / 2], mp[n / 2], mp[n]);
        mp[n][0] = 1;
        //for (int ii = 1; ii <= k; ++ii) {
        //    for (int i = 0; i <= ii; ++i) {
        //        (mp[n][ii] += C[ii][i] * mp[n / 2][i] % mod * mp[n / 2][ii - i] % mod) %= mod;
        //    }
        //}
    }
    //do
    solved.insert(n);
}
void solve(int test_ind) {
    int st = clock();
    prec();
    ll n;
    cin >> n >> m >> k;
    kk = 1;
    while (kk < k) {
        kk <<= 1;
    }
    kk <<= 1;
    fft.set(kk);

    invm = bininv(m);
    calc(n);
    cout << mp[n][k] * fact[k] % mod << endl;
}

int main() {
    int t = 1;
    //cin >> t;
    for (int i = 0; i < t; i++) {
        solve(i);
    }
    return 0;
}


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

int main() {
    int n,k;cin>>n>>k;
    while(k--){
        if(n%10==0) n=n/10;
        else n-=1;

    }
    cout<<n<<endl;
    return 0;
}


#include <iostream>
#include <string.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int dem=0;
	for (int i=0;i<(s.size());i++)
	{
		if (s[i]=='a')
			dem++;
	}
  if (dem==0)
    cout<<0<<endl;
  else if (dem==s.size())
    cout<<dem<<endl;
  else
  {
    bool sua=false;
    int n=s.size();
    if(n%2==0)
    {
      if (dem>(n/2))
        cout<<n<<endl;
      else
        cout<<2*dem-1<<endl;
    }
    else
    {

      if (dem>(float)(n/2))
        cout<<n<<endl;
      else
        cout<<2*dem-1<<endl;
    }

  }
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int p[100];
int t[100];
int main(){
	int n,c,templ(0),tt(0),tempr(0);
	cin>>n>>c;

	for(int i=0;i<n;i++){
		cin>>p[i];}
		for(int i=0;i<n;i++)
		cin>>t[i];
	for(int i=0;i<n;i++){
		tt+=t[i];
		templ+=max(0,p[i]-c*tt);
	}
	tt=0;
	for(int i=n-1;i>=0;i--){
		tt+=t[i];
		tempr+=max(0,p[i]-c*tt);
	}
	if(templ>tempr) cout<<"Limak";
	else if(templ<tempr) cout<<"Radewoosh";
	else if(templ==tempr) cout<<"Tie";
	return 0;
}


#include <cstdio>
#include <cstring>
#include <bitset>
#include <cmath>

using namespace std;

const int N = 3 * 1e8 + 10;

bitset<N> prime;

int main() {

	int l, r;

	while(~scanf("%d%d", &l, &r)) {

		prime.set();
		int e = sqrt(r) + 1;

		for (int i = 3; i <= e; i += 2)
			if (prime[i])
				for (int j = i * i, s = i * 2; j <= r; j += s) {
					prime[j] = false;
				}

		int cnt = (l <= 2 && 2 <= r);
		for (int i = 5; i <= r; i += 4)
			if (i >= l && prime[i])
				cnt ++;

		printf("%d\n", cnt);

	}

	return 0;
}


/*
There's nothing to me now. An empty shell unfolded.
How, when we learn to pray inside our demons are laughing
How long will this go on? Are we a bit much stronger?
Do you think you can save me from living this way?

I don't know how to love. I just know how to live.
All I feel is hate. Will you forgive me?

For all those things I've done, they keep on creeping by me.
And though we've changed our ways,
still all our demons are laughing.
How long will this go on? Aren't we a bit much stronger?
I'd like to think you've came into my life to stay.

I don't know how to love. I just know how to live.
All I feel is hate. Will you forgive me?
I don't know how to breathe with you too far away.
Don't know how to love. Will you forgive me?
No I can't live this way!
I don't know how to love. I just know how to live.
All I feel is pain. Will you forgive me?
I don't know how to breathe with you too far away.
I don't know how to love.

Past lives I've lived. Uncontrolled but sacred.
You've finally seen all that's left of me.
So hard to feel. So hard to breathe.
Will you forgive me?
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-12
#define M_PI 3.141592653589793
#define bsize 300

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 210031;

int ar[N];

int main(){
//    freopen("apache.in","r",stdin);
//    freopen("apache.out","w",stdout);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    //cin.tie(0);

    for (int i=0;i<4;i++){
    	cin>>ar[i];
    }

    if (ar[0]!=ar[3]||ar[2]>0&&ar[0]==0)
    	cout<<"0"<<endl;
    else
    	cout<<"1"<<endl;

//    cin.get(); cin.get();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=998244353;
int n;
ll ans,m,d=1,tmp=1;
inline ll qp(ll base,int p) {
	ll res=1;
	while(p) {
		if(p&1) res=res*base%mod;
		p>>=1;base=base*base%mod;
	}
	return res;
}
inline ll Inv(ll base) {return qp(base%mod,mod-2);}
inline ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
int main() {
	cin>>n>>m;
	if(m==1) {cout<<n-1;return 0;}
	ans=m%mod*(qp(m%mod,n)-1)%mod*Inv(m-1)%mod;
	for(int i=1;i<=n;i++) {
		if(d<=m&&gcd(d,i)==1) d=1LL*d*i;
		if(d>m) break;
		tmp=1LL*(m/d)%mod*tmp%mod;
		ans-=tmp;
		ans%=mod;
	}
	cout<<(ans+mod)%mod;
	return 0;
}


#include <iostream>
using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {

int a=0,b=0,z,i,m,cc=0;

cin>>i>>m>>z;

a=i;
b=m;

while (a<=z)
{
	while(b<=a && b<=z)
	{
		if(a==b)
		cc++;
		b+=m;
	}
	a+=i;
}
cout << cc;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#define ll long long
using namespace std;

vector <int> p;
bool used[50];
int n;
ll m;

ll pow(int x)
{
    ll ans = 1;
    for (int i = 0; i < x; i++)
        ans *= 2;
    return ans;
}

void go(ll ost)
{
    int last = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = last + 1; j <= n; j++)
        {
            if (ost > pow(n - j - 1))
                ost -= pow(n - j - 1);
            else
            {
                last = j;
                used[j] = true;
                p[i] = j;
                break;
            }
        }
    }
    bool flag = false;
    for (int i = 0; i < n; i++)
    {
        if (!p[i])
            flag = true;
        if (flag)
        {
            for (int j = n; j >= 1; j--)
            {
                if (!used[j])
                {
                    used[j] = true;
                    p[i] = j;
                    break;
                }
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        printf("%d ", p[i]);
    }
}

int main()
{
    //freopen("xxx.in", "r", stdin);
    //freopen("xxx.out", "w", stdout);
    cin >> n >> m;
    p.resize(n);

    go((ll)m);
    return 0;
}


#include <stdio.h>

int p, i, j, P[78777];

int C(long long x){
    for (j = 0; ;j++){
        long long y = P[j];
        if ((y*y) > x) return 1;
        if (!(x%y)) return 0;
    }
}

inline int F(int i, long long a){
    if (a == 1) return 1;
    long long y = P[i];
    if ((y + 1) > a) return 0;
    if (((y*y) + 1) > a) return C(--a);

    int res = F(i + 1, a);
    for (; ;){
        if (++y > a) break;
        if (!(a%y)) res += F(i + 1, a/y);
        y--;
        y *= P[i];
    }
    return res;
}

int main(){
    P[p++] = 2;
    for (i=3; i<1000010; i+=2){
        if (C(i)) P[p++] = i;
    }

    long long a;
    scanf("%I64d",&a);
    printf("%d\n", ((a < 5)?(a != 2):F(0, a)));
}


#include<bits/stdc++.h>
using namespace std;
int i,j,n,k;
main()
{
 cin>>n;
 for(i=1;i<=n;i++)
{
j=n-i;
if(j%i==0) k++;
}
cout<<k-1;
}


#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;
#define SYN					ios_base::sync_with_stdio(0);cin.tie(0);
#define FORab(i,a,b)		for(int i=int(a);i<=int(b);i++)
#define FOR(i,n)			FORab(i,0,(n)-1)
#define FOR1(i,n)			FORab(i,1,n)
#define FORN(i,n)			for(int i=int(n)-1;i>=0;i--)
#define FORN1(i,n)			for(int i=int(n);i>=1;i--)
#define wh(n,m)				while(int(n)<int(m))
#define WH(n,m)				while(int(n)>int(m))
#define o(X)				cout<<X
#define oo(X, Y)            cout<<X<<Y
#define ooo(X, Y, Z)		cout<<X<<Y<<Z
#define cie(X)				cout<<X<<endl
#define ci(X)				(cin>>X)
#define cii(X,Y)			(cin>>X>>Y)
#define ciii(X,Y,Z)			(cin>>X>>Y>>Z)
typedef long long			LL;
typedef unsigned long long	LLU;
typedef unsigned long		LU;
typedef long long int		LLI;
typedef int					I;

int main()
{
	SYN;
	for(int i=0,mt;ci(mt);++i)
	{

		if (mt)
		{
			oo(abs(i % 5 - 2) + abs(i / 5 - 2),endl);
			break;
		}
	}
	return 0;
}


#include <iostream>
using namespace std;
int main()
{
		long long a, b;
	cin >> a >> b;
	long long i = 0;
	while (a != b)
	{
		long long temp = a;
		if (a > b)
		{

			i += a / b;
			if (a%b == 0)
				break;
			a = a%b;
		}
		else
		{
			i += b / a;
			if (b%a == 0)
				break;
			a = b%a;
			b = temp;
		}
	}
	cout << i;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
 int main()
 {
     int n,m,b;
     cin>>n>>m;
     int a[n+1]={0};
     for(int i=0;i<m;i++)
     {
         cin>>b;
         int y=b;
         while(y<=n)
         {
             if(a[y]!=0)break;
             else a[y]=b;
             y++;
         }
     }
     for(int i=1;i<=n;i++)cout<<a[i]<<"\n";
 }


#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define mp make_pair
#define pb push_back
#define f first
#define s second

//var
string s1,s2;
int ar[105][2],n, dp[105][4], ans = 0; //mxcount ending in state

bool vals(int g, int s){
	if(s == 1)
		return (!ar[g][0] && !ar[g][1] && !ar[g+1][0]);
	if(s == 2)
		return (!ar[g][0] && !ar[g+1][1] && !ar[g+1][0]);
	if(s == 3)
		return (!ar[g+1][0] && !ar[g][1] && !ar[g+1][1]);
	if(s == 4)
		return (!ar[g][0] && !ar[g][1] && !ar[g+1][1]);
	return 0;
}

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

	cin >> s1 >> s2; n = s1.size();
	for(int i = 0; i<n; i++){
		if(s1[i] == 'X') ar[i+1][0] = 1;
		if(s2[i] == 'X') ar[i+1][1] = 1;
	}

	for(int i = 1; i<n; i++){
		for(int j = 1; j<=4; j++){
			if(vals(i, j)){
				//cout << i << " " << j << endl;
				dp[i][j]++;
			}

			int curm = 0;
			for(int k = 1; k<i-1; k++)
				for(int z = 1; z<=4; z++)
					curm = max(curm, dp[k][z]);

			if(j == 2)
				curm = max(curm, dp[i-1][4]);
			if(j == 3)
				curm = max(curm, dp[i-1][1]);

			dp[i][j] += curm;
			ans = max(ans, dp[i][j]);
		}
	}

	cout << ans << endl;

	cout.flush();
	return 0;
}


#include <iostream>
#include <cmath>//ceil需要
using namespace std;
int main()
{
    int n,m,a;
    cin>>n>>m>>a;
    cout<<(long long)(ceil((double)n/a)*ceil((double)m/a));
}


#include <iostream>
#include <cstdio>
#include <cstring>
#define N 410
using namespace std;
typedef long long ll;
int dp[N][N];
int n,mod;
void add(int &x,int y){
    x=(x+y)%mod;
}
int main()
{
    scanf("%d%d",&n,&mod);
    dp[1][1]=1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=i;j++){
            add(dp[i+1][j],1ll*dp[i][j]*j*2%mod);
            add(dp[i+2][j+1],1ll*dp[i][j]*(j+1)%mod);
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        add(ans,dp[n][i]);
    }
    printf("%d",ans);
    return 0;
}


#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
long long n,a,b;
int main()
{
	cin>>n>>a>>b;
	cout<<min(n-a,b+1)<<endl;
	return 0;
}


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

int main() {
	//freopen("in.txt","r",stdin);
	long long n;
	long long m;
	long long a,b;
	while(scanf("%lld %lld %lld %lld",&n,&m,&a,&b)!=EOF) {

		if(n==0)
			printf("0\n");
		if(n%m == 0) {
			printf("0\n");
		}
		else {
			long long  mod = n%m;
			long long div = n/m;
			long long build = (m-mod)*a;
			long long destroy = mod*b;
			if(build<destroy) {
				printf("%lld\n",build);
			}
			if(destroy<build) {
				printf("%lld\n",destroy);
			}
			if(build == destroy) {
				printf("%lld\n",build);
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
    for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
    return x*f;
}
inline void write(ll x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void writeln(ll x)
{
    write(x);
    puts("");
}
const int N=21;
ll k,t,dep;
ll c[N][N],f[N][N];
int a[23],num[N];
ll dp(int x){
    for(int i=0;i<=16;i++)
        f[0][i]=1;
    for(int i=1;i<=x;i++)
        for(int j=1;j<=16;j++){
            f[i][j]=0;
            for(int k=0;k<=min(i,a[j]);k++)
                f[i][j]+=f[i-k][j-1]*c[i][k];
        }
    return f[x][16];
}
void prt(int x){
    if(x<10)putchar(x+'0');
    else putchar(x-10+'a');
}
void dfs(int k,int x)
{
    if(x==0)return;
    for(int i=(x==dep)?2:1;i<=16;i++){
        if(a[i]==0)continue;
        a[i]--;
        ll size=dp(x-1);
        if(size>=k){
            prt(i-1);
            dfs(k,x-1);
            break;
        }
        k=k-size;
        a[i]++;
    }
}
int main(){
    k=read();t=read();
    for(int i=1;i<=16;i++)
        a[i]=t;
    c[1][0]=c[1][1]=1;
    for(int i=2;i<=10;i++){
        c[i][0]=1;
        for(int j=1;j<=i;j++)
            c[i][j]=c[i-1][j-1]+c[i-1][j];
    }
    dep=1;
    while(1){
        a[2]--;
        ll size=dp(dep-1)*15;
        a[2]++;
        if(size>=k)break;
        dep++,k-=size;
    }
    dfs(k,dep);
    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main() {
  int a1, a2, a3, a4;
  cin >> a1 >> a2 >> a3 >> a4;

  int sum = a1 + a2 + a3 + a4;
  if ((sum % 2) > 0) {
    cout << "NO\n";
    return 0;
  }
  int half = sum / 2;
  if (a1 == half || a2 == half || a3 == half || a4 == half ||
      (a1 + a2 == half) || (a1 + a3 == half) || (a1 + a4 == half)) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}


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

main()
{
      int n=0,b=0;
      string s;

      cin>>s;

      for(int i=0;s[i]!='\0';i++)
      {
         if(s[i]=='-')
         n++;
        else
        b++;
      }
      if(b==0||n%b==0)
      cout<<"YES";
          else
            cout<<"NO";
      }


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

#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define ll long long int
#define ld long double
#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)

using namespace __gnu_pbds;
using namespace std;

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

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

typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

#ifdef LOCAL
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif

std::mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int ri(int a, int b) {
    return uniform_int_distribution<int>(a, b)(rng);
}

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

const ll INF = (ll)(8e18);
const ll MOD = (ll)(1e9 + 7);
const ll HMOD = (ll)4222234727;
const ll Hashprime = (ll)31;

const int maxn = 100100;

std::vector<ll> Brute(std::vector<ll> v, ll n){
   std::vector<ll> tv;
   for(ll i = 0; i < (ll)(1LL << n); i++){
       ll tval = 0;
       for(ll j = 0; j < n; j++){
           if((1LL << j) & i){
              tval += v[j];
           }
       }
       tv.push_back(tval);
   }
   sort(all(tv));
   return tv;
}

bool checkInOwn(std::vector<ll> vtot, ll m){
   map <ll, bool> mp;
   for(auto i : vtot){
      if(mp.find(i - m) != mp.end()) return true;
      mp[i] = true;
    }
    return false;
}

bool solve(){
   ll w,m; cin >> w >> m;
   std::vector<ll> v;
   ll val = 1;
   while(val <= 3 * MOD){
      v.push_back(val);
      val = val * w;
   }
   ll n = (ll)v.size();
   if(w > 3){
      std::vector<ll> vtot = Brute(v, n);
      return checkInOwn(vtot, m);
   }
   return true;
}

int32_t main(){
    IOS;
    #ifndef ONLINE_JUDGE
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    int t = 1; // cin >> t;
    while(t--){
       cout << (solve() ? "YES\n" : "NO\n");
    }
    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}
//g++ -DLOCAL -std=c++17 -Wshadow -Wall -o "c" "comp.cpp" -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g


/*

Ocean's apart day after day
And I slowly go insane
I hear your voice on the line
But it doesn't stop the pain

If I see you next to never
How can we say forever

Wherever you go
Whatever you do
I will be right here waiting for you
Whatever it takes
Or how my heart breaks
I will be right here waiting for you

I took for granted, all the times
That I thought would last somehow
I hear the laughter, I taste the tears
But I can't get near you now

Oh, can't you see it baby
You've got me going crazy

I wonder how we can survive
This romance
But in the end if I'm with you
I'll take the chance

Oh, can't you see it baby
You've got me going crazy

*/

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

int main()
{
    int i,j,col=0,row=0,col1,row1;
    char cb[8][8];
    for(i=0;i<8;i++) {
        for(j=0;j<8;j++) {
            cin>>cb[i][j];
        }
    }
    for(i=0;i<8;i++) {
        if(cb[i][0]=='B') {
            col1=0;
            for(j=0;j<8;j++) {
                if(cb[i][j]=='B') col1++;
            }
            if(col1==8) col++;
        }
    }
    for(i=0;i<8;i++) {
        if(cb[0][i]=='B') {
            row1=0;
            for(j=0;j<8;j++) {
                if(cb[j][i]=='B') row1++;
            }
            if(row1==8) row++;
        }
    }
    if(col==8 && row==8) {
        cout<<8<<'\n';
        return 0;
    }
    cout<<col+row<<'\n';
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define sz(x) x.size()
#define F first
#define S second
#define mp make_pair
#define ll long long
#define sqr(x) ((x)*(x))
#define inf 1e18
using namespace std;
    ll a[1000010], b[1000], d[100010][26], p[10010];
    ll mn=inf, mx=-inf, ans, cnt, sm=1, n, m;
    bool ok, okk, u[1000010], uu[310][310], uk[1000010];
    char ck[510][510], ch[100010];
    int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
    vector <int> g[900010];

int main(){

    //freopen ("input.txt","r",stdin); freopen ("output.txt","w",stdout);

    cin>>n;
    string s;
    cin>>s;
    int mid=sz(s)/2;
    for(int i=0;i<sz(s);i++){
    	if(islower(s[i])){
    		a[s[i]-'a']=1;
    	}
    }
    cnt=-1;
    if(sz(s)%2==1){
    	if(s[mid]=='?'){
    		for(int i=n-1;i>=0;i--){
    			if(a[i]==0){
    				cnt=i;
    				break;
    			}
    		}
    		cnt=max(cnt, 0*1LL);
    		s[mid]=char(cnt+'a');
    		a[cnt]=1;
    	}
    }
    mid--;
    for(int i=mid;i>=0;i--){
    	if(s[i]=='?' && s[sz(s)-i-1]=='?'){
    		for(int j=n-1;j>=0;j--){
    			if(a[j]==0){
    				s[i]=char(j+'a');
    				s[sz(s)-i-1]=char(j+'a');
    				a[j]=1;
    				break;
    			}
    		}
    	}
    }
    for(int i=0;i<=mid;i++){
    	if(s[i]=='?'){
    		s[i]=s[sz(s)-i-1];
    	}
    	if(s[sz(s)-i-1]=='?'){
    		s[sz(s)-i-1]=s[i];
    	}
    }
    //cout<<s<<endl;
    for(int i=0;i<n;i++){
    	if(a[i]==0){
    		cout<<"IMPOSSIBLE";
    		return 0;
    	}
    }
    for(int i=0;i<=mid;i++){
    	if(s[i]!=s[sz(s)-i-1]){
    		//cout<<i<<endl;
    		//cout<<s[i]<<' '<<s[sz(s)-i-1]<<endl;
    		cout<<"IMPOSSIBLE";
    		return 0;
    	}
    }
    for(int i=0;i<26;i++){
    	if(a[i] && i>=n){
    		cout<<"IMPOSSIBLE";
    		return 0;
    	}
    }
    for(int i=0;i<sz(s);i++){
    	if(s[i]=='?'){
    		s[i]='a';
    	}
    }
    cout<<s<<endl;

    return 0;
}


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

ll cal(ll n, ll r, ll d) {
	if (!r) return n / d;
	if (n < r) return 0;
	return (n - r) / d + 1;
}

int main() {
    ll n, m, i, k, ret = 0;
    scanf("%lld %lld", &n, &m);
    for (i = 0; i < m; i++)
    	for (k = 0; k < m; k++)
    		if ((i * i + k * k) % m == 0)
    			ret += cal(n, i, m) * cal(n, k, m);
    printf("%lld", ret);
    return 0;
}


#include <bits/stdc++.h>
int qwq, n, m, s, ans = 1;
int main(void) {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; ++i) {
        std::cin >> qwq;
        if (s + qwq > m) {
            ++ans;
            s = 0 + 1 - 1;
        }
        s += qwq;
    }
    printf("%d\n\r", ans);
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int i,j,n,tmp,ans=0;
    cin>>n;
    int arr[105];
    for(i=0;i<n;i++){
        cin>>arr[i];
    }
    for(i=0;i<=
    n;i++){
        tmp=0;
        for(j=0;j<i;j++){
            if(arr[j]==0)
                tmp++;
        }
        for(j=i;j<n;j++){
            if(arr[j]==1)
                tmp++;
        }
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,ans=0;
    cin>>a>>b;
    while(a<=b){
        a*=3;
        b*=2;
        ans++;
    }
    cout<<ans;
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <numeric>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll MOD = 1000000007;
const ll INF = 1LL << 60;
#define PI (acos(-1))
#define ALL(c) (c).begin(), (c).end()

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (auto &v : vec)
        is >> v;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec)
{
    os << "[";
    for (auto v : vec)
        os << v << ",";
    os << "]";
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &vec)
{
    os << "deq[";
    for (auto v : vec)
        os << v << ",";
    os << "]";
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &vec)
{
    os << "{";
    for (auto v : vec)
        os << v << ",";
    os << "}";
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &vec)
{
    os << "{";
    for (auto v : vec)
        os << v << ",";
    os << "}";
    return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{
    os << "(" << pa.first << "," << pa.second << ")";
    return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &mp)
{
    os << "{";
    for (auto v : mp)
        os << v.first << "=>" << v.second << ",";
    os << "}";
    return os;
}

#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
template <typename A, size_t N, typename T>

ll lcm(ll a, ll b)
{
    return a / __gcd(a, b) * b;
}

bool is_prime(ll x)
{
    if (x == 1)
    {
        return false;
    }
    for (ll i = 2; i * i <= x; i++)
    {
        if (x % i == 0)
            return false;
    }
    return true;
}

vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod)
{
    return modpow(a, mod - 2, mod);
}

const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

    int root(int x)
    {
        if (par[x] < 0)
            return x;
        else
            return par[x] = root(par[x]);
    }

    bool issame(int x, int y)
    {
        return root(x) == root(y);
    }

    bool merge(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (par[x] > par[y])
            swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x)
    {
        return -par[root(x)];
    }
};

struct BIT
{
    int n;
    vector<int> bit;
    BIT()
    {
        init();
    }
    BIT(int n) : n(n)
    {
        init();
    }
    void init()
    {
        bit.clear();
        bit.resize(n + 1, 0);
    }
    int sum(int i)
    {
        int s = 0;
        while (i > 0)
        {
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }
    int sum(int x, int y)
    {
        return sum(y) - sum(x - 1);
    }
    void add(int i, int x)
    {
        while (i <= n)
        {
            bit[i] += x;
            i += i & -i;
        }
    }
    int lower_bound(int w)
    {
        if (w <= 0)
            return 0;
        int x = 0, r = 1;
        while (r < n)
            r <<= 1;
        for (int k = r; k > 0; k >>= 1)
        {
            if (x + k <= n && bit[x + k] < w)
            {
                w -= bit[x + k];
                x += k;
            }
        }
        return x + 1;
    }
};

struct LazySegmentTree
{
    // private:
    ll n;
    vector<ll> node, lazy;

    // public:
    LazySegmentTree(vector<ll> v)
    {
        int sz = (int)v.size();
        n = 1;
        while (n < sz)
            n *= 2;
        node.resize(2 * n - 1);
        lazy.resize(2 * n - 1, 0);

        for (int i = 0; i < sz; i++)
            node[i + n - 1] = v[i];
        for (int i = n - 2; i >= 0; i--)
            node[i] = node[i * 2 + 1] + node[i * 2 + 2];
    }

    void eval(int k, int l, int r)
    {
        if (lazy[k] != 0)
        {
            node[k] += lazy[k];
            if (r - l > 1)
            {
                lazy[2 * k + 1] += lazy[k] / 2;
                lazy[2 * k + 2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }

    void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1)
    {
        if (r < 0)
            r = n;
        eval(k, l, r);
        if (b <= l || r <= a)
            return;
        if (a <= l && r <= b)
        {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }
        else
        {
            add(a, b, x, 2 * k + 1, l, (l + r) / 2);
            add(a, b, x, 2 * k + 2, (l + r) / 2, r);
            node[k] = node[2 * k + 1] + node[2 * k + 2];
        }
    }

    ll getsum(int a, int b, int k = 0, int l = 0, int r = -1)
    {
        if (r < 0)
            r = n;
        eval(k, l, r);
        if (b <= l || r <= a)
            return 0;
        if (a <= l && r <= b)
            return node[k];
        ll vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2);
        ll vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r);
        return vl + vr;
    }
};

ll digit_sum(ll v)
{
    ll ret = 0;
    while (v)
    {
        ret += (v % 10);
        v /= 10;
    }
    return ret;
}

template <typename T>
struct Kruskal
{

    struct edge
    {
        ll from, to;
        T cost;
        ll used;
        edge() {}
        edge(ll from, ll to, T cost) : from(from), to(to), cost(cost), used(0) {}
        bool operator<(const edge &e) const
        {
            return cost < e.cost;
        }
    };

    ll n;
    vector<ll> p, r;
    vector<edge> edges;

    Kruskal() {}
    Kruskal(ll n) : n(n) {}

    void init(ll n)
    {
        r.assign(n, 1);
        p.resize(n);
        iota(p.begin(), p.end(), 0);
    }

    ll find(ll x)
    {
        return (x == p[x] ? x : p[x] = find(p[x]));
    }

    bool same(ll x, ll y)
    {
        return find(x) == find(y);
    }

    void unite(ll x, ll y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (r[x] < r[y])
            swap(x, y);
        r[x] += r[y];
        p[y] = x;
    }

    void add_edge(ll u, ll v, T c)
    {
        edges.emplace_back(u, v, c);
    }

    T build()
    {
        sort(edges.begin(), edges.end());
        init(n);
        T res = 0;
        for (auto &e : edges)
        {
            if (!same(e.from, e.to))
            {
                res += e.cost;
                unite(e.from, e.to);
                e.used = 1;
            }
        }
        return res;
    }

    T build(ll k)
    {
        sort(edges.begin(), edges.end());
        init(n);
        T res = 0;
        ll cnt = 0;
        for (auto &e : edges)
        {
            if (!same(e.from, e.to))
            {
                res += e.cost;
                unite(e.from, e.to);
                e.used = 1;
                cnt++;
            }
            if (cnt == k)
            {
                break;
            }
        }
        return res;
    }
};

int LIS(int a[], int n)
{
    vector<int> A(n, 0x3f3f3f3f);
    for (int i = 0; i < n; i++)
        *lower_bound(A.begin(), A.end(), a[i]) = a[i];
    return find(A.begin(), A.end(), 0x3f3f3f3f) - A.begin();
}

// string maze[1010];
ll maze[100][100];
ll grid_bfs(ll H, ll W, ll sx, ll sy, ll gx, ll gy)
{

    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};

    vector<vector<ll>> dist(H, vector<ll>(W, -1));
    dist[sy][sx] = 0;

    queue<PL> q;
    q.push({sy, sx});
    while (!q.empty())
    {
        ll x, y;
        tie(y, x) = q.front();
        q.pop();
        if (y == gy && x == gx)
        {
            break;
        }
        for (int t = 0; t < 4; t++)
        {
            ll nx = x + dx[t], ny = y + dy[t];
            if (nx < 0 || ny < 0 || nx >= W || ny >= H || dist[ny][nx] != -1 || maze[ny][nx] == '#')
            {
                continue;
            }

            dist[ny][nx] = dist[y][x] + 1;
            q.push({ny, nx});
        }
    }

    return dist[gy][gx];
}

vector<vector<ll>> warshall_floyd(ll n, vector<vector<ll>> g, ll INF)
{
    //init vector<vector<ll>> c(10,vector<ll>(10,0));

    for (int k = 0; k < n; k++)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                if (g[i][k] == INF || g[k][j] == INF)
                    continue;
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }

    return g;
}

struct Dijkstra
{

    ll n;
    vector<vector<pair<ll, ll>>> Edges;
    vector<ll> Dist;
    vector<ll> Prev;
    vector<ll> PathNum;

    Dijkstra(ll n) : n(n), Edges(n), Dist(n), Prev(n), PathNum(n)
    {
        Prev.assign(n, -1);
    };

    void add_edge(ll a, ll b, ll c, bool directed = true)
    {
        if (directed)
        {
            Edges[a].emplace_back(make_pair(b, c));
        }
        else
        {
            Edges[a].emplace_back(make_pair(b, c));
            Edges[b].emplace_back(make_pair(a, c));
        }
    }
    // O((E+V)logV)
    void build(int start)
    {
        priority_queue<P, vector<P>, greater<P>> queue;
        fill(Dist.begin(), Dist.end(), 1e+18); //1e18 !?!?
        fill(Prev.begin(), Prev.end(), -1); //1e18 !?!?
        Dist[start] = 0;
        PathNum[start] = 1;
        queue.push(PL(0, start));

        while (!queue.empty())
        {
            PL p = queue.top();
            queue.pop();
            int v = p.second;
            if (Dist[v] < p.first)
                continue;

            for (int i = 0; i < Edges[v].size(); i++)
            {
                PL e = Edges[v][i];
                if (Dist[e.first] > Dist[v] + e.second)
                {
                    Dist[e.first] = Dist[v] + e.second;
                    queue.push(P(Dist[e.first], e.first));

                    Prev[e.first] = v;

                    PathNum[e.first] = PathNum[v];
                }
                else if (Dist[e.first] == Dist[v] + e.second)
                {
                    PathNum[e.first] += PathNum[v];
                    PathNum[e.first] %= MOD;
                }
            }
        }
    }

    ll dist(ll t)
    {
        return Dist[t];
    }

    vector<ll> get_path(ll t)
    {
        vector<ll> path;
        for (; t != -1; t = Prev[t])
        {
            path.push_back(t);
        }
        reverse(path.begin(), path.end());
        return path;
    }

    ll get_path_num(ll t)
    {
        return PathNum[t];
    }

    // int solve()
    // {
    //    ll v, e, r;
    //    cin >> v >> e >> r;
    //    Dijkstra dij(v);
    //    for (int i = 0; i < e; i++)
    //    {
    //       ll a, b, c;
    //       cin >> a >> b >> c;
    //       dij.add_edge(a, b, c);
    //    }
    //    dij.build(r);
    //    for (int i = 0; i < v; i++)
    //    {
    //       if (dij.dist(i) == 1e18)
    //       {
    //          cout << "INF" << endl;
    //       }
    //       else
    //       {
    //          cout << dij.dist(i) << endl;
    //          cout << dij.get_path(i) << endl;
    //          cout << dij.get_path_num(i) << endl;
    //       }
    //    }
    //    return 0;
    // }
};

struct CumulativeSum2D
{
    int H;
    int W;
    vector<vector<ll>> data;

    CumulativeSum2D(int H, int W) : H(H), W(W), data(H + 1, vector<ll>(W + 1, 0LL)) {}

    void add(int x, int y, ll z)
    {
        data[x + 1][y + 1] += z;
    }

    void build()
    {
        for (int i = 1; i < data.size(); i++)
        {
            for (int j = 1; j < data[i].size(); j++)
            {
                data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
            }
        }
    }

    void print()
    {

        for (int i = 0; i <= H; i++)
        {
            for (int j = 0; j <= W; j++)
            {
                cout << data[i][j] << " ";
            }
            cout << endl;
        }
    }

    ll query(int sx, int sy, int gx, int gy)
    {
        return (data[gy][gx] - data[sy - 1][gx] - data[gy][sx - 1] + data[sy - 1][sx - 1]);
    }
};

struct LCA
{
   int n, h;
   vector<vector<int>> par;
   vector<vector<pair<int, int>>> v;
   vector<ll> depth, dis;
   LCA(int sz) : n(sz), v(n), depth(n), dis(n)
   {
      h = 1;
      while ((1 << h) < n)
         h++;
      par.assign(h, vector<int>(n, -1));
   }

   void add_edge(int x, int y, int z)
   {
      v[x].push_back({y, z});
      v[y].push_back({x, z});
   }

   void dfs(int x, int p, int d, ll di)
   {
      par[0][x] = p;
      depth[x] = d;
      dis[x] = di;
      for (auto to : v[x])
         if (to.first != p)
            dfs(to.first, x, d + 1, di + to.second);
   }

   void build()
   {
      dfs(0, -1, 0, 0);
      for (int i = 0; i < h - 1; i++)
      {
         for (int j = 0; j < n; j++)
         {
            if (par[i][j] < 0)
               par[i + 1][j] = -1;
            else
               par[i + 1][j] = par[i][par[i][j]];
         }
      }
   }

   int lca(int u, int v)
   {
      if (depth[u] > depth[v])
         swap(u, v);
      for (int i = 0; i < h; i++)
         if ((depth[v] - depth[u]) >> i & 1)
            v = par[i][v];
      if (u == v)
         return u;
      for (int i = h - 1; i >= 0; i--)
      {
         if (par[i][u] != par[i][v])
         {
            u = par[i][u];
            v = par[i][v];
         }
      }
      return par[0][u];
   }

   ll dist(int u, int v)
   {
      return dis[u] + dis[v] - 2 * dis[lca(u, v)];
   }

   // int solve()
   // {
   //    ll n;
   //    cin >> n;
   //    LCA lca(n);
   //    for (int i = 0; i < n - 1; i++)
   //    {
   //       ll u, v, w;
   //       cin >> u >> v >> w;
   //       lca.add_edge(u, v, w);
   //    }
   //    lca.build();
   //    ll q;
   //    cin >> q;
   //    while (q--)
   //    {
   //       ll a, b, c;
   //       cin >> a >> b >> c;
   //       cout << (lca.dist(a, b) + lca.dist(b, c) + lca.dist(c, a)) / 2 << endl;
   //    }

   //    return 0;
   // }
};

//IMOS https://imoz.jp/algorithms/imos_method.html

/*名前
bitcount    __builtin_popcountll
二次元累積和 CumulativeSum2D
10進数の桁和 digit_sum
(b*b+c*c)**0.5 hypot

// 文字列t　->整数　atoi(t.c_str());
// 文字列t　->long long整数　stoll(t); ローカルではつかえない
to_string()も使えないので、どうにかしたい
*/

/*実装例
DP
-部分文字列DP https://www.hackerrank.com/contests/bbc003/challenges/bbc003-e/submissions/code/1321355726

組み合わせ
完全順列(pi!=i)
*/

/*------------------------------*/
ll a[101010];

ll cnk(ll n ,ll k){
    ll ret = 1;
    for(ll i=n-k+1; i <= n; i++){
        ret *= i;
    }
    for(int i=1; i <= k; i++){
        ret /= i;
    }
    return ret;
}
void solve()
{
    ll n , k;
    cin >> n >> k;
    if(k == 1){
        cout << 1 << endl;
        exit(0);
    }
    a[2] = 1;
    for(int i=3; i <= 10; i++){
        a[i] = (i - 1) * (a[i - 1] + a[i - 2]);
    }

    ll ans = 1;
    for(int i=0; i < k; i++){
        ans += cnk(n, k - i) * a[k - i];
    }

    cout << ans << endl;
}

int main()
{
    cout.precision(10);
    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();
}


#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<cmath>
#include<stdlib.h>
#define MAX 200000
#define M 1e18+7
using namespace std;
int main(){
string s;
int n,k,t,g;
cin>>n>>k>>s;
for(int i=0;i<n;i++){
    if(s[i]=='T'){
        t=i;
    }
    else if(s[i]=='G'){
        g=i;
    }
}
if((abs(t-g))%k!=0){
    cout<<"NO"<<'\n';
}
else{
    int x=min(t,g)+k;
 while(x<max(t,g)){
    if(s[x]=='#'){
        cout<<"NO\n";
        return 0;
    }
    x+=k;
 }
 cout<<"YES\n";
}
return 0;
}


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

int main(){

	int n ;
	cin >> n ;
	int min = INT_MAX ;
	int a[n] ;

	for(int i=0 ; i<n ; i++){
		cin >> a[i] ;
		if(a[i] < min){
			min = a[i] ;
		}
	}
	vector<int> arr(100) ;
	for(int i=0 ; i<100 ; i++){
		arr[i] = 0 ;
	}

	for(int i=0 ; i<n ; i++){

		for(int j=0 ; j<100 ; j++){

			if(a[i] % (j+1) == 0){

				int hai = 0 ;
				for(int k=0 ; k<n ; k++){
					if(j+1 == a[k]){
						hai = 1 ;
						arr[j] = 1 ;
						break ;
					}
				}
				if(hai == 1){
					break ;
				}else{
					continue ;
				}
			}
		}
	}
	int sum = 0 ;
	for(int i=0 ; i<100 ; i++){
		sum += arr[i] ;
	}
	cout << sum ;

	return 0 ;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{int a,b,p,q,x,y;
cin>>a>>b>>p>>q>>x>>y;
if((p-a)%x==0 && (q-b)%y==0 && ((p-a)/x+(q-b)/y)%2==0) cout<<"YES"<<endl;
else cout<<"NO";
}


#include <iostream>
using namespace std;

int main() {
    int n, s;
    cin >> n >> s;
    if (s%n == 0){cout << s/n;}
    else {cout << s/n + 1;}
}


#include<bits/stdc++.h>
using namespace std;
string a;
int sum;
int main(){
	cin>>a;
	char b,c;
	for(int i=0;i<a.size()/2;i++){
		b=a[i];
		c=a[a.size()-i-1];
		if(b!=c&&sum==1){
			cout<<"NO";
			return 0;
		}
		if(b!=c) sum++;
	}
	if(sum==0&&a.size()%2==1) cout<<"YES";
	if(sum==1) cout<<"YES";
	if(sum==0&&a.size()%2!=1) cout<<"NO";
}


#define NDEBUG

#include <bits/stdc++.h>

using namespace std;

#ifdef NDEBUG
#  define debug(...)
#else
#  include "debug.hh"
#endif

int static_init = []() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout << fixed;
  return 0;
}();

int k, s[5], c[3];

bool run() {
  while (k-- > 0) {
    int a;
    cin >> a;
    int d = min(s[4], a/4);
    s[4] -= d, a -= 4*d;
    d = min(s[2], a/2);
    s[2] -= d, a -= 2*d;
    if (a == 3) {
      if (s[4] > 0) s[4]--, a = 0;
      else if (s[2] > 0) s[2]--, a -= 2;
    }
    if (a >= 3) return false;
    c[a]++;
  }
  int d = min(c[2], s[4]);
  c[2] -= d, s[4] -= d, s[1] += d;
  c[1] += 2*c[2];
  return c[1] <= s[1] + s[2] + 2*s[4];
}

int main() {
  cin >> s[4] >> k;
  s[2] = 2*s[4];
  cout << (run() ? "YES" : "NO") << endl;
  return 0;
}


#define CIN_ONLY 1
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = 998244353;
const ld PI = acos(ld(-1));
int fix(ll i) { return (i % MOD + MOD) % MOD; }

const int N = 502;

ll h[N][N];
ll he[N][N];
ll sumh[N][N];

void solve(int n, int k)
{
  for (int i = 0; i <= 1; ++i) {
    for (int j = 1; j <= n; ++j) {
      h[i][j] = 1;
      he[i][j] = h[i][j] - h[i][j - 1];
      sumh[i + 1][j] = sumh[i][j] + h[i][j];
    }
  }
  for (int i = 2; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      h[i][j] = fix(sumh[i][j] - sumh[max(0, i - j)][j]);
      he[i][j] = fix(h[i][j] - h[i][j - 1]);
      sumh[i + 1][j] = fix(sumh[i][j] + h[i][j]);
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (i * j < k) {
        ans = fix(ans + he[n][i] * he[n][j]);
      }
    }
  }
  cout << fix(ans * 2) << endl;
}

int main()
{
  if (CIN_ONLY) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  }
  int n, k;
  cin >> n >> k;
  solve(n, k);
  return 0;
}


// Solution By Doolatbek uulu Bektemir
#include <bits/stdc++.h>
using namespace std;
int main(){
    double i,x,y,f,a,b,ans1=0,ans2=0;
    cin >> x >> y, f=pow(y,x-1);
    for(i=0; i<x; i++){
        cin >> a;
        ans1=ans1+(f*a),f=f/y;
    }
    cin >> x >> y, f=pow(y,x-1);
    for(i=0; i<x; i++){
        cin >> b, ans2=ans2+(f*b), f=f/y;}
        if(ans1==ans2){cout << "=";}
        else if(ans1<ans2){cout << "<";}
        else if(ans1>ans2){cout << ">";}
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll , ll>
#define pci pair<char,int>
#define fi first
#define se second
//cout << fixed << setprecision(5) << f << '\n';
/*
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    //ascending
    return (a.second < b.second);
}
bool comp(pii a , pii b)
{ // descending
    if(a.second == b.second)return(a.first > b.first);
    return(a.second > b.second);
}

 // Inserts str2 in str1 starting
    // from 6th index of str1
    str1.insert(6, str2);
*/
//map<pii,int> m; m[mp(0,0)]=0; pii ans=mp(1,1e9); ans.x , ans.y
//template<class T>
//using min_heap = priority_queue<T , vector<T> , greater<T>>;
//template<class T>
//using max_heap = priority_queue<T>;
//sort(B.begin() , B.end() , [](const box &l , const box &r){return l.x1 < r.x1;});
//min_heap<pair<ll , size_t>> byx2;
//max_heap<pair<ll , size_t>> byy1;
//using vll = vector<ll>
//vi gone(n , 0);
//sortdesc(arr, arr+n, greater<int>());
// x | (1 << n) returns x with nth bit set
//  x & (-x) returns the rightmost 1 of x
//getline(cin , s);
// vector<vector<int>> dist(size of the outer vector = n , vector<int>(size of EACH VECTOR in the vector = 10));
/*for(int k=0;k<4;k++)
use this for four adjacent ;
                {
                    int ni = i + int (k = 0) - int (k = 1);
                    int nj = j + int (k = 2) - int (k = 3);
                    if(ni < 0 || nj < 0 || ni >= n || nj >= m )continue;
                }
                */

/*
-----------BFS----------------

           // was[][] is for visited
            int was[n][m];
            for(int i=0;i<n;i++)
            {
                for(int j = 0; j < m ; j++)
                {
                 was[i][j] = 0;
                }
             }
              pii q[n*m];

             was[n-1][m-1] = 1; // n,m is starting node
              q[0] = mp(n-1 , m-1);
              int l = 0 , r = 1;
              while(l < r )
            {
                int i = q[l].fi;
                int j = q[l].se;
                for(int k = 0; k < 4;k++)
                {
                    int ni = i + int (k == 0) - int (k == 1); // for this disable int long long
                    int nj = j + int (k == 2) - int (k == 3);
                    if(ni < 0 || nj < 0 || ni >= n || nj >= m|| was[ni][nj])continue;
                    q[r++] = mp(ni , nj);
                    was[ni][nj] = 1;
                }
                l+=1;
            }

-----------BFS----------------
*/
/*
-------------DFS--------------
bool visit[N];
int par[N];
vector<int> g[N];
void dfs1(int v)
{
    visit[v] = true;
    for(auto child : g[v])
    {
         if(!visit[child])
              dfs1(child);
    }

}

void dfs2(int v, int p)
{
    par[v] = p;
    for(auto child : g[v])
    {
          if(child == par[v])
                continue;
          dfs(child,v);
    }

}
-------------DFS--------------
*/
/*
----------------DFS for calculating depth of each element as well as number of children---------------
#define maxn 200005
#define pb push_back
vector<int>adj[maxn];
int depth[maxn] , size[maxn] , det[maxn];
int dfs(int u , int f)
{
    depth[u] = depth[f] + 1;
    size[u] = 1;
    for(auto i : adj[u])
    {
        size[u] += dfs(i , u);
    }
    det[u] = size[u] - depth[u];
    return size[u];
}
dfs(1 , 0);
---------------------DFS---------------------------
*/
#define pb push_back
//#define int long long
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;

    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}

/*int dfs(string s , char c)
{
    int n = s.length();
    if(n == 1)
    {
        if(c == s[0]) return 0;
        else return 1;

    }
    int lc = 0;

    for(int i=0;i<n/2;i++)
    {
        if(s[i] != c){lc += 1;}
    }
int rc = 0;
    for(int i=n/2;i<n;i++)
    {
        if(s[i] != c){rc += 1;}
    }
    return min(dfs(s.substr(0 , n/2) , c + 1) + rc , dfs(s.substr(n/2 , n) , c + 1) + lc);
}
*/
//cout<<sum==1?"Carrots":sum==2?"Kiwis":"Grapes"
//printf("%s\n",sum==1?"Carrots":sum==2?"Kiwis":"Grapes");
#define float double
float distance(int x1, int y1, int x2, int y2)
{
    // Calculating distance
    return sqrt(pow(x2 - x1, 2) +
                pow(y2 - y1, 2) * 1.0);
}

int factorial(int n)
{
    // single line to find factorial
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
bool comp(pair<int , float>a , pair<int , float>b)
{
    if(a.se == b.se)return a.fi < b.fi;
    return a.se > b.se;
}
const int X[]={1,0,-1,0,1,1,-1,-1};
const int Y[]={0,1,0,-1,1,-1,1,-1};
/*bool dista(int x ,int y)
{
    for (int i = 0; i<n; i++)
    {
        int l = (x-data[i].x)*(x-data[i].x) + (y-data[i].y)*(y-data[i].y);
        if ( l <= data[i].r * data[i].r )
        {
            return false;
        }
    }
    return true;
}
*/
//const int mxn=1e6+9;
//int divv[mxn];
//for(i=1;i<mxn;i++) for(j=i;j<mxn;j+=i) divv[j]++;
#define int long long
vector<int>adj[51];
bool vis[51];
int sum;
void dfs(int u)
{
    if(vis[u])return ;
    vis[u] = 1;
    sum += 1;
    for(auto i : adj[u])
    {
        //if(!vis[i])
        {dfs(i);}
    }
    return ;
}

signed main()
{   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    //cin>>t;
    while(t--){

       //----------------------------------------------//

        int n;
        cin>>n;
        int mod = 1e9 + 7;
        int u = 1 , g = 1;
        for(int i=0;i<n;i++)
        {
            u *= 27;
            u %= mod;
            g *= 7;
            g %= mod;
        }
        int nas = (u%mod - g%mod)%mod;
        nas += mod;
        cout<<nas%mod;

        //---------------------------------------------//

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n1,n2;
int main()
{
	cin>>n1>>n2;
	if(n1>n2) cout<<"First\n";
	  else cout<<"Second\n";
	return 0;
 }


#include <iostream>

using namespace std;

bool testIndex(char arr[4][4], int i, int j)
{
	if (i == 3 || j == 3)
		return false;
	return arr[i][j] == arr[i][j + 1] && arr[i][j] == arr[i + 1][j] && arr[i][j] == arr[i + 1][j + 1];
}

bool test(char arr[4][4])
{
	for (int i = 0; i < 4; i++)
		for (int j = 0; j < 4; j++)
			if (testIndex(arr, i, j))
				return true;
	return false;
}

void change(char arr[4][4], int i, int j)
{
	if (arr[i][j] == '.')
		arr[i][j] = '#';
	else
		arr[i][j] = '.';
}

int main()
{
	char mat[4][4]; int i, j; bool flag=false;
	for (i = 0; i < 4; i++)
		for (j = 0; j < 4; j++)
			cin >> mat[i][j];
	flag = test(mat);
	if (!flag)
	{
		for (i = 0; i < 4; i++)
			for (j = 0; j < 4; j++)
			{
			change(mat, i, j);
			flag = test(mat);
			if (flag)
				break;
			else
				change(mat, i, j);
			}
	}
	if (flag)
		cout << "YES";
	else
		cout << "NO";

	return 0;
}


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

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

	int a, b, c;

	while(cin >> a >> b >> c)
	{
		long long x, y, z;

		x = sqrt((a*c)/b);
		y = sqrt((b*c)/a);
		z = sqrt((a*b)/c);

		cout << 4*x + 4*y + 4*z << endl;
	}

	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    double vp,vd,t,f,c,sum=0.00000;
    scanf("%lf%lf%lf%lf%lf",&vp,&vd,&t,&f,&c);
    int count=0;
    if(vp>=vd)
        printf("0\n");
    else{
    sum=sum+vp*t;
    t=sum/(vd-vp);
    sum=sum+t*vp;
    if(c-sum>=0.000001)
        count++;
    else
    {
        printf("0\n");
        return 0;
    }
    sum=sum+(t+f)*vp;
    while(c-sum>=0.000001)
    {
        t=sum/(vd-vp);
        sum=sum+t*vp;
        if(c-sum>=0.000001)
            count++;
        else
        {
            printf("%d\n",count);
            return 0;
        }
        sum=sum+(t+f)*vp;
    }
    printf("%d\n",count);
    }
    return 0;
}


#include <cstdio>

int k, b, n, t;
int main()
{
    scanf("%d %d %d %d", &k, &b, &n, &t);
    if (t==1)
        printf("%d\n", n);
    else {
    long long z = 1; int s = 0;
    while (z < t)
    {
        z = k*z+b;
        s++;
    }
    if (s > n)
        printf("0\n");
    else
    if (z==t)
        printf("%d\n", n-s);
    else
        printf("%d\n", n-s+1);
    }
}


 ///IN THE NAME OF ALLAH
 #include<bits/stdc++.h>
 using namespace std;
 int main(){
 int n;
 cin >> n;
 if(5*(n/5)!=n)
   cout<<(n/5+1);
 else
   cout<<n/5;
 }


#include<bits/stdc++.h>
using namespace std;
string s,a;
int main()
{
    cin >> s;
    a = s;
    s.append(s);
    cout << s.find(a , 1) << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cassert>
#include <string>
#define int long long

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pa;
typedef pair<ll, ll> pal;

const int N = 1e5;

int solve(){
	return 0;
}

signed main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	while (true) {
		string ss = s;
		for (int symb = 'z'; symb >= 'a'; --symb){

			string p;
			n = s.size();
			vector<int> used(n, 0);
			int g = 0;
			for (int i = 0; i < n - 1; ++i){
				if (s[i] == s[i + 1] + 1 && s[i] == symb) {
					used[i] = 1;
					g = 1;
					break;
				}
			}
			if (g == 0) {
				for (int i = n - 1; i >= 1; --i){
					if (s[i] == s[i - 1] + 1 && s[i] == symb) {
						used[i] = 1;
						break;
					}
				}
			}
			for (int i = 0; i < n; ++i) {
				if (!used[i])
					p += s[i];
				ans += used[i];
			}

			if (p != s) {
				s = p;
				break;
			}

		}
		if (ss == s)
			break;
	}
	cout << ans;
	return 0;
}


#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
//int arr[]={0};
int main()
{
    int noOfApples;
    cin>>noOfApples;
    //map<int,int> arr;
    int weight100=0,weight200=0;
    for(int i=0;i<noOfApples;i++)
    {
        int x;
        cin>>x;
       // arr[i]=x;
        if(x==100)
            weight100++;
        if(x==200)
            weight200++;
    }
    int sum=(200*weight200)+(100*weight100);
    int afterdiv=sum/2;
    if(afterdiv%100==0 )
    {
        if(weight200%2==0 && weight100%2==0)
            cout<<"YES"<<endl;
        else if(weight200%2==1&&weight100%2==0 &&weight100/2>=1)
        {
            cout<<"YES"<<endl;
        }
        else
            cout<<"NO"<<endl;
    }
    else
        cout<<"NO"<<endl;
}


// InterestingLSY
// 2659723130
// 《幽灵公主》是真的好看！
#include <bits/stdc++.h>
using namespace std;
#define il inline
#define elif else if

// Type
#define ld double
#define ll long long
#define ull unsigned ll

// Vector
#define vc vector
#define Pb push_back
#define Pf push_front
#define Eb emplace_back
#define All(x) x.begin(),x.end()
#define AllRev(x) x.rbegin(),x.rend()

// Memory
#define Ms(_data) memset(_data,0,sizeof(_data))
#define Msn(_data,_num) memset(_data,_num,sizeof(_data))

// Template
#define _cl class
#define _tp template
#define _tyn typename

// Pair
#define Mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>

// Loop
#define For(i,j) for( int (i) = 1 ; (i) <= (j) ; ++(i) )
#define For0(i,j) for( int (i) = 0 ; (i) < (j) ; ++(i) )
#define Forx(i,j,k) for( int (i) = (j) ; (i) <= (k) ; ++(i) )
#define Forstep(i,j,k,st) for( int (i) = (j) ; (i) <= (k) ; (i) += (st) )
#define fOR(i,j) for( int (i) = (j) ; (i) >= 1 ; --(i) )
#define fOR0(i,j) for( int (i) = (j)-1 ; (i) >= 0 ; --(i) )
#define fORx(i,j,k) for( int (i) = (k) ; (i) >= (j) ; --(i) )

// Read
struct InputReader{
	#define bs 1048576
	char buf[bs]; int p;
	il InputReader(){ p = bs; }
	il void Flush(){ p = 0; fread(buf,1,bs,stdin); }
	il char C(){ if(p >= bs) Flush(); return buf[p++]; }
	il char Readnum(){ char ch = C(); while( !isdigit(ch) && ch != '-' ) ch = C(); return ch; }
	il void Readalpha( char &c ){ c = C(); while( !isalpha(c) ) c = C(); }
	int operator() (){
		int ans = 0, fu = 1; char ch = Readnum();
		if( ch == '-' ) fu = -1, ch = C();
		while( ch >= '0' && ch <= '9' ){
			ans = ans*10 + ch-'0';
			ch = C();
		}
		return ans * fu;
	}
	ll Readll(){
		ll ans = 0LL, fu = 1LL; char ch = Readnum();
		if( ch == '-' ) fu = -1LL, ch = C();
		while( ch >= '0' && ch <= '9' ){
			ans = ans*10LL + ch-'0';
			ch = C();
		}
		return ans * fu;
	}
	il void Readstring( string &x ){
		x.clear(); char ch = C();
		while( !isdigit(ch)  &&  !isalpha(ch)  &&  ch != '#'  &&  ch != '.' ) ch = C();
		while( isdigit(ch)  ||  isalpha(ch)  ||  ch == '#'  ||  ch == '.' ){
			x += ch;
			ch = C();
		}
	}
	il void Readchstring( char s[] ){
		int len = 0; char ch = C();
		while( !isdigit(ch)  &&  !isalpha(ch)  /*&&  ch != '*'  &&  ch != '?'*/ ) ch = C();
		while( isdigit(ch)  ||  isalpha(ch)  /*||  ch == '*'  ||  ch == '?'*/ ){
			s[len++] = ch;
			ch = C();
		}
		s[len] = '\0';
	}
	il void Specialread( char &c ){
		c = C();
		while( !isdigit(c) && !isalpha(c) && c != '#'  &&  c != '.'  &&  c != '='  &&  c != 'B' ) c = C();
	}
	#undef bs
}In;
il void Read( int &x ){ x = In(); }
il void Read( int &x, int &y ){ x = In(); y = In(); }
il void Read( int &x1 , int &x2 , int &x3 ){ x1 = In(); x2 = In(); x3 = In(); }
il void Read( int &x1 , int &x2 , int &x3 , int &x4 ){ x1 = In(); x2 = In(); x3 = In(); x4 = In(); }
il void Read( ll &x ){ x = In.Readll(); }
il void Read( ll &x, ll &y ){ x = In.Readll(); y = In.Readll(); }
il void Read( ll &x1 , ll &x2 , ll &x3 ){ x1 = In.Readll(); x2 = In.Readll(); x3 = In.Readll(); }
il void Read( ll &x1 , ll &x2 , ll &x3 , ll &x4 ){ x1 = In.Readll(); x2 = In.Readll(); x3 = In.Readll(); x4 = In.Readll(); }
_tp<_tyn T> void Read( T a[] , int st , int ed ){ Forx(i,st,ed) Read(a[i]); }
#define iRead(k) int k; Read(k);
#define iRead2(a,b) iRead(a); iRead(b);
#define iRead3(a,b,c) iRead2(a,b); iRead(c);
#define iRead4(a,b,c,d) iRead2(a,b); iRead2(c,d);
#define lRead(k) ll k; Read(k);
#define lRead2(a,b) lRead(a); lRead(b);
#define lRead3(a,b,c) lRead2(a,b); lRead(c);
#define lRead4(a,b,c,d) lRead2(a,b); lRead2(c,d);

// File
#define Fin(a) freopen(a,"r",stdin)
#define Fout(a) freopen(a,"w",stdout)
il void FILEIO(){
	#ifdef intLSY
		Fin("in.in");
	#endif
}
il void FILEIO( string pname ){
	#ifndef intLSY
		Fin((pname+".in").c_str());
		Fout((pname+".out").c_str());
	#else
		Fin("in.in");
	#endif
}
il void FILEIO_OICONTEST( string pname ){
	Fin((pname+".in").c_str());
	#ifndef intLSY
		Fout((pname+".out").c_str());
	#endif
}
void Printtime(){
	#ifdef intLSY
		double _timeuse = clock()* 1000.0 / CLOCKS_PER_SEC;
		fprintf(stderr,"\n\nTime usage:\n%.0lf ms\n",_timeuse);
	#endif
}
void END(){ Printtime(); exit(0); }
_tp<_tyn T>void END( T mes ){ cout << mes << endl; END(); }

// Debug
#define B cerr << "BreakPoint" << endl;
#define O(x) cerr << #x << " " << (x) << endl;
#define o(x) cerr << #x << " " << (x) << "  ";
#define Msz(x) cerr << "Sizeof " << #x << " " << sizeof(x)/1024/1024 << " MB" << endl;
_tp<_tyn T>void Print( T a[] , int s , int t , char sp = ' ' , char ed = '\n' ){
	if( s > t ) return;
	for( int i = s ; i < t ; i++ )
		cout << a[i] << sp;
	cout << a[t] << ed;
	cout.flush();
}
_tp<_tyn T>void Print( T a , int s = 0 , int t = -1 , char sp = ' ' , char ed = '\n' ){
	if( t == -1 ) t = a.size()-1;
	for( int i = s ; i <= t ; i++ )
		cout << a[i] << sp;
	cout << ed;
	cout.flush();
}

// Optimize
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define Mymax(a,b) (a) = max((a),(b))
#define Mymin(a,b) (a) = min((a),(b))
#define MyMax(a,b) (a) = Max((a),(b))
#define MyMin(a,b) (a) = Min((a),(b))
#define INF (0x3f3f3f3f)
#define LINF ((long long)(0x3f3f3f3f3f3f3f3f))
#define Sqr(x) ((x)*(x))
#define Lowbit(a) ((a)&(-(a)))
vc<int> Range( int l , int r ){
	vc<int> ret{};
	Forx(i,l,r) ret.Pb(i);
	return ret;
}
mt19937 Rand(0xe38195e38293);	// さん
#define MOD (1000000007LL)
#define Rmoi(a,b) (((a)%b+b)%b)
#define Rmo(a) (((a)%MOD+MOD)%MOD)
#define Rmod(a) a = ((a%MOD+MOD)%MOD)
#define Rmodi(a,b) a = ((a%(b)+(b))%(b))
#define Mymoi(a,b) ((a)>=b?((a)-b):(a))
#define Mymodi(a,b) a = ((a)>=(b))?((a)-(b)):(a)
template<typename T>
il T Mymo( const T &x ){ return x >= MOD ? x-MOD : x; }
template<typename T>
il void Mymod( T &x ){ x = x >= MOD ? x-MOD : x; }
template<typename T1, typename T2>
il void Addi( T1 &x , const T2 &y ){ x = Mymo(x+y); }
template<typename T1, typename T2>
il void Deci( T1 &x , const T2 &y ){ x = Mymo(x-y+MOD); }
il ll Pow( ll a , ll b , const ll p = MOD ){
	ll ret = 1;
	for( ; b ; a = a*a%p, b >>= 1LL )
		if(b&1LL) ret = ret*a%p;
	return ret;
}
il ll Inv( ll a , const ll p = MOD ){ return Pow(a,p-2LL,p); }
#define FACT 1048576
ll fact[FACT], invfact[FACT];
il void InitFact(){
	fact[0] = 1;
	For(i,FACT-1) fact[i] = fact[i-1]*i % MOD;
	invfact[FACT-1] = Inv(fact[FACT-1]);
	fOR0(i,FACT-1) invfact[i] = invfact[i+1]*(i+1) % MOD;
}
il ll C( int n , int m ){
	if( n < m ) return 0;
	return fact[n] * invfact[m]%MOD * invfact[n-m]%MOD;
}
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
const int MAXN = 1048576;

int n,k;

ll dp[MAXN], sum[MAXN];

int main(){
	FILEIO();
	InitFact();

	Read(n,k);

	dp[0] = 1;
	sum[0] = 1;
	dp[1] = 1;
	sum[1] = 2;
	Forx(i,2,n){
		dp[i] = fact[i-1] * (sum[i-1]-(i-k<=0?0:sum[i-k-1])+MOD) % MOD;
		sum[i] = ( sum[i-1] + dp[i]*invfact[i] ) % MOD;
	}
	// Print(dp,1,n);

	ll ans = 0;
	For(i,n){
		ll tans = dp[i-1] * C(n-1,i-1) % MOD * fact[n-i] % MOD;
		Addi(ans,tans);
	}
	ans = Rmo( fact[n] - ans );
	cout << ans << endl;

	END();
}


#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>
#include<iomanip>
#include <string>
#include <vector>
#include<unordered_map>
#include<unordered_set>
using namespace std;

typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const ll mod = 1000000007;
const ll inf = 1000000000009;

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

int main()
{
	IO;
	int n{},ans{};
	cin>>n;
	For(i,1,n+1)
	{
		For(j,i,n+1)
		{
			int x=i^j;
			if(x<j || x>n || i+j<=x)continue;
				ans++;
		}
	}
	cout<<ans<<"\n";
//	system("pause");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,kk;
vector<string>v;
vector<ll>sol;
map<ll,ll>m;
int main()
{
    string s,s1;
    cin>>s;
    n =s.size();
 char a[100];
 for(int i=0;i<n;i++)
    a[i]=s[i];
 for(int i=0;i<(1<<n);i++)
 {
    for(int j=0;j<n;j++)
    {
        if((i&(1<<j))!=0)
            s1+=a[j];
    }
    v.push_back(s1);
    s1="";
 }
 for(int i=1;i<v.size();i++)
     {
         ll x=0,y=1;
          for(int q=v[i].size()-1;q>=0;q--)
          {
              x+=(v[i][q]-'0')*y;
              y*=10;
          }
          sol.push_back(x);
     }
     sort(sol.begin(),sol.end());
     for(int i=sol.size()-1;i>=0;i--)
     {
         kk=sqrt(sol[i]);
        if(kk*kk==sol[i]&&sol[i]!=0)
        {
           s1=to_string(sol[i]);
           cout<<s.size()-s1.size();
           return 0;
        }
     }
     cout<<-1;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
int n, l, r, k, a;
signed main() {
    scanf("%lld%lld%lld%lld", &n, &l, &r, &k);
    a = (r - l + n + 1) % n;
    int ans = -1;
    for (int i = 1, j; i <= k; i = j + 1) {
        int cnt = k / i;
        j = k / cnt;
        int lp = max(n, i);
        int rp = min(2 * n, j);
		lp = max(lp, (k - 2 * a + cnt - 1) / cnt);
		rp = min(rp, min((2 * n + k - 2 * a + 1) / (cnt + 1), (k - a) / cnt));
        if (lp <= rp) ans = max(ans, rp - n);
    }
    if (k >= a && k <= a * 2) ans = max(ans, min(a, k - a + 1) + (n - a));
    if (!a && k == n) ans = max(ans, 1ll);
    printf("%lld\n", ans);
    return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main(int argc,char** argv)
{
	string first;
	string second;
	cin>>first>>second;
	int pos=0;
	for(int i=0;i<(int)second.size();i++)
	{
		if(first[pos]==second[i])
		{
			pos++;
		}
	}
	cout<<pos+1<<endl;

	//system("pause");
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int n;

string s;

int main()
{
	cin >> n >> s;
	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		int cnt = 0;
		while(s[i] == 'x' && i < n)
		{
			cnt++, i++;
		}
		if(cnt) i--;
		if(cnt >= 3) ans += cnt - 2;
	}
	cout << ans << endl;
	return 0;
}


#include<iostream>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main() {
    int u=0;
    string s;
    char c;
    cin>>s;
    c=s[1];
    for(int i=0;i<s.size();i++)
     {
        if(s[i]==c){
            u++;
            c=s[i];
        }
        else{
            u=0;
            c=s[i+1];
        }//cout<<u<<":";
        if(u>=7){
            cout<<"YES\n";
            break;
        }

     }
    if(u<7){
        cout<<"NO\n";
    }

    return 0;
}


// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const int N = 1e7 + 1;
int dp[2*N];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //  // freopen("output.txt", "w", stdout);
    // #endif
   int n, in, c;
   cin >> n >> in >> c;
   for(int i = 1; i <= n; i++) {
       dp[i] = dp[i-1] + in;
       if(i%2 == 0) {
           dp[i] = min(dp[i], dp[i/2] + c);
       }
       else {
           dp[i] = min(dp[(i+1)/2] + c + in, dp[i]);
       }
   }
   cout << dp[n] << '\n';
}


#include <cstdio>
#include <cstring>

using namespace std;

const int MAXL=105;
char a[MAXL], c[MAXL];
int b, d, f[MAXL];

int main()
{
    scanf("%d%d%s%s", &b, &d, a, c);
    int n=strlen(c);
    int i, j, k;
    for (i=0; i<n; i++)
        for (j=0; a[j]; j++)
            f[i] += a[j]==c[(i+f[i])%n];
    int ans=0;
    for (i=1; i<=b; i++)
        ans += f[ans%n];
    printf("%d", ans/n/d);
    return 0;
}


//its not over until i win
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b;
    cin>>a>>b;
    if(a==b)
    {
        cout<<1;
        return 0;
    }
    //cout<<(b-a)<<endl;
    if((b-a)>=5)
    {
        cout<<0;
        return 0;
    }
    if(a==0)
        a=1;
    if(b==0)
        b=1;
        int c=1;
        a=a%10;
        b=b%10;
        if(b<a)
        {
        cout<<0;
        return 0;
        }
        //cout<<a<<" "<<b;
    for(long long int i=b;i>a;i--)
    {  // cout<<"dfs";
         if((i%10)==0 || c%10==0)
    {
        cout<<c%10;
        return 0;
    }

        c=((c%10)*(i%10))%10;;
        //cout<<c<<"loop"<<endl;
    }
    cout<<c%10;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n,k;
int main()
{
	cin>>n>>k;
	cout<<n+k-n%k;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define SZ(a)          (int)a.size()

int main() {
	string st = "";
	cin >> st;
	int arr[3440];
	for(int i = 0; i < 100; i++) arr[i] = 0;
	int sz = SZ(st);
	for(int i = 0; i < sz; i++) {
		int x = (st[i] - '0');
		arr[i] = x;
	}
	for(int i = 0; i < sz; i++) {
                if(i == 0 && arr[i] == 9) continue;
		int x = 9 - arr[i];
		arr[i] = min(arr[i], x);
	}
	int i = 0;
	for(; i < sz; i++)
		cout << arr[i];

	cout << "\n";
}


#include<iostream>
#include<math.h>
using namespace std;
int pos[16];
int main()
{
	long double n;
	cin>>n;
	long double N = pow(2,n);
	for(int i = 0; i < n; i++)
		cin>>pos[i];
	int d, j;
	for(int i = 0; i < N; i++)
	{
		d = 0;
		for(j = 0; j < n; j++) d+=pos[j];
		//cout<<d;
		//system("pause");
		if(d%360 == 0)
		{
			cout<<"YES";
			return 0;
		}
		j = 0;
		if(pos[j] > 0)
			while(pos[j] > 0)
			{
				pos[j] *= -1;
				j++;
			}
		pos[j] *= -1;
	//	for(j = 0; j < n; j++) cout<<mar[j];
	//	system("pause");
	}
	cout<<"NO";
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define PB push_back
#define ST first
#define ND second

int main()
{
	ios_base::sync_with_stdio(0);
	int v[1000];
	int n, d;
	cin >> n >> d;
	for(int i=0; i < n; i++)
	{
		cin >> v[i];
	}
	sort(v, v+n);
	int minr=1e3;
	for(int i=0; i < n; i++)
	{
		for(int j=n-1; j>=i; j--)
		{
			if(v[j]-v[i]<=d)
			{
				minr = min(minr, i+n-1-j);
				break;
			}
		}
	}
	cout << minr << "\n";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define N 1005
#define M 1000005
#define LL long long
#define fo(i,j,k) for(register int i=j;i<=k;++i)
#define fx(i,j,k) for(register int i=j;i>=k;--i)
template<typename T>inline void read(T &x) {
   int f=1;x=0;char c=getchar();
   for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
   for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
   x*=f;
}
int i,j,k,m,n;
int a[101][101]={{0,1,2},{1,0,2},{1,2,0},{2,1,0},{2,0,1},{0,2,1},{0,1,2}};
int main(){
    read(n);read(m);
    cout<<a[n%6][m]<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[10005], f[10005], b[305];
int main() {
    ios::sync_with_stdio( false );
    int n, t, i, j;
    cin >> n >> t;
    int len = n * min( n, t );
    for ( i = 1; i <= n; i++ ) {
        cin >> a[i];
        b[a[i]]++;
    }
    int mxa = 1;
    for ( i = n + 1; i <= len; i++ )
        a[i] = a[i - n];
    for ( i = 1; i <= len; i++ ) {
        f[i] = 1;
        for ( j = i - 1; j >= max( i - n, 1 ); j-- ) {
            if ( a[i] >= a[j] )
                f[i] = max( f[i], f[j] + 1 );
        }
        mxa = max( mxa, f[i] );
    }
    if ( n >= t )
        cout << mxa << endl;
    else {
        int mxaa = 0;
        for ( i = 0; i < 305; i++ )
            mxaa = max( mxaa, b[i] );
        cout << mxa + mxaa * ( t - n ) << endl;
    }
    return 0;
}


#include<cstdio>
#include <iostream>
#include<iomanip>
#include<string>
using namespace std;
int a[30][30];

int main()
{
	int n, i, j, x, y;
	cin >> n;
	string s;
	cin >> s;
	for (i = 0; i < n - 1; i++) {
		x = s[i] - 'A';
		y = s[i + 1] - 'A';
		a[x][y]++;
	}
	int max = 0, b = 0, c = 0;
	for (i = 0; i < 26; i++) {
		for (j = 0; j < 26; j++) {
			if (max < a[i][j]) {
				b = i;
				c = j;
				max = a[i][j];

			}
		}
	}
	printf("%c%c\n", b + 'A', c + 'A');
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
using namespace std;
bool cmp (int a, int b){
    return a>b;
}
int x[1005], n;
bool solve(int k){
    priority_queue<int> pq;
    while(!pq.empty()) pq.pop();
    int i,put, now;

    for(i = 0; i < k ; i++){
        pq.push(1005);
    }
    put = 0;
    for(i = 0; i < n ; i++){
        now = pq.top(); pq.pop();
        if(now!=0){
           now = min(now -1, x[i]);
           put++;
        }
        pq.push(now);
    }

   if(put==n) return true;
   else return false;
}
int main()
{
    int i;

    cin >> n;
    for(i = 0; i < n ; i++)
        cin >> x[i];

    sort(x, x+n, cmp);

    for(i = 1; i <= n ; i++){
        if(solve(i)==true){
            printf("%d\n", i);
            break;
        }
    }

    return 0;
}


#include<iostream>
using namespace std;
int main(){
	int a,b,k,i,ans=0;
	cin>>a>>b>>k;
	for(i=0;i<k;i++){
		int w,h;
		w=a-4*(i);
		h=b-4*(i);
		//cout<<"w"<<w<<"h"<<h<<"\n";
		ans=ans+(w-2)*2+(h-2)*2+4;
	}
	cout<<ans;
	return 0;
}


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

long long sum, first;
int x[1008];
int main()
{

	long long n;
	cin >> n >> first;
	for(int i = 0 ; i < n-1; i++)
		cin >> x[i] ;

	bool f = 1;
	sort(x, x+n-1);

	while(f){
	f  = 0;
	sort(x, x+n-1);
	reverse(x, x+n-1);
		if(first <= x[0])
		{
			x[0]--;
			first++;
			sum++;
			f = 1;
		}
	}

	cout << sum;

    return 0;
}


#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
//#include<queue>
//#include<stack>

using namespace std;

inline int read();

string s1,s2;

int main(){
    cin>>s1>>s2;
    sort(s1.begin(),s1.end());
    if(s1[0]=='0')
        for(int i=1;i<s1.length();++i)
            if(s1[i]!='0') {
				swap(s1[0],s1[i]);
				break;
			}
    if(s2==s1) cout<<"OK"<<endl;
    else cout<<"WRONG_ANSWER"<<endl;
    return 0;
}

inline int read() {
	int x=0;
	char c=getchar();
	bool flag=0;
	while(c<'0' || c>'9') {if(c=='-') flag=1; c=getchar();}
	while(c>='0' && c<='9') {x=(x<<3)+(x<<1)+c-'0'; c=getchar();}
	return flag?-x:x;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define deb(x) cout<<#x<<" "<<x<<endl
#define sc(ar,n) for(int pen=0;pen<n;pen++){ cin>>ar[pen];}
#define pr(ar) for(int pen=0;pen<sizeof(ar)/8;pen++){ cout<<ar[pen]<<" ";} cout<<endl;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rt return 0;
#define mod 1000000007
signed main(){
	int n,m;
    cin>>n>>m;
    vector < pair<int,int> > vt;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        if(a>b)
        swap(a,b);
        vt.push_back(make_pair(a,b));
    }
    if(n<=6)
    {
        cout<<m<<endl;
        rt;
    }
    int mx=0;
    int cnt=0;
    for(int i=1;i<=6;i++){
      //  cout<<i<<endl;
        for(int j=1;j<=6;j++){
            for(int k=1;k<=6;k++){
                for(int l=1;l<=6;l++){
                    for(int m=1;m<=6;m++){
                        for(int n=1;n<=6;n++){
                            for(int o=1;o<=6;o++){
                                int dp[7][7];
                              //  cnt++;
                                for(int p=0;p<7;p++)
                                {
                                    for(int q=0;q<7;q++)
                                    dp[p][q]=0;
                                }
                                for(int p=1;p<7;p++)
                                {
                                    for(int q=i;q<7;q++)
                                    dp[p][q]=1;
                                }
                                // if(i==1)
                                // cout<<"hi"<<endl;
                                int sum=0;
                                for(auto it=vt.begin();it!=vt.end();it++)
                                {
                                    int a=it->first;
                                    int b=it->second;
                                   // cout<<a<<" "<<b<<endl;
                                    int c=-1,d=-1;
                                    if(a==1)
                                    c=i;
                                    else if(a==2)
                                    c=j;
                                    else if(a==3)
                                    c=k;
                                    else if(a==4)
                                    c=l;
                                    else if(a==5)
                                    c=m;
                                    else if(a==6)
                                    c=n;
                                    else if(a==7)
                                    c=o;

                                    if(b==1)
                                    d=i;
                                    else if(b==2)
                                    d=j;
                                    else if(b==3)
                                    d=k;
                                    else if(b==4)
                                    d=l;
                                    else if(b==5)
                                    d=m;
                                    else if(b==6)
                                    d=n;
                                    else if(b==7)
                                    d=o;

                                    if(dp[c][d]==1 || dp[d][c]==1)
                                    {
                                        sum++;
                                        dp[c][d]=0;
                                        dp[d][c]=0;
                                    }
                                    // if(i==1)
                                    // {
                                    //     cout<<"hi"<<endl;
                                    // }
                                }
                                mx=max(sum,mx);
                            }
                        }
                    }
                }
            }
        }
    }
    cout<<mx<<endl;
  //  cout<<cnt<<endl;
}


#include <iostream>

using namespace std;

int main()
{
  long long n ;
  cin>>n ;
  cout<<(n-2)*(n-2)<<endl;
    return 0;
}


#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stdio.h>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <assert.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define TR(i,x) for(typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))

using namespace std;

const double eps = 1e-8;

#define PB push_back
#define MP make_pair

typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int,int> PII;
typedef long long int64;
typedef long long ll;
typedef unsigned int UI;
typedef long double LD;
typedef unsigned long long ULL;

int n, m;

inline int calc(int A, int B, int C, int low, int high) {

	int ret = 0;
	int res = B / (C - low);
	for (int i = low; i <= high; ++i) {
		while ((C - i) * (res + 1) <= B) ++res;
		ret += A + res;
	}

	return ret;
}

int main() {
	cin >> n >> m;

	long long ans = 0, center = 0;
	for (int i = m + 1; i <= n - i + 1; ++i) {

		int A = i - (n + 1);
		int B = (3 * i * (n + 1 - i) - 1);
		int C = i + n + 1;

		/*
		we need to count A + B / (C - X);
		*/

		int low = m + 1, high = n - m;
		if (low > high) continue;
		while (low < high) {
			int mid = ((low + high) >> 1);
			if (A + B / (C - mid) >= m + 1) {
				high = mid;
			} else {
				low = mid + 1;
			}
		}

		if (i == n - i + 1) center = ans;

		if (A + B / (C - low) <= m) continue;

		int upperBound = low;
		low = upperBound; high = n - m;
		while (low < high) {
			int mid = ((low + high) >> 1) + 1;
			if (A + B / (C - mid) <= n - m) {
				low = mid;
			} else {
				high = mid - 1;
			}
		}

		if (A + B / (C - low) > n - m) {
			ans += (n - m - upperBound + 1) * (n - 2 * m);
			continue;
		}

		ans += (n - m - low) * (n - 2 * m);
		ans += calc(A, B, C, upperBound, low) - m * (low - upperBound + 1);
	}

	if (n % 2 == 1) {
		ans = center * 6 + (ans - center) * 3;
	} else {
		ans *= 6;
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

int main()
{
	string str,x="";
	cin >> str;
	int i, t1 = 0, t2 =str.size()-1;
	if (str.size() % 2 == 0)
	{
		for (i = 0;i < str.size();i++)
			if (i % 2 == 0)
			{
				x += str[t2];
				t2--;
			}
			else
			{
				x += str[t1];
				t1++;
			}
	}
	else
	{
		for (i = 0;i < str.size();i++)
			if (i % 2 != 0)
			{
				x += str[t2];
				t2--;
			}
			else
			{
				x += str[t1];
				t1++;
			}
	}
	for (i = str.size() - 1;i >= 0;i--)
		cout << x[i];
	getchar();
	getchar();
	return 0;
}


/****************************
 * Name   :B. Good String
 * Time   :2019-3-26 18:33
 * Author :大哥
 * Type   :
 * 版权所有_翻版不管
 ****************************
 */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define lowbit(x) (x&-x)
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
ll gcd(ll p,ll q){
	return q==0?p:gcd(q,p%q);
}
ll qpow(ll p,ll q){
	ll f=1; while(q){
		if(q&1)f=f*p; p=p*p; q>>=1;
	}return f;
}

#define exp 1e-8
#define MOD 1000000007
#define M 105
#define N 1005

int main(){
#ifdef LOCAL
	freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
#endif
	int n;
	cin>>n;
	ll ans=0;
	for(int i=2; i<n; i++){
		ans+=i*i+i;
	}
	cout<<ans;
	return 0;
}


#include <bits/stdc++.h>

#define endl "\n"
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;

constexpr int N = 2e5 + 5;

int n, b, p, x = 0, y = 0;

void Solve() {
  cin >> n >> b >> p;
  cout << (n - 1) * ((b << 1) + 1) << " " << n * p << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  // int t;
  // cin >> t;
  // while(t--)
  //auto start = chrono::high_resolution_clock::now();
    Solve();
  // auto end = chrono::high_resolution_clock::now();
  // cout << endl << (chrono::duration_cast<chrono::duration<double>>(end - start)).count();
  return 0;
}


// the problem is to find a subset with all same elements
// of maximum size such that their sum is not formable by
// taking any combination of the other elements other than
// those in the subset (the 'other' could include 'that'
// 'same' element itself too)

// so dp state is dp[sum][k elements] where 'k' is the number
// of elements used to form the 'sum'

// eg: (5 5 5), (4 5 6) and hence dp[15][3] = 2 ways

// now you can't iterate over elements of the array like
// in knapsack/subset sum problem as in the case of duplicates
// you'll end up counting the same way twice.

// Eg: if arr = 5 5 5
// knapsack ind 1:
// dp[5][1] = 1 dp[10][2] = 0
// knapsack ind 2:
// dp[5][1] = 2 dp[10][2] = 1
// knapsack ind 3:
// dp[5][1] = 3 dp[10][2] = 3
// which is not what we want for dp[10][2]
// if sum is composed of same elements, we want it to be
// counted as just 1 way.

// 20
// 50 50 50 50 39 39 9 9 24 24 96 90 90 77 59 98 98 77 96 80
// that happens for 150 = 50*3 in the above case
// hence the first method in main below doesn't work
// i.e. commented out code

// however, if you change the update to only include
// values from the previous distinct value, then it works
// i.e.: 4 4 5 5
// for 4,4 do one pass for all relevant (sum,k) for dp[sum][k]
// for 5,5 do the next pass, but use old dp[sum][k] from previous 4,4
// 	pass to update values for this 5,5 combo
// this is illustrated in the accepted code

// way better than this using two dp arrays with last index
// indicating which is old and which is new, is to fill in some
// order so that what we want holds - this is done by Swistakk's
// solution below, he fills it in descending order for (sum,k)
// in that way we don't repeat values.

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 3.1415926535897932
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define bolt ios::sync_with_stdio(0)
#define forr(i,p,n) for(int i=p;i<n;i++)
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;

ll mult(ll a,ll b, ll p=MOD){ll ans = ((a%p)*(b%p))%p; return (ans+p)%p;}
ll add(ll a, ll b, ll p=MOD){ll ans = (a%p + b%p)%p; return (ans+p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}

// ncr mod p
// vector<ll> fact(200005,0);
// vector<ll> invvec(200005,0);

// void fillfact(){
//     fact[0] = 1; invvec[0] = 1;
//     fact[1] = 1; invvec[1] = 1;
//     forr(i,2,200001){
//         fact[i] = mult(fact[i-1],i);
//         invvec[i] = inv(fact[i]);
//     }
// }

// ll ncr(ll n, ll r){
//     return (mult(fact[n],mult(invvec[r],invvec[n-r])));
// }

// disjoint sets union
// vector<ll> par(200005,0);
// vector<ll> rnk(200005,0);
// ll find_root(ll v) {
//     return par[v] == v ? v : (par[v] = find_root(par[v]));
// }

// void merge(ll x,ll y) {
//     if ((x = find_root(x)) == (y = find_root(y))) return;
//     if(rnk[y] > rnk[x])
//         swap(x, y);
//     par[y] = x;
//     rnk[x] += rnk[y];
// }

// sieve for first 1000 primes
// vector<bool> prime(100005,0);
// vector<ll> vec;

// void sieve() {
//     forr(i, 2, 8005) {
//         if (!prime[i]) {
//             vec.pb(i);
//             for(ll j = 2 * i; j < prime.size(); j += i)
//                 prime[j] = 1;
//         }
//     }
// }

int main(){

	int n;
	cin>>n;
	map<int, int> cnt;
	// vector<int> arr;
	forr (i, 0, n) {
		int a;
		cin>>a;
		// arr.pb(a);
		cnt[a]++;
	}

	// notice that this doesn't work
	// the reason is that you end up recounting things
	// for sums made of same elements, which should
	// not be done since the condition we're checking
	// for is that dp[sum][k] = 1

	// sort(all(arr));
	// int R = 10001;
	// vector<vector<vector<int>>> ways(R,vector<vector<int>>(n+1,vector<int>(2,0)));
	// ways[0][0][0] = 1;
	// ways[0][0][1] = 1;
	// int sp = 0;
	// forr(k, 0, sz(arr)){
	// 	sp++;
	// 	forr(i,0,R){
	// 		forr(now,1,n+1){
	// 			ways[i][now][sp&1] = ways[i][now][(sp-1)&1];
	// 			if(i-arr[k] >= 0)
	// 				ways[i][now][sp&1] += ways[i-arr[k]][now-1][(sp-1)&1];
	// 			ways[i][now][sp&1] = min(ways[i][now][sp&1],9);
	// 		}
	// 	}
	// }
	// forr(i,0,151){
	// 	if(i<10)
	// 		cout<<i<<"   ";
	// 	else if(i<100)
	// 		cout<<i<<"  ";
	// 	else
	// 		cout<<i<<" ";
	// 	forr(j,1,n+1){
	// 		cout<<ways[i][j][sp&1];
	// 	}
	// 	cout<<endl;
	// }

	int R = 10001;
	vector<vector<vector<int>>> ways(R,vector<vector<int>>(n+1,vector<int>(2,0)));
	// initialization takes care so that even single
	// elements are accounted for
	// i.e.: if ele=5, dp[0][0] = 1, hence dp[5][1] = 1
	ways[0][0][0] = 1;
	ways[0][0][1] = 1;
	int sp = 0;
	for (auto p : cnt) {
		sp++;
		int wei = p.first;
		int mul = p.second;
		// for all sums
		forr(i,0,R){
			// for all k (k has meaning in topmost comments section)
			// - i.e. ways to form sum 'i' using  exactly 'now' elements
			forr(now,0,n+1){
				// use only dp vals from previous
				// distince 'wei' for this iter
				ways[i][now][sp&1] = ways[i][now][(sp-1)&1];
				// iterating over all relevant j given i,now
				// so that doesn't go out of bounds
				forr (j, 1, min(i/wei, min(mul, now))+1) {
					// lhs: current dp arr, rhs: prev dp arr
					// where prev is dp arr for (4,4) if cur is dp arr for
					// (4,4,5,5) and arr = 4,4,5,5
					ways[i][now][sp&1] += ways[i-j*wei][now-j][(sp-1)&1];
					ways[i][now][sp&1] = min(ways[i][now][sp&1],2);
				}
			}
		}
	}
	if (sz(cnt) == 2) {
		cout<<n<<endl;
		return 0;
	}
	int best = 0;
	for (auto p : cnt) {
		int wei = p.first;
		int mul = p.second;
		forr (i, 0, mul+1) {
			// if only 1 way to form that sum,
			// composed of all same elements
			// then that is a possible candidate
			// answer, since you can identify that
			// sum with that many weights, all
			// weights are of a particular kind
			if(ways[wei*i][i][(sp)&1] == 1){
				best = max(best, i);
			}
		}
	}
	cout<<best<<endl;
	return 0;
}

// Swistakk fills it in decreasing order of
// (i,now) do avoid repeat count

// int main(){
//   int n;
//   cin>>n;
//   map<int, int> cnt;
//   RE (i, n) {
//       int a;
//       cin>>a;
//       cnt[a]++;
//   }
//   int R = 1e4 + 5;
//   vector<vector<int>> ways(R, vector<int>(n + 1));
//   ways[0][0] = 1;
//   for (auto p : cnt) {
//       int wei = p.st;
//       int mul = p.nd;
//       FORD (i, R - 1, 0) {
//         FORD (now, n, 0) {
//           FOR (j, 1, min(i / wei, min(mul, now))) {
//               ways[i][now] += ways[i - j * wei][now - j];
//               mini(ways[i][now], 2ll);
//             }
//           }
//       }
//   }
//   if (SZ(cnt) == 2) {
//     cout<<n<<endl;
//     return 0;
//   }
//   int best = 0;
//   for (auto p : cnt) {
//       int wei = p.st;
//       int mul = p.nd;
//       FOR (i, 0, mul) {
//           if (ways[wei * i][i] == 1) {
//               maxi(best, i);
//           }
//       }
//   }
//   cout<<best<<endl;
// }


#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>;

const int N=510;
char s[N],cr;
int n;

void solve()
{
	cin>>s;
	n=strlen(s);
	cr='a';
	for(int i=0;i<n;i++)
	{
		if(s[i]>cr)
		{
			cout<<"NO\n";
			return;
		}
		else if(s[i]==cr)
		{
			if(cr<'z')cr++;
		}
	}
	cout<<"YES\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}


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

int main()
{
    int N,X,Y;
    while(scanf("%d%d%d",&N,&X,&Y) != EOF )
    {
        for(int i = 0 ; ; i++)
        {
            if ( ( X + i ) * 100 >= ( N * Y ) )
            {
                printf("%d\n",i);
                break;
            }
        }
    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include<stack>
#include<utility>
using namespace std;
#define ll long long
typedef vector<int> vi;
#define all(v) ((v).begin()),((v).end())
void fast()
{std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main(){
    fast();
    int n,x1,y1,x2,y2;
    cin>>n>>x1>>y1>>x2>>y2;
    long long dist1=0,dist2=0;
    if(x1==x2 && (x1==0 || x1==n) || y1==y2 && (y1==n || y2==0)){
        cout<<sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    }
    else if(y1==0 && y2==n || y2==0 && y1==n){
        dist1=n+x1+x2; dist2=n+n-x1+n-x2;
        cout<<min(dist1,dist2);
    }
    else if(x1==0 && x2==n || x2==0 && x1==n){
        dist1=n+n-y1+n-y2; dist2=n+y1+y2;
        cout<<min(dist1,dist2);
    }
    else if(x1==0 && y2==n){
        dist1=n-y1+x2;
        cout<<dist1;
    }
    else if(x2==0 && y1==n){
        dist1=n-y2+x1;
        cout<<dist1;
    }
    else if(x1==n && y2==n){
        dist1=n-y1+n-x2;
        cout<<dist1;
    }
    else if(x2==n && y1==n){
        dist1=n-y2+n-x1;
        cout<<dist1;
    }
    else if(x2==0 && y1==0){
        dist1=x1+y2;
        cout<<dist1;
    }
    else if(x1==0 && y2==0){
        dist1=x2+y1;
        cout<<dist1;
    }
    else if(y1==0 && x2==n){
        dist1=n-x1+y2;
        cout<<dist1;
    }
    else if(y2==0 && x1==n){
        dist1=n-x2+y1;
        cout<<dist1;
    }

    return 0;
}