#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define each(e, v) for(auto &e: v)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct io_setup{
    io_setup(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout << fixed << setprecision(15);
    }
} io_setup;

template<typename T>
vector<T> divisors(const T &n){
    vector<T> ret;
    for(T i = 1; i*i <= n; i++){
        if(n%i == 0){
            ret.pb(i);
            if(i*i != n) ret.pb(n/i);
        }
    }
    sort(all(ret));
    return ret;
}

template<typename T>
vector<pair<T, int>> prime_factor(T n){
    vector<pair<T, int>> ret;
    for(T i = 2; i*i <= n; i++){
        int cnt = 0;
        while(n%i == 0) cnt++, n /= i;
        if(cnt > 0) ret.emplace_back(i, cnt);
    }
    if(n > 1) ret.emplace_back(n, 1);
    return ret;
}

template<typename T>
bool is_prime(const T &n){
    if(n == 1) return false;
    for(T i = 2; i*i <= n; i++){
        if(n%i == 0) return false;
    }
    return true;
}

vector<bool> Eratosthenes(const int &n){
    vector<bool> ret(n+1, true);
    if(n >= 0) ret[0] = false;
    if(n >= 1) ret[1] = false;
    for(int i = 2; i*i <= n; i++){
        if(!ret[i]) continue;
        for(int j = i+i; j <= n; j += i) ret[j] = false;
    }
    return ret;
}

vector<int> Eratosthenes2(const int &n){
    vector<int> ret(n+1);
    iota(begin(ret), end(ret), 0);
    if(n >= 0) ret[0] = -1;
    if(n >= 1) ret[1] = -1;
    for(int i = 2; i*i <= n; i++){
        if(ret[i] < i) continue;
        for(int j = i+i; j <= n; j += i) ret[j] = min(ret[j], i);
    }
    return ret;
}

int main(){
    ll A, B; cin >> A >> B;

    vector<bool> p = Eratosthenes(B-A);

    vector<int> ps;

    rep2(i, 1, B-A){
        if(p[i]) ps.eb(i);
    }

    //cout << sz(ps) << '\n';
    int n = sz(ps);

    vector<int> s(B-A+1, 0);
    rep2(i, 0, B-A){
        ll k = A+i;

        rep(j, n){
            if(k%ps[j] == 0) s[i] |= (1<<j);
        }
    }

    vector<ll> dp(1<<n, 0);
    dp[0] = 1;

    rep(i, B-A+1){
        rep3(j, (1<<n)-1, 0){
            if((j&s[i]) == 0) dp[j|s[i]] += dp[j];
        }
    }

    cout << accumulate(all(dp), 0LL) << '\n';
}

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

int diri[] = {1, 0, -1, 0}, dirj[] = {0, 1, 0, -1};

#define mp make_pair
typedef pair <int, int> ii;
#define INF 1000000005

int h, w;
char grid[2005][2005];
vector<ii> tele[30];
int dist[2005][2005];
int gi, gj;
queue<ii> q;

int main() {
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; i++) {
		scanf(" %s", grid[i]);
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			dist[i][j] = INF;
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (grid[i][j] == 'S') {
				dist[i][j] = 0;
				q.push(mp(i, j));
			} else if (grid[i][j] == 'G') {
				gi = i, gj = j;
			} else if (grid[i][j] - 'a' >= 0 && grid[i][j] - 'a' < 27) {
				tele[grid[i][j] - 'a'].push_back(mp(i, j));
			}
		}
	}
	while (!q.empty()) {
		int i, j; tie(i, j) = q.front(); q.pop();
		for (int k = 0; k < 4; k++) {
			int ni = i + diri[k], nj = j + dirj[k];
			if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
			if (grid[ni][nj] == '#') continue;
			if (dist[ni][nj] > dist[i][j] + 1) {
				dist[ni][nj] = dist[i][j] + 1;
				q.push(mp(ni, nj));
			}
			if (ni == gi && nj == gj) {
				printf("%d\n", dist[ni][nj]);
				return 0;
			}
		}
		if (grid[i][j] - 'a' >= 0 && grid[i][j] - 'a' < 27) {
			for (ii ports : tele[grid[i][j] - 'a']) {
				int ni, nj; tie(ni, nj) = ports;
				if (ni == i && nj == j) continue;
				if (dist[ni][nj] > dist[i][j] + 1) {
					dist[ni][nj] = dist[i][j] + 1;
					q.push(mp(ni, nj));
				}
			}
		}
	}
	printf("-1\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,t,n) for(int64_t i=t;i<n;i++)
#define Sort(a) sort(a.begin(),a.end())
#define rSort(a,n,m) sort(a.begin()+n-1,a.begin()+m)
#define Reverse(a) reverse(a.begin(),a.end())
#define rReverse(a,n,m) reverse(a.begin()+n-1,a.begin()+m)
#define MOD 1000000007
#define sign(i) -1*pow(-1,i)
#define vi(A,N,i)  vector<int64_t> A(N,i)
#define vs(A,N,i)  vector<string> A(N,i)
#define vb(A,N,i)  vector<bool> A(N,i)
#define INF ((1LL<<62)-(1LL<<31))
//((a+b+c)-max(a,max(b,c))-min(a,min(b,c)))

/*template <class T>

}*/

//cout << fixed << setprecision(桁数);

int64_t def_str(string x,string y){
  int64_t def=0;
  rep(i,0,(int64_t)x.size()){
    if(x[i]!=y[i]){
      def++;
    }
  }
  return def;
}

int main() {
  int64_t a,b,c,d,e,f,ans=0,now_ans=0,mlt_ans=1;
  //double a,b,c,d,e,f,ans=0,now_ans=0,mlt_ans=1;
  string x,y,z;
  char s,t,u;
  bool frag=false,frag1=false,frag2=false;
  vector<int64_t> A{},B{};
  vector<string> C{},D{};
  vector<char> E{},F{};
  vector<bool> G(26,false);
  cin>>a;
  //cin>>x>>y;
  //cin>>s>>t;////////////////////////
  ans=INF;
  rep(i,0,a){
    cin>>b>>c>>d;
    if(b<d){
      ans=min(ans,c);
    }
  }
  if(ans==INF){
    cout<<-1;
    return 0;
  }
  cout<<ans;
}

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

using namespace std;

#define PB push_back
#define MP make_pair
#define REP(i,n) for(i=0;i<(n);++i)
#define PER(i,n) for(i=(n - 1);i>=0;--i)
#define FOR(i,l,h) for(i=(l);i<=(h);++i)
#define FORD(i,h,l) for(i=(h);i>=(l);--i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define lINF 0x3f3f3f3f3f3f3f3f

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long LL;
typedef pair<int,int> PII;
typedef map<int, int> MII;

int main()
{
    int n,i;
    while(cin>>n){
        int a,p,x;
        int res = INF;
        FOR(i,1,n){
            cin>>a>>p>>x;
            if(x>a) res = min(res, p);
        }
        if(res==INF) res=-1;
        cout<<res<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[100];int n;const int mod=998244353;
int f[210000],finv[210000];
inline int qpow(int a,int b,int p)
{
    int k=1;
    while(b)
    {
        if(b&1) k=k*a%p;
        a=a*a%p;b>>=1;
    }return k;
}
inline int comb(int n,int m)
{
    if(n<m) return 0;
    if(n==m||m==0) return 1;
    return f[n]*finv[n-m]%mod*finv[m]%mod;
}int ans=0;
/*inline int lowbit(int x){return x&(-x);}
int num=0;
inline void dfs(int x,int left,int bas,int mul)
{
    if(left==0)
    {
        int res=1;
        //cout<<">> "<<r<<endl;
        num++;
        if(num%10000000==0) cout<<num<<endl;
        ans+=mul;
        return ;
    }
    if(lowbit(left)<bas) return ;
    if(bas>left) return ;
    for(int i=0;i*bas<=left&&i<=n;i+=2)
    {
        a[x]=i;
        dfs(x+1,left-i*bas,bas<<1,mul*comb(n,i)%mod);
    }
}*/

int dp[6000];
signed main()
{
    f[0]=finv[0]=1;
    for(int i=1;i<=201000;i++) f[i]=f[i-1]*i%mod;
    finv[201000]=qpow(f[201000],mod-2,mod);
    for(int i=201000-1;i>=1;i--) finv[i]=finv[i+1]*(i+1)%mod;

    int m;
    cin>>n>>m;
    ans=0;
    dp[0]=1;
    for(int i=2;i<=m;i+=2)
    {
        for(int j=0;j<=i;j+=2)
        {
            dp[i]+=dp[(i-j)>>1]*comb(n,j)%mod;
            dp[i]%=mod;
        }
    }
    cout<<dp[m]<<endl;
}

#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pii;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b); i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)

#define sz(x) (int)(x).size()
#define popcnt(x) __builtin_popcount(x)
#define low_bo(a, x) (lower_bound(a.begin(), a.end(), x) - a.begin())
#define up_bo(a, x) (upper_bound(a.begin(), a.end(), x) - a.begin())
#define unique(a) a.resize(unique(a.begin(), a.end()) - a.begin())
#define shuffle(a) shuffle(a.begin(), a.end(), rnd)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 998244353;
const char nl = '\n';
const int MX = 20000; //check the limits, dummy
int n, m, np;
ull fac[MX];
ll c[5001];
ll rev(ll x, ll m) { return x == 1 ? 1 : (1 - rev(m % x, x) * (ll)m) / x + m; }
ll choose(ll n, ll r) {
	if (n < r)
		return 0;
	if (r == 0)
		return 1;
	return ((fac[n] * (rev(fac[r], MOD) % MOD)) % MOD * (rev(fac[n - r], MOD) % MOD)) % MOD;
}
void init() {
	fac[0] = 1;
	for (int i = 1; i < MX; i++)
		fac[i] = (fac[i - 1] * i) % MOD;
}
void solve(int t) {
	cin >> n >> m;
	np = (n / 2) * 2;
	if (m % 2) {
		cout << "0\n";
		return;
	}
	ll dp[5001][13];
	for (int ma = 0; ma < 5001; ma++) {
		if (ma % 2) continue;
		dp[ma][0] = choose(n, ma);
	}
	for (int d = 1; d < 13; d++) {
		for (int ma = 0; ma < 5001; ma++) {
			if (ma % 2) continue;
			int p2 = (1 << d);
			int mx = min(ma / 2 / p2, n / 2);
			ll ret = 0;
			for (int i = 0; i <= mx; i++) {
				ret = ((dp[2 * i][0] * dp[ma - i * 2 * p2][d - 1]) % MOD + ret) % MOD;
			}
			dp[ma][d] = ret;
		}
	}
	int d = 0;
	while ((1 << d) <= m)
		d++;
	cout << dp[m][d - 2] << nl;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(20);
	cout << fixed;
	init();
	int T = 1;
	F0R(i, T) {
		solve(i + 1);
	}
}

// read the question correctly (ll vs int)
// template by bqi343


#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <unordered_map>
#include <vector>

// #include <atcoder/all>
/*
cd $dir && g++ -std=c++17 -Wall -Wextra -O2 -DATCODERDEBUG
-I/mnt/d/MyProjects/atcoder/lib/ac-library $fileName && echo 'compilation ok!'
&&  ./a.out
*/
using namespace std;
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define ALL(x) x.begin(), x.end()
#define dame(a)        \
  {                    \
    cout << a << endl; \
    return 0;          \
  }
typedef long long ll;

class dstream : public ostream {};

template <typename T>
dstream &operator<<(dstream &os, T v) {
#ifdef ATCODERDEBUG
  cout << "\033[1;31m" << v << "\033[0m";
#endif
  return os;
}

ostream &endd(std::ostream &out) {
#ifdef ATCODERDEBUG
  out << std::endl;
#endif
  return out;
}
dstream dout;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "[ ";
  for (auto const &x : v) {
    os << x;
    if (&x != &v.back()) {
      os << " : ";
    }
  }
  os << " ]" << endl;
  return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<vector<T>> &v) {
  os << "[" << endl;
  for (auto const &x : v) {
    os << " ";
    os << x;
  }
  os << "]" << endl;
  return os;
}

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &v) {
  os << "[ " << v.first << " " << v.second << " ]" << endl;
  return os;
}

template <typename T, typename U, typename Comp = less<>>
bool chmax(T &xmax, const U &x, Comp comp = {}) {
  if (comp(xmax, x)) {
    xmax = x;
    return true;
  }
  return false;
}

template <typename T, typename U, typename Comp = less<>>
bool chmin(T &xmin, const U &x, Comp comp = {}) {
  if (comp(x, xmin)) {
    xmin = x;
    return true;
  }
  return false;
}

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

  ll N;
  cin >> N;
  vector<vector<ll>> C(N, vector<ll>(N, 0));
  REP(i, N) {
    REP(j, N) { cin >> C[i][j]; }
  }

  // check
  for (ll i = 1; i < N; i++) {
    ll d = C[i][0] - C[0][0];
    for (ll j = 1; j < N; j++) {
      if (C[0][j] + d != C[i][j]) {
        dout << "no1" << endd;
        cout << "No" << endl;
        return 0;
      }
    }
  }

  ll upper = 1e12;
  REP(j, N) { chmin(upper, C[0][j]); }

  ll downer = 0;
  for (ll i = 1; i < N; i++) {
    ll e = C[i][0] - C[0][0];
    chmax(downer, -e);
  }

  if (downer > upper) {
    cout << "No" << endl;
    return 0;
  }

  ll d = downer;
  cout << "Yes" << endl;
  // A
  REP(i, N) {
    cout << (C[i][0] - C[0][0] + d);
    if (i != N - 1)
      cout << " ";
    else
      cout << endl;
  }
  // B
  REP(j, N) {
    cout << (C[0][j] - d);
    if (j != N - 1)
      cout << " ";
    else
      cout << endl;
  }
  // cout << std::fixed << std::setprecision(15) << sqrt(ans) << endl;
}

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

