#include "bits/stdc++.h"
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, m = 0, n = 0, p = 0, q = 0, mod = 1000000007, pi = 3.1415926535;
    string s1, s2;
    char moji;

    cin >> a;
    vector<long long> v(a);
    vector<vector<long long>> dou(200);
    for(int i=0;i<a;i++)
    {
        cin >> b;
        b%=200;
        v.at(i)=b;
    }
    for(int i=1;i<pow(2,min(8LL,a));i++)
    {
      m=0;
        vector<int> bit(8,false);
        for(int j=0;j<8;j++)
        {
            long long div=pow(2,j);
            bit.at(j)=(i/div)%2;
            if(bit.at(j))
            {
                m+=v.at(j);
            }
        }
        m%=200;
        if(dou.at(m).size())
        {
            cout << "YES" << endl;
            cout << dou.at(m).size() << ' ';
            for(auto x:dou.at(m))
            cout << x+1 << ' ';
            cout << endl;
            cout << count(bit.begin(),bit.end(),true) << ' ';
            for(int j=0;j<8;j++)
            {
                if(bit.at(j))
                {
                    cout << j+1 << ' ';
                }
            }
            cout << endl;
            return 0;
        }
        else
        {
            for(int j=0;j<8;j++)
            {
                if(bit.at(j))
                {
                    dou.at(m).push_back(j);
                }
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}


//This Code was made by Chinese_zjc_.
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <time.h>
// #include<windows.h>
#define int long long
#define double long double
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
using namespace std;
int n, m;
int power(int A, int B, int C)
{
    int res = 1;
    A %= C;
    while (B)
    {
        if (B & 1)
        {
            res = res * A % C;
        }
        B >>= 1;
        A = A * A % C;
    }
    return res;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin >> n >> m;
    cout << power(10, n, m * m) / m % m << endl;
    return 0;
}

#include <bits/stdc++.h>
#define rep(i,a) for (int i = 0; i < (a); i++ )
#define Rep(i,start,a) for (int i = start; i < (a); i++ )
#define ALL(vec) (vec).begin(), (vec).end()
#define Sort(vec) sort((vec).begin(), (vec).end()) // 小さい順
#define SORT(vec) sort((vec).begin(), (vec).end(), [](int a, int b){return a>b;}) // 大きい順
#define Sortll(vec) sort((vec).begin(), (vec).end()) // 小さい順
#define SORTll(vec) sort((vec).begin(), (vec).end(), [](long long a, long long b){return a>b;}) // 大きい順
#define debug(x) cout << #x << " = " << (x) << endl
#define VI vector<int>
#define VLL vector<long long>
#define PII pair<int,int>
#define VPII vector<PII>
#define VB vector<bool>
#define Graph vector<vector<int>>
#define PB push_back
#define USI unordered_set<int>
typedef long long ll;
// const int mod = 998244353;
// const int MOD = 1000000007;
const ll INFLL = (1LL << 62) -1;
const int INF = (1 << 30) -1;
// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

using namespace std;

long long modpow(long long x, long long n, ll MOD) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x % MOD;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

int main(){

  ll N;
  ll M;
  cin >> N >> M;

  ll d = modpow(10,N,M*M);
  cout << (d/M)%M << endl;

}


#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <functional>
#include <array>
#include <algorithm>
#include <iomanip>

using namespace std;

int main()
{
	int a, b, c;

	int total = 0;

	cin >> a >> b >> c;

	if (a == b)
	{
		cout << c;
	}
	else if (a == c)
	{
		cout << b;
	}
	else if (b == c)
	{
		cout << a;
	}
	else
	{
		cout << total;
	}

	return 0;
}

#include<bits/stdc++.h>
#define llu unsigned long long int
#define ll long long
#define l1 int
#define u_m unordered_map
#define M map
#define sort1(s) sort(s.begin(),s.end())
#define pb(x) push_back(x)
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define answer cout<<ans<<endl;
#define Sum cout<<sum<<endl;
#define P1(a) cout<<a<<endl;
#define P2(a,b) cout<<a<<" "<<b<<endl;
#define P3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl;
#define forn(i, n) for (int i = 0; i < int(n); i++)

using namespace std;

// vector<vector<int>> v(101,vector<int>());
// vector<bool> b(101,false);
// vector<int> ans(101);

ll power(ll x, ll y , ll mod)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%mod;
        y = y/2;
        x = (x*x)%mod;
    }
    return res%mod;
}
void bfs(vector<vector<l1>> v,int s,int x,set<int> &ans)
{
	int i;
	if(x==0)
	{
		ans.insert(s);
		return;
	}
	for(i=0;i<v[s].size();i++)
	{
		bfs(v,v[s][i],x-1,ans);
	}
	return;
}

/*
ll prime(ll n)
{
    ll mx=n+1;//cout<<mx<<endl;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0 && n/i!=i)
        {
            mx=min(mx,(n/i) + i);
            //cout<<mx<<endl;
        }
    }
    return mx;
}
ll modinv(ll x)
{
    return power(x,mod-2)%mod;
}
void swap(ll *xp, ll *yp)
{
    ll temp = *xp;
    *xp = *yp;
    *yp = temp;
}
void print(vector<ll> v)
{
    ll i,j,n=v.size();
    for(i=0;i<n;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
bool sortcol( const vector<int>& v1,
               const vector<int>& v2 ) {
 return v1[1] < v2[1];
}

bool sortcol1( const vector<int>& v1,
               const vector<int>& v2 ) {
 return v1[0] < v2[0];
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
*/

// C++ program to split an array into Two
// equal sum subarrays
/*
bool partition (int arr[], int n)
{
	int sum = 0;
	int i, j;

	for (i = 0; i < n; i++)
	sum += arr[i];

	if (sum % 2 != 0)
	return false;

	bool part[n + 1][sum / 2 + 1];

	// initialize top row as false
	for (i = 0; i <= sum/2; i++)
        part[0][i] = false;

	// initialize leftmost column as true
	for (i = 0; i <= n; i++)
	part[i][0] = true;

	// Fill the partition table in botton up manner
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= sum/2; j++)
		{
			part[i][j] = part[i-1][j];
			if (j >= arr[i - 1])
			part[i][j] = part[i][j] ||
						part[i - 1][j - arr[i -1]];

		}
	}

	return part[n][sum/2];
} */

void scan(vector<ll> &v,ll n)
{
    for(ll i=0;i<n;i++)
    cin>>v[i];
}

void sol()
{
	ll a,b,c;
	cin>>a>>b>>c;
	if(a==b)
	{
		P1(c);
	}
	else if(a==c)
	{
		P1(b);
	}
	else if(b==c)
	{
		P1(a);
	}
	else
	{
		P1(0);
	}
	//cout<<endl;
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	l1 t=1;
	//cin>>t;
	while(t--)
	{
		sol();
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
#define int long long
// typedef long long int;

int const N = 4e6 + 10, mod = 1e9 + 7;
int fact[N], infact[N];
int n, m, k;

int qmi(int a, int k, int p) {
    int res = 1;
    while (k) {
        if (k & 1) res = res * a % p;
        k >>= 1;
        a = a * a % p;
    }
    return res;
}

// 预处理
void init() {
    fact[0] = infact[0] = 1;
    for (int i = 1; i < N; ++i) {
        fact[i] = (int)fact[i - 1] * i % mod;
        infact[i] = (int)infact[i - 1] * qmi(i, mod - 2, mod) % mod;
    }
}

int cnm(int a, int b) {
    return (int)fact[a] * infact[b] % mod * infact[a - b] % mod;
}

signed main() {
    init();  // 预处理
    cin >> n >> m >> k;  // c(n + m, n) - c(n + m, n - k - 1)
    if (n >= m + k + 1) cout << 0;
    else cout << ((cnm(n + m, n) % mod - cnm(n + m, n - k - 1) % mod) % mod + mod) % mod ;
    return 0;
}

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

const long long MOD = 998244353;

long long fact[400005];
long long inv[400005];
long long invFact[400005];

long long powmod(long long a, long long b){
    long long ans = 1%MOD;
    a %= MOD;
    while(b){
        if(b&1){ans = (ans*a)%MOD;}
        b >>= 1;
        a = (a*a)%MOD;
    }
    return ans;
}

inline long long ncr(long long a, long long b){
    if(b < 0 || b > a || a < 0){return 0;}
    return ((fact[a]*invFact[b])%MOD * invFact[a-b])%MOD;
}

long long memo[5005][15];

int N, M;

long long dp(int i, int j){
    if(i == 0){
        return 1;
    }else if(j == 0){
        return 0;
    }else if(memo[i][j] != -1){
        return memo[i][j];
    }else{
        long long ans = 0;
        for(int k = 0; k <= (i>>j); k ++){
            ans += ncr(N, (k<<1)) * dp(i - (k<<j), j-1) % MOD;
        }
        ans %= MOD;
        return memo[i][j] = ans;
    }
}

int main(){
    scanf("%d%d", &N, &M);

    fact[0] = 1;
    for(int i = 1; i < 400004; i ++){
        fact[i] = i*fact[i-1]%MOD;
    }

    inv[1] = 1;
    for(int i = 2; i < 400004; i ++){
        inv[i] = inv[MOD%i]*(MOD-MOD/i)%MOD;
    }

    invFact[0] = 1;
    for(int i = 1; i < 400004; i ++){
        invFact[i] = inv[i]*invFact[i-1]%MOD;
    }

    memset(memo, -1, sizeof(memo));
    printf("%lld\n", dp(M, 12));
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

bool move(ll a, ll b, ll c, ll d){
    bool ret = false;
    if(a + b == c + d){
        ret = true;
    }
    else if(a - b == c - d){
        ret = true;
    }
    else if(abs(a-c) + abs(b-d) <= 3){
        ret = true;
    }
    return ret;
}

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a == c && b == d){
        printf("%d\n", 0);
        return 0;
    }
    if((a+b) % 2 == (c+d) % 2){
        if(move(a, b, c, d)){
            printf("%d\n", 1);
        }
        else{
            printf("%d\n", 2);
        }
    }
    else{
        if(move(a, b, c, d)){
            printf("%d\n", 1);
        }
        else{
            bool ch = false;
            int x[16] = {3,2,2,1,1,1,0,0,0,0,-1,-1,-1,-2,-2,-3};
            int y[16] = {0,-1,1,-2,0,2,-3,-1,1,3,-2,0,2,-1,1,0};
            for (int i = 0; i < 16; i++) {
                if(move(a+x[i], b+y[i], c, d)){
                    ch = true;
                }
            }
            if(ch){
                printf("%d\n", 2);
            }
            else{
                printf("%d\n", 3);
            }
        }
    }

}

#include<iostream>
#include<bits/stdc++.h>
#include <vector>
//#include <string>
using namespace std;
int main(){
  vector <int> number;
  int a;
  cin>>a;
  number.push_back(a);
  cin>>a;
  number.push_back(a);
  cin>>a;
  number.push_back(a);
  sort(number.begin(),number.end());
  if(abs(number[0]-number[1])==abs(number[2]-number[1])){
  cout<<"Yes";
  }
  else{
    cout<<"No";
  }

  return(0);
}


#include<bits/stdc++.h>
#define p 998244353
using namespace std;
int n;
long long a[200005],ans,sum;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	sort(a+1,a+n+1);sum=0;
	for(int i=1;i<=n;i++)
	{
		sum=(sum*2+a[i-1])%p;
		ans=(ans+a[i]*sum%p+a[i]*a[i]%p)%p;
	}
	printf("%lld",ans);
}

