#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inc(i, l, r) for (int i = l; i <= r; i++)
#define dec(i, l, r) for (int i = l; i >= r; i--)
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back

const int maxn = 4e5 + 5;
const int maxm = 3e5 + 5;

int N, M, Q;

int par[maxn];
void init(int n) { inc(i, 1, n) par[i] = i; }
int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
}
bool same(int x, int y) { return find(x) == find(y); }

struct edge {
    int u, v, id;
} e[maxm];
int vis[maxn], node[maxn], root[maxn], vis_point[maxn];
vector<int> g[maxn];

int euler[maxn], in[maxn], out[maxn], top;
int a[maxn], mx[4 * maxn], pos[4 * maxn];
void dfs(int x) {
    vis_point[x] = 1;
    in[x] = ++top;
    if (x <= N) euler[top] = a[x];
    for (int son : g[x]) {
        if (!vis_point[son]) dfs(son);
    }
    out[x] = ++top;
}

void up(int k) {
    mx[k] = max(mx[k << 1], mx[k << 1 | 1]);
    if (mx[k << 1] >= mx[k << 1 | 1])
        pos[k] = pos[k << 1];
    else
        pos[k] = pos[k << 1 | 1];
}
void build(int k, int l, int r) {
    if (l == r) {
        mx[k] = euler[l];
        pos[k] = l;
        return;
    }
    int mid = l + r >> 1;
    build(k << 1, l, mid);
    build(k << 1 | 1, mid + 1, r);
    up(k);
}
pii query(int k, int l, int r, int a, int b) {  //�������ֵ����λ��
    if (a <= l && r <= b) {
        return pii(mx[k], pos[k]);
    }
    int mid = l + r >> 1;
    pii res = pii(0, 0);
    if (a <= mid) res = max(res, query(k << 1, l, mid, a, b));
    if (b > mid) res = max(res, query(k << 1 | 1, mid + 1, r, a, b));
    return res;
}
void change(int k, int l, int r, int pos) {
    if (l == r) {
        mx[k] = 0;
        return;
    }
    int mid = l + r >> 1;
    if (pos <= mid)
        change(k << 1, l, mid, pos);
    else
        change(k << 1 | 1, mid + 1, r, pos);
    up(k);
}