#define  fl(i,a,b) for(long long i=a;i<b;i++)
#define  test long long t_c;cin>>t_c;for(long long ks=1;ks<=t_c;ks++)
#define pb push_back
#define vi vector<int>
#define all(x) x.begin(),x.end()
#define cy cout<<"YES\n";
#define cn cout<<"NO\n";
#define nl cout<<endl;
#define case(x) cout<<"Case "<<x<<": ";

typedef long long ll;
typedef long long int lli;
void sc(int &x){scanf("%d",&x);}
void sc(lli &x){scanf("%lld",&x);}
void sc(char *x){scanf("%s",x);}
void sc(double &x){scanf("%lf",&x);}

using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
   lli a,b;
   cin>>a>>b;
   if(abs(a-b)<3)
   {
       cout<<"Yes\n";
   }
   else
   {
       cout<<"No\n";
   }

}


#include<ctime>
#include<cstdio>
#include<cctype>
using namespace std;
const int N=1e2+7;
int read() {
	char c;
	int x=0,f=1;
	while(!isdigit(c=getchar()))
		f-=2*(c=='-');
	while (isdigit(c)){
		x=x*10+(c-48)*f;
		c=getchar();
	}
	return x;
}
char s[N];
int n,m,a[N];
int chk(int x){
	for(int i=1;i<=n;++i){
		if(s[i-1]=='<'){
			if(a[i-1]%x>a[i]%x){
				if(a[i-1]/x+1>=a[i]/x)
					return 0;
			}
			else{
				if(a[i-1]/x>=a[i]/x)
					return 0;
			}
		}
		else{
			if(a[i-1]%x<a[i]%x){
				if(a[i-1]/x<=a[i]/x+1)
					return 0;
			}
			else{
				if(a[i-1]/x<=a[i]/x)
					return 0;
			}
		}
	}
	return 1;
}
void solve(){
	int l=1,r=1e4,ans=0;
	while(l<=r){
		int mid=(l+r)>>1;
		if(chk(mid)){
			l=mid+1;
			ans=mid;
		}
		else
			r=mid-1;
	}
	printf("%d\n",ans);
	for(int i=1;i<=ans;++i){
		for(int j=0;j<=n;++j)
			printf("%d ",a[j]/ans+(a[j]%ans>=i));
		puts("");
	}
}
int main() {
	#ifndef ONLINE_JUDGE
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
	#endif
	clock_t t1=clock();
	//--------
	n=read();
	scanf("%s",s);
	for(int i=0;i<=n;++i)
		a[i]=read();
	solve();
	//--------
	clock_t t2=clock();
	fprintf(stderr,"time:%0.3lfs",1.0*(t2-t1)/CLOCKS_PER_SEC);
	return 0;
}


#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#include<cstdio>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int to[400001], ne[400001], he[200001];
int Q[200001], pl[200001], dl[200001];

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}

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

	int N = getint(), K = getint();
	int k = 1;
	rep(i, N - 1) {
		int u = getint(), v = getint();
		to[k] = v;
		ne[k] = he[u];
		he[u] = k++;
		to[k] = u;
		ne[k] = he[v];
		he[v] = k++;
	}

	int q = 0, p = 0;
	Q[q++] = 1;
	while (p < N) {
		int u = Q[p++];
		int tmp = 0;
		int ind = he[u];
		he[u] = 0;
		while (ind) {
			int v = to[ind];
			tmp = ne[ind];
			if (he[v] > 0) {
				Q[q++] = v;
				ne[ind] = he[u];
				he[u] = -ind;
			}
			ind = tmp;
		}
	}

	int are = 1000000, pd0 = are;
	int L = 0, R = (N + K - 1) / K;
	while (L + 1 < R) {
		int wj = (L + R) / 2;

		int num = 0;

		for (int i = N - 1; i >= 0; i--) {
			int po = pd0 - 1;
			int dd = pd0;
			int u = Q[i];
			for (int ind = -he[u]; ind; ind = -ne[ind]) {
				int v = to[ind];
				if (po < pl[v]) po = pl[v];
				if (dd < dl[v]) dd = dl[v];
			}
			if (po >= dd) dd = 0;
			if (dd >= pd0 + wj) {
				num++;
				po = pd0 + wj;
				dd = 0;
			}
			pl[u] = po - 1;
			dl[u] = dd + 1;
			if (num > K) break;
		}

		int are = num + (dl[1] > pd0);
		if (are > K) L = wj;
		else R = wj;

		pd0 += are;
	}

	printf("%d", R);

	Would you please return 0;
}

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