#include <bits/stdc++.h>
#include <bits/extc++.h>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;
typedef vector<vi> vvi;

typedef set<int> si;

#define vt vector
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define ts to_string
#define EACH(x, a) for (auto& x: a)

template<class T> void read(T &x){ cin >> x; }
template<class A> void read(vt<A> &v){ EACH(x, v) read(x); }
template<class H, class... T> void read(H& h, T& ...t){ read(h); read(t...); }

str to_string(const char* c){ return (str)c; }
str to_string(char c){ return (str)""+c; }
str to_string(str s){ return s; }
str to_string(bool b){ return b?"True" : "False"; }
template<class A> str to_string(vt<A> v){ str s; EACH(x, v) s+= to_string(x) + " "; return s; }
template<class H, class... T> str to_string(H& h, T& ...t){ str s; s+=to_string(h); s+=" "; s+=to_string(t...); return s; }
void print(str s){ cout << s << "\n"; }
template<class... A> void print(A ...a){ print(to_string(a...)); }

int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); }
str tb(int x) {str ans; int c = x; for(int i = log2(x); i >= 0; --i){if(pow(2,i) <= c){ ans += "1"; c-=pow(2,i); } else { ans += "0"; } } return ans;}
bool ispr(int x){if(x <= 1){return false;} for(int i = 2; i <= sqrt(x); ++i){ if(x%i == 0){ return false; } }return true; }

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18;

//tree<int,null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> T;

void solve(){
	ll n; cin >> n;
	ll b = 0;
	ll cu = 1;
	ll ans = INF;
	while(cu <= n){
		ans = min(ans,b+n/cu+n%cu);
		cu*=2;
		b++;
	}
	cout << ans << '\n';

}

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

	bool isT = 0;
	if(isT){
		int t; cin >> t; while(t--){
			solve();
		}
		return 0;
	}
	solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD int(1e9+7)
#define INF int(1e9)
#define LINF ll(1e18)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define P pair<ll,ll>

ll gcd(ll m, ll n) {//最大公約数
    if (n == 0)return m;
    return gcd(n, m % n);
}//gcd

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

void solve(ll a, ll b, ll m){
  b=((b%m)+m)%m;
  ll x;
  ll d=gcd(a,m);
  if(b%d!=0) x=-1;
  else{
    a/=d; b/=d; m/=d;
    x=b*modinv(a,m)%m;
  }
  cout<<x<<endl;
  return;
}

int main(){
  int t;cin>>t;
  ll n,s,k;
  rep(tmp,t){
    cin>>n>>s>>k;
    solve(k,-s,n);
  }
}

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author houghstc
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
#include <cstring>
#include <climits>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cassert>

using namespace std;
using pii = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;

const int MOD = 1e9+7;
const double PI = std::acos(-1);

class EThrone {
public:

    ll gcd(ll a, ll b)
    {
        return b == 0 ? a : gcd(b, a%b);
    }

    ll exgcd(ll a, ll b, ll &x, ll &y)
    {
        if(b == 0)
        {
            x = 1;
            y = 0;
            return a;
        }
        int d = exgcd(b, a%b, y, x);
        y -= a/b * x;
        return d;
    }

    void solveOne(std::istream& in, std::ostream& out) {
        ll n, s, k;
        in >> n >> s >> k;
        // x * k == (n-s) mod n
        // x * k + y * n = n-s
        // gcd(k, n) | (n-s)
        ll x, y;
        ll d = exgcd(k, n, x, y);
        if((n-s) % d != 0)
        {
            out << -1 << endl;
            return;
        }

        x *= (n-s)/d;
        ll r = n/d;
        x = (x % r + r) % r;
        out << x << endl;
    }
    void solve(std::istream& in, std::ostream& out) {
        int t;
        in >> t;
        while(t--) {
            solveOne(in, out);
        }
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    EThrone solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef pair<int,int> P;
typedef long long ll;
const int INF = 1001001001;
const ll INFL = 1e17;
const int MOD = 1e+9+7;

int main(){
	int n;
	string s;
	cin >> n >> s;
	string ss="";
	int ans = 0;
	for(int i=0; i<n; i++){
		if(s[i]=='f' || s[i]=='o' || s[i]=='x'){
			ss+=s[i];
			int len = ss.length();
			if(len>=3){
				if(ss[len-3]=='f' && ss[len-2]=='o' && ss[len-1]=='x'){
					ans++;
					ss = ss.substr(0,len-3);
				}
			}
		}else{
			ss="";
		}
		//cout << i << " " << ss << " " << endl;
	}
	cout << n-ans*3 << endl;
	return 0;
}

#include <cstdio>
#include <cstring>
#include <iostream>

#define int long long

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

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

const int N = 1e5 + 5;
int n;
int a, p, x;
double aa;
int ans = 0x3f3f3f3f;

signed main() {
    read(n);
    for(int i = 1; i <= n; i++){
        read(a), read(p), read(x);
        if(a < x) ans = min(ans, p);
    }
    if(ans == 0x3f3f3f3f) cout<<-1;
    else cout<<ans;
    return 0;
}


#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  ll x = 1000;
  if (N >= x) {
    ans += N - x + 1;
  }
  x *= 1000;
  if (N >= x) {
    ans += N - x + 1;
  }
  x *= 1000;
  if (N >= x) {
    ans += N - x + 1;
  }
  x *= 1000;
  if (N >= x) {
    ans += N - x + 1;
  }
  x *= 1000;
  if (N >= x) {
    ans += N - x + 1;
  }
  x *= 1000;

  cout << ans << endl;

  return 0;
}

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

#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep_up(i, a, n) for (ll i = a; i < n; ++i)
#define rep_down(i, a, n) for (ll i = a; i >= n; --i)
#define P pair<ll, ll>

#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define vvvll vector<vector<vector<ll>>>
#define vvll vector<vector<ll>>
#define vll vector<ll>
#define pqll priority_queue<ll>
#define pqllg priority_queue<ll, vector<ll>, greater<ll>>

constexpr ll INF = (1ll << 60);
constexpr ll mod = 1000000007;
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
ll mypow(ll a, ll n) {
    ll ret = 1;
    rep(i, n) {
        if (ret > (ll)(1e18 + 10) / a) return -1;
        ret *= a;
    }
    return ret;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll t;
    cin >> t;
    vector<string> ans(t);
    rep(i, t){
        ll n;
        cin >> n;
        if(n%4==0)ans[i]="Even";
        else if(n%2==0)ans[i]="Same";
        else ans[i]="Odd";
    }
    rep(i, t)cout << ans[i] << endl;
    return 0;
}


#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
    // string __fname = "";
    // ifstream in (__fname + ".in");
    // ofstream out (__fname + ".out");
    // #define cin in
    // #define cout out
#define ss cout << " ";
#define nn cout << "\n";
#define ct(x) cout << x;
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define qr queries();
void solve(int);
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;for (int i = 1; i <= n; i++) solve(i);}
int64 ceildiv(int64 a, int64 b) {return a / b + !!(a % b);}
// // // // // // // // // // // // // // // // // // // // // //
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
const int maxn = 200200;
const int64 mod = 1000000007;
const double pi = 3.14159265359;
const int ddx[] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

void solve(int id){

    return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    ctn(ceildiv(n, 100));
    return 0;
}

#include<stdio.h>
int main(void)
{
	int n;
	scanf("%d",&n);
	printf("%d\n",(n-1)/100+1);
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <deque>
#include <bitset>
#include <cassert>
#include <unordered_set>
#include <unordered_map>
#define ll              long long
#define ull             unsigned long long
#define pii             pair<int, int>
#define PLL             pair<ll,ll>
#define rep(i,a,b)      for(int  i=a;i<=b;i++)
#define dec(i,a,b)      for(int  i=a;i>=b;i--)
#define forn(i, n)      for(int i = 0; i < int(n); i++)
using namespace std;
int dir[4][2] = { { 1,0 },{ 0,1 } ,{ 0,-1 },{ -1,0 } };
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.0);
const double eps = 1e-6;
const ll mod = 1e9 + 7;

inline ll read()
{
    ll x = 0; bool f = true; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') f = false; c = getchar(); }
    while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f ? x : -x;
}

ll gcd(ll m, ll n)
{
    return n == 0 ? m : gcd(n, m % n);
}
ll qpow(ll m, ll k)
{
    ll res = 1, t = m;
    while (k)
    {
        if (k & 1)
            res = res * t % mod;
        t = t * t % mod;
        k >>= 1;
    }
    return res;
}
/**********************************************************/

const int N = 1e5 + 5;

int main()
{
    ll n, w;
    cin >> n >> w;
    cout << n / w << endl;
}

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

int main(){
	int n,w; cin >> n >> w;
	int ans = n / w;
	cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005;
int n,m,a[N],b[N],s[N],t[N],ans=1e18;
signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=m;i++)
		cin>>b[i];
	sort(b+1,b+m+1);
	for(int i=2;i<=n-1;i+=2)
		s[i]=s[i-2]+abs(a[i]-a[i-1]);
	for(int i=n-1;i>=1;i--)
		t[i]=t[i+2]+abs(a[i]-a[i+1]);
	for(int i=1;i<=n;i++)
	{
		if(i&1)
		{
			int r=s[i-1]+t[i+1];
			int x=lower_bound(b+1,b+m+1,a[i])-b,y=1e18;
			if(x!=m+1) y=min(y,abs(a[i]-b[x]));
			if(x!=1) y=min(y,abs(a[i]-b[x-1]));
			ans=min(ans,r+y);
		}
		else
		{
			int r=(n<=3?0:s[i-2]+t[i+2])+(n<=1?0:abs(a[i-1]-a[i+1]));
			int x=lower_bound(b+1,b+m+1,a[i])-b,y=1e18;
			if(x!=m+1) y=min(y,abs(a[i]-b[x]));
			if(x!=1) y=min(y,abs(a[i]-b[x-1]));
			ans=min(ans,r+y);
		}
	}
	cout<<ans<<endl;
	return 0;
}