int main() {
    scanf("%d %d %d", &N, &M, &Q);
    inc(i, 1, N) scanf("%d", &a[i]);
    inc(i, 1, M) {
        scanf("%d %d", &e[i].u, &e[i].v);
        e[i].id = i;
    }
    vector<pii> q;
    while (Q--) {
        int op, x;
        scanf("%d %d", &op, &x);
        q.push_back(pii(op, x));
        if (op == 2) vis[x] = 1;
    }
    inc(i, 1, M) if (!vis[i]) q.push_back(pii(2, i));
    init(2 * N);
    int cnt = N;
    dec(i, (int)q.size() - 1, 0) {
        if (q[i].fi == 1) {
            root[i] = find(q[i].se);  //ѯ��i������
            //    cout << "root " << i << " " << root[i] << "\n";
        } else {
            int p = q[i].se;
            if (!same(e[p].u, e[p].v)) {
                ++cnt;
                g[cnt].push_back(par[e[p].u]), g[cnt].push_back(par[e[p].v]);
                par[par[e[p].u]] = cnt, par[par[e[p].v]] = cnt;
            }
        }
    }

    inc(i, 1, cnt) if (!vis_point[find(i)]) dfs(find(i));

    build(1, 1, cnt);
    inc(i, 0, (int)q.size() - 1) {
        if (q[i].fi == 1) {
            int l = in[root[i]], r = out[root[i]];
            pii res = query(1, 1, cnt, l, r);
            printf("%d\n", res.fi);
            change(1, 1, cnt, res.se);
        }
    }
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ls (x<<1)
#define rs (x<<1|1)
#define db double
#define inf 2147483647
#define llinf 9223372036854775807
#define ll long long
#define ull unsigned long long
using namespace std;
typedef pair<int,int> PII;
int inline read(){
    int num=0,neg=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
    while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
    return num*neg;
}
const int maxn=500010,mod=998244353;
int n,m,q,p[maxn],cnt,fa[maxn],tot;
struct Q{
	int t,x;
}a[maxn];
struct Edge{
	int u,v,w;
}edge[maxn];
bool cmp(Edge x,Edge y){
	return x.w>y.w;
}
int Find(int x){
	return fa[x]==x?x:fa[x]=Find(fa[x]);
}vector<int>G[maxn];int val[maxn];
void kruskal(){
	for(int i=1;i<=2*n;i++)fa[i]=i;tot=n;
	for(int i=1;i<=m;i++){
		int x=Find(edge[i].u),y=Find(edge[i].v);
		if(x!=y){
			++tot;fa[x]=fa[y]=tot;val[tot]=edge[i].w;
			G[tot].pb(x);G[tot].pb(y);
		}
	}
}int dfn[maxn],c,rev[maxn],L[maxn],R[maxn],jmp[maxn][20],dep[maxn];
void dfs(int x){
	for(int i=1;i<=19;i++)jmp[x][i]=jmp[jmp[x][i-1]][i-1];
	if(!G[x].size()){
		dfn[x]=++c;rev[c]=x;L[x]=c;R[x]=c;return;
	}L[x]=inf;R[x]=0;
	for(int i=0;i<G[x].size();i++){
		int v=G[x][i];dep[v]=dep[x]+1;jmp[v][0]=x;dfs(v);
		L[x]=min(L[x],L[v]);R[x]=max(R[x],R[v]);
	}
}
int sum[maxn<<2],pos[maxn<<2];
void pushup(int x){
	if(sum[ls]>sum[rs])pos[x]=pos[ls];
	else pos[x]=pos[rs];
	sum[x]=max(sum[ls],sum[rs]);
}
void update(int x,int l,int r,int P,int k){
	if(l==r){
		sum[x]=k;pos[x]=rev[l];return;
	}int mid=l+r>>1;
	if(mid>=P)update(ls,l,mid,P,k);
	if(mid<P)update(rs,mid+1,r,P,k);pushup(x);
}
int Query(int x,int l,int r,int L,int R){
	if(l>=L&&r<=R)return pos[x];
	int mid=l+r>>1,posl=0,posr=0,ans=0;
	if(mid>=L)posl=Query(ls,l,mid,L,R);
	if(mid<R)posr=Query(rs,mid+1,r,L,R);
	if(p[posl]>=p[ans])ans=posl;
	if(p[posr]>=p[ans])ans=posr;return ans;
}
int main(){
	n=read();m=read();q=read();
	for(int i=1;i<=n;i++)p[i]=read();
	for(int i=1;i<=m;i++){
		int x=read(),y=read();
		edge[i].u=x;edge[i].v=y;edge[i].w=inf;
	}
	for(int i=1;i<=q;i++){
		int op=read(),x=read();
		if(op==1){
			a[++cnt].t=i;a[cnt].x=x;
		}else edge[x].w=i-1;
	}sort(edge+1,edge+m+1,cmp);kruskal();dep[tot]=1;dfs(tot);
	for(int i=1;i<=n;i++)update(1,1,n,dfn[i],p[i]);
	for(int i=1;i<=cnt;i++){
		int now=a[i].x;
		for(int j=19;j>=0;j--)
			if(val[jmp[now][j]]>=a[i].t)now=jmp[now][j];
		int ans=Query(1,1,n,L[now],R[now]);
		printf("%d\n",p[ans]);
		p[ans]=0;update(1,1,n,dfn[ans],p[ans]);
	}return 0;
}


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

LL dp[20][2525][50];
unordered_map<LL,LL>mp;
LL ve[20];
LL gcd(LL a,LL b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
LL change(LL a,LL b)
{
    if(b==0)
        return a;
    return a/gcd(a,b)*b;
}
LL dfs(LL pos,LL st,LL lca,LL lead,LL op)
{
    if(pos==0)
    {
        if(st%lca==0)
        {
            return 1;
        }
        else
            return 0;
    }
    if((!lead)&&(!op)&&(dp[pos][st][mp[lca]]!=-1))
        return dp[pos][st][mp[lca]];
    LL tmp=op?ve[pos]:9;
    LL ans=0;
    for(Ll i=0;i<=tmp;i++)
    {
        if(lead&&i==0)
        {
            ans+=dfs(pos-1,st,lca,lead,op&&tmp==i);
        }
        else
            if(lead)
                ans+=dfs(pos-1,(st+i)%2520,change(lca,i),0,op&&tmp==i);
            else
                ans+=dfs(pos-1,(st+i)%2520,change(lca,i),0,op&&tmp==i);
    }
    if((!lead)&&(!op))
        dp[pos][st][mp[lca]]=ans;
    return ans;
}
LL solve(string nu)
{
    LL len=0;
    ve[len++]=-1;
    for(LL i=nu.size()-1;i>=0;i---)
    {
        ve[len++]=nu[i]-'0';
    }
    return dfs(len-1,0,1,1,1);
}
int main()
{
    for()
    scanf("%d",&t);
    while(t--)
    {
        cin>>l>>r;
        ans1=solve(r);

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n, k;
vector<ll>v;
int main() {
	scanf("%I64d %I64d", &n, &k);
	if (n <= k && n > 1) {
		printf("%d", 1);
		return 0;
	}
		for (int i = 0; i <= k; i++) {
			if (i == 1)
				continue;
			v.push_back(i);
		}
		int cnt = 1;
		for (unsigned i = 1; i <v.size(); i++) {
			if (i > 1) {
				v[i] += v[i - 1];
			}
			else
				v[i] += (v[i - 1]);
		}
		for (unsigned i = 2; i < v.size(); i++) {
			v[i] -= cnt++;
		}
		int s = 0, e = v.size()-1, ans;
		while (s < e) {
			int mid = s + (e - s + 1) / 2;
			if (v[mid] == n) {
				e = mid - 1;
				ans = mid;
			}
			else {
				s = mid;
				ans = -1;
			}
		}
		cout << ans << endl;

	return 0;
}


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

using namespace std;

int main(int argc, char *argv[])
{
	int i,l,r,ref,s,t;
	long long max,w;
	scanf("%d %d",&l,&r);

	max=0;
	for(i=l;i<=r;i++)
	{
		if(i==l||ref==-1)
		{
			ref=0;
			t=i;
			s=0;
			while(t>0)
			{
				t/=10;
				if(s==0) s=1;
				else s*=10;
			}
			t=i;
			while(s>0)
			{
				ref=ref+(9-(t/s))*s;
				t-=(t/s)*s;
				s/=10;
			}
		}

		w=((long long )i)*((long long)ref);
		if(max<w)  max=w;
		ref--;
	}
	cout << max<<endl;
  //  system("PAUSE");
    return EXIT_SUCCESS;
}


#include <bits/stdc++.h>
using namespace std;
#define read() freopen("input.txt", "r", stdin)
#define write() freopen("output.txt", "w", stdout)
#define f(i,a,b) for(int i = (a); i <= (b); i++)
#define fr(i,a,b) for(int i = (a); i >= (b); i--)
#define REP( i , n ) for( int i = 0 ; i < n ; i++ )
#define REPI( n , i ) for( int i = n ; i >= 0 ; i-- )
#define sc( x ) scanf( "%d" , &x )
#define sc2( x , y ) scanf( "%d%d" , &x , &y )
#define scd( x ) scanf( "%.9f" , &x )
#define scl( x ) scanf( "%I64d" , &x )
#define pf( x ) printf( "%d\n" , x )
#define pfd( x ) printf( "%.9f\n" , x )
#define pfl( x ) printf( "%I64d\n" , x )
#define all( v ) v.begin(),v.end()
#define all_r( v ) v.rbegin() , v.rend()
#define fi first
#define se second
#define SZ(a) int(a.size())
#define pb push_back
#define pi acos(-1.0)
#define EPS (int)( 1e-6 )
#define e2( x ) ( x )*( x )
#define r2( x ) round( sqrt( 1.0*( x ) ) )
#define ones(x) __builtin_popcount(x)
#define MCM( a , b ) ( ( a*b )/( __gcd( a , b ) ) )
#define ddd cout << "despues" << endl ;
#define sss cout << "------------------" << endl ;
#define aaa cout << "antes" << endl ;
#define DEBUG( x ) cerr <<  #x << "=" << x << endl;
#define DEBUG2( x , y ) cerr << #x << "=" << x << " " << #y << "=" << y << endl;
#define DEBUGL(x,n) cout << #x << " :" <<endl; REP(i,n)cout<<x[i]<<char(i+1==n?10:32);
#define DEBUGC(x,n,m) cout << #x << " :" <<endl; REP(i,n)REP(j,m)cout<<x[i][j]<<char(j+1==m?10:32);

typedef double db ;
typedef long long ll ;
const int INF = (int)( INT_MAX - 100 ) ;
const int N = (int)( 0 ) ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef pair<int,int> pii ;
typedef vector<pii> vpii ;
const ll mod = (int)( 1e+6 + 3 ) ;
typedef long double ld ;
inline ll modulo( int num ){ ( ( num %= mod ) += mod ) %= mod ; return num ; }
//inline ll pot( int b , int e ){ ll p = 1 ; REP( i , e ) p = (p*b)%mod ; return p ; }

ll f1( int n ){
	if( n == 1 ) return 1 ;
	return modulo( 3LL*f1( n - 1 ) ) ;
}

int main()
{
//	ios_base::sync_with_stdio(0);
	int n ;
	cin >> n ;
	cout << modulo( f1( n ) ) ;

	return 0 ;
}


//#include <algorithm>
//#include <map>
//#include <set>
//#include <vector>
//#include <string>
//#include <iostream>
//using namespace std;
//int main()
//{
//  vector <int> vec;
//  int n, m, answer = 0;
//  cin >> n >> m;
//  vec.resize(n);
//  for (int i = 0; i < n; cin >> vec[i++]);
//  while (vec.size())
//  {
//      int counter = 0, counter2 = 0;
//      for (int i = 0; i < vec.size(); ++i)
//      if (counter + vec[i] <= m)
//      {
//          counter += vec[i];
//          ++counter2;
//      }
//      else break;
//      vec.erase(vec.begin(), vec.begin () + counter2);
//      ++answer;
//  }
//  cout << answer << endl;
//  return 0;
//}
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
map <string, bool> ma;
vector <string> vec;
string t;
void ay_7aga1(string s, int index)
{
    if (index == s.size() - 1) return;
    t = s;
    swap(t[index], t[index + 1]);
    if (!ma [t]) vec.push_back(t);
    ma[t] = true;
    ay_7aga1(s, index + 1);
}
void ay_7aga2(string s, int index)
{
    if (!index) return;
    t = s;
    swap(t[index], t[index - 1]);
    if (!ma [t]) vec.push_back(t);
    ma[t] = true;
    ay_7aga2(s, index - 1);
}
int main()
{
    string s;
    int k;
    cin >> s >> k;
    vec.push_back(s);
    for (int i = 0; i < k; ++i)
    {
        int x = vec.size();
        for (int j = 0; j < x; ++j)
        {
            ay_7aga1(vec[j], 0);
            if ((s.size() % 2)) ay_7aga2(vec[j], s.size() - 1);
        }
        sort(vec.begin(), vec.end());
        //vec.push_back(s);
        //ay_7aga1(s, 0);
        //if ((s.size() % 2)) ay_7aga2(s, s.size() - 1);
        //sort(vec.begin(), vec.end());
        //s = vec[vec.size() - 1];
        //vec.clear();
    }
    cout << vec[vec.size() - 1] << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,flag=0;
  cin>>n;
  if(n==1)
  cout<<"Ehab\n";
  while(n!=0)
  {
  for(int i=2;i<=n;i++)
  {
   if(i%2==0)
   {
     n-=i;
     flag=1;
   }
   else
   {
    n--;
    flag=0;
   }
  }
  }
  if(flag)
  cout<<"Mahmoud\n";
  else
  cout<<"Ehab\n";
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{ string s;
  set <string> a;
  cin >> s;
  for (int i=0;i<s.length();i++)
  { a.insert(s);
    s=s+s[0];
    s.substr(1,s.length()-1);
  }
  cout << a.size();
}


#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
int main() {fio; // remove during scanf
	ll N;
	cin >> N;
	N++;
	for(int i = 0; i < N; i++) {
		if(0 == (N ^ (1LL << i))) {
			cout << i << endl;
			return 0;
		}
	}
	cout << N << endl;
    return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main(void)
{

	int64_t n, k;
	cin >> n >> k;
	n--; k--;

	vector<int64_t>arr;
	for (int i = 1; i <= k; i++)
	{
		arr.push_back(i);
	}
	int64_t sum = 0;
	for (auto it : arr)sum += it;
	//sum -= (k-1);
	if (sum < n)
	{
		cout << -1;
		return 0;
	}

	if (sum == n)
	{
		cout << arr.size();
		return 0;
	}
	sum = 0;
	int j = 0;
	for (int i = n - 1; i >= 0; i--)
	{
		sum += arr[i];
		j++;
		if (sum >= n)
		{
			cout << j;
			return 0;
			break;
		}
	}
	cout << -1;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct node {
	int x, y, z, cnt;
	node(int x,int y,int z, int cnt) : x(x), y(y), z(z), cnt(cnt) {}
	bool operator < (const node & a) const {
		return cnt > a.cnt;
	}
};
bool check(node a) {
	int x = a.x, y = a.y, z = a.z;
	if(x < y + z && y < x + z && z < x + y) return 1;
	return 0;
}
int main() {
	priority_queue<node> q;
	int x, y, z;
	scanf("%d %d %d",&x, &y, &z);
	q.push(node(x,y,z,0));
	while(!q.empty()) {
		node cur = q.top();
		q.pop();
		if(check(cur)) {
			printf("%d\n",cur.cnt);
			return 0;
		}
		cur.cnt++;
		cur.x++;q.push(cur);
		cur.x--;cur.y++;q.push(cur);
		cur.y--;cur.z++;q.push(cur);
	}
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <map>
#include <cmath>
#include <set>
using namespace std;
typedef long long ll;

int rec(int n)
{
	if (n == 1) {
		return 1;
	}
	return 3 * rec(n - 1) % 1000003;
}

int main()
{
    #if !defined(ONLINE_JUDGE)
    freopen("input.txt", "r", stdin);
    freopen("output.txt ", "w", stdout);
    #endif

	int n;
	cin >> n;
	cout << rec(n) << endl;

	return 0;
}


#pragma warning(disable:4996)

#include <stdio.h>
#include <vector>
#include <map>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <set>
#include <string>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

#define FILE_NAME "file"

#define forn(i, n) for(i64 i = 0; i < (n); ++i)
#define down(i, n) for(i64 i = ((i64)n) - 1; i >= 0; --i)

typedef vector<int> vint;
typedef long long int i64;
typedef long long unsigned int u64;
typedef vector<i64> vi64;
typedef pair<i64, i64> pi64;

#define MODULE 1000000007

i64 ans(i64 n)
{
    if (n == 0)
        return 1;

    return 3 * ans(n-1) % 1000003;

}

int main()
{
    srand(13);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(15);
#ifdef FILE_INPUT
    freopen(FILE_NAME ".in", "r", stdin);
    freopen(FILE_NAME ".out", "w", stdout);
#endif
    i64 n;
    cin >> n;
    cout << ans(n-1);

    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
long long n,ans,i,a[1000000001];
int main(){
 cin>>n;
 i=2;
 a[1]=1;

for(i=0;i<1000000001;i++)
{
	a[i]=0;
}
i=0;
while(i<=1000001)
{
  a[i]=a[i-1]+a[i-2];
  i++;
}
i=2;
while(a[i]<=n)
{
    i++;
    ans++;
}
ans--;
cout<<ans<<endl;
 return 0;
 }


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
vector<ll> fac;
int n;
ll bin(int pos, int i, int j, ll left, ll right, int it)
{
    int middle = (i+j)/2;
    // if(middle==pos) return fac[n-it];
    if(i>=j && i>0) return fac[n-it];
    else if(middle>pos)
    {
        return (right*(bin(pos, i, middle, left, right-1, it+1))%mod)%mod;
    }
    else
    {
        return (left*(bin(pos, middle, j, left-1, right, it+1))%mod)%mod;
    }
}

int main()
{
    int x,pos;
    cin>>n>>x>>pos;
    fac.assign(n, 1);
    for(int i=2;i<n;i++) fac[i]=(i*fac[i-1])%mod;
    ll right = n-x;
    ll left = x;
    cout<<bin(pos, 0, n, left, right, 0);
}


// in the name of god
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
//#include <unistd.h>
using namespace std ;
using namespace __gnu_pbds;
void operator+=(vector<int>&in1,const vector<int>&in2){for(int i=0;i<in2.size();i++)in1.push_back(in2[i]);}
#define y2 sdfklgjsdkfd
#define y1 sdfklgjsdkafd
#define L first
#define R second
#define X first
#define Y second
#define int long long
typedef long long ll ;
typedef long double ld ;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ALL(x) (x).begin(),(x).end()
typedef pair < int , int > pii ;
typedef pair < int , pii > pi_ii ;
typedef pair < pii , int > pii_i ;
typedef pair < pii , pii > pii_ii ;
#define ordered_set(TYPE) tree<TYPE, null_type, less<TYPE>, rb_tree_tag, tree_order_statistics_node_update>
//#define "%I64d" "%I64d
const int mod = 1e9 + 7 ;
const int maxL = 22 ;
const ll inf = 1e16 ;
const int baze = 547 ;
const int maxn = 1e6 +10 ;
int n , x , ans ;

main ( )
{
  x = 1e9;
  cin >> n ;
  for ( int i = 1 ; i < n ; i ++ )
    if ( n % i == 0 )
      {
	if ( abs ( i - n / i ) < x )
	  x = abs ( i - n / i ) , ans = i ;
      }

  cout << ans << ' ' << n / ans ;
}


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

int main () {
      long long n, k;
      cin >> n >> k;
      const long long val = ((k*(k+1)/2) - 1) - (k-2);
      if (n < 2 || n > val) {
            cout << "-1\n";
            return 0;
      }
      vector<long long> array;
      long long j = 1;
      for (int i = (k-1); i >= 1; i--) {
            for (int p = 0; p < i; p++){
                  array.push_back (j);
            }
            j++;
      }
      cout << array[n-2] << "\n";
      return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int> > vvi;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<vector<pair<int,int> > > vvii;
#define boost ios_base::sync_with_stdio(false);cin.tie(0);
#define pb push_back
#define PB pop_back
#define pf push_front
#define PF pop_front
#define MP make_pair
#define C(a,b) memset(a,b,sizeof(a))
#define ia(a,n) FOR(i,0,n-1)cin>>a[i]
#define ia1(a,n) FOR(i,1,n)cin>>a[i]
#define F first
#define S second
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define NFOR(i,a,b) for(int i=a;i>=b;--i)
#define rep(i,n) FOR(i,0,n-1)
#define clr clear
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
int main()
{

	#ifndef ONLINE_JUDGE
     	// for getting input from input.txt
        freopen("D:/try/Platforms/a2oj/in.txt", "r", stdin);
        // for writing output to output.txt
        freopen("D:/try/Platforms/a2oj/out.txt", "w", stdout);
    #endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//boost
	int bo,f;
	cin>>bo>>f;

	string s;
	cin>>s;

	vector<vector<int>> fb;

	fb.resize(f);
	int a[26]={0};

	for(int i=0;i<bo;i++)
		a[s[i]-'a']++;

	for(int i=0;i<26;i++)
	{
		int ttt=0;
		//cout<<"\n char : "<<char(i+'a')<<" with f : "<<a[i];
	}
	int atf=0;
	int ff=1;
	for(int i=0;i<26;i++)
	{
		if(a[i]>f)
		{
			ff=0;
			break;
		}
		else
		{
				while(a[i]>0)
				{
					if(fb[atf].size()==f)
						atf++;
					else
					{
						fb[atf].push_back(i);
						atf++;
						a[i]--;
					}

					if(atf==26)
						break;
				}

		}
	}

	if(ff)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int k,ind=0;
int n;
int a[9010];
int c[9010],tm[9010];
long long dp[9010][9018];

long long  explore(int i, int sum)
{
    long long ans;
    ans = 0;

    if(sum == n) {
        return 1;
    }

    if(i == ind) {
        return 0;
    }

    if(dp[i][sum] != -1) {
        return dp[i][sum];
    }

    for (int j = 0; j <= c[i] and (j * a[i]) + sum <= n; j++) {
        ans += explore(i+1, sum + j * a[i]);
    }

    return dp[i][sum] = ans;

}

int main()
{
    cin>>n;
    for(int i=1; i<=n; i++){
        int s=0,tt=0;
        bool ok=false;
        while(s+i<=n){
            s++;
            tt++;
        }
        if(tt){
            c[ind]=i;
            tm[i]=tt;
            ind++;
        }
    }
    for(int i=0; i<ind; i++){
        a[i]=tm[c[i]];
    }
    memset(dp,-1,sizeof(dp));
    int ttt=0;
    if(n>2)ttt=1;
    cout<<explore(0,0)+ttt<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
typedef long long int ll;
typedef vector<ll>vi;
const ll MAX_SIZE = 100000001;
vi isprime(MAX_SIZE , true);
vi prime;
vi SPF(MAX_SIZE);
vi factor;
bool checklast(ll n)
{

    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
  for (ll i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
void optimized_seive(ll N)
{
  ll N1;
    isprime[0] = isprime[1] = false ;
    for (ll i=2; i*i<=N ; i++)
    {
        if (isprime[i])
        {
            prime.push_back(i);
            if(N%i==0){factor.push_back(i); N1=N/i;}
            SPF[i] = i;
        }
        for (ll j=0;
             j <(int)prime.size() &&
             i*prime[j] < N && prime[j] <= SPF[i];
             j++)
        {
            isprime[i*prime[j]]=false;
            SPF[i*prime[j]] = prime[j] ;
        }
    }
    //cout<<N1<<endl;
 if((N1*N1)!=N)
    {if(checklast(N1)) factor.push_back(N1);}

}
ll power(ll x, ll m)
{
    ll total = 1;
    x=x%mod;
    if(x==0) return 0;
  while (m>0)
    {
        if (m & 1)
            total =(total*x)%mod;
        m=m>>1;
        x=(x*x)%mod;
    }
    return total;
}
int main()
{
    ll x,n,h,m;
    cin>>x>>n;
    optimized_seive(x);
    if(factor.empty())
    {
        factor.push_back(x);
    }
   ll ans=1;
    for(ll i=0;i<factor.size();i++)
    {
    h=n;
    m=0;
   while(h)
    {
        m=m+h/factor[i];
        h=h/factor[i];
    }
    ans=ans*power(factor[i],m);
     ans=ans%mod;
    }
cout<<ans<<endl;
}


#include <iostream>
using namespace std;
int main()
{
    string s; int c=0;
     cin >> s;

    L: for(int a=0;a<s.size();a++)
     {
         if(s[a]=='h')
         {
             c++;
             for(int b=a+1;b<s.size();b++)
                if(s[b]=='e')
             {
                 c++;
                 for(int d=b+1;d<s.size();d++)
                    if(s[d]=='l')
                 {
                     c++;
                     for(int e=d+1;e<s.size();e++)
                        if(s[e]=='l')
                     {
                         c++;
                         for(int i=e+1;i<s.size();i++)
                         if(s[i]=='o')
                         {
                             c++;
                             if(c==5)
                             {
                                 cout<<"YES";
                                 break;
                             }
                             else
                             {goto L;
                             c=0;
                             }

                         }
                     }
                 }

            }
         }
     }
     if(c<5)
        cout<<"NO";

    return 0;
}


#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	string a;
	int ans=0,ans2=0;
	cin>>a;
	for(int i=0;i<a.length();i++){
		if(a[i]==a[i-1]){
			ans++;
		}
		else{
			if(ans%2==1)ans2++;

			ans=0;
		}
	}
	printf("%d",ans2);
	return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
struct Buying{
	int which, profit;
	double profit;
	Buying(){}
	Buying(int _w,  int _p): which(_w), profit(_p){}
	bool operator < (Buying b)
	{
		return profit > b.profit;
	}

};
struct Product{
	int bc, sc, r;
};
Product products[20][200];
int main()
{
	int n, m, rem;
	cin >> n >> m >> rem;
	cin.ignore();
	for (int i = 0; i < n; i++)
	{
		string name;
		getline(cin, name);
		for (int j = 0; j < m ;j++)
			cin >> products[i][j].bc >> products[i][j].sc >> products[i][j].r;
		cin.ignore();
	}
	int ans = 0, crem = rem;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
		{
			if (i == j)
				continue;
			Buying benefits[200];
			for (int r = 0; r < m; r++)
				benefits[r] = Buying(r, products[j][r].sc - products[i][r].bc);
			sort(benefits, benefits + m);
			int r = 0;
			int calc = 0;
			while (rem > 0 && r < m)
			{
				if (benefits[r].profit < 0)
					break;
				int dec = min(products[i][benefits[r].which].r, rem);
				calc += dec * benefits[r].profit;
				rem -= dec;
				r++;
			}
			if (calc > ans)
				ans = calc;
			rem = crem;
		}

	cout << ans;
}


#include <iostream>
#include <cstdlib>
#include <stdio.h>
using namespace std;

int main()
{
    int n,i;
    while(scanf("%d",&n)==1)
    {
        int memo[100002],ptr=0;
        memset(memo,0,sizeof(memo));
        for(int i=1;i<=n;i++)
        {
            memo[++ptr]++;
            while(memo[ptr]==memo[ptr-1])
            {
                memo[ptr]=0;
                memo[--ptr]++;
            }
        }
        for(int i=1;memo[i];i++)
        {
            if(i!=1)    printf(" ");
            printf("%d",memo[i]);
        }
        printf("\n");
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <fstream>
#include <list>
#include <set>
#include <climits>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <sstream>
#include <deque>
#include <utility>
#include <bitset>
#include <ext/hash_set>
#include <ext/hash_map>

using namespace std;
using namespace __gnu_cxx;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REV(i,a,b) for(int i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define oo 2e9
#define MAX 2001
#define sz(v) (int)v.size()
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define iter(it,s) for(it=s.begin();it!=s.end();it++)
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define mem(s,v) memset(s,v,sizeof(s))

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

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

int main() {
#ifndef ONLINE_JUDGE
    //  freopen("test.in", "rt", stdin);
    //  freopen("txt.out", "wt", stdout);
#endif
    int a, b, c;
    cin >> a >> b >> c;
    vi v;
    v.pb(a), v.pb(b), v.pb(c);
    sort (all(v));
    a = v[0], b = v[1], c = v[2];
    if (a != b && b != c && a != c){
        cout << b * 6 << endl;
    }
    else if (a == b && b == c){
        cout << 1/ 0 << endl;
        cout << a * ((a - 1) * 3) + 1 << endl;
    }
    else
        cout << 1/ 0 << endl;
    return 0;
}


#include <bits/stdc++.h>
#define c(n,m) (1ll*pl[n]*ny[m]%mo*ny[(n)-(m)]%mo)
using namespace std;
const int N=1000050,mo=1e9+7;
int fap(int a,int b){
  int s=1;
  while(b){
    if (b&1) s=1ll*s*a%mo;
    b>>=1,a=1ll*a*a%mo;
  }
  return s;
}
int f[N],pl[N],ny[N];
int main(){
  int n,k; cin>>n>>k;
  pl[0]=ny[0]=1;
  for (int i=1; i<=n; ++i) pl[i]=1ll*pl[i-1]*i%mo;
  ny[n]=fap(pl[n],mo-2);
  for (int i=n-1; i>=1; --i) ny[i]=1ll*ny[i+1]*(i+1)%mo;
  int ans=0;
  for (int i=k+2; i<=n; ++i){
    f[i]=1ll*(i-k-1)*pl[i-2]%mo;
    for (int j=i-k; j<i; ++j)
      (f[i]+=1ll*c(i-2,j-1)*pl[i-j-1]%mo*f[j]%mo)%=mo;
    (ans+=1ll*f[i]*c(n-1,i-1)%mo*pl[n-i]%mo)%=mo;
  }
  cout<<ans;
  return 0;
}


#include<bits/stdc++.h>

#define LL long long
#define RG register

using namespace std;
template<class T> T gi() {
	T x = 0; bool f = 0; char c = getchar();
	while (c != '-' && (c < '0' || c > '9')) c = getchar();
	if (c == '-') f = 1, c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f ? -x : x;
}
const int N = 1e6 + 10, Mod = 1e9 + 7;
int fac[N], ifac[N], f[N];
int fpow(int a, int b) {
	int res = 1;
	for (; b; b >>= 1, a = 1ll * a * a % Mod)
		if (b & 1) res = 1ll * res * a % Mod;
	return res;
}
int C(int n, int m) {
	if (n < m) return 0;
	return 1ll * fac[n] * ifac[m] % Mod * ifac[n - m] % Mod;
}
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	int n = gi<int>(), k = gi<int>();
	fac[0] = 1;
	for (int i = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % Mod;
	ifac[n] = fpow(fac[n], Mod - 2);
	for (int i = n; i >= 1; i--) ifac[i - 1] = 1ll * ifac[i] * i % Mod;
	f[0] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= k && j <= i; j++)
			(f[i] += 1ll * f[i - j] * C(i - 1, j - 1) % Mod * fac[j - 1] % Mod) %= Mod;
	int ans = 0;
	for (int i = 1; i <= n; i++)
		(ans += 1ll * f[i - 1] * C(n - 1, i - 1) % Mod * fac[n - i] % Mod) %= Mod;
	printf("%d\n", (fac[n] - ans + Mod) % Mod);
	return 0;
}


//author ----> noobiesAG

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

#define rep(i,a,b)         for(i=a;i<b;i++)
#define repd(i,a,b)        for(i=a;i>b;i--)
#define int                long long
#define double             long double
#define pb                 push_back
#define mp                 make_pair
#define ld                 long double
#define vi                 vector<int>
#define vvi                vector<vector<int>>
#define vpii               vector<pair<int,int>>
#define pii                pair<int,int>
#define mii                map<int,int>
#define umap               unordered_map
#define all(c)             c.begin(),c.end()
#define si(c)              (int)c.size()
#define lb                 lower_bound
#define ub                 upper_bound
#define gi                 greater<int>
#define rev                reverse
#define ff                 first
#define ss                 second
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define ayes               cout << "Yes" << endl
#define ano                cout << "No" << endl
#define mone               cout << -1 << endl
#define imp                cout << "IMPOSSIBLE" << endl
#define nl                 cout << endl
#define hello              cout << "hello" << endl
#define sp(x)              fixed << setprecision(x)
#define re                 return
#define p_q                priority_queue
#define FAST               ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

void dbg_out(){cerr << endl;}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

const double pi = 3.14159265359;
const int mod = 1000000007;
const int modc = 998244353;
const int inf = LLONG_MAX;
const int neg_inf = LLONG_MIN;

int inline power(int a, int b, int p){
    a %= p;
    int ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

int mod_inv(int n, int p){
    return power(n,p-2, p);
}

bool inline isPrime(int n) {
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    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;
}
template<typename... T>
void W(T&&... args)
{
	((cout << sp(17) <<  args << " "), ...);
	nl;
}
template<typename... T>
void R(T&&... args)
{
	((cin >> args), ...);
}
int ston(string s)
{
	int a = 0;
	reverse(s.begin(),s.end());
	int pow = 1;
	for(int i=0;i<s.size();i++)
	{
		a += pow*(s[i]-'0');
		pow*=10;
	}
	return a;
}
template <class T>
string to_binary(T n)
{
	string binaryNum;
	int i = 0;
	while (n > 0) {
		binaryNum.pb((n % 2)+'0');
		n = n / 2;
		i++;
	}
	if(si(binaryNum) == 0)
		binaryNum.pb('0');
	reverse(binaryNum.begin(),binaryNum.end());
	return binaryNum;
}
int bton(string &s, int base)
{
	int ans = 0;
	int pow  = 1;
	rev(all(s));
	for(auto x : s)
	{
		if(x >= 'a' && x <= 'z')
			ans += (x - 'a' + 10)*pow;
		else
			ans += (x-'0')*pow;
		pow *= base;
	}
	return ans;
}
template<class T>
void wv(T &v)
{
	for(auto x : v)
		cout << x << " " ;
	nl;
}
template<class T>
void rv(T &v)
{
	for(int i=0;i<si(v);i++)
		cin >> v[i];
}

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

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
/*
int ncr(int n, int r)
{
	int ans = fact[n];
	int denom = (fact[r]*fact[n-r])%mod;
	ans = (ans * mod_inv(denom,mod))%mod;
	return ans;
}
*/

const int M = 2e5;

//int fact[M];
//vector<int>v[M];

void solve()
{
	int i,j,sum = 0,prod = 1,maxl = neg_inf, minl = inf;
	int n;
	cin >> n;
	vector<tuple<int,int,int>>vv;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			int temp = (i^j);
			if(temp < 1 || temp > n)
				continue;
			vi v;
			v.pb(i);
			v.pb(j);
			v.pb(temp);
			sort(all(v));
			if(v[0] + v[1] > v[2])
			{
				tuple<int,int,int>ayush;
				ayush = make_tuple(v[0],v[1],v[2]);
				vv.pb(ayush);
			}
		}
	}
	sort(all(vv));
	if(si(vv))
		sum++;
	for(i=1;i<si(vv);i++)
		if(vv[i] != vv[i-1])
			sum++;
	cout << sum << endl;
}
int32_t main()
{
	FAST;
	int t = 1;
	/*
	fact[0] = 1;
	for(int i = 1;i<M;i++)
		fact[i] = (i * fact[i-1])%mod;
		*/
	while(t--)
	{
		solve();
	}
}


#include <iostream>
#include <fstream>
//#include <>
using namespace std;

const int MAXPLANETS = 10;
const int MAXTYPES = 100;
const int MAXSUM = 100*999;

struct pl {
         int buy, sell, remaining;
       };

pl p[MAXPLANETS][MAXTYPES];
int PlanetCount, TypeCount, Storage;

void read() {
     ifstream in("in");
     in >> PlanetCount >> TypeCount >> Storage;
     for(int i = 0; i < PlanetCount; i++) {
       for(int j = 0; j < TypeCount; j++) {
         in >> p[i][j].buy >> p[i][j].sell >> p[i][j].remaining;
       }
     }
     in.close();
}

int min(int a, int b) {
    if (b > a)
      return a;
    return b;
}

int MaxProfit(int BuyPlanet, int SellPlanet) {
    /*dynamic programing*/
    P[MAXTYPE + 1][MAXSUM + 1];
    for(int i = 0; i < TypeCount; i++) {
      for
    }
}

long long LargestProfit() {
     long long MaxPP/*MaxProfitPossible*/ = 0, profit;
     for(int i = 0; i < PlanetCount; i++) {
       for(int j = 0; j < PlanetCount; j++) {
           profit = MaxProfit(i, j);
           if (profit > MaxPP)
             MaxPP = profit;
       }
     }
     return MaxPP;
}

int main() {
    read();
    //cout << LargestProfit() << endl;
    system("Pause");
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <cstdlib>
// Input macros
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%lld",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
// Useful constants
#define INF                         (int)1e9
#define EPS                         1e-9
// Useful hardware instructions
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
// Useful container manipulation / traversal macros
#define REP(i,a,b)               for(int i=a;i<=b;i++)
#define miN(a,b)                  ( abs(a)<= abs(b) ? abs(a) : abs(b))
#define maX(a,b)                  ( abs(a)>= abs(b) ? abs(a) : abs(b))
using namespace std;
typedef long long ll;

int main(){
    int n, diff, ans;
    vector<int> factors;
    cin >> n;
    REP(i, 1, n/2)
    {
        if((n%i))
            continue;
        else{
            factors.push_back(n/i);
        }
    }
    vector<int>::iterator it = factors.begin();
    diff = abs ((n/(*it))-(*it));
    ans = *it;
    for(++it; it < factors.end(); it++){
        if(diff > abs ((n/(* (it)))-(*(it))))
           {
               ans = *(it);
               diff = abs ((n/(* (it)))-(*(it)));
           }
    }
    cout << miN(ans,n/ans) << " " << maX(ans,n/ans);

    return 0;

}


#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;

long long int c;
long long int sum=0;
long long tt=0;

int main()
{
    long long int a;
    long long int b;
    cin>>a>>b;
    int time =0;
    int result=0;
    for(long long int i=a;i<=b;i++)
    {
        c=i;
        tt=0;
        sum=0;
        while(c)
        {
            sum+=c&0x01;
            tt++;
            c>>=1;
        }
        if(tt-sum==1)
            result++;
    }
    cout<<result;
    return 0;
}


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

int n,m,w,ans,tmp[2],a[88][88],b[6600][4];
bool col[88][88],vis[88][88];

void Dfs(int x,int y) {
	if ((x<1)||(x>n)||(y<1)||(y>m)) return;
	if (col[x][y]) return;
	if (vis[x][y]) return;
	vis[x][y]=true; ++tmp[(x+y)&1];
	Dfs(x-1,y); Dfs(x+1,y);
	Dfs(x,y-1); Dfs(x,y+1);
}

bool Greed(int x1,int y1,int x2,int y2) {
	col[x1][y1]=col[x2][y2]=true;
	memset(vis,false,sizeof(vis));
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m;++j)
			if ((!col[i][j])&&(!vis[i][j])) {
				tmp[0]=tmp[1]=0;
				Dfs(i,j);
				if (tmp[0]!=tmp[1])
					{col[x1][y1]=col[x2][y2]=false;return false;}
			}
	return true;
}

void Search(int k,int sum) {
	if (k==w+1) {ans=max(ans,sum);return;}
	if (w-k+10+sum<=ans) return;
	bool flag=Greed(b[k][0],b[k][1],b[k][2],b[k][3]);
	if (flag) Search(k+1,sum+1);
	col[b[k][0]][b[k][1]]=false;
	col[b[k][2]][b[k][3]]=false;
	Search(k+1,sum);
}

int main() {
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m;++j) scanf("%d",&a[i][j]);
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m;++j) {
			if ((i<n)&&(a[i+1][j]==a[i][j]))
				b[++w][0]=i,b[w][1]=j,b[w][2]=i+1,b[w][3]=j;
			if ((j<m)&&(a[i][j+1]==a[i][j]))
				b[++w][0]=i,b[w][1]=j,b[w][2]=i,b[w][3]=j+1;
		}
	Search(1,0);
	printf("%d\n",n*m/2-ans);
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

#define MAXN 101
#define MAXM 10001
#define MAXANS 8

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

int n, m;
int a[MAXN][MAXN];
int c[MAXN][MAXN];
int p[MAXN][MAXN];
int mark[MAXN][MAXN];
int b[MAXM];
int ans;

inline bool look(int x, int y)
{
	if (mark[x][y]) return 0;
	mark[x][y] = 1;
	if (p[x][y] == -1) return 1;
	int xx = p[x][y] / m;
	int yy = p[x][y] % m;
	for (int k = 0; k < 4; ++k)
	{
		int sx = xx + dx[k];
		int sy = yy + dy[k];
		if (0 <= sx && sx < n && 0 <= sy && sy < m && c[sx][sy] && look(sx, sy))
		{
			p[xx][yy] = sx * m + sy;
			p[sx][sy] = xx * m + yy;
			return 1;
		}
	}
	return 0;
}

inline void go(int v)
{
	if (v >= ans) return;

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			p[i][j] = -1;

	bool ok = 1;
	for (int i = 0; i < n && ok; ++i)
		for (int j = 0; j < m && ok; ++j)
		{
			if (c[i][j]) continue;
			if (b[a[i][j]])
			{
				memset(mark, 0, sizeof(mark));
				int t = 0;
				for (int k = 0; k < 4 && !t; ++k)
				{
					int sx = i + dx[k];
					int sy = j + dy[k];
					if (0 <= sx && sx < n && 0 <= sy && sy < m && c[sx][sy] && look(sx, sy))
					{
						p[i][j] = sx * m + sy;
						p[sx][sy] = i * m + j;
						t = 1;
					}
				}
				ok = t;
			}
			else
			{
				int t = 0;
				for (int k = 0; k < 4 && !t; ++k)
				{
					int sx = i + dx[k];
					int sy = j + dy[k];
					if (0 <= sx && sx < n && 0 <= sy && sy < m && a[sx][sy] == a[i][j]) t = 1;
				}

				ok = t;
			}
		}

	if (ok)
	{
/*		cout << "mm" << endl;
		for (int i = 0; i < n; ++i)
		{
			for (int j = 0; j < m; ++j)
				cout << c[i][j] << ' ';
			cout << endl;
		}*/
		ans = v;
	}

	if (v == MAXANS) return;

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			if (!b[a[i][j]])
			{
				b[a[i][j]] = 1;
				c[i][j] = 1;
				go(v + 1);
				c[i][j] = 0;
				b[a[i][j]] = 0;
			}
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			scanf("%d", &a[i][j]);

	ans = 1000;
	go(0);
	printf("%d\n", ans);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<fstream>
#include<set>
using namespace std;
int a[103][103];
int b[103][103];
int coun[1053];
int n,m;
int rec=1000000000;
struct kros
{
    int x,y;
};
kros c[5][1053];
int modul(int x)
{
    if(x<0)
        return -x;
    return x;
}
void dfs(int xx)
{
    int i,j;
    int res;
    if(xx==n*m)
    {
        res=0;
        for(i=0;i<n;i++)
            for(j=0;j<m;j++)
                if(b[i][j]!=a[i][j])
                    res++;
        if(res<rec)
            rec=res;
        return;
    }
    for(i=0;i<((n*m)>>1);i++)
    {
        if(coun[i]==2)
        {
            coun[i]--;
            b[xx/m][xx%m]=i;
            c[coun[i]][i].x=xx%m;
            c[coun[i]][i].y=xx/m;
            dfs(xx+1);
            coun[i]++;
        }
        else if(coun[i]==1)
        {
            if(modul(c[1][i].x-xx%m)+modul(c[1][i].y-xx/m)>1)
            {

            }
            else
            {
                coun[i]--;
                b[xx/m][xx%m]=i;
                c[coun[i]][i].x=xx%m;
                c[coun[i]][i].y=xx/m;
                dfs(xx+1);
                coun[i]++;
            }
        }
    }
}
int main()
{
    int i,j;
    cin>>n>>m;
    for(i=0;i<n;i++)
        for(j=0;j<m;j++)
        {
            cin>>a[i][j];
            a[i][j]--;
        }
    for(i=0;i<n*m/2;i++)
        coun[i]=2;
    dfs(0);
    cout<<rec<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main()
{
    long long n;
    cin>>n;
    vector<int>v;
    for(int i=1;i<=n;i++)
    {
        v.push_back(i);
    }
    int t=n%mod;
    if(t%2==0)
    {
       cout<<"Mahmoud"; //mahmud
    }
   if(t%2!=0)
   {
      cout<<"Ehab"; //ehabs
   }
}


#include"bits/stdc++.h"

using namespace std;

bool check(long long int n)
{
    int i=2;
    while(i<n)
    {
        i=i*2;
    }
    if(i==n)
    {
        return true;
    }
    return false;
}
int main()
{
    long long int n;
    cin>>n;
    if(n==0)
    {
        cout<<n<<endl;
        return 0;
    }
    n++;
    if(n&1)
    {
        cout<<n<<endl;
    }
    else
    {
        if(check(n))
        {
            int i=2,cnt=1;
            while(i<n)
            {
                i=i*2;
                cnt++;
            }
            cout<<cnt<<endl;
        }
        else
        {
            cout<<n<<endl;
        }

    }

    return 0;
}


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

const int maxn = 505;
const int mod = 1000000007;

int mult(int x, int y) {
  return (ll)x * y % mod;
}
int add(int x, int y) {
  return (x + y) % mod;
}
int sub(int x, int y) {
  x -= y;
  if (x < 0)
    x += mod;
  return x;

int n, k, sol;
int powr[maxn * maxn], dp[maxn][maxn];

int main(void) {
  cin >> n >> k;
  powr[0] = 1;
  for (int i=1; i<maxn * maxn; i++)
    powr[i] = mult(powr[i - 1], 2);
  dp[0][0] = 1;
  for (int i=0; i<=n; i++)
    for (int j=0; j<=k; j++) {
      if (j == k)
        sol = add(sol, dp[i][j]);
      for (int l=i + 1; l<=n; l++)
        dp[l][j + 1] = add(dp[l][j + 1], mult(dp[i][j], mult(sub(powr[l + 1], powr[i + 1]), powr[(l - i - 1) * (i + 1)])));
    }
  cout << sol << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long a,b,i,ans;
int main()
{
	scanf("%lld%lld",&a,&b);
	for(i=a;i<=b;i++)
	{
		long long v=i,s=0;
		while(v>0)
		{
			if(v%2==0)s++;
			if(s>1)
			break;
			v/=2;
		}
		if(s==1)ans++;
	}
	printf("%lld",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
  while(n>=0)
  {
      if(n%2==0)
      cout<<"Mahmoud";
      else cout<<"Ehab";
  }

}


//奇怪
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class AK>void r(AK &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int x,y,a[15][15]={{0,1,2},{1,0,2},{1,2,0},{2,1,0},{2,0,1},{0,2,1},{0,1,2}};
int main(){
	r(x);r(y);
	printf("%d\n",a[x][y]);
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <set>
#include <stack>
#include <memory.h>
#include<queue>
#include <math.h>
#include <map>
using namespace std;
#define FOR(I,N) for(int(i)=0;i<int(N);++i)
#define FORj(J,N) for(int(j)=0;i<int(N);++j)
typedef vector<int> vec;
typedef vector<vector<int> > graph;
#define pyes() printf("YES\n");
#define pno() printf("NO\n");
#define filla(x,y) memset(x,y,sizeof(x));
#define p1(x) printf("%d\n",x);
#define in1(x) scanf("%d",&x);
#define in2(x,y) scanf("%d %d",&x,&y);
#define in3(x,y,z) scanf("%d %d %d",&x,&y,&z);
#define p2(x,y) printf("%d %d\n",x,y);
#define p3(x,y,z) printf("%d %d %d\n",x,y,z);
long long pwr(long long x,long long y){
    if(y==1)
        return x;
    long long z=pwr(x,y/2);
    x=x*x;
    if(y&1)
        z=z*x;
    return z;
}
int main() {
    //freopen("in.txt","rt",stdin);
    //freopen("out.txt","wt",stdout);
    long long r,x,y,x1,y1;
    scanf("%lld %lld %lld %lld %lld",r,x,y,x1,y1);
    long long sum=ceil((sqrt( pwr(x1-x,2)+ pwr(y1-y,2)))/2.0*r)+1e-9;
    printf("%lld",sum);

    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;

int main() {
//	freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
    set<int> x1, y1;
    vector<pair<int, int>> a;
    int n = 8;
    for(int i = 0; i < n; i++){
        int x, y;
        cin >> x >> y;
        if(x > 3 || x < 0 || y > 3 || Y < 0)
            return cout << "ugly", 0;
        x1.insert(x);
        y1.insert(y);
        a.push_back({x, y});

    }
    if(x.size() != 3 || y.size() != 3)
        return cout << "ugly";
    pair<int, int> fuck = {0,0};
    int checker = 0;
    for(auto c : x){
        if(checker == 1)
            fuck.first = c;
        checker++;
    }
    int checker = 0;
    for(auto c : y){
        if(checker == 1)
            fuck.second = c;
        checker++;
    }
    for(auto c : a)
        if(fuck  == c)
            return cout << "respectable";
    cout << "ugly";
    return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
    char c;
    string text="";
    cin>>c;
    while(c!='0'){
        text+=c;
        cin>>c;
    }
    string text2=text;
    reverse(text2.begin(),text2.end());
    if(text==text2) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


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

int main()
{
    int x ;
    cin >> x ;
    string str = to_string(x);
    deque<char> s ;
    for(int i=0 ; i < str.size(); i++)
        s.push_back(str[i]);
    while(s.size()!=1)
    {
        if(s[0]==s[s.size()-1])
        {
            s.pop_back();
            s.pop_front();
        }
        else if(s[0]=='0')
            s.pop_front();
        else if(s[s.size()-1]=='0')
            s.pop_back();
        else
        {
            cout <<"NO" ;
            return 0 ;
        }
    }
    cout << "YES";
    return 0 ;
}


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

#define ll long long

const int MAXI = 2e9;

const int N = 1000;

int fac[N];

int org(int x){
   int ret = 0;
   queue<int> q;
   q.push(0);
   while(!q.empty()){
      int u = q.front();
      q.pop();
      int v= u*10 + 4;
      int v2 = u*10 + 7;
      if(v<=x){
         q.push(v);
         ++ret;
      }
      if(v2<=x){
         q.push(v2);
         ++ret;
      }
   }
   return ret;
}

bool isLucky(int x){
   while(x>0){
      int g = x%10;
      if(g==4 || g==7){
         x/=10;
      } else {
         return false;
      }
   }
   return true;
}
void solve() {
   int n,k;
   scanf("%d%d",&n,&k);
   ll ret = 1;
   int ind = 0,l = 0,r = n,mid;
   bool isSatisfy = false;
   for(int i=1;i<=n;++i){
      ret*=i;
      if(ret>=k){
         isSatisfy = true;
         break;
      }
   }
   fac[0] = 1;
   for(int i=1;i<N;++i){
      fac[i] = fac[i-1]*i;
   }
   if(!isSatisfy){
      printf("-1\n");
      return;
   }
   while(l<r) {
      mid = (l+r+1)/2;
      bool isGood = false;
      ll tmp = 1;
      for(int i=1;i<= n - mid;++i){
         tmp*=i;
         if(tmp>=k){
            isGood = true;
            break;
         }
      }
      if(!isGood){
         r = mid -1;
      } else {
         l = mid;
      }
   }
   int R = org(l);
   set<int> s;
   for(int i=l+1;i<=n;++i){
      s.insert(i);
   }
   ind = l+1;
   while(!s.empty()){
      int rem = s.size();
      int g = 0;
      while( g+1 <rem){
         ll v = fac[rem-1]*(g+1);
         if(v<k){
            ++g;
         } else {
            break;
         }
      }
      k -= g*fac[rem-1];
      for(set<int>::iterator it = s.begin();it!= s.end();++it){
         if(g==0){
            if(isLucky(*it)&& isLucky(ind)){
               ++R;
            }
            s.erase(it);
            break;
         } else {
            --g;
         }
      }
      ++ind;
   }
   printf("%d\n", R);
}

int main(){
   //freopen("input.txt","r",stdin);
   solve();
}


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

vector <int> a;

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

	string x;

	cin >> x;

	for(int i=0;i<x.size();i++)
	{
		if(x[i] == '4')
		{
			a.push_back(2);
			a.push_back(2);
			a.push_back(3);
		}
		else if(x[i] == '6')
		{
			a.push_back(3);
			a.push_back(5);
		}
		else if(x[i] == '8')
		{
			for(int j=1;j<4;j++)
				a.push_back(2);
			a.push_back(7);
		}
		else if(x[i] == '9')
		{
			for(int j=1;j<4;j++)
				a.push_back(2);
			for(int j=1;i<3;j++)
				a.push_back(3);
			a.push_back(7);
		}
		else
			a.push_back(x[i]-'0');
	}

	sort(a.begin(),a.end());

	for(int i=a.size()-1;i>=0;i--)
	{
		if(a[i] != 1 && a[i] != 0)
			cout << a[i];
	}
	cout << endl;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int x=0,y=0;
int n;
int ans=0;
char opset[102];
void go(int x1,int y1,int k,int step)
{
	int xx=0,yy=0;
	if(x1==0&&y1==0)
		ans=max(ans,step);
	if(k>n)
		return;
	char op=opset[k];
	if(op=='L')
		xx--;
	if(op=='R')
		xx++;
	if(op=='U')
		yy++;
	if(op=='D')
		yy--;
	go(x1,y1,k+1,step);
	go(x1+xx,y1+yy,k+1,step+1);
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>opset[i];
	}
	go(x,y,1,0);
	cout<<ans<<endl;
}


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string input;
unsigned long long int row;
unsigned long long int seconds;
int main() {
	cin >> input;
    row = input[0] - '0';
    if (row == 1) {
       if (input[1] == 'a') cout << "1";
        else if (input[1] == 'b') cout << "2";
        else if (input[1] == 'c') cout << "3";
        else if (input[1] == 'd') cout << "4";
        else if (input[1] == 'e') cout << "5";
        else if (input[1] == 'f') cout << "6";
    }
    else if (row == 2) {
        if (input[1] == 'a') cout << "8";
        else if (input[1] == 'b') cout << "9";
        else if (input[1] == 'c') cout << "10";
        else if (input[1] == 'd') cout << "11";
        else if (input[1] == 'e') cout << "12";
        else if (input[1] == 'f') cout << "13";
    }
    else if (row % 4 == 1 || row % 4 == 3) {
    	seconds += (16 * row / 4)
        if (input[1] == 'a') seconds += 4;
        else if (input[1] == 'b') seconds += 5;
        else if (input[1] == 'c') seconds += 6;
        else if (input[1] == 'd') seconds += 3;
        else if (input[1] == 'e') seconds += 2;
        else if (input[1] == 'f') seconds += 1;
    }
    else if (row % 4 == 2 || row % 4 == 0) {
        seconds += (16 * row / 4)
        if (input[1] == 'a') seconds += 4;
        else if (input[1] == 'b') seconds += 5;
        else if (input[1] == 'c') seconds += 6;
        else if (input[1] == 'd') seconds += 3;
        else if (input[1] == 'e') seconds += 2;
        else if (input[1] == 'f') seconds += 1;
	    seconds += 7;
    }
    cout << seconds;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
void solve(){
int a,b,c,d;
cin>>a>>b>>c>>d;
if(a==c || b==d){
    cout<<1<<" ";
}
else{
    cout<<2<<" ";
}

 if((a+b)%2==0 && (c+d)%2!=0 || (a+b)%2!=0 && (c+d)%2==0){
    cout<<0<<" ";
}
else if(a+b == c+d){
    cout<<1<<" ";
}
else if(a+b != c+d)
{
    int p=a,q=b;
 while(p>=1 && q>=1){
     p=p-1;
     q=q-1;
     if(p== c  && q==d){
         cout<<1<<" ";

     }
 }
 p=a,q=b;
  while(p<=8 && p<=8){
     p=p+1;
     q=q+1;
     if(p== c  && q==d){
         cout<<1<<" ";

     }
 }

}
else{
    cout<<2<<" ";
}

if(a==c){cout<<abs(b-d);
return;}
if(b==d){cout<<abs(a-c);
return;}
int count=0;

if(a > c && b > d)
{
while(a!=c && b!=d){
a=a-1;
b=b-1;
count++;
}
if(a==c){
    count+= abs(b-d);
}
else{
    count+= abs(c-a);
}
cout<<count;
return;
}

if(a > c && b < d)
{
while(a!=c && b!=d){
a=a-1;
b=b+1;
count++;
}
if(a==c){
    count+= abs(b-d);
}
else{
    count+= abs(c-a);
}
cout<<count;
return;
}

if(a < c && b > d)
{
while(a!=c && b!=d){
a=a-1;
b=b+1;
count++;
}
if(a==c){
    count+= abs(b-d);
}
else{
    count+= abs(c-a);
}
cout<<count;
return;
}

if(a < c && b<d)
{
while(a!=c && b!=d){
a=a+1;
b=b+1;
count++;
}
if(a==c){
    count+= abs(b-d);
}
else{
    count+= abs(c-a);
}
cout<<count;
return;
}

}
    int main() {
    solve();
}


#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;//1a:2b:4c
    int i=1;
    while(i<=a)
    {
        if(((2*i)<=b)&&(4*i<=c))
        i++;
    }
    i--;
    cout<<i+(2*i)+(4*i);
}


#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
string player1="Mahmoud",player2="Ehab";

bool play(int n,bool even)
{
    int i;
    if(even)
    {
        for(i=1;i<=n;i++)
        if(i%2==0&&!play(n-i,false))
        {
            //cout<<player1<<" win"<<endl;
            return true;
        }
        return false;
    }
    else
    {
        for(i=1;i<=n;i++)
        if(i%2==1&&!play(n-i,true))
        {
            //cout<<player2<<" win"<<endl;
            return true;
        }
        return false;
    }

}

int main()
{
    int n;
    cin>>n;
    if(play(n,1)) cout<<player1;
    else  cout<<player2;
    return 0;
}


#include<bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
typedef long long ll;
int main()
{
//	freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	ll r,i,minv=1e12+10;
	cin>>r;
	r--;
	for(i=1;i*i<=r;i++)
		if(r%i==0)
		{
			if((r/i-i-1)%2==0)
				minv=min(minv,i);
			if((r/(r-i)-(r-i)-1)>0&&(r/(r-i)-(r-i)-1)%2==0)
				minv=min(minv,r/i);
		}
	if(minv==1e12+10)
		cout<<"NO";
	else
		cout<<minv<<' '<<(r-minv-minv*minv)/2/minv;
	return 0;
}


#include <bits/stdc++.h>

#define fileio ifstream cin("input.txt"); ofstream cout("output.txt")
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define bench cerr << endl << "Time: " << clock() << " ms" << endl
#define endl "\n"

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;

vector<int> t;
int sz;

void update(int pos, int val){
    pos += sz - 1;
    t[pos] = val;
    while (pos != 0) {
        pos = (pos - 1) / 2;
        t[pos] = max(t[2 * pos + 1], t[2 * pos + 2]);
    }
}

int get(int l, int r, int x = 0, int tl = 0, int tr = sz){
    if(l >= tr || r <= tl)
        return 0;
    if(l <= tl && r >= tr)
        return t[x];
    int m = (tl + tr) / 2;
    int x1 = get(l, r, 2 * x + 1, tl, m);
    int x2 = get(l, r, 2 * x + 2, m, tr);
    return max(x2, x1);
}

int main() {
    fileio;
    int n, m;
    cin >> n >> m;
    vector<pii> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end());
    vector<int> a(m);
    int cur = 0;
    multiset<int> s;
    for (int i = 0; i < m; i++) {
        while(cur < v.size() && v[cur].first == i + 1){
            s.insert(v[cur].second);
            cur++;
        }
        while (s.size() != 0 && *s.begin() < i + 1) {
            s.erase(s.begin());
        }
        a[i] = s.size();
    }
    sz = 1 << (int)ceil(log2(n + 1));
    t.resize(2 * sz);
    vector<int> dp1(m);
    for (int i = 0; i < m; i++) {
        dp1[i] = get(0, a[i] + 1) + 1;
        update(a[i], dp1[i]);
    }
    fill(t.begin(), t.end(), 0);
    reverse(a.begin(), a.end());
    vector<int> dp2(m);
    for (int i = 0; i < m; i++) {
        dp2[i] = get(0, a[i] + 1) + 1;
        update(a[i], dp2[i]);
    }
    reverse(dp2.begin(), dp2.end());
    int res = 0;
    for (int i = 0; i < m; i++) {

        res = max(res, dp1[i] + dp2[i] - 1);
    }
    cout << res;
    return 0;
}


#include <iostream>

using namespace std;

const int MAXN = 3000;
int earn[MAXN];
int cost[MAXN];
const int INF = 99999999;
int dp[MAXN][MAXN];
int idx, n, m;

int main(){
    idx = 0;
    cin>>n>>m;

    int tc, td;
    cin>>tc>>td;

    for(int i=0; i<n/tc; i++){
        earn[idx] = td;
        cost[idx] = tc;
        idx++;
    }

    //cin>>cost[0]>>earn[0];
    //idx++;
    for(int i=0; i<m; i++){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int number = a/b;
        for(int k=0; k<number; k++){
            cost[idx] = c;
            earn[idx] = d;
            idx++;
        }
    }

    memset(dp,0,sizeof(dp));

    dp[0][cost[0]] = earn[0];

    int ans =- INF;
    for(int i=1; i<idx; i++){
        for(int j=0; j<=n; j++){
            if(j-cost[i]>=0){
                dp[i][j] = max(dp[i][j], earn[i] + dp[i-1][j-cost[i]]);
                //cout<<"dp["<<i<<"]["<<j<<"] = "<<dp[i][j]<<endl;
                ans = max(ans, dp[i][j]);
            }
        }
    }
    cout<<ans<<endl;
}


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

long long field[10001][10001];

void populate() {
	field[0][0] = 0;
	for (int x = 1; x <= 10000; x++) {
		field[x][0] = field[x-1][0]+x;
	}
	for (int y = 1; y <= 10000; y++) {
		field[0][y] = field[0][y-1]+y;
	}

	for (int x = 1; x <= 10000; x++) {
		for (int y = 1; y <= 10000; y++) {
			field[x][y] = field[x-1][y]+field[x][y-1]+x+y-field[x-1][y-1];
		}
	}
}

int main() {
	//freopen("input.txt", "r", stdin);
	populate();
	int m, b;
	cin >> m >> b;
	long long sol = 0;
	for (int x = 0; x <= 10000; x++) {
		int y = -(ceil((double)x/m))+b;
		if (y<0) break;
		sol = max(sol, field[x][y]);
		//cout << x << y << "\n";
	}
	cout << sol;

	return 0;
}


/*
  /\     /\
  | ).|.( |
  |  >-<  |
  =========
It's AdilkhanKo miaaaaaau
*/
#include<bits/stdc++.h>

#define ll long long
#define pb push_back
#define endl "\n"
#define foreach(it, S) for(__typeof (S.begin()) it = S.begin(); it != S.end(); it++)
#define mp make_pair
#define f first
#define s second
#define name ""
#define _ ios_base::sync_with_stdio(false);cin.tie(0);

using namespace std;

const int MaxN = int (2e6) + 256;
const int INF = int(1e9);
const int mod = (int)(1e9) + 7;
const double pi = 3.1415926535897932384626433832795;
ll n, m, t, ans;

vector<int> v, v1;

ll rec(int i, int oi){
	if(i == v1.size()){
		if(v1.size() + 1 == v.size() && oi == 1)return 1;
		if(v.size() == v1.size() && oi != 1)return 1;
		return 0;
	}
	ll ans = 1;
	if(v1[i] == 0 && oi && v[i] != 1)return 0;
	if(v1[i] == 1 && oi && v[i] != 0)return 0;
	if(v1[i] == 0 && !oi && v[i] != 0)return 0;
	if(v1[i] == 1 && !oi && v[i] != 1)return 0;

	if(v1[i] == 0){
		ans *= (rec(i + 1, 0) + rec(i + 1, 1));
	}else{
		ans *= rec(i + 1, oi) * 2;
	}
	return ans;
}
int main () { _
	ll  a, b; cin >> a >> b;
	ll cnt = 0;
	if(a == b)cnt = 2;
	while(a){
		v.pb(a % 2);
		a /= 2;
	}
	while(b){
		v1.pb(b % 2);
		b /= 2;
	}
	while(v.size() != v1.size())v1.pb(0);
	cout << rec(0, 0) - cnt;
return 0;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <stack>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <list>
#include <deque>
#include <fstream>
#include <string>
#include <iterator>
typedef long long ll;
typedef long double ld;
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fi first
#define se second
#define sqr(a) ((a) * (a))

using namespace std;

int n, k, cnt;
bool was[100005];

int main()
{
    //ifstream in("haybales.in");
    //ofstream out("haybales.out");
    int x, y, x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2 ;
    cin >> x >> y;
    if (((x1 - x) % x2) || ((y1 - y) % y2))
        cout << "NO" << endl;
    else
        cout << "YES" << endl;

    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
/*#include <sstream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include<climits>
#include <bitset>
#include <ctime>
#include <cassert>
#include <functional>
#include <iomanip>
#include <vector>
#include <stack>
#include <fstream>*/
//std::ifstream cin("input.txt");
//std::ofstream cout("output.txt");
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//cout<<fixed<<setprecision(*)<<***<<endl;
/*scanf("%d",&..);
printf("%d",..);*/

using namespace std;
vector<pair<long long,long long> >vec,vec1;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long x1,y1,x2,y2,x,y,c=0; cin>>x1>>y1>>x2>>y2>>x>>y;
	if(x1==x2&&y2==y1){cout<<"YES"<<endl; return 0;}
	vec.push_back(make_pair(x1+x,y1+y));
	vec.push_back(make_pair(x1-x,y1-y));
	vec.push_back(make_pair(x1+x,y1-y));
	vec.push_back(make_pair(x1-x,y1+y));
	while(true)
    {
        c++;
        if(c%2!=0)
        {
            vec1.clear();
            for(long long i=0;i<vec.size();i++)
            {
                if(vec[i].first==x2&&vec[i].second==y2){cout<<"YES"<<endl; return 0;}
                if(vec[i].first>x2&&vec[i].second>y2){cout<<"NO"<<endl; return 0;}
                vec1.push_back(make_pair(vec[i].first+x,vec[i].second+y));
                vec1.push_back(make_pair(vec[i].first-x,vec[i].second-y));
                vec1.push_back(make_pair(vec[i].first+x,vec[i].second-y));
                vec1.push_back(make_pair(vec[i].first-x,vec[i].second+y));
            }
        }
        else
        {
            vec.clear();
            for(long long i=0;i<vec1.size();i++)
            {
                if(vec1[i].first==x2&&vec1[i].second==y2){cout<<"YES"<<endl;  return 0;}
                if(vec1[i].first>x2&&vec1[i].second>y2){cout<<"NO"<<endl; return 0;}
                vec.push_back(make_pair(vec1[i].first+x,vec1[i].second+y));
                vec.push_back(make_pair(vec1[i].first-x,vec1[i].second-y));
                vec.push_back(make_pair(vec1[i].first+x,vec1[i].second-y));
                vec.push_back(make_pair(vec1[i].first-x,vec1[i].second+y));
            }
        }
    }
	return 0;
}


#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n,q,ans,i,met[16];
char s[100001];
int gc(int n,int k){
	if(k==1)return n;else
	return n*gc(n-1,k-1);
}
int lz(int i){
	if(i)return 0;
	if(s[i]=='?')return 1;else return 0;
}
int aj(){
	if(s[i]=='1' || s[i]=='2' || s[i]=='3' || s[i]=='4' ||
	   s[i]=='5' || s[i]=='6' || s[i]=='7' || s[i]=='8' ||
	   s[i]=='9' || s[i]=='0' || s[i]=='?') return 0;else return 1;
}
int main(){
	//freopen("input.txt","r",stdin);
	gets(s);
	n=strlen(s);
	ans=1;
	memset(met,0,sizeof met);
	for(i=0;i<n;++i){
		if(s[i]=='?')ans*=10-lz(i);else
			if(s[i]=='A')met[0]=1;else
			if(s[i]=='B')met[1]=1;else
			if(s[i]=='C')met[2]=1;else
			if(s[i]=='D')met[3]=1;else
			if(s[i]=='E')met[4]=1;else
			if(s[i]=='F')met[5]=1;else
			if(s[i]=='G')met[6]=1;else
			if(s[i]=='H')met[7]=1;else
			if(s[i]=='I')met[8]=1;else
			if(s[i]=='J')met[9]=1;
	}
	q=0;
	for(i=0;i<10;++i)q+=met[i];
        if(aj())ans*=9*gc(9,q-1);else ans*=gc(10,q);
        printf("%d\n",ans);
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<iomanip>
#include<stack>
#include<queue>
#define ll long long int
#define pb push_back
#define ld long double
#define sz size
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pil pair<ll, int>
#define F first
#define S second
#define mp make_pair
using namespace std;
ll a[3];
ll L;
ll ans = 0;
ll c[4][100100];
int main() {
	for (int i = 0; i < 3; i++) cin >> a[i];
	cin >> L;
	c[0][0] = 1;
	for (int i = 0; i <= 3; i++) {
		for (int j = 0; j <= (int)(1e5+10); j++) {
			if (i - 1 >= 0 && j - 1 >= 0) c[i][j] += c[i - 1][j - 1];
			if (j - 1 >= 0) c[i][j] += c[i][j - 1];
		}
	}
	ans = c[3][L + 3];
	for (int i = 0; i < 3; i++) {
		for (int l = 0; l <= L; l++) {
			ll x = min(a[i]-a[(i+1)%3]-a[(i+2)%3]+l, L-l);
			ans -= c[2][x+2];
		}
	}
	cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define F first
#define S second
const int mod = 1000000007;

int mpow(int base, int exp);

int main()
{
	ll a, b;
	cin>>a>>b;
	vi x, y;
	ll n = a, m = b;
	while(a>0){
		x.pb(a%2);
		a = a/2;
	}
	while(b>0){
		y.pb(b%2);
		b = b/2;
	}
	int LL = y.size();
	while(y.size() != x.size())
		y.pb(0);
	int len = x.size();
	int i, A[len], B[len];
	fo(i, len)
		A[i] = B[i] = -1;
	int cn = 0;
	for(i=len-1; i>=0; i--){
		if(x[i] == 1 && y[i] == 1){
			if(cn){
				cout<<"0\n";
				return 0;
			}
			A[i] = 1;
			B[i] = 0;
			cn = 0;
		}
		if(x[i] == 1 && y[i] == 0){
			if(cn){
				A[i] = 1;
				B[i] = 1;
				cn = 1;
			}
			else{
				A[i] = 0;
				B[i] = 0;
				cn = 1;
			}
		}
		if(x[i] == 0 && y[i] == 1){
			if(cn){
				A[i] = 1;
				B[i] = 0;
				cn = 1;
			}else{
				cout<<"0\n";
				return 0;
			}
		}
		if(x[i] == 0 && y[i] == 0){
			if(cn){
				A[i] = 1;
				B[i] = 1;
				cn = 0;
			}
			else{
				A[i] = 0;
				B[i] = 0;
				cn = 0;
			}
		}

	}
	if(cn){
		cout<<"0\n";
		return 0;
	}
	int ans = 0;

	for(int i = LL-1;i >=0 ; i--){
		int zz = A[i]^B[i];
		if(zz == 1)
			ans++;
	}
	ll res = pow(2, ans);
	if(n==m)
		res -= 2;
	cout<<res<<endl;

	return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}


#include <bits/stdc++.h>
using namespace std;
bool check(int x,int l,int r) {
	return (x >=l && x<=r);
}
int gcd(int x,int y) {
	if (y==0) return x;
	return gcd(y, x%y);
}
int lcm(int x,int y) {
	return (x * y / gcd(x,y));
}
vector<int> vt,vt1,vt2;
int main() {
	int l , r , x, y;
	cin >> l >> r >> x >> y;
	if (y %x != 0) {
		cout<<0;
		return 0;
	}
	for(int i=1;i<=sqrt(y);i++) {
		if (y%i==0) {
			vt.push_back(i);
		}
		if (y/i !=i) {
			vt.push_back(y/i);
		}
	}

	for(int i=1;i<=sqrt(x);i++) {
		if (x%i==0) {
			vt1.push_back(i);
		}
		if (x/i !=i) {
			vt1.push_back(x/i);
		}
	}
	int cnt = 0;
	for(int i=0;i<vt.size();i++) {
		for(int j=0;j<vt1.size();j++) {
			vt2.push_back(vt[i] * vt[j]);
		}
	}
	sort(vt2.begin() ,vt2.end());
	vt2.resize(distance(vt2.begin(), unique(vt2.begin(), vt2.end())));
	for(int i=0;i<vt2.size();i++) {
		  {
			int xx = vt2[i];
			int yy = x * y / xx;
			if (gcd(xx,yy) != x || lcm(xx,yy) !=y) continue;
			if (xx == yy) {
				if (check(xx,l,r)) cnt++;
			} else {
				if (check(xx,l,r) && check(yy,l,r)) cnt+=1;
			}
		   }
	}
	cout<<cnt;
}


#include <iostream>
#include <fstream>
using namespace std;

int minn (int a,int b,int c)
{
	if (a < b)
		if (a<c)
			return a;
		else
			return c;
	else
		if (b>c)
			return c;
		else
			return b;
}
int main()
{
	ifstream inp;
	ofstream oup;
	inp.open("standart input.txt");
	if (!inp)
		cout << "!";
	oup.open("standard output.txt");
	int n=0,k=0,l=0,c=0,d=0,p=0,nl=0,np=0;
	inp >>n>>k>>l>>c>>d>>p>>nl>>np;
	int ml,dolk,sol;
	ml = (k*l)/nl;
	dolk = c*d;
	sol = p / np;
	float tost;
	tost = minn (ml,dolk,sol) / n;
	if (tost > 1)
		oup<< tost;
	else
		oup << 0;
	oup.close();
	inp.close();
}


//#pragma GCC optimize(2)
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#define INF 0x3f3f3f3f
#define mod 1000000007
#define PI 3.14159265358979323846
#define Base 23333333
//#define set unordered_set
//#define map unordered_map
#define int long long
//#define int unsigned long long
using namespace std;
//#define scanf scanf_s

//#define read() _read()
//#define cout fout
//#define cin fin
//ifstream fin("in.txt");fstream fout("out.txt");
//int _read() {	int tmp;	fin >> tmp;	return tmp;}

inline int read() { int x = 0, f = 1;	char ch = getchar();	while (ch<'0' || ch>'9') { if (ch == '-') { f = -1; }		ch = getchar(); }	while (ch >= '0'&&ch <= '9') { x = 10 * x + ch - '0';		ch = getchar(); }	return x * f; }

const int maxnum = 10005;
int c[maxnum][maxnum];
int fac[maxnum];
int n, x, pos;
// c[i][j]  �� i ������ѡ  j����
void init() {
	c[0][0] = 1;
	c[1][0] = c[1][1] = 1;
	for (int i = 2; i < maxnum; i++) {
		c[i][0] = 1;
		for (int j = 1; j < maxnum; j++) {
			c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
			c[i][j] %= mod;
		}
	}
	fac[0] = 1;
	fac[1] = 1;
	for (int i = 2; i < maxnum; i++) {
		fac[i] = i * fac[i - 1] % mod;
		fac[i] %= mod;
	}
}

int A(int a, int b) {
	return (fac[a] / fac[a - b]) % mod;
}
int C(int a, int b) {
	return c[b][a] % mod;
}
signed main()
{
	init();
	n = read(), x = read(), pos = read();
	int L = 0, R = n;
	int MIN = 0, MAX = 0;
	while (L < R) {
		int mid = (L + R) / 2;
		if (pos < mid) {
			MAX++;
			R = mid;
		}
		else  if (pos > mid) {
			MIN++;
			L = mid + 1;
		}
		else {
			break;
		}
	}
	//cout << MAX << "\t" << MIN << endl;
	int ans = 1;
	ans *= (C(MAX, n-x)*A(MAX, MAX)) % mod; ans %= mod;
	ans *= (C(MIN, x-1)*A(MIN, MIN)) % mod; ans %= mod;
	ans *= A(n - MAX - MIN -1, n - MAX - MIN - 1) % mod;
	ans %= mod;
	cout << ans << endl;
	return 0;
}


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

int n, k, x, r=0, b[110], oll[110], ll[110];

int f(int start){
    if(start>=n) return 0;

    int c=0, pointer=start;
    for(int i=start;i<n;i=ll[i]){
        if(b[i]==b[pointer]) c++;
        else if(c>2){
            if(pointer>start) ll[pointer-1]=i;
            else start=i;
        }
        else {
            pointer=i; c=1;
        }
    }

    if(c>2){
        if(pointer>start) ll[pointer-1]=n;
        else start=n;
    }

    c+=f(start);

    return c;
}

int main()
{

    cin>>n>>k>>x; for(int i=0;i<n;i++) { cin>>b[i]; oll[i]=i+1; }
    for(int i=0;i<(n-1);i++){
        memcpy(ll,oll,sizeof(ll));
        if((b[i]==b[i+1])&&(b[i+1]==x)){
            if(i>0) ll[i-1]=i+2;
            int tempR = 2;
            tempR+=f(((i>0)?0:i+2));
            r=max(r,tempR);
        }
    }

    cout<<r;
    return 0;
}


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

#define mod 1000000007
#define ll long long int

ll fac(ll x) {
    if (x == 0)
        return 1;
    return ((x % mod) * fac(x - 1) % mod) % mod;
}

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;
}

ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
ll nPrModPFermat(ll n, ll r, ll p)
{
    if (r == 0)
        return 1;

    return ((fac(n)%p)  * modInverse(fac(n-r), p) % p) % p;
}

void solve()
{
    ll n, x, pos;
    cin >> n >> x >> pos;
    ll left = 0, right = 0;
    ll l = 0, r = n;
    while (l < r)
    {
        ll mid = l + (r - l) / 2;
        if (mid < pos)
        {
            left++;
            l = mid + 1;
        }
        else if (mid > pos)
        {
            right++;
            r = mid;
        }
        else
            break;
    }

    ll total = (ll)right + left;
    ll less = (ll)x - 1ll;
    ll more = (ll)n - x;
    ll ans = (ll)(((ll)(nPrModPFermat(less,left,mod) % mod) * (ll)(nPrModPFermat(more,right,mod) % mod))%mod * (ll)(fac(n-total-1)%mod)) % mod;
    cout << ans << "\n";

}

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

    solve();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int const nax = 4e5 + 10;
int par[nax];
int n, m, q;
vector <int> g[nax];
vector < pair <int, int>> queries;
vector < pair <int, int>> edges;
int a[nax];
int lc[nax];
int rc[nax];
bool del[nax];
int where[nax + nax / 4];
int in[nax];
int out[nax];
int cur;
int T = 1;
int p[nax];
bool vis[nax];

pair <int, int> sg[nax * 4];

void pull(int v) {
    sg[v] = max(sg[v << 1], sg[v << 1 | 1]);
}

void update(int v, int x, int y, int pos, pair <int, int> val) {
    if (x == y) {
        sg[v] = val;
    } else {
        int mid = x + y >> 1;
        if (pos <= mid) update(v << 1, x, mid, pos, val);
        else update(v << 1 | 1, mid + 1, y, pos, val);
        pull(v);
    }
}

pair <int, int> get_max(int v, int x, int y, int l, int r) {
    if (l == x && r == y) {
        return sg[v];
    } else {
        int mid = x + y >> 1;
        if (r <= mid) return get_max(v << 1, x, mid, l, r);
        else if (l > mid) return get_max(v << 1 | 1, mid + 1, y, l, r);
        else return max(get_max(v << 1, x, mid, l, mid)
                        , get_max(v << 1 | 1, mid + 1, y, mid + 1, r));
    }
}

int find(int x) {
    return x == par[x] ? x : par[x] = find(par[x]);
}

void join(int u, int v) {
    int fake = cur ++;
    u = find(u);
    v = find(v);
    lc[fake] = u;
    rc[fake] = v;
    par[u] = fake;
    par[v] = fake;
}

void dfs(int v) {
    if (v == 0) return;
    vis[v] = true;
    in[v] = T++;
    dfs(lc[v]);
    dfs(rc[v]);
    out[v] = T;
}

int main() {
    scanf("%d %d %d", &n, &m, &q);

    for (int i = 1 ; i <= n ; ++ i) {
        scanf("%d", a + i);
    }

    edges.resize(m);

    for (auto &[u, v] : edges) {
        scanf("%d %d", &u, &v);
    }

    queries.resize(q);

    for (auto &[u, v] : queries) {
        scanf("%d %d", &u, &v);
        if (u == 2) {
            -- v;
            del[v] = true;
        }
    }

    cur = n + 1;

    iota(par, par + n + n + 15, 0);

    for (int i = 0 ; i < m ; ++ i) {
        if (del[i]) continue;
        auto &[u, v] = edges[i];
        join(u, v);
    }

    reverse(queries.begin(), queries.end());

    int now = 0;

    for (auto &[u, v] : queries) {
        if (u == 1) {
            where[now] = find(v);
        } else if (u == 2) {
            auto &[x, y] = edges[v];
            join(x, y);
        } else throw;
        now ++;
    }

    for (int i = 1 ; i <= n ; ++ i) {
        int root = find(i);
        if (vis[i]) continue;
        T++;
        dfs(root);
    }

    int s = T;

    for (int i = 1 ; i <= n ; ++ i) {
        update(1, 1, s, in[i], make_pair(a[i], i));
    }

    vector <int> ans;

    for (int i = q - 1 ; i >= 0 ; -- i) {
        if (queries[i].first == 2) continue;
        int x = where[i];
        auto y = get_max(1, 1, s, in[x], out[x]);
                printf("%d\n", y.first);
        if (y.first > 0) {
            update(1, 1, s, in[y.second], make_pair(0, 0));
        }
    }

}
/*
    Good Luck
        -Lucina
*/


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd,x,y;
int a,b,p;
ll rng;
void ext_euc(int a,int b){
	if(b==0){
		x=1;
		y=0;
		gcd=1;
	}
	else{
		ext_euc(b,a%b);
		int temp=x;
		x=y;
		y=temp-(a/b)*y;
	}
}
int bigmod(int a,int b,int mod){
	int res=1;
	a=(a%mod);
	while(b>0){
		if(b&1)
		   res=(res*1LL*a)%mod;
		a=(a*1LL*a)%mod;
		b/=2;
	}
	return res;
}
int main() {
	// your code goes here
	cin>>a>>b>>p>>rng;
	ll ans=0;
	ext_euc(a,p);
	int ainv=(x+p)%p;
	for(int i=1;i<p;i++){
		ll y=b*1LL*bigmod(ainv,i,p)%p;
		ll n=((i-y+p)%p)*1LL*(p-1)+i;
		if(n<=rng)
		   ans+=(rng-n)/(p*1LL*(p-1))+1;
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
       int n,a;
       cin>>n;
       vector<int>v;
       set<int>s;
       for(int i=0;i<n;i++)
       {
              cin>>a;
              s.insert(a);
       }
       for(auto i=s.begin();i!=s.end();i++)
       {
              v.push_back(*i);
       }
       sort(v.begin(),v.end());
       for(int i=0;i<=s.size()-3;i++)
       {
        if(v[i+1]==v[i]+1 && v[i+2]==v[i]+2)
        {
               cout<<"YES";
               return 0;
        }
       }
       cout<<"NO";
       return 0;
}


#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bits/stdc++.h>
#define lli long long int
#define li long int
#define ld long double
using namespace std;
const lli mod = 1e9 + 7;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    while(1==1){
        int cnt1=0,cnt2=0,cnt3=0,mn;
        a/=1;cnt1++;
        b/=2;cnt2++;
        c/=4;cnt3++;
        mn=min(cnt1,cnt2);

        cout<<min(mn,cnt3)<<endl;
    }
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#define Inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
int main()
{
    double l,d,v,g,r;
    double ans;
    while(~scanf("%lf%lf%lf%lf%lf",&l,&d,&v,&g,&r))
    {
        if(v*g>d)
            ans=l/v;
        else
        {
            ans=(d/v+(r-(d-v)/3))+(l-d)/v;
        }
        printf("%.8f\n",ans);
    }
    return 0;
}


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

#define pb push_back
#define mp make_pair
#define sz 10001
#define pb push_back
#define mp make_pair

bool cmp(pair<int, int> a, pair<int, int> b){
    if(a.second < b.second)
        return true;
    if(a.second > b.second)
        return false;
    return a.first > b.first;
}

int main(){
    int t = 100;
    while(t--){
    ios_base::sync_with_stdio(false);
    int n, i, j;
    cin >> n;
    int layer[sz] = {0};
    vector <int> arr, dep;
    vector <pair<int, int> >a;
    for(i = 1; i <= n; i++){
        for(j = 1; j <= n-i+1; j++){
            int arr1 = j;
            int dep1 = j+i;
            arr.pb(arr1);
            dep.pb(dep1);
        }
    }
    int ans = 0, tmp = 0;
    i = j = 0;
    n = arr.size();
    sort(arr.begin(), arr.end());
    sort(dep.begin(), dep.end());
    while(i < n && j < n){
//        cout << arr[i] << ' ' << dep[j] << endl;
        if(arr[i] < dep[j]){
            i++;
            tmp++;
            ans = max(tmp, ans);
        }
        else{
            tmp--;
            j++;
        }
//        cout << "tmp: " << tmp << endl;
    }
    cout << ans << endl;
    }
}


#include <bits/stdc++.h>

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define sortv(v) sort(v.begin(),v.end());
#define sorta(a,n) sort(a,a+n);
#define arrayin(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define arrayout(a,n) for(int i=0;i<n;i++) cout<<" ";cout<<"\n";
#define INF INT_MAX //Infinity
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define MOD 1000000007
#define fi first
#define se second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define vi64 vector<lli>
#define viii vector<tuple<int,int,int>>
#define mii map<int,int>
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define nl "\n"

typedef long long int lli;
typedef unsigned long long int ulli;
typedef double ld;

using namespace std;

ulli poW(lli x,ulli y)
{
	//this function only returns correct values upto the order of ~10^18
	//use pow of math to obtain greater answers
	lli temp;
	if(y==0)
		return 1;
	temp=poW(x,y/2);
	if(y%2==0)
		return temp*temp;
	else return x*temp*temp;
}

int bSearch(int low,int high,int a[],int sh)
{
	//function for searching till where is a sh<=
	while(low<high)
	{
		int mid=low+(high-low+1)/2;
		if(a[mid]>sh)
			high=mid-1;
		if(a[mid]<=sh)
			low=mid;
	}
	return low;
}

ulli modular_pow(ulli b,ulli e,ulli m)
{
	if(e==0)
		return 1;
	if(e==1)
		return b;
	else
	{
		ulli res=1;
		b=b%m;
		while(e>0)
		{
			if(e&1) //e%2
				res=(res*b)%m;
			e=e>>1;
			b=(b*b)%m;
		}
		return res%m;
	}
}
const int sz=10001;
vector<pair<int,int> > a[sz];
int dis[sz];
bool vis[sz]={0};
void Dijkstra(int source, int n)
{
	//you need an [int] array dis and a bool array vis
	//also a vii [a] with edge,weight pair
	//n is the number of nodes(vertices)
    for(int i=0;i<sz;i++)
        dis[i]=INF;
    class prioritize
    {
    	public: bool operator ()(pair<int, int>&p1 ,pair<int, int>&p2)
    	{
    		return p1.second>p2.second;
    	}
    };
    priority_queue<pair<int,int> ,vector<pair<int,int> >, prioritize> pq;
    pq.push(make_pair(source,dis[source]=0));
    while(!pq.empty())
    {
        pair<int, int> curr=pq.top();
        pq.pop();
        int cv=curr.first,cw=curr.second;
        if(vis[cv])
            continue;
        vis[cv]=true;
        for(int i=0;i<a[cv].size();i++)
            if(!vis[a[cv][i].first] && a[cv][i].second+cw<dis[a[cv][i].first])
                pq.push(make_pair(a[cv][i].first,(dis[a[cv][i].first]=a[cv][i].second+cw)));
    }
}

int check[10000];
void shieve(vi &v)
{
    for(int i=3;i<=100;i+=2)
    {
        if(!check[i])
        {
            for(int j=i*i;j<=10000;j+=i)
                check[j]=1;
        }
    }
    v.push_back(2);
    int j=1;
    for(int i=3;i<=10000;i+=2)
    {
        if(!check[i]){
            v.push_back(i);
        }
    }
}

int findLevel(ii s,ii d,ii moves)
{
	queue<ii> q;
	q.push(mp(s.fi,s.se));
	while(!q.empty())
	{
		ii node=q.front();
		q.pop();
		if(node.fi-moves.fi>=(-1)*1e5&&node.se-moves.se>=(-1)*1e5)
		{
			if(node.fi-moves.fi==d.fi&&node.se-moves.se==d.se)
				return 1;
			else
				q.push(mp(node.fi-moves.fi,node.se-moves.se));
		}
		if(node.fi-moves.fi>=(-1)*1e5&&node.se+moves.se<=1e5)
		{
			if(node.fi-moves.fi==d.fi&&node.se+moves.se==d.se)
				return 1;
			else
				q.push(mp(node.fi-moves.fi,node.se+moves.se));
		}
		if(node.fi+moves.fi<=1e5&&node.se-moves.se>=(-1)*1e5)
		{
			if(node.fi+moves.fi==d.fi&&node.se-moves.se==d.se)
				return 1;
			else
				q.push(mp(node.fi+moves.fi,node.se-moves.se));
		}
		if(node.fi+moves.fi<=1e5&&node.se+moves.se<=1e5)
		{
			if(node.fi+moves.fi==d.fi&&node.se+moves.se==d.se)
				return 1;
			else
				q.push(mp(node.fi+moves.fi,node.se+moves.se));
		}
	}
	return 0;
}

int main()
{
	fio;
	/*int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
	}*/
	ii s,d;
	cin>>s.fi>>s.se>>d.fi>>d.se;
	ii moves;
	cin>>moves.fi>>moves.se;
	int ans=findLevel(s,d,moves);
	if(ans)
		cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


#include <iostream>
#include <stdio.h>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
#define for1(i,n) for(int i=0;i<n;i++)
#define for2(i,n) for(int i=1;i<=n;i++)
#define for3(i,n,m) for(int i=n;i<m;i++)
#define for4(i,n,m) for(int i=n;i<=m;i++)
const int maxm = 1e5 + 10;
const int maxn = 1e9;
const int INF = 2147483647;
const double pi = acos(-1.0);
int x1,Y1,x2,y2,x,y;
struct node{
   int x,y;
};
bool bfs(){
   int num=0;
   queue<node>tp;
   node now,then;
   now.x=x1,now.y=Y1;
   tp.push(now);
   while(!tp.empty()){
      now=tp.front();
      tp.pop();
      if(num>100000000)
         return false;
      if(now.x==x2&&now.y==y2)
         return true;
      then.x=now.x+x,then.y=now.y+y;
      tp.push(then),num++;
      then.x=now.x+x,then.y=now.y-y;
      tp.push(then),num++;
      then.x=now.x-x,then.y=now.y+y;
      tp.push(then),num++;
      then.x=now.x-x,then.y=now.y-y;
      tp.push(then),num++;
   }
}
int main() {
    while(scanf("%d%d%d%d%d%d",&x1,&Y1,&x2,&y2,&x,&y)!=EOF){
        printf("%s\n",bfs()?"YES":"NO");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int dp[500000];
int main()
{
    int n,a;
    int c=1;
    cin>>n;
    dp[1]=2;
    dp[0]=1;
    i=1;
    while(dp[i]+dp[i-1]<=n)
    {

        i++;
    dp[i]=dp[i-1]+dp[i-2];

    }

    cout<<i;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define N 1000010
using namespace std;
const ll p=1000000007;
ll w[N],q[N],v[N];
int m,k,n;
ll C(int x,int y){
if(y>x)return 0;
return w[x]*q[y]%p*q[x-y]%p;}
inline ll A(int x,int y){
if(y>x)return 0;
return w[x]*q[x-y]%p;}
ll a(ll x,ll y){
if(y<0)return 0;ll ans=1;
for(;y;x=x*x%p,y>>=1)if(y&1)ans=ans*x%p;
return ans;}
int main(){
scanf("%d%d%d",&m,&K,&n);
int i,j,L;
w[0]=w[1]=q[0]=q[1]=v[0]=v[1]=1;
for(i=2;i<=K;i++){w[i]=w[i-1]*i%p;
v[i]=1ll*(p-p/i)*v[p%i]%p;
q[i]=q[i-1]*v[i]%p;}
ll ans=0;
for(l=1;l<=k&&n+l<=m;l++){
if(n-l>=2)(ans+=a(k,n-l-2)*(1ll*k*k%p*A(k,l)%p*A(k,l)%p-A(k,l+1)*A(k,l+1)%p+p)%p)%=p;
else if(n-L==1)(ans+=(1ll*k*A(k,l)%p*A(k,l)%p-A(k,l+1)*A(k-1,l)%p+p)%p)%=p;
else (ans+=(1ll*A(k,l-n)*A(k-(l-n),n)%p*A(k-(l-n),n)%p-A(k,l-n+2)*A(k-(l-n+2),n-1)%p*A(k-(l-n+2),n-1)%p)%p)%=p;
}printf("%lld\n",(ans%p+p)%p);
return 0;}


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

using namespace std;

 long long max_n = 1e18;

int main() {
     long long x, y, l, r;
    cin >> x >> y >> l >> r;
    vector< long long> Xa;
    vector< long long> Yb;
     long long t = 1;
    while(t <= r){
        Xa.emplace_back(t);
        t *= x;
    }
    t = 1;
    while(t <= r){
        Yb.emplace_back(t);
        t *= y;
    }
    typedef long long ull;
    set<ull> unlucky;
    for(auto i1 : Xa){
        for(auto i2: Yb){
            if(i1 + i2 >= l && i1 + i2 <= r){
                unlucky.insert(i1 + i2);
            }
        }
    }
    unlucky.insert(r+1);
    ull left = l-1;
    ull ans = 0;
    for(auto d: unlucky){
        ans = max(ans, d-left-1);
        left = d;
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n, lg_min = INT_MAX;
char c[105];
vector<string> s[2];
int main()
{
    cin >> n;
    cin >> (c+1);
    bool ok = 1;
    string st;
    for(int i=1; i<=n; i++)
        st+=c[i];
    s[0].push_back(st);
    for(int l=1; ok; l = (l+1)%2)
    {
        ok = 0;
        for(auto it:s[(l+1)%2])
        {
            int m = it.size();
            lg_min = min(lg_min, m);
        }
        for(auto it:s[(l+1)%2])
        {
            int m = it.size();
            if(m!=lg_min)
                continue;
            string st2;
            for(int i=0; i<m; i++)
            {
                if(i!=0 && i!=m-1)
                {
                    if(it[i] == it[i-1]+1 || it[i] == it[i+1]+1)
                    {
                        ok = 1;
                        st = st2;
                        for(int j=i+1; j<m; j++)
                            st+=it[j];
                        s[l].push_back(st);
                    }
                }
                else if(i == 0 && it[i] == it[i+1]+1)
                {
                    ok = 1;
                    st = st2;
                    for(int j=i+1; j<m; j++)
                        st+=it[j];
                    s[l].push_back(st);
                }
                else if(i == m-1 && it[i] == it[i-1]+1)
                {
                    ok = 1;
                    st = st2;
                    for(int j=i+1; j<m; j++)
                        st+=it[j];
                    s[l].push_back(st);
                }
                st2+=it[i];
            }
        }
        s[(l+1)%2].clear();
    }
    cout << n-lg_min;
    /*
    string saux;
    saux+=c[1];
    s[1].insert(saux);
    for(int i=2; i<=n; i++)
    {
        lg_min = INT_MAX;
        for(auto it:s[i-1])
        {
            int x = it.size();
            lg_min = min(lg_min, x);
        }
        cout << lg_min << ' ';
        for(auto it:s[i-1])
        {
            int x = it.size();
            if(x == lg_min)
            {
                int m = it.size();
                if(it[m-1] == c[i]-1)
                    s[i].insert(it);
                else if(it[m-1] == c[i]+1)
                {
                    saux.clear();
                    for(int i=0; i<m-1; i++)
                        saux+=it[i];
                    saux+=c[i];
                    s[i].insert(saux);
                }
                else
                {
                    saux = it;
                    saux+=c[i];
                    s[i].insert(saux);
                }
            }
        }

    }
    int lg_min = INT_MAX;
    for(auto it:s[n])
    {
        int x = it.size();
        lg_min = min(lg_min, x);
    }
    cout << n-lg_min;
    */
    return 0;
}


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e2;
string a,b,v,ans;
int kmp[N+2],dp[N+2][N+2][N+2];
void _kmp(string s)
{
  kmp[0]=0;
  for(int i=1;s[i];i++)
  {
    int now=kmp[i-1];
    while(true)
    {
      if(s[now]==s[i])
      {
        kmp[i]=now+1;
        break;
      }
      if(!now)break;
      now=kmp[now-1];
    }
  }
}
int dfs(int i,int j,int k)
{
  if(i>=a.size()||j>=b.size())return dp[i][j][k]=0;
  if(dp[i][j][k]!=-1)return dp[i][j][k];
  int here=0;
  here=max(here,dfs(i+1,j,k));
  here=max(here,dfs(i,j+1,k));
  if(a[i]==b[j])
  {
    if(a[i]!=v[k])
    {
      if(k==0)here=max(here,1+dfs(i+1,j+1,k));
      else
      {
        int now=kmp[k-1];
        while(true)
        {
          if(v[now]==a[i])
          {
            now++;
            break;
          }
          if(!now)break;
          now=kmp[now-1];
        }
        here=max(here,1+dfs(i+1,j+1,now));
      }
    }
    else if(k<v.size()-1)
      here=max(here,1+dfs(i+1,j+1,k+1));
  }
  return dp[i][j][k]=here;
}
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  cin>>a>>b>>v;_kmp(v);
  memset(dp,-1,sizeof(dp));
  int ln=dfs(0,0,0);
  if(ln==0)cout<<0<<endl,exit(0);

//  for(int i=0;i<a.size();i++)
//  {
//    for(int j=0;j<b.size();j++)
//    {
//      for(int k=0;k<v.size();k++)
//      {
//        cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k]<<endl;
//      }
//    }
//  }

  int i=0,j=0;
  while(true)
  {
    if(ln==0)break;
    int f=0;
    for(int k=0;k<v.size()-1;k++)
    {
      if(dp[i+1][j+1][k]==ln-1&&a[i]==b[j])
      {
        ans.push_back(a[i]);
        f=1,i++,j++,ln--;
        break;
      }
    }
    if(f)continue;
    for(int k=0;k<v.size()-1;k++)
    {
      if(dp[i+1][j][k]==ln)
      {
        f=1,i++;
        break;
      }
    }
    if(f)continue;
    for(int k=0;k<v.size()-1;k++)
    {
      if(dp[i][j+1][k]==ln)
      {
        f=1,j++;
        break;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
//#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}

template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod
	ll ans=1;
	while(n){
		if(n&1) ans=((ans%mod)*(a%mod))%mod;
		a=((a%mod)*(a%mod))%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================
const int maxn=115;
char s1[maxn],s2[maxn],v[maxn];
int len1,len2,lenv;
int dp[maxn][maxn][maxn];
int NEXT[maxn];
struct Path{
    int a,b,c;
    Path(int aa=0,int bb=0,int cc=0){a=aa,b=bb,c=cc;}
}path[maxn][maxn][maxn];
void get_next(){
    int j=0;
    rep(i,1,lenv-1){
        while(j&&v[i]!=v[j+1]) j=NEXT[j];
        if(v[j]==v[i]) j++;
        NEXT[i]=j;
    }
}
Path st;
inline bool solve1(){
    rep(i,1,len1){
        rep(j,1,len2){
            rep(k,0,lenv-1){
                if(dp[i][j][k]<dp[i-1][j][k]){
                    dp[i][j][k]=dp[i-1][j][k];
                    path[i][j][k]=Path(i-1,j,k);
                }
                if(dp[i][j][k]<dp[i][j-1][k]){
                    dp[i][j][k]=dp[i][j-1][k];
                    path[i][j][k]=Path(i,j-1,k);
                }
                if(s1[i]==s2[j]){
                    int w=k;
                    while(w&&s1[i]!=v[w]) w=NEXT[w-1];
                    if(s1[i]==v[w]) w++;
                    else w=0;
                    if(dp[i][j][w]<dp[i-1][j-1][k]+1){
                        dp[i][j][w]=dp[i-1][j-1][k]+1;
                        path[i][j][w]=Path(i-1,j-1,k);
                        //cerr<<i<<" "<<j<<" "<<w<<" "<<dp[i][j][w]<<endl;
                    }
                }
            }
        }
    }
    int ma=0;
    rep(i,0,lenv-1){
        //cerr<<"*"<<dp[len1][len2][i]<<" ";
        if(ma<dp[len1][len2][i]){
            ma=dp[len1][len2][i];
            st=Path(len1,len2,i);
        }
    }
    /*cerr<<endl;
    rep(i,1,len1){
        rep(j,1,len2){
            cerr<<dp[i][j][1]<<"|"<<dp[i][j][2]<<" ";
        }
        cerr<<endl;
    }*/
    return ma!=0;
}
void print_path(int a,int b,int c){
    if(a+b+c==0) return;
    Path nxt=path[a][b][c];
    print_path(nxt.a,nxt.b,nxt.c);
    if(dp[a][b][c]==dp[nxt.a][nxt.b][nxt.c]+1){
        putchar(s1[a]);
    }
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	//===========================================================
	scanf("%s",s1+1);len1=strlen(s1+1);
    scanf("%s",s2+1);len2=strlen(s2+1);
    scanf("%s",v);lenv=strlen(v);
    /*cerr<<s1+1<<endl;
    cerr<<s2+1<<endl;
    cerr<<v+1<<endl;*/
    get_next();
    if(!solve1()){
        puts("0");
    }
    else{
        print_path(st.a,st.b,st.c);
    }
	//===========================================================
	return 0;
}


// luogu-judger-enable-o2
#include <bits/stdc++.h>
using namespace std;
int main ()
{
	string s;
	cin>>s;
	for(register int i=0;i<s.size()-4;i++){
		for(register int i2=i+1;i2<s.size()-3;i2++){
			for(register int i3=i2+1;i3<s.size()-2;i3++){
				for(register int i4=i3+1;i4<s.size()-1;i4++){
					for(register int i5=i4+1;i5<s.size();i5++){
						if(s[i]=='h'&&s[i2]=='e'&&s[i3]=='l'&&s[i4]=='l'&&s[i5]=='o') {
							cout<<"YES"<<endl;
							return 0;
						}
					}
				}
			}
		}
	}
	cout<<"NO"<<endl;
	return 0;
}


#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string clean(string hello)
{
    for(int i=0; i<hello.size(); i++)
        if(hello[i]!='h'&&hello[i]!='e'&&hello[i]!='l'&&hello[i]!='o')
        {
            hello.erase(i,1);
            i--;
        }
    return hello;
}

int main()
{
    string x;
    cin>>x;
    if(x.size()<=1||x.size()>100)
    {
        cout<<"NO"<<endl;
        return 0;
    }
    else
    {
        x=clean(x);
        string start =x.substr(x.find('h'),x.size());
        for(int i=0; i<start.size(); i++)
        {
            if(start[i]=='h'&&i>0)
            {
                start.erase(i,1);
                i--;
            }
            if(start[i]=='e'&&i>1)
            {
                start.erase(i,1);
                i--;
            }
            if(start[i]=='l'&&(i>3||i<2))
            {
                start.erase(i,1);
                i--;
            }
            if(start[i]=='o'&&i<start.size()&&i!=4)
            {
                start.erase(i,1);
                i--;
            }

        }

        if(start=="hello")
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;

    }

}


#include <iostream>
#include <vector>
using namespace std;

int main() {
    int x,y,a,b,k=0; cin>>x>>y>>a>>b;
    vector<int>v;
    for (int i=a; i<=b; i++){
        v.push_back(i);
    }
    for (int i=0; i<v.size(); i++){
        if (v[i]%x==0 && v[i]%y==0)
        k++;
    }
    cout<<k<<endl;
    return 0;
}