// clang-format off
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define per(i, a, b) for (int i = a; i >= (b); --i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define rll(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<long long>;
// (* read and write *)
template <class T>
void re(vector<T> &v, int n) {v.resize(n); for (auto &e : v) cin >> e;}
template <class T>
void re(vector<T> &v){for (auto &e : v) cin >> e;}
// void usaco(string s) {freopen((s + ".in").c_str(), "r", stdin );freopen((s + ".out").c_str(), "w", stdout );}
// clang-format on

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

  double a, b; cin >> a >> b;
  cout << a * (b / 100.0);
}


#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
#define int long long
int32_t main()
{
  int n; cin >> n;
  vi v(n);fr(i,n) cin >> v[i];
  vi pfx = v;
  rep(i,1,n-1) pfx[i] += pfx[i-1];
  vi mxpfx = pfx;
  rep(i,1,n-1) mxpfx[i] = max(mxpfx[i-1], pfx[i]);

  int mx = 0;
  rep(i,1,n-1) pfx[i] += pfx[i-1];
  rep(i,0,n-2) mx =  max(mx, pfx[i] + mxpfx[i+1]);
  mx = max(mx, pfx[n-1]);
  cout << mx;

}

#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>

using namespace std;

#define rep(i,N) for(ll i=0;i<N;i++) //0から

typedef long long ll;

ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    //a>=b
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

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

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

//cout<<fixed<<setprecision(10);
int main(){
    ll a,b,x,y;
    cin>>a>>b>>x>>y;
    ll ans=0;
    if(a>b){
        ans=min(x+y*(a-b-1),x+2*x*(a-b-1));
    }
    else{
        ans=min(x+y*(b-a),x+2*x*(b-a));
    }
    cout<<ans<<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll INF = numeric_limits<ll>::max() / 4;
// const int INF = numeric_limits<int>::max() / 4;

int main() {
	// ll N;
	int R, C;
	cin >> R >> C;
	vector<vector<int> > A(R,vector<int>(C,0));
	vector<vector<int> > B(R,vector<int>(C,0));
	for(int i = 0; i < R; i++){
		for(int j = 0; j < C - 1; j++){
			cin >> A[i][j];
		}
	}
	for(int i = 0; i < R - 1; i++){
		for(int j = 0; j < C; j++){
			cin >> B[i][j];
		}
	}

	vector<vector<ll> > X(R*2,vector<ll>(C,INF));

	multimap<int,pair<int,int> > P;
	X[0][0] = 0;
	P.insert(make_pair(0,make_pair(0,0)));
	while(!P.empty()){
		auto p = P.begin();
		P.erase(p);
		int r = p->second.first;
		int c = p->second.second;
		int x = X[r][c];
		if(R <= r){
			r -= R;
			if(0 < r){
				if(x + 1 < X[r-1][c]){
					X[r-1][c] = x + 1;
					P.insert(make_pair(X[r-1][c],make_pair(r-1,c)));
				}
				if(x + 1 < X[r-1+R][c]){
					X[r-1+R][c] = x + 1;
					P.insert(make_pair(X[r-1+R][c],make_pair(r-1+R,c)));
				}
			}
			continue;
		}
		if(c < C - 1){
			if(x + A[r][c] < X[r][c+1]){
				X[r][c+1] = x + A[r][c];
				P.insert(make_pair(X[r][c+1],make_pair(r,c+1)));
			}
		}
		if(0 < c){
			if(x + A[r][c-1] < X[r][c-1]){
				X[r][c-1] = x + A[r][c-1];
				P.insert(make_pair(X[r][c-1],make_pair(r,c-1)));
			}
		}
		if(r < R -1){
			if(x + B[r][c] < X[r+1][c]){
				X[r+1][c] = x + B[r][c];
				P.insert(make_pair(X[r+1][c],make_pair(r+1,c)));
			}
		}
		if(x + 1 < X[r + R][c]){
			X[r + R][c] = x + 1;
			P.insert(make_pair(X[r+R][c],make_pair(r +R,c)));
		}
	}
	cout << X[R-1][C-1] << endl;
	return(0);
}

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define REP(i,k,n) for(ll i=k;i<ll(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define UNIQUE(a) sort(all(a));a.erase(unique(all(a)),a.end())
#define decimal cout<<fixed<<setprecision(10)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)
using ll=long long;
using P=pair<ll,ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
constexpr ll inf=1001001001001001;
constexpr int INF=1001001001;
constexpr int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
void YesNo(bool b){if(b)out("Yes");else out("No");}
void yesno(bool b){if(b)out("yes");else out("no");}
void YESNO(bool b){if(b)out("YES");else out("NO");}
ll modpow(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%mod;}a=a*a%mod;b>>=1;}return c;}
vi calc(ll x){vi v;while(x>0){v.eb(x%10);x/=10;}reverse(all(v));return v;}

int main(){
    int r,c;
    cin>>r>>c;
    int n=r*c;
    vector<vector<P>> edge(2*n);
    rep(i,n){
        edge[i].eb(P(i+n,1));
        edge[i+n].eb(P(i,0));
    }
    rep(i,r)rep(j,c-1){
        int a; cin>>a;
        edge[i*c+j].eb(P(i*c+j+1,a));
        edge[i*c+j+1].eb(P(i*c+j,a));
    }
    rep(i,r-1)rep(j,c){
        int b; cin>>b;
        edge[i*c+j].eb(P((i+1)*c+j,b));
        edge[(i+1)*c+j+n].eb(P(i*c+j+n,1));
    }
    vi cost(2*n,INF);
    SPQ(P) q;
    q.push(P(0,0));
    cost[0]=0;
    while(!q.empty()){
        ll x=q.top().se,z=q.top().fi;
        q.pop();
        if(cost[x]<z) continue;
        for(P y:edge[x]){
            if(chmin(cost[y.fi],cost[x]+y.se)){
                q.push(P(cost[y.fi],y.fi));
            }
        }
    }
    out(cost[r*c-1]);
    //rep(i,2*n) outvp(edge[i]);
}


#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // int64_t
using ull = unsigned long long;
using pll = pair<ll,ll>;
using pii = pair<int,int>;

#define REP(i,m,n) for(int i = m; i <= (n); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)

const int INF = 1e9+7;   //10oku7

int main() {

  int V, T,S,D;
  cin >> V >> T >> S >> D;
  if (V* T <= D  &&  D <= V*S){
    cout<< "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

}

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cassert>
#include <iostream>
#include <stdio.h>
#include <time.h>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)

#define MOD 1000000007

ll d[20][20];

int main(){
  ll h,w,a,b;
  cin>>h>>w>>a>>b;
  vector<ll> v;
  rep(i,0,b){
    v.pb(0);
  }
  rep(i,0,a){
    v.pb(1);
  }
  ll ans = 0;
  do{
    rep(i,0,1<<a){
      vector<ll> v1;
      rep(j,0,a){
        if((i>>j)&1){
          v1.pb(0);
        }
        else{
          v1.pb(1);
        }
      }
      clr(d,-1);
      rep(y,0,h){
        rep(x,0,w){
          d[y][x] = 0;
        }
      }
      ll flag = 1;
      ll index1 = 0;
      ll index2 = 0;
      rep(y,0,h){
        rep(x,0,w){
          if(d[y][x]!=0)continue;
          if(v[index1]==0){
            d[y][x] = 1;
          }
          else{
            if(v1[index2]==0){
              if(d[y][x+1]==0){
                d[y][x] = 2;
                d[y][x+1] = 2;
              }
              else{
                flag = 0;
              }
            }
            else{
              if(d[y+1][x]==0){
                d[y][x] = 2;
                d[y+1][x] = 2;
              }
              else{
                flag = 0;
              }
            }
            index2++;
          }
          index1++;
        }
      }

      if(flag==1)ans++;
    }
  }while(next_permutation(all(v)));
  cout << ans << endl;
  return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define forr(i,n) for(int i=0;i<n;i++)
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define pb push_back
//#define mp make_pair
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define CASE(t) ll t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vi vector<ll>
#define cs(ele) cout<<ele<<'\n'
#define pii pair<ll,ll>
#define MAXN   100001
#define all(d) d.begin(),d.end()
const ll mod=1e9 +7;
//const ll mod=998244353;
//ll Mod(ll n){return ((n%mod)+mod)%mod;}
//ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=mod(res*x);x=mod(x*x);y=mod(y>>1);}return mod(res);}

void fast(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

}
ll f[200005];
ll invfact[200005];
ll power(ll x,ll y){
     ll res=1;
     while(y>0){
         if(y&1){
             res=(res*x)%mod;
         }
         x=(x*x)%mod;
         y>>=1;
    }
    return res;
}
void precal(){
    f[0]=1;
    invfact[0]=1;
    for(int i=1;i<200005;i++){
        f[i]=(f[i-1]*i)%mod;
        invfact[i]=power(f[i],mod-2);
    }
}
ll ncr(ll n,ll k){
    if(n<k||n<0||k<0){
        return 0;
    }
    return ((f[n]*invfact[k])%mod*invfact[n-k])%mod;
}

bool prime[10000011];
void primenumbers(ll n)
{

    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }

}
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}
int spf[MAXN];

void sieve()
{
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)

        spf[i] = i;

    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (int j=i*i; j<MAXN; j+=i)

                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}
vector<int> getFactorization(int x)
{
    vector<int> ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}

int main()
{
  fast();
  ll a,b;
  cin>>a>>b;
  double ans=(double)(a-b)/(double)a;
  ans=ans*100.00;
  cout<<fixed<<setprecision(9)<<ans;

  return 0;
}


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

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

int64_t gcd(int64_t a,int64_t b){
    if(a < b)
    {
        int64_t temp = a;
        a = b ;
        b = temp;
    }
    int64_t copya = a;
    int64_t copyb = b;
    int64_t r = a%b ;
    while (r != 0)
    {
        a = b ;
        b = r ;
        r = a%b ;
    }
    return b ;

}
int solve(string s, int start){
    if (start >= s.size())
    {
        return 100000000 ;
    }

    string at = "atcoder" ;
    if (start >= at.size())
    {
        return 0 ;
    }

    int l = 100000000 ;
    int same = 100000000 ;
    for (int i = start; i < s.size(); i++)
    {
        if (l == 100000000)
        {
            if (s.at(i) > at.at(start))
            {
                l = i -start ;
                break ;
            }

        }
        if (same == 100000000)
        {
            if (s.at(i) == at.at(start))
            {
                same = i - start ;
            }

        }

    }
    if (same != 100000000)
    {
        for (int i = 0; i < same; i++)
        {
            swap(s.at(same+start -i),s.at(same+start -i-1)) ;
        }
    }

    if(l != 100000000 && same != 100000000)
    {
        return min(l,solve(s,start+1)+same) ;
    }else if (same == 100000000)
    {
        return l  ;
    }else
    {
        return solve(s,start+1)+same ;
    }

}

int main(){
    string at = "atcoder" ;
    int t ;
    cin >> t ;
    for (int cases = 0; cases < t; cases++)
    {
        string s ;
        cin >> s ;
        string copy = s ;
        sort(copy.begin(),copy.end()) ;
        reverse(copy.begin(),copy.end()) ;
        if (at >= copy)
        {
            cout << -1 << endl ;
            continue ;
        }
        int ans = solve(s,0) ;

        cout << ans << endl ;
    }

}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(all(v));
#define RSORT(v) sort(rall(v));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

ll comb(int n, int r) {
  if (r * 2 > n) r = n - r;
  ll ans = 1;
  for (int i = 1; i <= r; ++i) {
    ans *= n - i + 1;
    ans /= i;
  }
  return ans;
}

void solve(long long L) { cout << comb(L - 1, 11) << endl; }

int main() {
  // cout << fixed << setprecision(5);

  long long L;
  scanf("%lld", &L);
  solve(L);
  return 0;
}


#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

vector<vector<int>> to;

vector<int> used, color, order;

int now;

void dfs(int i){
  if(used[i] == 1) return;
  used[i] = 1;
  order.push_back(i);
  for(int s: to[i]) dfs(s);
}

void color_dfs(int i){
  if(i == order.size()){
    // for(int c: color) cout << c << " ";
    // cout << endl;
    now++;
    return;
  }
  int o = order[i];
  rep(c,3){
    bool ok = true;
    for(int s: to[o]) if(c == color[s]) ok = false;
    if(ok){
      color[o] = c;
      color_dfs(i+1);
    }
  }
  color[o] = -1;
  return;
}

int main()
{
  int n, m;
  cin >> n >> m;
  to = vector<vector<int>>(n);

  int a, b;
  rep(i,m){
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  long long ans = 1;

  used = vector<int>(n,0);
  color = vector<int>(n,-1);
  rep(i,n){
    if(used[i] == 1) continue;
    // used[i] = 1;
    order = vector<int>();
    dfs(i);

    // cout << "dfs is finished" << endl;
    // cout << "order" << endl;
    // for(int o: order) cout << o << " ";
    // cout << endl;

    now = 0;
    color[i] = 0;
    color_dfs(1);
    ans *= 3*now;
  }
  cout << ans << endl;
}

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

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


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

// DFSの実装例
bool vis[21];
ll par[21];
map<ll, vector<ll>> edges;
stack<ll> st;
vector<ll> con;
vector<vector<ll>> cons;
void dfs(ll num) {
  vis[num] = true;
  con.push_back(num);
  auto es = edges[num];
  for (auto e : es) {
    if (!vis[e]) {
      st.push(e);
      vis[e] = true;
      par[e] = num;
    }
  }
  while (!st.empty()) {
    auto top = st.top();
    st.pop();
    dfs(top);
  }
};

int main() {
  ll N, M;
  cin >> N >> M;
  rep(i, 0, M) {
    ll ai, bi;
    cin >> ai >> bi;
    edges[ai].push_back(bi);
    edges[bi].push_back(ai);
  }

  vis[0] = true;
  rep(i, 1, N + 1) {
    if (!vis[i]) {
      con = {};
      dfs(i);
      cons.push_back(con);
    }
  }

  ll ans = 1;
  for (auto co : cons) {
    map<ll, ll> col;
    ll comb = 0;
    col[co[0]] = 1; // 1 for red, 2 for green, 3 for blue;
    rep(bit, 0, 1 << (co.size() - 1)) {
      for (ll i = 1; i < (ll)co.size(); ++i) {
        ll flag = bit & (1 << (co.size() - 1 - i));
        if (col[par[co[i]]] == 1) {
          col[co[i]] = flag ? 3 : 2;
        } else if (col[par[co[i]]] == 2) {
          col[co[i]] = flag ? 3 : 1;
        } else if (col[par[co[i]]] == 3) {
          col[co[i]] = flag ? 2 : 1;
        }
      }
      bool abl = true;
      for (ll i = 0; i < (ll)co.size(); ++i) {
        for (auto edge : edges[co[i]]) {
          if (col[edge] == col[co[i]]) {
            abl = false;
            break;
          }
          if (abl == false)
            break;
        }
      }
      if (abl) {
        comb += 1;
      }
    }
    comb *= 3;

    ans *= comb;
  }
  cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  long n,m;cin>>n;
  set<long> s;
  rep(i,n){cin>>m; s.insert(m);}

  //cout<<*rbegin(s)<<endl;

  while(1){
    if(*rbegin(s)==*begin(s)||s.size()==1){cout<<*rbegin(s);break;}
    else {
      //if(s.size()==1){cout<<*begin(s);return 0;}
       s.insert(*rbegin(s)-*begin(s)); s.erase(*rbegin(s));  /*cout<<*rbegin(s)-*begin(s)<<endl;*/ }

  }

}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
using ll = long long;
ll GCD(ll a, ll b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

int main() {
    int n;
    cin >> n;
    ll res = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        res = GCD(res, a);
    }
    cout << res << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long lnt;
const lnt P = 1000000007;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, m, s;
lnt PowMod(lnt x, int k) {
	lnt ret = 1;
	for (; k; k >>= 1, x = x*x%P)
		if (k&1) ret = ret*x%P;
	return ret;
}
lnt C(int n, int m) {
	lnt ret = 1;
	for (int i = 2; i <= m; i++)
		ret = ret*i%P;
	ret = PowMod(ret, P-2);
	for (int i = n; i > n-m; i--)
		ret = ret*i%P;
	return ret;
}
int main() {
	read(n), read(m);
	for (int i = 0, a; i < n; i++)
		read(a), s += a;
	return printf("%lld\n", C(n+m, n+s)), 0;
}

#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main() {
    string n;
    cin >> n;
    int nlen = n.size(), res=-1;

    rep2(i, 1, 1<<nlen){
        int sum = 0;
        rep(j, nlen){
            if((i>>j) & 1){
                sum += n[j] - '0';
                // cout << sum << endl;
            }
        }
        if(sum%3==0){
            // cout << i << " " << sum << endl;
            res = max(res, __builtin_popcount(i));
        }
    }

    if(res == -1){
        cout << res << endl;
    }else{
        cout << nlen - res << endl;
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <bitset>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr int MOD = 998244353;

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  ll N, K, M; cin >> N >> K >> M;
  vector<ll> A(N);
  for(int i = 0; i < N-1; ++i) cin >> A[i];

  ll f = N * M;
  REP(i, N-1) f -= A[i];

  if (f > K) {
    cout << -1;
  } else {
    cout << max(0LL, f);
  }

  return 0;
}

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

int main()
{
  int n,k,m,s=0,i;

  cin>>n>>k>>m;
    int arr[n];

  for(i=0;i<n-1;i++)
  {
    cin>>arr[i];
    s+=arr[i];
  }
  int ans=n*m-s;
  if(ans>k)
  cout<<"-1"<<endl;
  else if(ans<0)
  cout<<"0"<<endl;
  else
  cout<<ans<<endl;

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define vec vector
#define rep(i,n) for (int i=0; i<(n); i++)
#define print(a) cout << a << endl
#define fix(n) fixed << setprecision(n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define Yes "Yes"
#define YES "YES"
#define No "No"
#define NO "NO"

int main() {
  int N, M, Q;
  cin >> N;
  vec<ll> X(N), Y(N);
  rep(i,N)
    cin >> X[i] >> Y[i];
  cin >> M;
  vec<ll> ax(M+1), ay(M+1), bx(M+1), by(M+1), sw(M+1,0);
  ax[0] = 1; ay[0] = 1;
  bx[0] = 0; by[0] = 0;
  rep(i,M) {
    int op,p;
    cin >> op;
    if ((op==1 && sw[i]==1) || (op==2 && sw[i]==0)) {
      ax[i+1] = ax[i];
      ay[i+1] = ay[i]*(-1);
      bx[i+1] = bx[i];
      by[i+1] = by[i]*(-1);
      sw[i+1] = (sw[i]+1)%2;
    } else if ((op==1 && sw[i]==0) || (op==2 && sw[i]==1)) {
      ax[i+1] = ax[i]*(-1);
      ay[i+1] = ay[i];
      bx[i+1] = bx[i]*(-1);
      by[i+1] = by[i];
      sw[i+1] = (sw[i]+1)%2;
    } else {
      cin >> p;
      if ((op==3 && sw[i]==1) || (op==4 && sw[i]==0)) {
        ax[i+1] = ax[i];
        ay[i+1] = ay[i]*(-1);
        bx[i+1] = bx[i];
        by[i+1] = 2*p-by[i];
        sw[i+1] = sw[i];
      } else {
        ax[i+1] = ax[i]*(-1);
        ay[i+1] = ay[i];
        bx[i+1] = 2*p-bx[i];
        by[i+1] = by[i];
        sw[i+1] = sw[i];
      }
    }
  }
  cin >> Q;
  rep(_,Q) {
    int A,B;
    cin >> A >> B;
    B--;
    ll x = X[B], y = Y[B];
    x = ax[A]*x + bx[A];
    y = ay[A]*y + by[A];
    if (sw[A])
      swap(x,y);
    print(x << " " << y);
  }
  return 0;
}


#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
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; }
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
}
std::uint32_t euclidean_gcd(std::uint32_t a, std::uint32_t b){return b != 0 ? euclidean_gcd(b, a % b) : a;}
const string YES = "Yes";
const string NO = "No";
void solve(long long V, long long T, long long S, long long D){
    if(V*T<=D && V*S>=D){
        cout<<NO<<endl;
    }
    else cout<<YES<<endl;
}
int main(){
    long long V;
    scanf("%lld",&V);
    long long T;
    scanf("%lld",&T);
    long long S;
    scanf("%lld",&S);
    long long D;
    scanf("%lld",&D);
    solve(V, T, S, D);
    return 0;
}

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

int main(){
  int V;
  int T;
  int S;
  int D;
  cin >> V >> T >> S >> D;
  if(V*T <= D && V*S >= D) {
    cout << "No";
  }
  else {
    cout << "Yes";
  }
}


//#pragma GCC optimize ("O2")
//#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;

#include<cstdio>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		if ((ct = *ci++) >= '0') {
			tmp = tmp * 10 + ct - '0';
			if (*ci++ == '0') {
				tmp = tmp * 10;
				ci++;
			}
		}
	}
	return tmp;
}
int tmp[200001];
void pakuri_sort(int N, int A[]) {
	const int b = 8;
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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

	int N = getint(), M = getint();

	int A[200010];
	rep1(i, M) A[i] = getint();
	A[0] = 0;
	A[M + 1] = N + 1;
	pakuri_sort(M, A + 1);

	int saishou = 2e9;
	int t = 0;
	rep(i, M + 1) {
		int kari = A[i + 1] - A[i] - 1;
		if (kari) {
			if (kari < saishou) saishou = kari;
			tmp[t++] = kari;
		}
	}

	if (saishou > 1.5e9) {
		printf("0");
		return 0;
	}

	ll kotae = 0;
	rep(i, t) kotae += (tmp[i] + saishou - 1) / saishou;

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

	Would you please return 0;
}

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rrep(i,n) for(ll i=n-1; i>=0; i--)
#define fi first
#define se second
#define pcnt __builtin_popcountll
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
string zero_padding(int val, int nf){ ostringstream sout;sout << setfill('0') << setw(nf) << val; return sout.str();};
const ld eps = 1e-10;
ull mo = 1000000007;
ld PI=asin(1)*2;
//using namespace atcoder;
int main(){
    ll N;
    cin >> N;
    vector<ld> A(N),B(N),C(N),D(N);
    ld aw=0,bw=0,cw=0,dw=0;
    rep(i,N){
        cin >> A[i] >> B[i];
        aw += A[i]; bw += B[i];
        // A[i] *= N;
        // B[i] *= N;
    }
    aw /= N; bw /= N;
    rep(i,N){
        cin >> C[i] >> D[i];
        cw += C[i]; dw += D[i];
    //     C[i] *= N;
    //     D[i] *= N;
    }
    cw /= N; dw /= N;
    rep(i,N){
        A[i] += (-aw);
        B[i] += (-bw);
    }
    rep(i,N){
        C[i] += (-cw);
        D[i] += (-dw);
    }
    vector<pair<ld,ld>> sp(N),tp(N);
    rep(i,N){
        sp[i].fi = A[i];
        sp[i].se = B[i];
    }
    rep(i,N){
        tp[i].fi = C[i];
        tp[i].se = D[i];
    }
    sort(sp.begin(), sp.end(), [](const auto &p1, const auto &p2) {
        if(-eps + atan2(p2.second, p2.first) <= atan2(p1.second, p1.first) && atan2(p1.second, p1.first) <= eps + atan2(p2.second, p2.first)){
            return p1.first*p1.first + p1.second*p1.second < p2.first*p2.first + p2.second*p2.second;
        }
        return atan2(p1.second, p1.first) < atan2(p2.second, p2.first);
    });
    sort(tp.begin(), tp.end(), [](const auto &p1, const auto &p2) {
        if(-eps + atan2(p2.second, p2.first) <= atan2(p1.second, p1.first) && atan2(p1.second, p1.first) <= eps + atan2(p2.second, p2.first)){
            return p1.first*p1.first + p1.second*p1.second < p2.first*p2.first + p2.second*p2.second;
        }
        return atan2(p1.second, p1.first) < atan2(p2.second, p2.first);
    });
    // cout << endl;
    // rep(i,N){
    //     cout << "(" << sp[i].fi << "," << sp[i].se << ")" << endl;
    // }
    // rep(i,N){
    //     cout << "(" << tp[i].fi << "," << tp[i].se << ")" << endl;
    // }
    if(N == 1) drop("Yes");
    rep(d,N){
        ll cnt =0;
        ld xs = sp[0].fi;
        ld ys = sp[0].se;
        ld xt = tp[d].fi;
        ld yt = tp[d].se;
        ld angle = atan2l(yt,xt)-atan2l(ys,xs);
        rep(i,N){
            ld x1 = sp[i].fi*cosl(angle)-sp[i].se*sinl(angle);
            ld y1 = sp[i].fi*sinl(angle)+sp[i].se*cosl(angle);
            bool f = 0;
            rep(j,N){
                ld x2 = tp[j].fi;
                ld y2 = tp[j].se;
                if( x2 - eps <= x1 && x1 <= x2 + eps){
                    if( y2 - eps <= y1 && y1 <= y2 + eps){
                        f = 1;
                    }
                }
            }
            cnt += f;
        }
        if(cnt == N) drop("Yes");
    }
    cout << "No" << endl;
}