#include <bits/stdc++.h>
#define yala ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define RW freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);
#define ll long long
#define ld long double
using namespace std;
const ll N = 4e5 + 5;
const ll INF = 1e18;
const int mod = 1e9 + 5;
const double pi = 3.1415926536;
int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
ll dp[N][2][2];
vector<pair<int, int>>v;
ll solve (int i, int sign, int yes) {
    if (i == v.size()) {
        return (!yes) * 1e18;
    }
    ll &val = dp[i][sign][yes];
    if (~val)
        return val;
    if (v[i].second) {
        val = solve(i + 1, sign, yes);
        if (!yes)
            val = min(val, (sign ? v[i].first : -v[i].first) + solve(i + 1, !sign, 1));
    } else
        val = (sign ? v[i].first : -v[i].first) + solve(i + 1, !sign, yes);
    return val;
}
int main() {
    yala;
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        v.push_back({a, 0});
    }
    for (int i = 0; i < m; ++i) {
        int b;
        cin >> b;
        v.push_back({b, 1});
    }
    sort(v.begin(), v.end());
    memset(dp, -1, sizeof dp);
    cout << solve(0, 0, 0) << '\n';
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

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

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define done(x) {cout << x << endl;return;}
#define mini(x,y) x=min(x,y)
#define maxi(x,y) x=max(x,y)
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;
uniform_int_distribution<int> rng(1,1e9);

//DEBUG FUNCTIONS START
#define cerr cout
void __print(int x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = "; _print(x)
#else
#define deb(x...)
#endif
// DEBUG FUNCTIONS END

const int N = 2e5+5;

int c[N], p[N], sz[N];
map<int, ordered_set> mp;

int find(int x){
	if(x==p[x])
		return x;
	return p[x] = find(p[x]);
}

void join(int x, int y){
	x = find(x), y = find(y);
	if(x==y)
		return;
	if(sz[x]>sz[y]){
		swap(x, y);
	}
	sz[y] += sz[x];
	p[x] = y;
	trav(t, mp[x]){
		mp[y].insert(t);
	}

}

void solve(){

	ordered_set d;

	int n, q;
	cin>>n>>q;
	fr(i,1,n){
		cin>>c[i];
		mp[i].insert({c[i], i});
		p[i] = i;
		sz[i] = 1;
	}
	while(q--){
		int x, y, z;
		cin>>x>>y>>z;

		if(x==1){
			join(y, z);
		}else{
			y = find(y);
			auto it1 = mp[y].lb(pii(z,0));
			auto it2 = mp[y].lb(pii(z, infl));

			int ans = (it2 == mp[y].end() ? sz(mp[y]) : mp[y].order_of_key(*it2)) - (it1 == mp[y].end() ? sz(mp[y]) : mp[y].order_of_key(*it1));
			cout<<ans<<endl;
		}

	}

}

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(15);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
#ifdef aa
    cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

int powm(int a, int b){
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

int divide(int a, int b) {
    return (a % mod) * powm(b % mod, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}

#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long LINF = 1LL << 60;

struct Edge {
    int to;
    long long w;
    Edge(int arg_to, long long arg_w) : to(arg_to), w(arg_w) {}
};

using Graph = vector<vector<Edge>>;

int N, M;

long long dijkstra(Graph G, int s, int g) {
    int min_v;
    vector<long long> dist(N, LINF);
    priority_queue<pair<long long, int>> pq;

    dist[s] = 0;
    pq.emplace(-dist[s], s);

    while (!pq.empty()) {
        min_v = pq.top().second;
        pq.pop();

        for (auto e : G[min_v]) {
            if (chmin(dist[e.to], dist[min_v] + e.w)) {
                pq.emplace(-dist[e.to], e.to);
            }
        }
    }
    return dist[g];
}

int main() {
    cin >> N >> M;
    Graph G(N);
    vector<vector<int>> to(N);
    int A, B, C;
    rep(i, M) {
        cin >> A >> B >> C; A--; B--;
        G[A].push_back(Edge(B, C));
        to[B].push_back(A);
    }
    long long res;
    rep(i, N) {
        res = LINF;
        for (Edge e : G[i]) if (e.to == i) chmin(res, e.w);
        for (int j : to[i]) {
            if (i == j) continue;
            chmin(res, dijkstra(G, i, j) + dijkstra(G, j, i));
        }
        if (res != LINF) cout << res << endl;
        else cout << "-1" << endl;
    }
}


#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("O3")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

ll N, M, K, H, W, A, B, C, D;
string S;
const ll INF = 1LL<<60;

vector<long double> x(300), y(300);

class union_find{
        vector<long> parent, tree_size;
    public:
        union_find(unsigned long _n) : parent(_n), tree_size(_n, 1){
            for(unsigned long i = 0; i < _n; ++i)parent[i] = i;
        }
        ll find(ll x){
            while(parent[x] != x)x = parent[x] = parent[parent[x]];
            return x;
        }
        void merge(ll a, ll b){
            a = find(a);
            b = find(b);
	    if(a==b) return;
            if(tree_size[a] < tree_size[b])swap(a, b);
            tree_size[a] += tree_size[b];
            parent[b] = a;
            return;
        }
	bool same(ll a, ll b){
	    a = find(a);
	    b = find(b);
	    return a == b;
	}
    };
//uf.mergeのように使う
//ufはMAX_N+1でとるか、代入時に0-indexedにする

bool ok(long double r){
    union_find uf(N + 2);
    rep(i, N){
        rep(j, i){
            long double dx = x[i] - x[j], dy = y[i] - y[j];
            if(r * r >= dx * dx + dy * dy){
                uf.merge(i, j);
            }
        }
    }
    rep(i, N/3){
        uf.merge(N, i + N / 3);
        uf.merge(N + 1, i + (N / 3) * 2);
    }
    return !uf.same(N, N + 1);
}

int main(){
    cin>>N;
    cout<<fixed<<setprecision(10);
    rep(i, N){
        cin>>x[i]>>y[i];
        x[i+N] = x[i+N*2] = x[i];
        y[i+N] = -100;
        y[i+N*2] = 100;
    }
    N *= 3;
    long double lb = 0, ub = 200;
    while(ub - lb > 5e-5){
        long double cen = (ub + lb) / 2;
        (ok(cen) ? lb : ub) = cen;
    }
    cout<<lb / 2<<endl;
}

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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << "Line " << __LINE__ << ": " <<  #x << " = " << (x) << "\n";
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;

template<typename T> using V = vector<T>;
template<typename T> using P = pair<T, T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

template <class T> void UNIQUE(vector<T> &x) {sort(ALL(x));x.erase(unique(ALL(x)), x.end());}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<"\n";}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<"\n";};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

int main(){

    ll N, M;
    cin >> N >> M;
    V<ll> X(M), Y(M);
    REP(i, M) cin >> X[i] >> Y[i];

    set<ll> st;
    st.insert(N);

    V<ll> ids(M, 0);
    iota(ALL(ids), 0);
    sort(ALL(ids), [&](ll x, ll y){
        return X[x] < X[y];
    });

    REP(i, M){
        ll j = i;
        while(j < M and X[ids[i]] == X[ids[j]]){
            j++;
        }
        ll len = j - i;
        V<ll> check(len, 0);
        V<ll> vals;
        for(ll k=i;k<j;k++){
            vals.push_back(Y[ids[k]]);
        }
        REP(k, len){
            if(st.find(vals[k]-1) != st.end() or st.find(vals[k]+1) != st.end()){
                check[k] = 1;
            }
        }
        REP(k, len){
            if(check[k]){
                st.insert(vals[k]);
            }else{
                auto itr = st.find(vals[k]);
                if(itr != st.end()) st.erase(itr);
            }
        }

        i = j - 1;

        // for(auto x: st) cerr << x << " ";
        // cerr << endl;
    }

    cout << st.size() << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
int k,l,m;
long long n;
cin>>n>>k;
string s="";

for(int i=1; i<=k; i++){
if(n%200==0) n=n/200;
else {
	n=n*1000+200;
}
}
cout<<n;
}

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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    float ans,a,b;
    cin>>a>>b;
    ans=a*b/100;
    cout<<ans<<endl;
    return 0;
}


// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const LL MOD = 998244353;
int board[1010][1010]; // マスの色(0: 色なし, 1: 赤, 2: 青).
int cnt[1010][3];      // 出現回数(0: 色なし, 1: 赤, 2: 青).

int main(){

    // 1. 入力情報.
    int H, W;
    scanf("%d %d", &H, &W);
    rep(i, H){
        char c[505];
        scanf("%s", c);
        rep(j, W){
            if(c[j] == 'R') board[i][j] = 1;
            if(c[j] == 'B') board[i][j] = 2;
        }
    }

    // 2. 右上から左下に向かって, マスの色を確認.
    rep(k, H + W - 1){
        rep(i, H + W - 1){
            int j = k - i;
            if(j >= 0) cnt[k][board[i][j]]++;
            else       break;
        }
    }
    // rep(i, H + W - 1) printf("n=%d r=%d b=%d\n", cnt[i][0], cnt[i][1], cnt[i][2]);

    // 3. 色なしのみをカウント.
    // -> 赤, 青が混在している場合は, 着色不可能と判定.
    // -> 開始地点, 終了地点も, '.' となる場合があるので, 注意.
    LL ans = 1;
    int noColor = 0;
    rep(i, H + W - 1){
        if(cnt[i][1] && cnt[i][2])   ans = 0;
        if(!cnt[i][1] && !cnt[i][2]) noColor++;
    }

    // 4. 塗り方の総数は？
    rep(i, noColor) ans <<= 1, ans %= MOD;

    // 5. 出力.
    printf("%lld\n", ans);
    return 0;

}

/**
*    author:  shu8Cream
*    created: 26.04.2021 20:04:07
**/

#include <bits/stdc++.h>
#include <chrono>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using namespace std::chrono;
inline double get_time_sec(void){
    return static_cast<double>(duration_cast<nanoseconds>(steady_clock::now().time_since_epoch()).count())/1000000000;
}

std::random_device seed_gen;
std::mt19937 engine(seed_gen());

int si,sj;
vvi t(50,vi(50));
vvi p(50,vi(50));
vector<vector<P>> locate(2500);

double start;
string finans = "";
int finscore = 0;

const vi di = {-1,0,1,0,-1,0};
const vi dj = {0,-1,0,1,0,-1};
const vector<string> direct = {"U","L","D","R","U","L"};

void input(){
    cin >> si >> sj;
    rep(i,50)rep(j,50){
        cin >> t[i][j];
        locate[t[i][j]].push_back({i,j});
    }
    rep(i,50)rep(j,50) cin >> p[i][j];
}

pair<int, string> fans = {-100, "U"};