#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 n,a,p,x,ans=INF;
    cin>>n;
    rep(i,n){
        cin>>a>>p>>x;
        if(x-a>0) chmin(ans,p);
    }
    if(ans==INF) ans=-1;
    cout<<ans<<endl;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
    long long A,B,C,D; cin >> A >> B >> C >> D;
    long long blue = A, red = 0;
    for(int i = 1; i <= A; i++){
        blue += B;
        red += C;
        if(blue <= D*red){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; debug_print(__VA_ARGS__); } while(false)
template<typename T, typename... Ts> void debug_print(const T &t, const Ts &...ts) { cerr << t; ((cerr << ", " << ts), ...); cerr << endl; }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, const T& b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, const T& b) { if (a < b) {a = b; return true; } return false; }
template<typename T, typename... Ts> void print(const T& t, const Ts&... ts) { cout << t; ((cout << ' ' << ts), ...); cout << '\n'; }
template<typename... Ts> void input(Ts&... ts) { (cin >> ... >> ts); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin, a, b, c;
    print(a + b + c - min({a, b, c}));
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int a, b, c;

int main() {
//  freopen("in.txt", "r", stdin);
  cin >> a >> b >> c;
  cout << max({a + b, a + c, b + c}) << '\n';
  return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#define rg register
inline int read(){
	rg int x=0,fh=1;
	rg char ch=getchar();
	while(ch<'0' || ch>'9'){
		if(ch=='-') fh=-1;
		ch=getchar();
	}
	while(ch>='0' && ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*fh;
}
const int maxn=1e4+5;
bool vis[maxn][maxn];
int n,x[maxn],y[maxn],r[maxn],ax[maxn],ay[maxn],bx[maxn],by[maxn];
int main(){
	n=read();
	for(rg int i=1;i<=n;i++) x[i]=read(),y[i]=read(),r[i]=read();
	for(rg int i=1;i<=n;i++) ax[i]=x[i],ay[i]=y[i],bx[i]=x[i]+1,by[i]=y[i]+1;
	for(rg int i=1;i<=n;i++){
		for(rg int j=ax[i];j<=bx[i];j++){
			for(rg int k=ay[i];k<=by[i];k++){
				vis[j][k]=1;
			}
		}
	}
	rg int nsum=0;
	for(rg int i=1;i<=n;i++){
		while(ax[i]>=1){
			nsum=(bx[i]-ax[i]+1)*(by[i]-ay[i]+1);
			rg int jud=1;
			for(rg int j=ay[i];j<=by[i];j++){
				if(vis[ax[i]-1][j]==1) jud=0;
			}
			if(!jud) break;
			rg double tmp1=(double)std::min(nsum,r[i])/(double)std::max(nsum,r[i]);
			rg double tmp2=(double)std::min(nsum+by[i]-ay[i]+1,r[i])/(double)std::max(nsum+by[i]-ay[i]+1,r[i]);
			if((1-tmp1*tmp1)*(1-tmp1*tmp1)>(1-tmp2*tmp2)*(1-tmp2*tmp2)){
				nsum+=by[i]-ay[i]+1;
				for(rg int j=ay[i];j<=by[i];j++){
					vis[ax[i]-1][j]=1;
				}
				ax[i]--;
			} else {
				break;
			}
		}
		while(ay[i]>=1){
			nsum=(bx[i]-ax[i]+1)*(by[i]-ay[i]+1);
			rg int jud=1;
			for(rg int j=ax[i];j<=bx[i];j++){
				if(vis[j][ay[i]-1]==1) jud=0;
			}
			if(!jud) break;
			rg double tmp1=(double)std::min(nsum,r[i])/(double)std::max(nsum,r[i]);
			rg double tmp2=(double)std::min(nsum+bx[i]-ax[i]+1,r[i])/(double)std::max(nsum+bx[i]-ax[i]+1,r[i]);
			if((1-tmp1*tmp1)*(1-tmp1*tmp1)>(1-tmp2*tmp2)*(1-tmp2*tmp2)){
				nsum+=bx[i]-ax[i]+1;
				for(rg int j=ax[i];j<=bx[i];j++){
					vis[j][ay[i]-1]=1;
				}
				ay[i]--;
			} else {
				break;
			}
		}
		while(bx[i]<=9999){
			nsum=(bx[i]-ax[i]+1)*(by[i]-ay[i]+1);
			rg int jud=1;
			for(rg int j=ay[i];j<=by[i];j++){
				if(vis[bx[i]+1][j]==1) jud=0;
			}
			if(!jud) break;
			rg double tmp1=(double)std::min(nsum,r[i])/(double)std::max(nsum,r[i]);
			rg double tmp2=(double)std::min(nsum+by[i]-ay[i]+1,r[i])/(double)std::max(nsum+by[i]-ay[i]+1,r[i]);
			if((1-tmp1*tmp1)*(1-tmp1*tmp1)>(1-tmp2*tmp2)*(1-tmp2*tmp2)){
				nsum+=by[i]-ay[i]+1;
				for(rg int j=ay[i];j<=by[i];j++){
					vis[bx[i]+1][j]=1;
				}
				bx[i]++;
			} else {
				break;
			}
		}
		while(by[i]<=9999){
			nsum=(bx[i]-ax[i]+1)*(by[i]-ay[i]+1);
			rg int jud=1;
			for(rg int j=ax[i];j<=bx[i];j++){
				if(vis[j][by[i]+1]==1) jud=0;
			}
			if(!jud) break;
			rg double tmp1=(double)std::min(nsum,r[i])/(double)std::max(nsum,r[i]);
			rg double tmp2=(double)std::min(nsum+bx[i]-ax[i]+1,r[i])/(double)std::max(nsum+bx[i]-ax[i]+1,r[i]);
			if((1-tmp1*tmp1)*(1-tmp1*tmp1)>(1-tmp2*tmp2)*(1-tmp2*tmp2)){
				nsum+=bx[i]-ax[i]+1;
				for(rg int j=ax[i];j<=bx[i];j++){
					vis[j][by[i]+1]=1;
				}
				by[i]++;
			} else {
				break;
			}
		}
	}
	for(rg int i=1;i<=n;i++) printf("%d %d %d %d\n",ax[i],ay[i],bx[i],by[i]);
	return 0;
}

#include <cstdio>
using namespace std;
int n,m,k;
int c[102],d[102],a[102],b[102],ans;
bool vis[102];
void dfs(int x){
	if(x==k){
		int cnt=0;
		for(int i=0;i<m;++i){
			if(vis[a[i]]&&vis[b[i]])++cnt;
		}
		if(ans<cnt)ans=cnt;
	}else if(vis[c[x]]&&vis[d[x]]){
		dfs(x+1);
	}else{
		if(!vis[c[x]]){
			vis[c[x]]=true;
			dfs(x+1);
			vis[c[x]]=false;
		}
		if(!vis[d[x]]){
			vis[d[x]]=true;
			dfs(x+1);
			vis[d[x]]=false;
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;++i){
		scanf("%d%d",a+i,b+i);
	}
	scanf("%d",&k);
	for(int i=0;i<k;++i){
		scanf("%d%d",c+i,d+i);
	}
	dfs(0);
	printf("%d\n",ans);
	return 0;
}


//@Author: KeinYukiyoshi

// clang-format off
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
#define int long long
using namespace std;
#define stoi stoll
#define fi first
#define se second
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep2(i, a, b) for (int i = (int)(a), i##_len=(b); i < i##_len; i++)
#define rep3(i, a, b) for (int i = (int)(a), i##_len=(b); i >= i##_len; i--)
#define FOR(i, a) for (auto &i: a)
#define ALL(obj) begin(obj), end(obj)
#define _max(x) *max_element(ALL(x))
#define _min(x) *min_element(ALL(x))
#define _sum(x) accumulate(ALL(x), 0LL)

const int MOD   = 1000000007;
// const int MOD    = 998244353;
// const int INF    = (int)1e18;
// const int INF    = 10000000000007; // 1e13 + 7
// const int INF    = LLONG_MAX; // 9.2e18
const double EPS = 1e-8;
const double PI  = 3.14159265358979;
template <class T> using V = vector<T>;
template <class T> using VV = vector<vector<T>>;
template <class T> using VVV = vector<vector<vector<T>>>;
template <class T, class S>  using P = pair<T, S>;
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b;return true;}return false;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b;return true;}return false;}
int _ceil(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); }
template<class T> T chmod(T &a, T mod=MOD) {a =  a >= 0 ? a % mod : a - (mod * _ceil(a, mod)); return a;};
int _mod(int a, int mod=MOD) {return a >= 0 ? a % mod : a - (mod * _ceil(a, mod));}
int _pow(int a, int b) {int res = 1;for (a %= MOD; b; a = a * a % MOD, b >>= 1)if (b & 1) res = res * a % MOD;return res;}
struct mint {long long x;mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}mint operator-() const { return mint(-x); }mint &operator+=(const mint a) {if ((x += a.x) >= MOD) x -= MOD;return *this;}mint &operator-=(const mint a) {if ((x += MOD - a.x) >= MOD) x -= MOD;return *this;}mint &operator*=(const mint a) { (x *= a.x) %= MOD;return *this; }mint operator+(const mint a) const { return mint(*this) += a; }mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; }mint pow(long long t) const {if (!t) return 1;mint a = pow(t >> 1);a *= a;if (t & 1) a *= *this;return a;}mint inv() const { return pow(MOD - 2); }mint &operator/=(const mint a) { return *this *= a.inv(); }mint operator/(const mint a) const { return mint(*this) /= a; }};istream &operator>>(istream &is, mint &a) { return is >> a.x; }ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
// clang-format on