vvi used(50,vi(50));
void dfs(int score, int i, int j, string s, vi rand){
    double end = get_time_sec();
    if(end-start>=1.99){
        cout << fans.second << endl;
        exit(0);
    }
    // shuffle(all(rand),engine);

    bool ok = true;
    rep(k,4){
        int ni = i + di[rand[k]];
        int nj = j + dj[rand[k]];
        if(ni<0 || ni>=50 || nj<0 || nj>=50 || used[ni][nj])
            continue;
        ok = false;
        int nowpos = t[ni][nj];
        for(auto [x,y] : locate[nowpos]){
            used[x][y]=1;
        }
        dfs(score+p[ni][nj],ni,nj,s+direct[rand[k]], rand);

        for(auto [x,y] : locate[nowpos]){
            used[x][y]=0;
        }
    }

    if(ok){
        if(fans.first<score){
            fans.first = score;
            fans.second = s;
        }
    }
}

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

    input();
    start = get_time_sec();

    int sPos = t[si][sj];
    for(auto [x,y]: locate[sPos]){
        used[x][y]=1;
    }

    vi rand = {0,1,2,3};
    do{
        dfs(p[si][sj],si,sj,finans,rand);
    }while(next_permutation(all(rand)));

    cout << finans << endl;
}


#include <iostream>
#include <vector>
#include <algorithm>
std::vector<std::vector<int>> children, list;
std::vector<int> in, out, depth;
int timer;
void dfs(const int u) {
    in[u] = timer++;
    list[depth[u]].push_back(in[u]);
    for (const int v : children[u]) {
        depth[v] = depth[u] + 1;
        dfs(v);
    }
    out[u] = timer++;
}
int main() {
    int N;
    std::cin >> N;
    children = list = std::vector<std::vector<int>>(N);
    in = out = depth = std::vector<int>(N);
    for (int i = 1; i < N; ++i) {
        int p;
        std::cin >> p;
        children[p - 1].push_back(i);
    }
    dfs(0);
    int Q;
    std::cin >> Q;
    while (Q--) {
        int u, d;
        std::cin >> u >> d;
        u -= 1;
        const auto& v = list[d];
        std::cout << std::lower_bound(v.cbegin(), v.cend(), out[u]) - std::lower_bound(v.cbegin(), v.cend(), in[u]) << '\n';
    }
    return 0;
}

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define all(v) v.begin(), v.end()
#define pb push_back
#define sz(x) (int)(x).size()
const int N = 3e5 + 5;
void solve() {

    int n, m;
    scanf("%d%d", &n, &m);
    vector<vi> g(n);
    vi cur, col(n, 0), vis(n, 0);

    for(int i = 0; i < m; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        g[--u].pb(--v);
        g[v].pb(u);
    }

    auto check = [&](int u, int c) {
        for(auto v : g[u]){
            if(col[v] == c)
                return 0;
        }
        return 1;
    };

    function<void(int)> make = [&](int u) {
        cur.pb(u);
        vis[u] = 1;
        for(int v : g[u])
            if(!vis[v])
                make(v);
    };

    function<int(int, int)> dfs = [&](int u, int c) -> int {
        if(u == sz(cur) - 1) {
            return 1;
        }
        int ret = 0;
        for(int i = 1; i <= 3; ++i) {
            if(check(cur[u + 1], i)) {
                col[cur[u + 1]] = i;
                ret += dfs(u + 1, i);
                col[cur[u + 1]] = 0;
            }
        }
        return ret;
    };

    ll ans = 1;
    for(int i = 0; i < n; ++i) {
        if(!vis[i]) {
            cur.clear();
            make(i);
            col[cur[0]] = 1;
            ans *= 3ll * dfs(0, 1);
        }
    }

    printf("%lld", ans);
}
int main() {
    int t = 1;
    // scanf("%d",&t);
    while(t--)
        solve(), puts("");
}


#include <bits/stdc++.h>
#pragma GCC target ("sse4.2")

using namespace std;

bool home = 1;
typedef long long ll;
///#define int ll
typedef long double ld;
typedef unsigned long long ull;

signed realMain();

mt19937 rng_home(0);
mt19937 rng_oj((long long) (new char));

int rng() {
  if (home) {
    return rng_home();
  } else{
    return rng_oj();
  }
}

ull rng_ull() {
  return (ull) rng() * rng() ^ ((ull) rng() * rng());
}

int rng_range(int l, int r) {
  return l + abs(rng()) % (r - l + 1);
}

signed main() {
#ifdef ONLINE_JUDGE
  home = 0;
#endif
  if (home) {
    freopen ("tony_stark", "r", stdin);
  } else {
    ios::sync_with_stdio(0); cin.tie(0);
  }
  realMain();
}

const int N = 100 + 7;
const int K = 10000 + 7;
int n, a[N], b[K][N];

bool ok(int k) {
  for (int j = 1; j <= n; j++) {
    for (int i = 1; i <= k; i++) {
      b[i][j] = a[j] / k;
    }
    for (int i = 1; i <= a[j] % k; i++) {
      b[i][j]++;
    }
  }
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j < n; j++) {
      if (b[i][j] == b[i][j + 1]) return 0;
      if ((b[i][j] > b[i][j + 1]) != (a[j] > a[j + 1])) {
        return 0;
      }
    }
  }
  return 1;
}