class CRingosFavoriteNumbers2 {
public:
  static void solve(istream &cin, ostream &cout) {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int N;
    cin >> N;
    V<int> A(N);
    rep(i, N) cin >> A[i];
    rep(i, N) A[i] = A[i] % 200;
    V<int> check(200);
    rep(i, N) check[A[i]]++;
    int ans = 0;
    rep(i, 200) ans += check[i] * (check[i] - 1) / 2;
    cout << ans << endl;
  }
};

signed main() {
  CRingosFavoriteNumbers2 solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
const int INF =2e5+1;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    int t=1 ;
    ll f[INF];
    f[1]=1;
    for(int i =2;i<INF;i++){
        f[i]=f[i-1]+i;
    }
   while(t--){
       int n ;
       cin>>n ;
       int a[n];
       for(int i =0;i<n;i++){
           cin>>a[i];
           a[i]%=200;
       }
       sort(a,a+n);
       ll ans = 0;
       int num = 0 ;
       for(int i = 1 ; i<n;i++){
           if(a[i]==a[i-1]){
               num++;
           }
           else if (num>=1) {
               ans += f[num];
               num=0;
           }
           else {num = 0;}
       }
       if (num>=1) {
               ans += f[num];
           }
           else {num = 0;}

cout<<ans<<endl;

   }
}