signed realMain() {
  cin >> n;
  n++;
  string do_not_need;
  cin >> do_not_need;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int l = 1, r = 10000, ret = 0;
  while (l <= r) {
    int m = (l + r) / 2;
    if (ok(m)) {
      ret = m;
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  ok(ret);
  cout << ret << "\n";
  for (int i = 1; i <= ret; i++) {
    for (int j = 1; j <= n; j++) {
      cout << b[i][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>
#include <iomanip>

#include <fstream>

using namespace std;
typedef long long ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main(){fastio
    ll n,m;cin>>n>>m;
    ll a[n];
    vector<ll> v[n];
    rep(i,0,n-1)v[i].pb(-1);
    rep(i,0,n-1){
        cin>>a[i];
        v[a[i]].pb(i);
    }
    rep(i,0,n-1)v[i].pb(n);
    rep(i,0,n-1){
        rep(j,0,(ll)v[i].size()-2){
            ll a=v[i][j];
            ll b=v[i][j+1];
            if(b-a>m){
                cout<<i<<endl;
                return 0;
            }
        }
    }
    cout<<n<<endl;

    return 0;

}

#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x){
	x=0;bool dp=false;char ch=getchar();
	while(!isdigit(ch)){dp|=ch=='-';ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	x=dp?-x:x;
	return ;
}
template<typename T>
inline void write(T x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10^48);
	return ;
}
const int N=2e5+5,INF=1e9+7;
#define ll long long
int n,m;
int main(){
	read(n),read(m);
	if(m==0){
		for(int i=1;i<=n;i++) printf("%d %d\n",i*2-1,i*2);
		return 0;
	}
	if(m<0 || m>n-2){
		puts("-1");
		return 0;
	}
	printf("1 %d\n",1<<25);int tot=2;
	for(int i=2;i<=m+2;i++,tot++) printf("%d %d\n",i*2-1,i*2);
	for(;tot<=n;tot++)printf("%d %d\n",(1<<25)+tot*2-1,(1<<25)+tot*2);
}


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

// modint
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() const { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b, swap(a, b);
            u -= t * v, swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr istream& operator >> (istream& is, Fp<MOD>& x) noexcept {
        is >> x.val;
        x.val %= MOD;
        if (x.val < 0) x.val += MOD;
        return is;
    }
    friend constexpr ostream& operator << (ostream& os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD>& r, long long n) noexcept {
        if (n == 0) return 1;
        if (n < 0) return modpow(modinv(r), -n);
        auto t = modpow(r, n / 2);
        t = t * t;
        if (n & 1) t = t * r;
        return t;
    }
    friend constexpr Fp<MOD> modinv(const Fp<MOD>& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b, swap(a, b);
            u -= t * v, swap(u, v);
        }
        return Fp<MOD>(u);
    }
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

int main() {
    long long N, M; cin >> N >> M;
    long long S = 0;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i], S += A[i];

    mint res = 1;
    for (long long r = 0; r < N+S; ++r) {
        res *= N + M - r;
        res /= N + S - r;
    }
    cout << res << endl;
}

using namespace std;
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 101
#define ll long long
#define mo 998244353
int n,K;
int a[N][N];
int dsu[N];
int getdsu(int x){return dsu[x]==x?x:dsu[x]=getdsu(dsu[x]);}
ll fac[N];
ll work(){
	for (int i=1;i<=n;++i)
		dsu[i]=i;
	for (int i=1;i<=n;++i)
		for (int j=i+1;j<=n;++j){
			int x=getdsu(i),y=getdsu(j);
			if (x==y) continue;
			bool bz=1;
			for (int k=1;k<=n && bz;++k)
				if (a[i][k]+a[j][k]>K)
					bz=0;
			if (bz)
				dsu[x]=y;
		}
	static int cnt[N];
	memset(cnt,0,sizeof cnt);
	for (int i=1;i<=n;++i)
		cnt[getdsu(i)]++;
	ll res=1;
	for (int i=1;i<=n;++i)
		if (dsu[i]==i)
			res*=fac[cnt[i]];
	for (int i=1;i<=n;++i)
		for (int j=i+1;j<=n;++j)
			swap(a[i][j],a[j][i]);
	return res;
}
int main(){
	scanf("%d%d",&n,&K);
	fac[0]=1;
	for (int i=1;i<=n;++i)
		fac[i]=fac[i-1]*i%mo;
	for (int i=1;i<=n;++i)
		for (int j=1;j<=n;++j)
			scanf("%d",&a[i][j]);
	ll ans1=work();
	ll ans2=work();
	printf("%lld\n",ans1*ans2%mo);
	return 0;
}


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

void solve()
{
	int n;
	cin >> n;
	int hist[n];
	for (int i = 0; i < n; i++) cin >> hist[i];
	stack<int> s;

    int max_area = 0;
    int tp;
    int area_with_top;

    int i = 0;
    while (i < n)
    {
        if (s.empty() || hist[s.top()] <= hist[i])
            s.push(i++);
        else
        {
            tp = s.top();
            s.pop();
            area_with_top = hist[tp] * (s.empty() ? i :
                                   i - s.top() - 1);
            if (max_area < area_with_top)
                max_area = area_with_top;
        }
    }
    while (s.empty() == false)
    {
        tp = s.top();
        s.pop();
        area_with_top = hist[tp] * (s.empty() ? i :
                                i - s.top() - 1);

        if (max_area < area_with_top)
            max_area = area_with_top;
    }
	cout << max_area << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	// cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define eb emplace_back
#define mp make_pair
typedef pair<int,int> pii;
#define f first
#define s second

#define min(a,b) ((a<b)?a:b)
bool debug=false;

//const int mod=1000000007;

char arr[400005],s;
string mm="BWR";
#define op(a,b) ((a==b)?a:(3-a-b))

char solve(vector<char>&v){
  if(debug){
    cout<<"TRYING: ";
    for(char x:v){
      cout<<(int)x;
    }cout<<'\n';
  }
  vector<char> vv,v2;
  if(v.size()<=3){
    vv=v;
    //pure brute force...
    while(vv.size()>1){
      for(int i=0;i+1<vv.size();i++)vv[i]=op(vv[i],vv[i+1]);
      vv.pop_back();
    }
    return vv[0];
  }else{
    int diff=( (v.size()-1)%3 )+1;
    for(int i=0;i<diff;i++){
      v2.clear();
      for(int j=i;j<v.size();j+=3)v2.push_back(v[j]);
      vv.push_back(solve(v2));
    }
    return solve(vv);
  }
}

int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int n;
  cin>>n;
  vector<char> vv;
  for(int i=0;i<n;i++){
    cin>>s;
    if(s=='B')arr[i]=0;
    else if(s=='W')arr[i]=1;
    else arr[i]=2;
    vv.push_back(arr[i]);
  }
  cout<<mm[solve(vv)];
  return 0;
}
/*
BW R
WR B
BR W

BB B
WW W
RR R

bw bw 	R
bw wr 	W
bw br 	B
bw bb 	W
bw ww 	B
wr wr 	B
wr br
wr ww
wr rr
br bw
br wr
br br
br bb
br rr
bb bw
bb br
bb bb
ww bw
ww wr
ww ww
rr wr
rr br
rr rr
*/


#include<bits/stdc++.h>
using namespace std;
#define ints(...)		int __VA_ARGS__; vin(__VA_ARGS__)
#define dbls(...)		double __VA_ARGS__; vin(__VA_ARGS__)
#define ulls(...) 		unsigned long long __VA_ARGS__; vin(__VA_ARGS__)
#define strs(...) 		string __VA_ARGS__; vin(__VA_ARGS__)
#define vifin(x, y)		vi x(y); fin(x, y)
#define vvis(x, y, z, p)vvi x(y, vi(z, p))
#define deb 			cout << "<deb> DEB" << endl
#define debi(x) 		cout << "<deb> " << #x << " == " << x << endl
#define rep(x, y) 		for(int x = 0; x < y; x++)
#define reps(x, y, z)	for(int x = y; x < z; x++)
#define rev(x, y)		for(int x = y; x >= 0; x--)
#define revs(x, y, z)	for(int x = y; x >= z; x--)
#define syz(x) 			(int)x.size()
#define ptg(x, y)		(sqrt((x*x)+(y*y)))
#define all(x) 			x.begin(), x.end()
#define will(x) 		do{cout << x << endl; return 0;}while(0)
using ll 	= long long;
using ull	= unsigned long long;
using str	= string;
using vi 	= vector<int>;
using vc 	= vector<char>;
using vs	= vector<str>;
using vvi	= vector<vector<int>>;
using vvc	= vector<vector<char>>;
using pi	= pair<int, int>;
template<class T> using v = vector<T>;
template<class T> using pq = priority_queue<T>;
void vin(){return;}
template<class T>void fin(T& __x,int __y){rep(i, __y){cin >>__x[i];};}
void lout(){cout<<"=============================================="<<endl;}
template<class T>void fout(T& __x){cout<<"<deb> ";for(auto __y:__x){cout<< __y<<' ';}cout<<endl;}
template<class T>void fout(T& __x,int __y){cout<<"<deb> ";rep(i,__y)cout <<__x[i]<<' ';cout<<endl;}
template<class T>void ffout(T __x){lout();for(auto __y:__x){for(auto __z:__y){cout<<__z<<' ';}cout<<endl;}}
template<class T>void ffout(T __x,int __y,int __z){lout();rep(i,__y){rep(j,__z)cout<<__x[i][j]<<' ';cout<<endl;}lout();}
template<class C,class ...T>inline void vin(C& __f,T&... __x){cin >> __f;vin(__x...);}
template<class T>inline void chmax(T &a,const T &b){if(a<b)a=b;}
template<class T>inline void chmin(T &a,const T &b){if(b<a)a=b;}
constexpr ull LINF	= 4500000000000000000;
constexpr int INF 	= 2000000000;
constexpr int four	= 10007		;
constexpr int five	= 100007	;
constexpr int six	= 1000007	;
constexpr int seven	= 10000007	;
constexpr int eight	= 100000007	;
constexpr int nine	= 1000000007;

signed main() {
	ints(a, b, c, d);
	int sum = -INF;
	reps(i, a, b+1) {
		reps(j, c, d+1) {
			chmax(sum, i-j);
		}
	}
	cout << sum << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
typedef pair<ll,ll> P;

ll a,b,c;
int main(){
    cin>>a>>b>>c;
    a%=10;
    b%=20;
    c%=4;
    if(c==0)c=4;
    ll d=(ll)pow(b,c)%4;
    if(d==0)d=4;
    ll an=(ll)pow(a,d)%10;
    cout<<an<<endl;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
ll a[200100];
void solve(int T)
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    ll sum=0;
    for(ll i=1;i<=n;i++)
    {
        //cout<<(a[i]*-1ll*(ll)(n-i)+a[i]*(ll)(i-1))<<endl;
        sum+=(a[i]*-1ll*(ll)(n-i)+a[i]*(ll)(i-1));
    }
    cout<<sum;
}
//#define ONLINE_JUDGE;
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("lotato.in","r",stdin);
    freopen("lotato.out","w",stdout);
    #endif
    int t=1;
    //scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        solve(i);
    }
    return 0;
}

#include <bits/stdc++.h>
#define rep(i, f, n) for (ll i = (f); i < (ll)(n); i++)
#define repe(i, f, n) for (ll i = (f); i <= (ll)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
  int n;
  cin >> n;
  ll a, b, ans = 0;
  rep(i, 0, n) {
    cin >> a >> b;
    ll num = (b - a) + 1;
    ans += num * (a + (a + num - 1)) / 2;
  }

  cout << ans << endl;

  return 0;
}


/*Author Sanjay shukla
verdict Ac
*/
#include<iostream>
#include<string.h>
// #define endl ("\n")
#define pi (3.141592653589)

// #define int long long
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) cc.begin(), c.end()
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr);
using namespace std;
// long long moduloMultiplication(long long a,
//                             long long b,
//                             long long mod)
// {
//     long long res = 0; // Initialize result

//     // Update a if it is more than
//     // or equal to mod
//     a %= mod;

//     while (b)
//     {
//         // If b is odd, add a with result
//         if (b & 1)
//             res = (res + a) % mod;

//         // Here we assume that doing 2*a
//         // doesn't cause overflow
//         a = (2 * a) % mod;

//         b >>= 1; // b = b / 2
//     }

//     return res;
// }

int32_t main(){
    fast
    string s;
    cin>>s;
   int occurrences = 0;
   std::string::size_type pos = 0;
   std::string target = "ZONe";
   while ((pos = s.find(target, pos )) != std::string::npos) {
          ++ occurrences;
          pos += target.length();
   }
   std::cout << occurrences << std::endl;
   return 0;

}

#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int p=0;
  for(int i=0;i<9;i++)
  {
    if(s[i]=='Z'&&s[i+1]=='O'&&s[i+2]=='N'&&s[i+3]=='e')
      p++;
  }
  cout<<p;
  return 0;
}


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

#ifdef LOCAL
#include "/debug.h"
#else
#define db(...)
#endif

#define all(v) v.begin(), v.end()
#define pb push_back
using ll = long long;
const int NAX = 2e5 + 5, MOD = 1000000007;

void solveCase(int64_t A, int64_t B, int64_t W)
{
    // TODO: edit here
    W *= 1000;
    vector<set<pair<int, int>>> toadd(W + A + B + 1), torem(W + A + B + 1);
    set<pair<int, int>> curr;
    curr.insert({0, 0});
    torem[1].insert({0, 0});
    for (size_t i = 0; i <= W; i++)
    {
        for (auto &x : toadd[i])
            curr.insert(x);
        for (auto &x : torem[i])
            curr.erase(x);
        db(i, curr, toadd[i], torem[i]);
        if (curr.size())
        {
            auto mini = (curr.begin())->first;
            auto maxi = (curr.rbegin())->first;
            toadd[i + A].insert({mini + 1, i});
            torem[i + B + 1].insert({mini + 1, i});
            toadd[i + A].insert({maxi + 1, i});
            torem[i + B + 1].insert({maxi + 1, i});
        }
    }
    if (curr.size())
    {
        auto mini = (curr.begin())->first;
        auto maxi = (curr.rbegin())->first;
        cout << mini << ' ' << maxi << '\n';
    }
    else
        cout << "UNSATISFIABLE\n";
}

// generated by oj-template v4.7.2 (https://github.com/online-judge-tools/template-generator)
int main()
{
#ifndef LOCAL
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    constexpr char endl = '\n';
    int64_t A, B, W;
    cin >> A >> B >> W;
    solveCase(A, B, W);
    return 0;
}

#include <bits/stdc++.h>
#define mem(arr, val) memset(arr, val, sizeof(arr))
#define all(v) v.begin(), v.end()
#define endl '\n'
#define decision (yes ? "YES" : "NO")
using namespace std;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
// const double PI = acos(-1.0);
// const double E = exp(1.0);
const double EPS = 1e-9;
const int INF = (int)2e9;
const int MOD = (int)1e9 + 7;
const int N = (int)1e5;

int main() {
#ifdef MY_LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int a, b, w;
    cin >> a >> b >> w;
    w *= 1000;
    int mini, maxi;
    mini = (w + b - 1) / b;
    maxi = w / a;
    if (mini > maxi) {
        cout << "UNSATISFIABLE" << endl;
        return 0;
    }
    cout << mini << " " << maxi << endl;

    return 0;
}


#include<ctime>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<algorithm>
#define ll long long
using namespace std;
const double k=(sqrt(5)-1)/2;
const double t=k;
ll read(){
	char c;
	ll x=0,f=1;
	while(!isdigit(c=getchar()))
		f-=2*(c=='-');
	while(isdigit(c)){
		x=x*10+f*(c-48);
		c=getchar();
	}
	return x;
}
ll n,x,y,cnt,ans[1000];
void solve(){
	if(n==1){
		puts("1");
		puts("1");
		return;
	}
	ans[1]=3;
	for(ll i=max(0ll,(ll)(k*n-1000000));i<=min(n,(ll)(k*n+1000000));++i){
		x=i;
		cnt=1;
		y=n-x;
		while(x>=1&&y>=1){
			if(cnt>130)
				break;
			if(x>y){
				ans[++cnt]=3;
				x-=y;
			}
			else{
				ans[++cnt]=4;
				y-=x;
			}
		}
		while(x){
			if(cnt>130)
				break;
			--x;
			ans[++cnt]=1;
		}
		while(y){
			if(cnt>130)
				break;
			--y;
			ans[++cnt]=2;
		}
		if(cnt<=130)
			break;
	}
	printf("%lld\n",cnt);
	for(ll i=cnt;i;--i)
		printf("%lld\n",ans[i]);
}
int main(){
	#ifndef ONLINE_JUDGE
	freopen("C.in","r",stdin);
	freopen("C.out","w",stdout);
	#endif
	clock_t t1=clock();
	//--------
	n=read();
	solve();
	//--------
	fprintf(stderr,"%0.3lfs",1.0*(clock()-t1)/CLOCKS_PER_SEC);
	return 0;
}