#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
int main(){
  ll a,b,mx=1; cin >> a >> b;
  vector<ll> count(b+1,0);
  for(ll i=a; i<=b; i++){
    for(ll j=1; j*j<=i; j++){
      if(i%j==0){
        if(j*j==i){
          count[j]++;
        }
        else{
          count[j]++;
          count[i/j]++;
        }
      }
    }
  }
  for(ll i=1; i<=b; i++){
    if(count[i]>=2 && mx < i){
      mx = i;
    }
  }
  cout << mx << endl;
}

    #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    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; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    using P=pair<int,int>;
    const int INF=1001001001;
    const int mod=1e9+7;

    struct mint {
      ll x;
      mint(ll x=0):x((x%mod+mod)%mod){}
      mint operator-() const { return mint(-x);}
      mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
      }
      mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
      }
      mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
      mint operator+(const mint a) const { return mint(*this) += a;}
      mint operator-(const mint a) const { return mint(*this) -= a;}
      mint operator*(const mint a) const { return mint(*this) *= a;}
      mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
      }

      mint inv() const { return pow(mod-2);}
      mint& operator/=(const mint a) { return *this *= a.inv();}
      mint operator/(const mint a) const { return mint(*this) /= a;}
     };
      istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
      ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
      struct combination {
      vector<mint> fact, ifact;
      combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
      }
      mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
      }
     } c(200005);

    void rot(vector<vector<int>>& s){
      int h=s.size(),w=s[0].size();
      vector<vector<int>>t(w,vector<int>(h));
      swap(s,t);
      rep(j,w){
        rep(i,h){
          s[j][i]=t[h-1-i][j];
        }
      }
    }

    int main(){
      int h,w;cin>>h>>w;
      vector<string>s(h);
      rep(i,h){cin>>s[i];}
      vector<vector<int>>a(h,vector<int>(w));
      int cnt=0;
      vector<vector<int>>sum(h,vector<int>(w));
      rep(i,h){
        rep(j,w){
          if(s[i][j]=='.'){a[i][j]=1;sum[i][j]=1;cnt++;}
        }
      }
      rep(z,4){
        vector<vector<int>>res(h,vector<int>(w));
        rep(i,h){
          rep(j,w){
            if(j&&a[i][j]&&a[i][j-1]){res[i][j]+=(res[i][j-1]+1);}
            sum[i][j]+=res[i][j];
          }
        }
        rot(a);
        rot(sum);
        swap(h,w);
      }
      vector<mint>two(h*w+1,1);
      rep(i,h*w){two[i+1]=two[i]*2;}

      mint ans=0;
      rep(i,h){
        rep(j,w){
          ans+=two[cnt]-two[cnt-sum[i][j]];
        }
      }
      cout<<ans<<endl;
      return 0;
    }


#include<bits/stdc++.h>
using namespace std;
const int mx=505;
const int mod=998244353;
int n,m,dp[mx][mx];
long long tmp=1;
char a[mx][mx];
int main() {
//	freopen("data.in","r",stdin);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%s",a[i]+1);
	for(int i=1;i<=n;i++) {
		int col=0,col2=0;
		for(int j=0;i-j>=1&&j+1<=m;j++) {
			if(a[i-j][j+1]=='B') {col=1;}
			if(a[i-j][j+1]=='R') {col2=1;}
		}
		if(!col&&!col2) tmp*=2,tmp%=mod;
		else if(col&&col2) {
			printf("0");
			return 0;
		}
	}
	for(int i=2;i<=m;i++) {
		int col=0,col2=0;
		for(int j=0;n-j>=1&&i+j<=m;j++) {
			if(a[n-j][i+j]=='B') {col=1;}
			if(a[n-j][i+j]=='R') {col2=1;}
		}
		if(!col&&!col2) tmp*=2,tmp%=mod;
		else if(col&&col2) {
			printf("0");
			return 0;
		}
	}
	printf("%lld",tmp);
}

#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i,a,b) for (ll i = (a); i < (ll)(b); i++)
#define rng(x) (x).begin(), (x).end()
#define rrng(x) (x).rbegin(), (x).rend()
#define popcnt(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

using namespace std;
template <class T, class U> inline bool chmax(T &a, const U &b) { return (a < b ? a = b, 1 : 0); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return (a > b ? a = b, 1 : 0); }
template <class T> using vc = vector<T>;
template <class T> using vv = vc<vc<T>>;
template <class T> using vvv = vc<vv<T>>;
template <class T> using PQ = priority_queue<T, vc<T>, greater<T>>;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using ti3 = tuple<int, int, int>;
using tl3 = tuple<ll, ll, ll>;
using vi = vc<int>;
using vl = vc<ll>;
using vpl = vc<pll>;
using vvi = vv<int>;
using vvl = vv<ll>;

const ld pi = 3.141592653589793;
const ll linf = 1001001001001001001LL;
const int inf = 1001001001;

vi dx = {1, 0}, dy = {0, 1};

int main() {
  ll h, w;
  cin >> h >> w;
  vc<string> s(h);
  rep(i,h) cin >> s[i];
  vvl dist(h, vl(w, linf));
  dist[0][0] = 0;
  queue<pll> que;
  que.emplace(0, 0);
  while(!que.empty()) {
    auto [y, x] = que.front();
    que.pop();
    rep(i,2) {
      ll ny = y+dy[i], nx = x+dx[i];
      if (0 <= ny && ny < h && 0 <= nx && nx < w && dist[ny][nx] == linf) {
        dist[ny][nx] = dist[y][x]+1;
        que.emplace(ny, nx);
      }
    }
  }
  vpl state(h+w-1);
  rep(i,h) rep(j,w) {
    auto &[R, B] = state[dist[i][j]];
    if (s[i][j] != '.') (s[i][j] == 'R' ? R : B) += 1;
  }
  ll ans = 1;
  const ll mod = 998244353;
  rep(i,h+w-1) {
    auto [R, B] = state[i];
    if (R >= 1 && B >= 1) ans *= 0;
    else if (R >= 1 || B >= 1) ans *= 1;
    else ans *= 2;
    ans %= mod;
  }
  cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ppll pair<ll,pair<ll,ll>>
#define pll pair<ll,ll>
#define rep(i,x,y) for(ll i=x;i<=y;i++)
#define inf 1e16
#define imin INT_MIN
#define imax INT_MAX
#define pb push_back
#define pf push_front
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vvb vector<vector<bool>>
#define vb vector<bool>
int mod =1e9+7;
bool comp(pair<int,int> a,pair<int,int> b)
{
    if(a.second == b.second) return a.first<b.first;
    return a.second<b.second;
}

void display(vll a)
{
    for(auto& val: a) cout<<val<<' ';
}

ll power(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if (b & 1) ans = (ans * a)%mod;
        a  = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

const ll N = 1e5 + 1;
ll F[N], inv[N];
void precompute(ll n)
{
    F[0] = 1;
    inv[0] = 1;
    rep(i, 1, n)
    {
        F[i] = (F[i-1] * i) % mod;
        inv[i] = power(F[i], mod - 2);
    }
}

bool isPrime(ll n)
{
    if(n<2) return false;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0) return false;
    }
    return true;
}

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

    ll n,q;
    cin>>n>>q;
    vll a(n);
    for(auto& val: a) cin>>val;
    sort(begin(a), end(a));
    vll b(n);
    rep(i, 0, n-1)
    {
        b[i] = a[i] - (i+1);
    }
    while(q--)
    {
        ll k;
        cin >> k;
        int idx = lower_bound(begin(b), end(b), k) - begin(b);
        if(idx < n) cout<<k + idx<<'\n';
        else {
            cout<<(k + (a[n -1] - b[n-1]))<<'\n';
        }
    }
    return 0;
}

#include"iostream"
#include"cstdio"
#include"cmath"
#include"cstring"
#include"algorithm"
#include"stack"
#include"queue"
using namespace std;

#define read(x) scanf("%d",&x)
#define readl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAXN 200005

int n,q,c;
int t,x,y;
struct  node
{
	int ls,rs,sum;
}a[MAXN*50];
int opt=0,rt[MAXN];
int fa[MAXN];

int getf(int u){return (fa[u]==u)?u:fa[u]=getf(fa[u]);}

void update(int k){a[k].sum=a[a[k].ls].sum+a[a[k].rs].sum;}

int build(int k,int l,int r,int x)
{
	if(!k) k=++opt;
	if(l==r)
	{
		a[k].sum+=1;
		return k;
	}
	int mid=(l+r)>>1;
	if(x<=mid) a[k].ls=build(a[k].ls,l,mid,x);
	else a[k].rs=build(a[k].rs,mid+1,r,x);
	return update(k),k;
}

int merge(int u,int v,int l,int r)
{
	if(!u||!v) return u|v;
	if(l==r)
	{
		a[u].sum+=a[v].sum;
		return u;
	}
	int mid=(l+r)>>1;
	a[u].ls=merge(a[u].ls,a[v].ls,l,mid);
	a[u].rs=merge(a[u].rs,a[v].rs,mid+1,r);
	return update(u),u;
}