#include <bits/stdc++.h>
#define REP(x, a) for(int x=0; x<a; x++)
#define sz(x) (int) (x).size()

using namespace std;

int _;

void solve() {
	string s;
	cin >> s;
	int n = sz(s);
	if (s > "atcoder") {
		cout << 0 << '\n';
		return;
	}
	int pos = -1;
	REP(i, n) {
		if (s[i] != 'a') {
			pos = i;
			break;
		}
	}
	if (pos == -1) {
		cout << -1 << '\n';
		return;
	}
	if (s[pos] > 't') cout << pos - 1 << '\n';
	else cout << pos << '\n';
}

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (cin >> _; _; --_) solve();
	return 0;
 }


// Guess Who's Back
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

const int N = 2e5 + 5;

int n;
int arr[N];
int par[N];

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

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

  for(int i = 0; i < N; i++) {
    par[i] = i;
  }

  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int ans = 0;
  for(int i = 0; i < n / 2; i++) {
    int j = n - 1 - i;
    int x = fs(arr[i]), y = fs(arr[j]);
    if(x != y) {
      ans++;
      par[x] = y;
    }
  }
  cout << ans << endl;
  return 0;
}

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

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

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

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

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}

ll const N=(ll)3e5+11;
ll const LG=(ll)log2(N)+1;

void solve() {
		ll i,j,k,l,n,m,x,y,z,r;

		cin>>n;
		map<string,ll> mp;
		set<string> st;
		for(i=0;i<n;i++){
			string t;
			cin>>t;
			if(st.find(t)==st.end()){
				if(t[0]=='!'){
					mp[t.substr(1)]++;
				}

				else{
					mp[t]++;
				}
			}
			st.insert(t);
		}
		for(auto x:mp){
			if(x.ss>1){
				cout<<x.ff<<endl;
				return;
			}
		}
		cout<<"satisfiable\n";
		return;

}
int main(){
        FS;

        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        for(ll tc=1;tc<=q;tc++){
                // cout<<"Case #"<<tc<<": ";
                solve();
        }
        return 0;
}

ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;

        if(m%2==0)return pow1((n*n)%mod,m/2,mod);

        return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}


#include<bits/stdc++.h>
#include<string>

using namespace std;

#define ll long long int
#define ld long double
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007
const int N = 2e6 + 5;
ll n , m , k;
ll fact[N];
ll mod_pow(ll a , ll n , ll mod){
    if(n == 0){
        return 1;
    }
    ll res = mod_pow((a*a)%mod , n/2 , mod);
    if(n % 2){
        res = (res*a)%mod;
    }
    return res;
}
ll mod_inv(ll x , ll mod){
    return mod_pow(x , mod - 2 , mod);
}
ll nCr(ll n , ll r , ll mod){
    return ((fact[n]*mod_inv(fact[r] , mod) % mod)* (mod_inv(fact[n - r] , mod) % mod))%mod;
}
void factorial(ll mod){
    fact[0] = 1;
    for(int i = 1; i < N; i++){
        fact[i] = (i*fact[i - 1]);
        fact[i] %= mod;
    }
}

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

    factorial(MOD);
    cin>>n>>m>>k;

    if(m + k < n){
        cout<<"0\n";
        return 0;
    }

    ll ans = nCr(n + m , n , MOD) - nCr(n + m , n - k - 1 , MOD);
    if(ans < 0){
        ans += MOD;
    }
    ans %= MOD;
    cout<<ans;
    return 0;
}