void work(int x,int y)
{
	int u=getf(x),v=getf(y);
	if(u==v) return;
	else
	{
		fa[v]=u;
		rt[u]=merge(rt[u],rt[v],1,200000);
	}
}

int query(int k,int l,int r,int x)
{
	if(!k) return 0;
	if(l==r) return a[k].sum;
	int mid=(l+r)>>1;
	return (x<=mid)?query(a[k].ls,l,mid,x):query(a[k].rs,mid+1,r,x);
}

int main()
{
	read(n),read(q);
	for(int i=1;i<=n;i++)
	{
		read(c),fa[i]=i;
		rt[i]=build(rt[i],1,200000,c);
	}
	for(int i=1;i<=q;i++)
	{
		read(t),read(x),read(y);
		if(t==1) work(x,y);
		else
		{
			int p=getf(x);
			printf("%d\n",query(rt[p],1,200000,y));
		}
	}
	return 0;
}


#include <iostream>

using namespace std;

int main() {

	long long b, c; cin >> b >> c;

	long long ans = 0;

	if (b == 0) {
		if (c == 0)
			ans = 1;
		else
			ans = c;
	}
	else if (0 < b) {
		if (c < 2 * b)
			ans = c + 1;
		else
			ans = 2 * b + 1;
		if (2 < c)
			ans += c - 2;
	}
	else {
		if (c == 0)
			ans = 1;
		else if (c == 1)
			ans = 2;
		else if (c == 2)
			ans = 3;
		else {
			if (c <= 2 * abs(b))
				ans = c;
			else
				ans = 2*abs(b)+1;
			ans += c - 1;
		}
	}

	cout << ans << endl;

}

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

const int N = 200005;

typedef pair<long long, long long> pll;

long long b, c;

int solve() {
  scanf("%lld %lld", &b, &c);

  long long ans = 0;
  pll range1 = {b - c/2, b + max(0LL, c - 2) / 2};
  pll range2 = {-b - (c - 1) / 2, -b + (c - 1) / 2};

  // cerr << range1.first << " " << range1.second << endl;
  // cerr << range2.first << " " << range2.second << endl;

  if (max(range1.first, range2.first) <= min(range1.second, range2.second)) ans = max(range1.second, range2.second) - min(range1.first, range2.first) + 1;
  else ans = range1.second - range1.first + 1 + range2.second - range2.first + 1;

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

  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  for (int tc = 0; tc < t; ++tc) {
    solve();
  }
  return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) ;
#endif

vector<string> vec_splitter(string s)
{
    s += ',';
    vector<string> res;
    while (!s.empty())
    {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}

void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM)
{
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T)
{
    if (idx > 0)
        cerr << ", ";
    else
        cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss;
    ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}

typedef long long ll;
typedef long double ld;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)((x).size())
#define pb push_back
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
#define X first
#define Y second
//#define debug(x) cerr << #x << " : " << (x) << " "
const long double PI = 3.14159265358979323846;
const long double eps = (1e-15);
//enum
//{
//    LESS, EQUAL, GREATER
//};

//int dcmp(ld x, ld y, ld EPS = eps)
//{
//    if (fabs(x - y) <= EPS)
//        return EQUAL;
//    return x > y ? GREATER : LESS;
//}
int n;
const int MAX_N = 2e5 + 5;
vector<pair<int, int> > adj[MAX_N];
int val[MAX_N];
enum {EQUAL, NOT_EQUAL};
void dfs(int u, int state, int num)
{
    if (state == EQUAL)
        val[u] = num;
    else
    {
        val[u] = 1;
        if (num == 1)
            val[u]++;
    }

    for (auto e : adj[u])
    {
        int v = e.first, c = e.second;
        if (val[v] != -1)
            continue;
        if (c == val[u])
            dfs(v, NOT_EQUAL, c);
        else
            dfs(v, EQUAL, c);
    }
}
void myMain()
{
    cin >> n;
    int m;
    cin >> m;
    for (int i = 0; i < m; ++i)
    {
        int u, v, c;
        cin >> u >> v >> c;
        --u; --v;
        adj[u].pb({v, c});
        adj[v].pb({u, c});
    }
    clr(val, -1);
    dfs(0, EQUAL, 1);
    for (int u = 0; u < n; ++u)
        cout << val[u] << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    int tc = 1;
//    cin >> tc;
    while(tc--)
        myMain();
}

#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif
struct UF {
public:
  int N,G/* # of disjoint sets */;
  UF(int N): N(N) { init(N); }
  void init(int N) {
    par=vector<int>(N),sz=vector<int>(N,1);
    for(int i=0; i<N; ++i) par[i]=i,sz[i]=1;
    G=N;
  }
  int find(int x) { return par[x]==x?x:par[x]=find(par[x]); }
  int size(int x) { return sz[find(x)]; }
  bool sameset(int x, int y) { return find(x)==find(y); }
  int unite(int x, int y) {
    x=find(x),y=find(y);
    if(x==y) return x;
    int p=x,c=y;
    if(sz[p]<sz[c]) swap(p,c);
    G--,sz[p]=sz[c]=sz[p]+sz[c];
    par[c]=p;
    return p;
  }
private:
  vector<int> par,sz;
};
// $ cp-batch KeepGraphConnected | diff KeepGraphConnected.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address KeepGraphConnected.cpp && ./a.out

/*

 11/21/2020

 21:31-

 */

const int MAX_N=1e6+1;
III E[MAX_N];
int N,M;

vector<II> G[MAX_N];
void solve() {
  REP(i,M) {
    int u,v,c; tie(u,v,c)=E[i];
    G[u].emplace_back(v,c),G[v].emplace_back(u,c);
  }
  VI res(N);
  VI viz(N);
  queue<int> Q;
  Q.emplace(0),viz[0]=1,res[0]=0;
  while(SZ(Q)) {
    int u=Q.front(); Q.pop();
    FORR(p,G[u]) {
      int v,c; tie(v,c)=p;
      if(viz[v]) continue;
      int col;
      if(res[u]!=c) col=c;
      else col=(c+1)%N;
      res[v]=col,viz[v]=1,Q.emplace(v);
    }
  }

  UF uf(N);
  REP(i,M) {
    int u,v,c; tie(u,v,c)=E[i];
    if(res[u]==c&&res[v]!=c) uf.unite(u,v);
    else if(res[v]==c&&res[u]!=c) uf.unite(u,v);
  }
  assert(uf.G==1);

  REP(i,N) cout<<res[i]+1<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N>>M;
  REP(i,M) {
    int u,v,c; cin>>u>>v>>c;
    --u,--v,--c;
    E[i]={u,v,c};
  }
  solve();

  return 0;
}


// author: erray
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    if (n % 2 == 1) {
      cout << "Second";
    } else {
      sort(a.begin(), a.end());
      bool ok = true;
      for (int i = 0; i < n; i += 2) {
        ok &= (a[i] == a[i + 1]);
      }
      cout << (ok ? "Second" : "First");
    }
    cout << '\n';
  }
}

// Problem : D - Let's Play Nim
// Contest : AtCoder - AtCoder Regular Contest 105
// URL : https://atcoder.jp/contests/arc105/tasks/arc105_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

//krishrawat

//----------------------------MACROS-------------------------------------------------
#define pb insert//                                                                 |
#define eb emplace_back//                                                           |
#define ff first//                                                                  |
#define ss second//                                                                 |
typedef long long int ll;//                                                         |
typedef long double ld;//                                                           |
#define all(a) a.begin(), a.end()//                                                 |
#define show(x) cerr << #x << " is " << x << "\n"//                                 |
#define show2(x, y) cerr << #x << " " << #y << " " << x << " " << y << "\n"//       |
typedef vector<ll> vl;//                                                            |
typedef vector<vl> vvl;//                                                           |
typedef pair<ll, ll> pp;//                                                          |
typedef vector<pp> vp;//                                                            |
typedef map<pp, ll> ipi;//                                                          |
typedef map<pp, char> ipc;//                                                        |
typedef map<ll, ll> ii;//                                                           |
typedef set<ll> sl;//                                                               |
typedef multiset<ll> msl;//                                                         |
typedef map<char, ll> ci;//                                                         |
typedef set<pair<ll, ll>> sp;//                                                     |
const ll mod = 1e9 + 7;//                                                           |
const ll N = 1e6 + 1;//                                                             |
//----------------------------------------------------------------------------------

void solve(){
    ll n;cin>>n;
    ii m;
    for(int i=0;i<n;i++){
    	ll k;cin>>k;
    	m[k]++;
    }
    int f=0;
    for(auto i:m){
    	if(i.ss%2) f=1;
    }
    if(n%2){
    	f=!f;
    }
    if(!f) cout<<"Second\n";
    else cout<<"First\n";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    ll t;cin>>t;
    while(t--) solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define faster                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define ff first
#define ss second
#define pb push_back
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * (b / gcd(a, b)))
#define all(a) a.begin(), a.end()
#define mod 10000007
#define num 1000000

/**----data type----*/
typedef long long int ll;
typedef unsigned long long int llu;
int main()
{
    faster
    int n,cnt=0;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; i*j<=n; j++)
        {
            for(int k=1; i*j*k<=n; k++)
            {
                cnt++;
//                    cout<<i<<' '<<j<<' '<<k<<endl;
            }
        }
    }
    cout<<cnt<<endl;
}

#include <cstdio>

long long two(int K) {
	long long ans = 0;
	for(int i = 1, j = 1; i <= K && j <= K; i = j+1, j = K/(K/i)) {
		ans += (j - i + 1) * (K/i);
		if(j == K) break;
	}
	return ans;
}

int main() {
	int K; scanf("%d", &K);
	long long ans = 0;
	for(int i = 1, j = 1; i <= K && j <= K; i = j+1, j = K/(K/i)) {
		ans += (j - i + 1ll) * two(K/i);
		if(j == K) break;
	}
	printf("%lld", ans);
	return 0;
}


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

/* MACROS START */
#define input std::cin
#define for2(i,n) for(int i=0; i<n; i++)
#define for3(i,a,n) for(int i=a; i<n; i++)
#define for4(i,a,n,s) for(int i=a; i<n; i+=s)

using lint = long long int;
using namespace std;

template <typename T>
void printvec(T vec) {
  for (auto& a: vec)
	cout << a << " ";
  cout << endl;
}
/* MACROS END */

/* LIBRARY START */
/* LIBRARY END */