/*Jai Shree Ram*/
// Never Give Up
/*自分を信じない人にとっては、一生懸命働くことは無意味です*/

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define umii            unordered_map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define F(i,s,e,j)        for(int i=s;i<=e;i+=j)
#define mt19937                 rng(chrono::steady_clock::now().tjhe_since_epoch().count());
//shuffle(arr,arr+n,rng)
/*---------------------------------------------------------------------------------------------------------------------------*/
int gcd(int a, int b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
int expo(int a, int b,int m) {int res = 1; while (b > 0) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b = b >> 1;} return res;}
void extendgcd(int a, int b, int*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); int x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size1 3
int mminv(int a, int b) {int arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
int mminvprime(int a, int b) {return expo(a, b - 2, b);}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
int combination(int n, int r, int m, int*fact, int *ifact) {int val1 = fact[n]; int val2 = ifact[n - r]; int val3 = ifact[r]; return (((val1 * val2) % m) * val3) % m;}
void google(int t) {cout << "Case #" << t << ": ";}
vi sieve(int n) {int*arr = new int[n + 1](); vi vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
int mod_add(int a, int b, int m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}
int mod_mul(int a, int b, int m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}
int mod_sub(int a, int b, int m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}
int mod_div(int a, int b, int m) {a = a % m; b = b % m; return (mod_mul(a, mminvprime(b, m), m) + m) % m;}  //only for prime m
int phin(int n) {int number = n; if (n % 2 == 0) {number /= 2; while (n % 2 == 0) n /= 2;} for (int i = 3; i <= sqrt(n); i += 2) {if (n % i == 0) {while (n % i == 0)n /= i; number = (number / i * (i - 1));}} if (n > 1)number = (number / n * (n - 1)) ; return number;} //O(sqrt(N))
/*--------------------------------------------------------------------------------------------------------------------------*/
 void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
const int MAXN = 2000000;
int fact[MAXN+1];
int inv_fact[MAXN+1];
void pre_compute()
{
    fact[0] = 1;
    for(int i=1;i<=MAXN;i++)
        fact[i] = mod_mul(i,fact[i-1],mod);
    inv_fact[0] = 1;
    for(int i=1;i<=MAXN;i++)
        inv_fact[i] = mod_mul(mminv(i,mod),inv_fact[i-1],mod);
}
int combination(int i,int j)
{
    int ans = fact[i];
    ans = mod_mul(ans,inv_fact[j],mod);
    ans = mod_mul(ans,inv_fact[i-j],mod);
    return ans;
}
int32_t main()
{
   c_p_c();
   pre_compute();
   int n,m,k;
   cin>>n>>m>>k;
   if(n>m+k)
    cout<<0<<endl;
   else
   {
      int ans = (combination(m+n,m)-combination(n+m,n-k-1)+mod)%mod;
      cout<<ans<<"\n";
   }
}


#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,-1,1};
ll dx[8] = {1,0,-1,0,1,-1,1,-1};
const double pi = acos(-1);
const double eps = 1e-10;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
//const int mod = 1e9 + 7;
//const int mod = 998244353;

const int M = 127500;
int dp[101][M+1];
int sdp[101][M+2];

int main(){
	int N,K,mod; cin >> N >> K >> mod;
	dp[0][0] = 1;
	rep(j,K+1) sdp[0][j] = 1;
	for(int i=1; i<=N; i++){
		rep(j,M+1){
			dp[i][j] += sdp[j%i][j];
			dp[i][j] %= mod;
			sdp[j%i][j] = 0;
		}
		rep(j,M+1){
			(sdp[j%(i+1)][j] += dp[i][j]) %= mod;
			(sdp[j%(i+1)][min(M+1,j+((K+1)*(i+1)))] += mod - dp[i][j]) %= mod;
		}
		rep(j,i+1){
			for(int k=j; k+i+1<=M; k+=i+1){
				(sdp[j][k+(i+1)] += sdp[j][k]) %= mod;
			}
		}
	}
	for(int x=1; x<=N; x++){
		ll ans = mod-1;
		for(int i=0; i<=M; i++){
			ans += (ll)dp[x-1][i] * dp[N-x][i] % mod * (K+1) % mod;
			ans %= mod;
		}
		cout << ans << "\n";
	}
}

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const int MAX = 505000 + 10;

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, K, M;
  while (cin >> N >> K >> M) {
    auto dp = make_v(N + 1, MAX, 0);
    auto sum = make_v(MAX, 0);
    dp[0][0] = 1;
    for (int n = 1; n <= N; n++) {
      for (int w = 0; w < MAX; w++) {
        sum[w] = (dp[n - 1][w] + (w - n >= 0 ? sum[w - n] : 0)) % M;
      }
      for (int w = 0; w < MAX; w++) {
        dp[n][w] = (sum[w] - (w - n * (K + 1) >= 0 ? sum[w - n * (K + 1)] : 0) + M) % M;
      }
    }
    for (int x = 1; x <= N; x++) {
      int res = 0;
      for (int w = 0; w < MAX; w++) {
        res = (res + 1ll * dp[x - 1][w] * dp[N - x][w] % M) % M;
      }
      res = (1ll * res * (K + 1)) % M;
      res = (res - 1 + M) % M;
      cout << res << endl;
    }
  }
  return 0;
}


#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
#define inf INT_MAX
#define linf LLONG_MAX
#define lninf LLONG_MIN
const int mod = 1e9 + 7;
const int N = 1e6 + 4;

int solve()
{
	int n, m; scn(n); scn(m);

	map<int, int> ma;

	rep(i, 0, n)
	{
		int val; scn(val); ma[val]++;
	}

	rep(i, 0, m)
	{
		int val; scn(val); ma[val]++;
	}

	for(auto it: ma)
	if(it.S == 1)
	printf("%d ", it.F);

	return 0;
}

int main()
{
	int t = 1; //scn(t);

	while(t--)
	{
		solve();
	}

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define io ios::sync_with_stdio(false); cin.tie(0)

int main()
{
    io;
    int n, k; cin >> n >> k;
    vector<int> a(n);
    vector<int> cnt(n, 0);
    rep(i, n) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    int res = 0;
    rep(i, k) {
        rep(j, n) {
            if (cnt[j] == 0) {
                res += j;
                break;
            }
            cnt[j]--;
        }
    }
    cout << res << endl;
    return 0;
}


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

void solve(double a,double b,double W){
    int min=ceil(W/b),max=floor(W/a);
    if((b*min-W)<=(b-a)*min&&(a*max-W)<=(b-a)*max){
        cout<<min<<" "<<max;
    }else{
        cout<<"UNSATISFIABLE";
    }
}

int main(){
    double a,b,w;
    cin>>a>>b>>w;
    double W=1000*w;
    solve(a,b,W);
    return 0;
}

#include<iostream>
#include<utility>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#define forn(i, x, n) for(int i = x; i < n; i++)
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const bool DEBUG = 0;

void solve(){
    int a, b, w;
    cin>>a>>b>>w;
    w *= 1000;
    int mn = ceil(w * 1.0 / b);
    int mx = w / a;
    if(mx < mn || mn == 0) cout<< "UNSATISFIABLE";
    else cout<< mn << ' ' << mx;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
    //cin>>t;
	//while(t--) cout<<solve()<<'\n';
	while(t--) solve(), cout<<'\n';

}


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

int main() {

	int  n, x, y, count, Flag;
	cin >> n;

  	count = 0;

  	for (int i = 1; i <= n; i++) {
      	Flag = 0;
      	x = i;
      	y = i;
  		for (int j = 0; j < 10; j++) {
            if ((x%10)==7 || (y%8)==7)  Flag = 1;
            x = x / 10;
            y = y / 8;
        }
      	if(Flag == 0) count++;
    }

  	cout << count << endl;

}

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

int main() {
string S;
cin>>S;
int ans=0;
for(int i=0;i<S.size();i++){
if(S.at(i)=='Z' && i<9){
if(S.at(i+1)=='O'){
if(S.at(i+2)=='N'){
if(S.at(i+3)=='e'){
ans++;
}else{
continue;
}
}else{
continue;
}
}else{
continue;
}
}else{
continue;
}
}
cout<<ans<<endl;
}


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

const vector<int> XS = { 0, 0, 1, 1 };
const vector<int> YS = { 0, 1, 0, 1 };
const char BLACK = '#';

int count(int i, int j, vector<string> &s) {
	int count = 0;
	for (int k = 0; k < int(XS.size()); k++) {
		if (BLACK == s[i + XS[k]][j + YS[k]]) {
			count++;
		}
	}
	return count;
}

int main(void) {
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	int ans = 0;
	for (int i = 0; i < h - 1; i++) {
		for (int j = 0; j < w - 1; j++) {
			if (1 == (1 & count(i, j, s))) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法

int main(){

    ll n,k;
    cin >> n >> k;

    vector<ll> vec;
    REP(i,n){
        REP(j,k){
            ll tmp = 100*(i+1);
            tmp += j+1;
            vec.push_back(tmp);
        }
    }
    /*
    REP(i,vec.size()){
        cout << vec[i] << endl;
    }*/

    cout << accumulate(vec.begin(),vec.end(),0) << endl;

    return 0;
}


#include <bits/stdc++.h>
#include <math.h>
#include <chrono>
using namespace std;
#pragma GCC optimize("-O3")
#define endl "\n"
#define mp make_pair
#define st first
#define nd second
#define pii pair<int, int>
#define pb push_back
#define _upgrade ios_base::sync_with_stdio(0), cout.setf(ios::fixed), cout.precision(10), cin.tie(0), cout.tie(0);
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FWD(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define fwd(i, a, b) for (int i = (a); i < (b); ++i)
#define all(c) (c).begin(), (c).end()
#define sz(X) (int)((X).size())
#define what(x) cerr << #x << " is " << x << endl;

ostream &operator<<(ostream &out, string str)
{
    for (char c : str)
        out << c;
    return out;
}
template <class L, class R>
ostream &operator<<(ostream &out, pair<L, R> p)
{
    return out << "(" << p.st << ", " << p.nd << ")";
}
template <class T>
auto operator<<(ostream &out, T a) -> decltype(a.begin(), out)
{
    out << '{';
    for (auto it = a.begin(); it != a.end(); it = next(it))
        out << (it != a.begin() ? ", " : "") << *it;
    return out << '}';
}
void dump() { cerr << "\n"; }
template <class T, class... Ts>
void dump(T a, Ts... x)
{
    cerr << a << ", ";
    dump(x...);
}
#define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)

const int MAXM = 1e8 + 99;
const int silnia = 40320;
int n, m;

int V[10];
int maks[MAXM + 22];

int get(vector<int> &X, int x, int y)
{
    int s = 0;
    for (int i = x; i <= y; i++)
        s += V[X[i]];
    return maks[min(s, MAXM)];
}

int solve(vector<int> X)
{
    vector<int> dp(10);
    for (int i = n - 1; i >= 0; i--)
        for (int j = i + 1; j < n; j++)
            dp[i] = max(dp[j] + get(X, i, j), dp[i]);
    // debug(X, dp);
    return dp[0];
}

int32_t main()
{
    _upgrade;

    cin >> n >> m;
    rep(i, n) cin >> V[i];

    rep(i, m)
    {
        int l, v;
        cin >> l >> v;
        maks[v + 1] = max(l, maks[v + 1]);
    }

    rep(i, MAXM + 10) maks[i + 1] = max(maks[i], maks[i + 1]);

    vector<int> perm;
    rep(i, n) perm.push_back(i);

    rep(i, n) if (maks[V[i]] > 0)
    {
        //   debug(i, V[i], maks[V[i]]);
        cout << -1 << endl;
        exit(0);
    }
    int res = 1e9;

    do
    {
        res = min(res, solve(perm));
        // debug(perm);
    } while (next_permutation(all(perm)));

    cout << res << endl;
}

#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;

const int M = 1e5+5;
int n,m;
int w[10];
int sums[M],mw[M];
int main(){
	cin >> n >> m;
	int maxw = 0;
	for(int i = 0;i < n;i++){
		cin >> w[i];
		maxw = max(maxw,w[i]);
	}
	int minv = 0x3f3f3f3f;
	for(int i = 0;i < 1<<n;i++){
		int x = 0;
		for(int j = 0;j < n;j++)
			if(i >> j & 1)x+=w[j];
		sums[i] = x;
	}
	for(int i = 0;i < m;i++){
		int a,b;
		cin >> a >> b;
		minv = min(minv,b);
		for(int s = 0;s < 1 << n;s++)
			if(sums[s] > b)
				mw[s] = max(mw[s],a);
	}

	if(maxw > minv){
		cout << "-1"<<endl;
		return 0;
	}
	int ans = 0x3f3f3f3f;
	vector<int>perm(n);
	iota(perm.begin(),perm.end(),0);
	do{
		vector<int>pos(n);
		for(int i = 0;i < n;i++){
			int x = 0;
			for(int j = i;j >= 0;j--){
				x|=1 << perm[j];
				pos[i] = max(pos[i],pos[j]+mw[x]);
			}
		}
		ans = min(ans,pos[n-1]);
	}while(next_permutation(perm.begin(),perm.end()));
	cout << ans << endl;
	return 0;
}


#include<iostream>
using namespace std;
int main() {
	string s, c;
	cin >> s >> c;
	int a = 0, b = 0;
	for (int i = 0; i < s.length(); i++) {
		a += s[i] - '0';
	}
	for (int i = 0; i < c.length(); i++) {
		b += c[i] - '0';
	}
	if (a > b) {
		cout << a;
	}
	else {
		cout << b;
	}
}

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

int sum(int n){
  int a = n/100;
  int b = (n-a*100)/10;
  int c = (n-a*100-b*10);
  return a+b+c;
}
int main() {
  int a, b;
  cin >> a >> b;
  int asum = sum(a);
  int bsum = sum(b);
  cout << max(asum, bsum) << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define e(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define out(s) cout << s << endl
typedef long long ll;
using Graph = vector<vector<int>>;
const int MOD = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  rep(i,n){
    cin >> x.at(i) >> y.at(i);
  }
  int num = 0;
  for (int i = 0; i < n - 1;i++){
    for (int j = i + 1; j < n;j++){
      float t = (float)(y.at(j) - y.at(i)) / (float)(x.at(j) - x.at(i));
      if (t >= -1 && t <= 1)
      {
        num++;
      }
    }
  }
  out(num);
}

#include <bits/stdc++.h>
using namespace std;
struct node {
	int x, y;
} a[1010];
int n, ans;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d%d", &a[i].x, &a[i].y);
	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++)
			if (i != j && a[i].x != a[j].x)
				if ((double)(a[i].y - a[j].y) / (double)(a[i].x - a[j].x) <= 1.0 && (double)(a[i].y - a[j].y) / (double)(a[i].x - a[j].x) >= -1.0)
					ans++;
	printf("%d\n", ans);
	return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
using ll = long long;
using ld = long double;

int main() {
	int N;
	ll ans=10000000;
	cin >> N;
	vector<ll>A(N), B(N);
	rep(i, N) {
		cin >> A[i] >> B[i];
		ans = min(ans, A[i] + B[i]);
	}
	sort(A.begin(), A.end());sort(B.begin(), B.end());
	if (A[0] + B[0] != ans) {
		ans = min(ans, max(A[0], B[0]));
	}
	else {
		ans = min(ans, max(A[0], B[1]));
		ans = min(ans, max(A[1], B[0]));
	}
	cout << ans<< endl;
}

#include<bits/stdc++.h>
using namespace std;
namespace Sakurajima_Mai{
    #define ms(a) memset(a,0,sizeof(a))
    #define repi(i,a,b) for(int i=a,bbb=b;i<=bbb;++i)//attention reg int or reg ll ?
    #define repd(i,a,b) for(int i=a,bbb=b;i>=bbb;--i)
    #define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
    #define ce(i,r) i==r?'\n':' '
    #define pb push_back
    #define all(x) x.begin(),x.end()
    #define gmn(a,b) a=min(a,b)
    #define gmx(a,b) a=max(a,b)
    #define fi first
    #define se second
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double db;
    const int infi=1e9;//infi较大，注意涉及inf相加时爆int
    const ll infl=4e18;
    inline ll ceil_div(ll a,ll b){ return (a+b-1)/b; }
    inline ll pos_mod(ll a,ll b){ return (a%b+b)%b; }
    //std::mt19937 rnd(time(0));//std::mt19937_64 rnd(time(0));
}
using namespace Sakurajima_Mai;
namespace Fast_Read{
    inline int qi(){
        int f=0,fu=1; char c=getchar();
        while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
        while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
        return f*fu;
    }
    inline ll ql(){
        ll f=0;int fu=1; char c=getchar();
        while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
        while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
        return f*fu;
    }
    inline db qd(){
        char c=getchar();int flag=1;double ans=0;
        while((!(c>='0'&&c<='9'))&&c!='-') c=getchar();
        if(c=='-') flag=-1,c=getchar();
        while(c>='0'&&c<='9') ans=ans*10+(c^48),c=getchar();
        if(c=='.'){c=getchar();for(int Bit=10;c>='0'&&c<='9';Bit=(Bit<<3)+(Bit<<1)) ans+=(double)(c^48)*1.0/Bit,c=getchar();}
        return ans*flag;
    }
}
namespace Read{
    #define si(a) scanf("%d",&a)
    #define sl(a) scanf("%lld",&a)
    #define sd(a) scanf("%lf",&a)
    #define ss(a) scanf("%s",a)
    #define rai(x,a,b) repi(i,a,b) x[i]=qi()
    #define ral(x,a,b) repi(i,a,b) x[i]=ql()
}
namespace Out{
    #define pi(x) printf("%d",x)
    #define pl(x) printf("%lld",x)
    #define ps(x) printf("%s",x)
    #define pc(x) printf("%c",x)
    #define pe() puts("")
}
namespace DeBug{
    #define MARK false
    #define DB if(MARK)
    #define pr(x) cout<<#x<<": "<<x<<endl
    #define pra(x,a,b) cout<<#x<<": "<<endl; \
            repi(i,a,b) cout<<x[i]<<" ";     \
            puts("");
    #define FR(a) freopen(a,"r",stdin)
    #define FO(a) freopen(a,"w",stdout)
}
using namespace Fast_Read;
using namespace Read;
using namespace Out;
using namespace DeBug;
typedef long double ld;//%Lf
const db pi=acos(-1.0);
const db eps=1e-8;
inline int sgn(db x){ return fabs(x)<eps?0:(x<0?-1:1); }
struct Point{
    #define Vec Point
    db x,y;
    Point(){}
    Point(db _x,db _y){x=_x,y=_y;}
    void input(){sd(x),sd(y);}
    bool operator ==(Point b)const{return sgn(x-b.x)==0&&sgn(y-b.y)==0;}
    Point operator +(const Point &b)const{return Point(x+b.x,y+b.y);}
    Point operator -(const Point &b)const{return Point(x-b.x,y-b.y);}
    Point operator /(const db b)const{return Point(x/b,y/b);}
    Point operator *(const db b)const{return Point(x*b,y*b);}
    db operator ^(const Point &b)const{return x*b.y-y*b.x;}//叉乘
    db operator *(const Point &b)const{return x*b.x+y*b.y;}//点乘
    Point transXY(Point b,db B){//绕点b 逆时针 旋转角度B(弧度制)后的坐标
        db tx=x-b.x,ty=y-b.y;
        return Point(tx*cos(B)-ty*sin(B)+b.x,tx*sin(B)+ty*cos(B)+b.y);
    }
    db dis(Point p){ return sqrt((x-p.x)*(x-p.x)+(y-p.y)*(y-p.y)); }//hypot(x-p.x,y-p.y)
};
int main()
{
    int n=qi();
    int x0=qi(),y0=qi(),xn2=qi(),yn2=qi();
    Point center=Point(1.0*(x0+xn2)/2,1.0*(y0+yn2)/2);
    db arc=2*pi/n;
    Point res=Point(1.0*x0,1.0*y0);
    res=res.transXY(center,arc);
    printf("%.10lf %.10lf\n",res.x,res.y);
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const int MX = 125001;

ll MOD;

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll dp[111][125001];

int main(void){
	int n,m,i,j,k;
	ll ans = 0ll;
	dp[0][0] = 1ll;
	scanf("%d%d%lld",&n,&m,&MOD);
	for(i=0; i<n; ++i){
		for(j=0; j<MX; ++j){
			if(!dp[i][j]){
				continue;
			}
			for(k=0; k<=m; ++k){
				if(j+(i+1)*k>=MX){
					break;
				}
				add_mod(dp[i+1][j+(i+1)*k],dp[i][j]);
			}
		}
	}
	for(i=1; i<=n; ++i){
		ans = 0ll;
		for(j=0; j<MX; ++j){
			add_mod(ans,dp[n-i][j]*dp[i-1][j]%MOD);
		}
		mul_mod(ans,(m+1));
		add_mod(ans,MOD-1);
		printf("%lld\n",ans);
	}
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define pb push_back

double dp[101][101][101];

double f(int a,int b,int c){

  if(dp[a][b][c]) return dp[a][b][c];

  if(a==100||b==100||c==100) return 0;

  double s=0;

  s+=(f(a+1,b,c)+1)*a/(a+b+c);

  s+=(f(a,b+1,c)+1)*b/(a+b+c);

  s+=(f(a,b,c+1)+1)*c/(a+b+c);

  dp[a][b][c]=s;

  return s;

}

int main(){

  string s;

  int a,b,c,d;

  cin>>a>>b>>c;

  cout<<fixed<<setprecision (12);

  cout<<f(a,b,c);}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
using ll = long long;

int a,b;

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

  cin >> a >> b;
  cout << (a+b)/2 << " " << (a-b)/2 << endl;
}

/*
* @Author: kabbo
* @Date:   2020-06-24 08:40:07
* @Last Modified by:   kabbo
* @Last Modified time: 2020-06-24 08:49:58
*/
#include<bits/stdc++.h>
using namespace std;
#define pii pair<long long,long long>
#define endl '\n'
#define ull unsigned long long
#define ll int64_t
#define ar array
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0200r0.html
template<class Fun>
class y_combinator_result {
    Fun fun_;
public:
    template<class T>
    explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}

    template<class ...Args>
    decltype(auto) operator()(Args &&...args) {
        return fun_(std::ref(*this), std::forward<Args>(args)...);
    }
};

template<class Fun>
decltype(auto) y_combinator(Fun &&fun) {
    return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}
const int mod = 1e9 + 7;
using u64 = uint64_t;
using u128 = __uint128_t;
#define sc1(x) scanf("%lld",&(x));
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
/*Well, probably you won't understand anything,
because you didn't try to understand anything in your life,
you expect all hard work to be done for you by someone else.
Let's start*/
void solve() {
    ll a,b;
    cin>>a>>b;
    cout<<(b%a?"No":"Yes")<<endl;
}
int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // int t;
    // cin>>t;
    // for (int i(1); i <= t; ++i) {
    //     printf("Case %d:\n", i);
        solve();
    //}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_
void debug_out() {cerr << endl;}
template<typename Head,typename... Tail> void debug_out(Head H,Tail... T){cerr << ' ' << H; debug_out(T...);}
#define debug(...) cerr << 'L' << __LINE__ << " [" << #__VA_ARGS__ << "]:",debug_out(__VA_ARGS__)
#define dump(x) cerr << 'L' << __LINE__ << " " << #x << " = " << (x) << endl;
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int N;
ll A[60];
map<PL,ll> mp;
ll dfs(int d,ll val,ll ret) {
    if (d == N - 1){
        return ret;
    }
    PL key = PL{d,val};
    if (mp.count(key)) return mp[key];
    ll k;
    if (d > 0) k = val/(A[d]/A[d-1]);
    else k = val/A[d];
    ll p = k%(A[d+1]/A[d]);
    if (p == 0) {
        ll ans = dfs(d+1,k,ret);
        return mp[key] = ans;
    }
    else {
        ll ans = 0;
        ans += dfs(d+1,k - p,ret);
        ans += dfs(d+1,k - p + A[d+1]/A[d],ret);
        return mp[key] = ans;
    }
}

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

    ll X;
    cin >> N >> X;
    rep(i,N) cin >> A[i];

    ll ans = dfs(0,X,1);
    cout << ans << '\n';
    return 0;
}

#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, s, n) for (ll i = s; i < (n); i++)

int main(){
  int x, y;
  cin >> x >> y;
  int diff = abs(x-y);
  if (diff < 3) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

#define F(type, i, a, b, incr) for (type i = a; i <= (type)(b); i += (type)(incr))
#define pb push_back
#define ppb pop_back
#define ff first
#define ss second
#define iter(it, s) for (auto it = s.begin(); it != s.end(); it++)
#define fillc(a,b) memset(a,b,sizeof(a))
#define MOD 1000000007
#define INF 1e17

void solve()
{
	ll x,y;
	cin>>x>>y;
	set<ll> s;
	s.insert(0);
	s.insert(1);
	s.insert(2);
	if(x==y)
	{
		cout<<x<<endl;
	}
	else
	{
		s.erase(x);
		s.erase(y);
		cout<<*s.begin()<<endl;
	}
}

int main()
{
    //freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
        solve();
}

        #include<iostream>
        #include<bits/stdc++.h>
        #include<string>
        #include<algorithm>
        #define ll long long
        #define pb push_back
        #define pob pop_back
        #define mp make_pair
        #define lb lower_bound
        #define ub upper_bound
        #define loop(i,n) for(i=0;i<n;i++)
        #define loop1(i,n) for(i=1;i<=n;i++)
        #define Loop(i,n,x) for(i=0;i<n;i+=x)
        #define Loop1(i,n,x) for(i=1;i<=n;i+=x)
        #define all(a) a.begin(),a.end()
        #define allr(a) a.rbegin(),a.rend()
        #define mem(name,val) memset(name,val,sizeof(name))
        const long long  MOD=(ll)1000000007;
        ll fact[100005];
        using namespace std;
        int main()
        {
            ll n,k;
            cin>>n>>k;
            while(k--)
            {
                if(n%200)
                {
                    n=n*1000+200;
                }
                else n/=200;
            }
            cout<<n<<endl;

        }


#include <bits/stdc++.h>

typedef long double ld;
#define int long long

#define gcd            __gcd
#define endl           "\n"
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define pb             push_back
#define all(x)         x.begin(), x.end()
#define f              first
#define s              second
#define lb             lower_bound
#define ub             upper_bound
#define ins            insert
#define sz(x)          (int)(x).size()
#define mk             make_pair
#define deci(x, y)     fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define PI             3.141592653589793238
#define mem0(x)        memset(x,0,sizeof x)
#define mem1(x)        memset(x,-1,sizeof x)
using namespace std;
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.f << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NITIN
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

void solve() {
    int n,k;
    cin>>n>>k;
    map<int,int>f;
    for(int i=1;i<=n;i++){
        f[i]=i-1;
    }
    for(int i=n+1;i<=2*n;i++){
        f[i]=2*n-i+1;
    }
    int cnt=0;
    for(int i=1;i<=2*n;i++){
        cnt+=f[k+i]*f[i];
    }
    cout<<cnt<<endl;
}

int32_t main() {
    nitin;

    solve();
}

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

long long pattern(long long x, long long N){
  if(x > 1 && x < N+1){
	return x - 1;
  }
  if(x > N && x < 2*N+1){
    return 2*N - x + 1;
  }
}

int main() {
	long long N, K, ans;
    ans = 0;
  	cin >> N >> K;
  	for (long long Q=2; Q<2*N+1; Q++){
      if(K + Q < 2){
        continue;
      }
      if(K + Q > 2*N+1){
        break;
      }
      else{
		ans += pattern(K + Q, N) * pattern(Q, N);
      }

    }
  	cout << ans;
}