int main() {
  std::ios_base::sync_with_stdio(0);
  lint n; input >> n;
  lint lo = 0, hi = (lint) 1e10;
  while (lo < hi-1) {
	lint mid = (lo+hi)/2;
	if ((mid * (mid+1))/2 <= n+1)
	  lo = mid;
	else
	  hi = mid;
  }
  lint k = lo;
  /* cout << k << endl; */
  cout << n-k + 1 << endl;
}

#include<bits/stdc++.h>
#define int long long int
using namespace std;
int32_t main()
{
	int a; cin >> a;
	int now = 0, ind = 1;
	while(now + ind <= a + 1)
	{
		now += ind;
		ind ++;
	}
	cout << a + 1 - ind + 1  << '\n';
	return 0;
}


//bismillahir rahmanir rahim            //Author:Fayed Anik
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long long
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
#define         FASTREAD                    ios_base::sync_with_stdio(0);cin.tie(nullptr);
#define         endl                        "\n"

//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};

ll a[45];

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    FASTREAD
    ll n,lim,T,now,ans=0,fh,sh;
    cin>>n>>T;
    fh = n/2;
    sh = n/2;
    if( !(n&1) ) fh--;
    if( n&1 ) sh++;
    for(ll i=0;i<n;i++) cin>>a[i];
    vector<ll>fst,sec;
    lim = 1LL<<(fh+1);
    for(ll mask=0;mask<lim;mask++){
        ll sum=0;
        for(ll i=0;i<=fh;i++){
            if( CHECK(mask,i) ) sum += a[i];
        }
        if( sum<=T ) ans = max(ans,sum);
        fst.pb(sum);
    }
    lim = 1LL<<(n-sh);
    for(ll mask=0;mask<lim;mask++){
        ll sum=0;
        for(ll i=sh;i<n;i++){
            if( CHECK(mask,i-sh) ) sum += a[i];
        }
        if( sum<=T ) ans = max(ans,sum);
        sec.pb(sum);
    }
    sort(all(sec));
    for(ll i=0;i<fst.size();i++){
        ll rem = T-fst[i];
        if( rem<0 ) continue;
        now = fst[i];
        ll lw=0,hi=sec.size()-1,mid,pos=-1;
        while(lw<=hi){
            mid=(lw+hi)/2;
            if( sec[mid]<=rem ){
                pos = mid;
                lw = mid+1;
            }
            else{
                hi = mid-1;
            }
        }
        if( pos!=-1 ) now += sec[pos];
        ans = max(ans,now);
    }
    cout << ans << endl;
    return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

using ll = long long;

const int maxn = 55;

int n; ll x;
ll a[maxn];
ll b[maxn];
ll k[maxn];

ll dp[maxn][2];

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

    cin>>n>>x;

    for (int i=1; i<=n; i++) {
	cin>>a[i];
    }

    for (int i=1; i<n; i++) {
	b[i] = a[i+1]/a[i];
    }

    for (int i=n; i>=1; i--) {
	k[i] = x/a[i];
	x %= a[i];
    }

    if (n==1) {
	out(1);
    }

    dp[1][0] = 1;
    if (k[1]!=0) {
	dp[1][1] = 1;
    }

    for (int i=2; i<n; i++) {
	dp[i][0] = dp[i-1][0];
	if (k[i]!=0) { //use a[i] in remainder, initiate carrying
	    dp[i][1] += dp[i-1][0];
	}
	if (k[i]!=b[i]-1) { // let the previous carrying end here
	    dp[i][0] += dp[i-1][1];
	}
	dp[i][1] += dp[i-1][1];
    }

    cout<<(dp[n-1][0]+dp[n-1][1])<<endl;
    return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
#define rprintf(fmt, begin, end) do { const auto end_rp = (end); auto it_rp = (begin); for (bool sp_rp=0; it_rp!=end_rp; ++it_rp) { if (sp_rp) putchar(' '); else sp_rp = true; printf(fmt, *it_rp); } putchar('\n'); } while(0)

int N;

int normal(int x) {
    int t = 20;
    while (x >= N) {
	x &= ~(1<<t);
	t--;
    }
    return x;
}

void MAIN() {
    scanf("%d", &N);

    REP (i, N) {
	int a = normal(i * 2);
	int b = normal(i * 2 + 1);
	printf("%d %d\n", a+1, b+1);
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()

const int N=50;
int t[N][N],s[N][N],sy,sx,highscore,dy[4]={-1,0,0,1},dx[4]={0,-1,1,0};
string highans;
using B=bitset<1500>;
const double TIMELIMIT=1.95*CLOCKS_PER_SEC;
clock_t start;

void dfs(int score,B used,int y,int x,string ans){
  if(clock()-start>TIMELIMIT){
    cout<<highans<<endl;
    exit(0);
  }
  REP(i,4){
    int Y=y+dy[i],X=x+dx[i];
    if(Y<0||Y>=N||X<0||X>=N||used[t[Y][X]])continue;
    dfs(score+s[Y][X],used|(B(1)<<t[Y][X]),Y,X,ans+"ULRD"[i]);
  }
  if(score>highscore){
    highscore=score;
    highans=ans;
  }
}

signed main(){
  start=clock();
  cin>>sy>>sx;
  REP(i,N)REP(j,N)cin>>t[i][j];
  REP(i,N)REP(j,N)cin>>s[i][j];
  dfs(0,B(1)<<t[sy][sx],sy,sx,"");
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll, ll>;
const ll INF = ll(1e18);
const ll mod = ll(998244353);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (a) - 1; (i) >= (b); --(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
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 (b<a) { a=b; return 1; } return 0; }
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int multipf(vector<string>& s){
    if(s.size() == 0)return 0;
    cout << s[0];
    rep1(i, s.size() - 1)cout << " " << s[i];
    cout << endl;
    return 0;
}

int multipf(vector<ll>& n){
    if(n.size() == 0)return 0;
    cout << n[0];
    rep1(i, n.size() - 1)cout << " " << n[i];
    cout << endl;
    return 0;
}

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b, ll m){
    ll ans = 1;
    while(b) {
        if(b & 1LL) ans = ans * a % m;
        ans %= m;
        a = a * a;
        a %= m;
        b >>= 1;
    }
    return ans % m;
}

vector<bool> fcolor(100000,false),f(100000,false);
vl color(100000);
vvl g(100000,vl(0));
vl ans(0);

int dfs(ll n){
    f[n] = true;
    bool ff = false;
    if(!fcolor[color[n]]){
        ans.push_back(n + 1);
        ff = true;
    }
    fcolor[color[n]] = true;
    rep0(i, g[n].size()){
        if(!f[g[n][i]])dfs(g[n][i]);
    }
    if(ff)fcolor[color[n]] = false;
    return 0;
}

//modを確認すること
int main() {
    ll n;
    cin >> n;
    rep0(i, n)cin >> color[i];
    rep0(i, n - 1){
        ll a,b;
        cin >> a >> b;
        --a;
        --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0);
    sort(all(ans));
    rep0(i, ans.size())pf(ans[i]);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*b);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
#define num_l(a,v) POSL(a,v) //v未満の要素数
#define num_eql(a,v) POSU(a,v) //v以下の要素数
#define num_h(a,v) (a.size() - POSU(a,v)) //vより大きい要素数
#define num_eqh(a,v) (a.size() - POSL(a,v)) //v以上の要素数
// static_cast< long long ll >

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin >> n >> m;

	vector<int> A(n);
	FOR(i,0,n){
		cin >> A[i];
	}

	map<int,int> in,no;

	FOR(i,0,n+1)no[i] = 1;

	int ans = n;
	FOR(i,0,m){
		in[ A[i] ]++;
		if(in[A[i]] == 1){
			no.erase(A[i]);
		}
	}

	ans = min( ans, (*no.begin()).first );

	FOR(i,m,n){
		in[A[i]]++;
		if(in[A[i]] == 1){
			no.erase(A[i]);
		}

		in[A[i-m]]--;
		if(in[A[i-m]] == 0){
			no[A[i-m]] = 1;
		}

		ans = min( ans, (*no.begin()).first );

	}

	cout << ans << endl;
}


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

ll solve(ll y, ll x, unordered_map<ll, ll> &mp)
{
    if(mp.find(y)!=mp.end())
        return mp[y];

    if(x>=y)
        return x-y;

    if(y%2==0)
    {
        ll temp = min(1 + solve(y/2, x, mp), y-x);
        mp[y] = temp;
        return temp;
    }
    else
    {
        ll temp = min(2 + min(solve((y-1)/2, x, mp), solve((y+1)/2, x, mp)), y-x);
        mp[y] = temp;
        return temp;
    }
}

int main()
{
    ll x, y;
    cin>>x>>y;
    unordered_map<ll, ll> mp;
    cout<<solve(y, x, mp)<<endl;
}

#include <bits/stdc++.h>
//#include <chrono>
#pragma GCC optimize("Ofast")
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()

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

ll N,M,H,W,Q,K,A,B;
string S;
using P = pair<ll, ll>;
const ll INF = (1LL<<60);

template<class T> bool chmin(T &a, const T &b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T &b){
    if(a < b) {a = b; return true;}
    else return false;
}
template<class T> void my_printv(std::vector<T> v,bool endline = true){
    if(!v.empty()){
        for(std::size_t i{}; i<v.size()-1; ++i) std::cout<<v[i]<<" ";
        std::cout<<v.back();
    }
    if(endline) std::cout<<std::endl;
}

ll dfs(ll d, int num, bool minus, mat &dp, mat &visited){
    assert(d < (1LL<<(num + 1)));
    if(num < 0) return (d == 0 ? 0 : INF);
    if(visited[num][minus]) return dp[num][minus];
    visited[num][minus] = true;
    ll &res = dp[num][minus];
    if((d>>num)&1) {
        chmin(res, dfs(d - (1LL << num), num - 1, minus, dp, visited) + 1);
    }else {
        if(d != 0) chmin(res, dfs((1LL << num) - d, num - 1, !minus, dp, visited) + 1);
        chmin(res, dfs(d, num - 1, minus, dp, visited));
    }
    return res;
}

ll solve(int num){
    ll res = num;
    ll from = N<<num, to = K, dif = abs(from - to), plus_max = 1LL<<num;
    res += dif / plus_max;
    dif %= plus_max;
    mat dp(num, vec(2, INF)), visited(num, vec(2, false));
    assert(dif < (1LL<<num));
    return res + dfs(dif, num - 1, false, dp, visited);
}

void solve(){
    ll res = abs(N - K);
    for(int i = 0; (N<<i) < (1LL<<62); ++i){
        chmin(res, solve(i));
    }
    cout<<res<<endl;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin>>N>>K;
    solve();
}