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

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

ll pre[4000100], *p = pre + 1000010;

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

	ll N, K;
	cin >> N >> K;

	ll kei = 0;
	rep(i, N) p[i] = i + 1;
	rep(i, N) p[2 * N - i - 2] = i + 1;
	rep(i, 3 * N + 10) p[i + 1] += p[i];

	ll tmpkei = 0;
	rep(i, 3 * N - 2) {
		tmpkei += p[i] - p[i - N];

		if (tmpkei >= K) {
			tmpkei -= p[i] - p[i - N];
			ll k = K - tmpkei;
			ll ima = 0;
			rep(j, min((int)N - 1, i) + 1) {
				ima += p[i - j] - p[i - j - 1];
				if (ima >= k) {
					ima -= p[i - j] - p[i - j - 1];
					co(j + 1);
					rep(a, N) {
						ll b = i - j - a;
						if (b >= 0 && b < N) {
							ima++;
							if (ima >= k) {
								co(a + 1);
								co(b + 1);
								return 0;
							}
						}
					}
				}
			}
		}
	}

	Would you please return 0;
}

#include<bits/stdc++.h>
using namespace std;
int t,n;
int main(){
        cin>>t>>n;
        cout<<(100*1ll*n+t-1)/t*(100+t)/100-1<<endl;
        return 0;
}


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

const int N = 233333;
const int mod = 10;
const int phi = 4;

int cnt[26];
char s[N];

int main() {
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    ll ans = 0;
    for(int i = n; i >= 1; --i) {
        cnt[(s[i]-'a')]++;
        if(i < n && s[i] == s[i+1]) {
            int len = n - i + 1;
            ans += (len - cnt[s[i]-'a']);
            cnt[s[i]-'a'] = len;
            for(int j = 0; j < 26; ++j) {
                if(j == (s[i]-'a')) continue;
                else cnt[j] = 0;
            }
        }
    }
    printf("%lld\n", ans);
}

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc
#define next          sdNNNmNNNNNNNmds
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot
#define read               tyhyt
#define rank              ytmNmo
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

const int N = 222222;
int cnt[26];
string s;
int n;

int solve() {
    cin >> s;
    n = sz(s);
    int ans = 0;
    rrep(i, 1, n) {
        int c = s[i - 1] - 'a';
        if(i < n && s[i] == c + 'a') {
            ans += n - i - cnt[c];
            fill(cnt, cnt + 26, 0);
            cnt[c] = n - i + 1;
        } else {
            cnt[c]++;
        }
    }
    cout << ans << endl;
    return 0;
}

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


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int main(){
	int n, m = 0; cin >> n;
	for(; m < n; m=m*2+1);
	rep(i,n){
		int t = i*2, u = t+1;
		while(t >= n) t -= 1 << (31 - __builtin_clz(t));
		while(u >= n) u -= 1 << (31 - __builtin_clz(u));
		cout << t+1 << " " << u+1 << "\n";
	}
}


#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int N;
ll W;
map<ll, ll> st;

int main()
{
  ll si, ti, pi;
  ll ps;

  cin >> N >> W;
  for (int i=0; i<N; i++) {
    cin >> si >> ti >> pi;
    if (st.count(si) == 0) {
      st.emplace(si, pi);
    } else {
      ps = st[si]+pi;
      st[si] = ps;
    }
    if (st.count(ti) == 0) {
      st.emplace(ti, -pi);
    } else {
      ps = st[ti]-pi;
      st[ti] = ps;
    }
  }
  ll psum=0;

//for (auto it=st.begin(); it!= st.end(); it++) printf("%lld %lld\n", it->first, it->second);
//printf("\n");

  for (auto it=st.begin(); it!= st.end(); it++) {
    psum += it->second;
//printf("%lld %lld %lld\n", it->first, it->second, psum);
    if (psum > W) {
      printf("No\n");
      return 0;
    }
  }

  printf("Yes\n");
  return 0;
}

#include <bits/stdc++.h>
#define ll long long int
#define omar main
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//priority_queue push_back make_pair emplace vector double float unordered_map unordered_set queue stack sort begin resize clear second first continue break
using namespace std;
int omar(){ fastIO
	int n, s, d; cin >> n >> s >>d;
	vector<pair<int, int>>spells(n);
	bool answer = 0;
	for (int i = 0 ; i < n ; i++){
		cin >> spells[i].first >> spells[i].second;
		answer = answer || ((spells[i].first < s) && spells[i].second > d);
	}
	puts((answer? "Yes": "No"));
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//
//using namespace __gnu_pbds;
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//class Timer {
//    clock_t start;
//    string name;
//public:
//    Timer() {name = "";start = clock();}
//    Timer(string s){name = s;start = clock();}
//    ~Timer() {fprintf(stderr, "%s: %.3gs\n", name.c_str(), 1.0*(clock() - start) / CLOCKS_PER_SEC);}
//};

//#define isValid(a, b) ((a) >= 0 && (a) < (b))
//int dr[]  =  {0, -1, -1, -1,  0,  1, 1, 1};
//int dc[]  =  {1,  1,  0, -1, -1, -1, 0, 1};

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define um unordered_map
#define us unordered_set
#define endl '\n'
#define what_is(x) cerr << fixed << setprecision(2) << boolalpha << #x << " = " << x << endl

const double EPS = 1e-9;
const double PI = acos(-1.0);

template<typename T> inline T sq(T a){return a*a;}
template<typename T1, typename T2> inline pair<T1, T2> mp(T1 a, T2 b){return make_pair(a, b);}
template<typename T1, typename T2> inline T1 safeMod(T1 a, T2 m){return (a%m + m)%m;}/*handling negative sign of remainder*/
template<typename T1, typename T2> inline bool isEq(T1 a, T2 b){return abs(a - b) < EPS;}
template<typename T1, typename T2, typename T3> inline bool isEq(T1 a, T2 b, T3 eps){return abs(a - b) < eps;}
template<typename T> inline bool isKthBitOn(T n, int k){assert(n <= numeric_limits<T>::max());assert(k<=numeric_limits<T>::digits);T ONE = 1;return bool((n & (ONE<<k)));}
template<typename T> inline void setKthBit(T& n, int k){assert(n <= numeric_limits<T>::max());assert(k<=numeric_limits<T>::digits);T ONE = 1;n = (n|(ONE<<k));}
//mt19937 rng((int)chrono::steady_clock::now().time_since_epoch().count());
//template<typename T> inline T nextRand(T lo, T hi){return uniform_int_distribution<T>(lo, hi)(rng);}

#define toRad(deg) ((deg)*PI/180.0)
#define toDeg(rad) ((rad)*180.0/PI)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int oo = 0x3f3f3f3f;
const int MAX = 200010;
const int MOD = 1000000007;
const int precision = 10;

//#define HAS_TEST_CASE
void solve(int kas){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int&x:a)cin >> x;
    ll s = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        s += a[i]*x;
    }
    if(s == 0)cout << "Yes\n";
    else cout << "No\n";
}

int main()
{
    //assert(freopen("in.txt", "r", stdin));
    //assert(freopen("out.txt", "w", stdout));
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif
    //cout << fixed << setprecision(precision);
    int tc = 1;
#ifdef HAS_TEST_CASE
    cin >> tc;
#endif
    for(int _ = 1; _ <= tc; _++){
        solve(_);
    }
    return 0;
}

#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (long long i = (s); i < (long long)(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>;
using Pll = pair<ll, ll>;

int main() {
    int n;
    cin >> n;
    ll sum = 0;
    vector<ll> a, b;
    rep(i, n){
        ll x;
        cin >> x;
        a.push_back(x);
    }
    rep(i, n) {
        ll y;
        cin >> y;
        b.push_back(y);
    }

    rep(i, n){
        sum += a[i]*b[i];
    }

    if(sum==0){
        cout << "Yes";
    }else{
        cout << "No";
    }
    cout << endl;
    return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;
class unionfind{
    int n;
    vector<int>par;
    vector<int>rank;
public:
    unionfind(int n_){
        n=n_;
        par.resize(n,-1);
        rank.resize(n,0);
    }
    int find(int x){
        if(par[x]<0)
            return x;
        return par[x]=find(par[x]);
    }
    void marge(int a,int b){
        a=find(a);
        b=find(b);
        if(a==b)
            return;
        if(rank[a]<rank[b])
            swap(a,b);
        par[b]=a;
        if(rank[a]==rank[b])
            rank[a]++;
    }
    bool same(int a,int b){
        return find(a)==find(b);
    }
    int size(int x){
        return -(par[find(x)]);
    }
};
vector<pair<int,int>>G[100000];
int ans[100000],n;
void dfs(int v,int par,int col){
    if(ans[par]==col)
        ans[v]=col%n+1;
    else
        ans[v]=col;
    for(int i=0;i<G[v].size();i++)
        if(G[v][i].first!=par)
            dfs(G[v][i].first,v,G[v][i].second);
}
signed main(){
    int m,u,v,c;
    cin>>n>>m;
    unionfind uf(n);
    while(cin>>u>>v>>c){
        u--,v--;
        if(uf.same(u,v))
            continue;
        uf.marge(u,v);
        G[u].emplace_back(v,c);
        G[v].emplace_back(u,c);
    }
    ans[0]=1;
    for(int i=0;i<G[0].size();i++)
        dfs(G[0][i].first,0,G[0][i].second);
    for(int i=0;i<n;i++)
        cout<<ans[i]<<endl;
}

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;

inline void MAX(int &a,const int &b) {if(b>a) a=b;}
inline void MIN(int &a,const int &b) {if(b<a) a=b;}
inline int max(const int &a,const int &b) {return a>b?a:b;}
inline int min(const int &a,const int &b) {return a<b?a:b;}

const int N=2e5+5;

int mx,n,m,a[N],b[N];
int tmp[N],len;

struct BIT {
	int c[N];
	long long d[N];
	inline void addc(int pos,int key) {for(int i=pos ; i<=mx ; i+=i&-i) c[i]+=key;}
	inline void addd(int pos,long long key) {for(int i=pos ; i<=mx ; i+=i&-i) d[i]+=key;}
	inline int sumc(int pos) {int res=0;for(int i=pos ; i ; i-=i&-i) res+=c[i];return res;}
	inline long long sumd(int pos) {long long res=0;for(int i=pos ; i ; i-=i&-i) res+=d[i];return res;}
	inline long long query(int key) {
		return sumd(mx)-sumd(key)+1LL*sumc(key)*tmp[key];
	}
}TA,TB;

struct ask {
	int t,x;
	long long y;
	inline ask (int T=0,int X=0,int Y=0) : t(T),x(X),y(Y) {}
}w[N];

int q;

int main() {
	tmp[++len]=0;
	scanf("%d%d",&n,&m);
	scanf("%d",&q);
	for(int i=1 ; i<=q ; ++i) scanf("%d%d%d",&w[i].t,&w[i].x,&w[i].y),tmp[++len]=w[i].y;
	sort(tmp+1,tmp+len+1);
	mx=unique(tmp+1,tmp+len+1)-tmp-1;
	TA.addc(1,n),TB.addc(1,m);
	long long ans=0;
	for(int i=1 ; i<=q ; ++i) {
		int t=w[i].t,x=w[i].x,y=w[i].y,p=lower_bound(tmp+1,tmp+mx+1,y)-tmp;
		if(t==1) {
			int po=lower_bound(tmp+1,tmp+mx+1,a[x])-tmp;
			ans-=TB.query(po),TA.addc(po,-1),TA.addd(po,-a[x]);
			ans+=TB.query(p),TA.addc(p,1),TA.addd(p,y);
			a[x]=y;
		}
		else {
			int po=lower_bound(tmp+1,tmp+mx+1,b[x])-tmp;
			ans-=TA.query(po),TB.addc(po,-1),TB.addd(po,-b[x]);
			ans+=TA.query(p),TB.addc(p,1),TB.addd(p,y);
			b[x]=y;
		}
		printf("%lld\n",ans);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  vector<ll> a;
  ll s=0;
  REP(i,1,n) {
    a.pb(i);
    s+=i;
  }
  REP(i,1,m) {
    a.pb(-i);
    s-=i;
  }
  if(n<m) {
    a.pb(100000000);
    s+=100000000;
    a.pb(-s);
  } else {
    a.pb(-100000000);
    s-=100000000;
    a.pb(-s);
  }
  PR(a,a.size());
}

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

#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> a(n+1);
    rep(i,n+1)cin >> a[i];
    int k = 1e9+7;
    for(int i=0;i<n;i++){
        chmin(k,abs(a[i] - a[i+1]));
    }
    cout << k << endl;
    for(int j=0;j<k;j++){
        for(int i=0;i<=n;i++){
            if(j < a[i] % k){
                cout << (a[i] + k - 1)/k << " ";
            }else{
                cout << a[i]/k << " ";
            }
        }
        cout << endl;
    }
}


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

#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define endl "\n"
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pi;
ll zero = 0;
ll one = 1;

int fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    return 0;
}

int main()
{
    fast();
    cout << setprecision(12);
    ll ttt = 1;
    // cin >> ttt;
    while (ttt--)
    {
        // Code Here
        // cout<<"nice"<<endl;
        ll n;
        cin >> n;
        ll answer = 1e18;
        for (int i = 0; i < 65; i++)
        {
            ll a, b = (ll)pow(2, i), c;
            a = n / b;
            c = n % b;
            // cout << a << " " << b << " " << c << endl;
            answer = min(answer, a + i + c);
            if (a == 0)
                break;
        }
        cout << answer << endl;
    }
    return 0;
}

#include<bits/stdc++.h>
#include<tuple>
typedef long long ll;
#define INF 9999999999
#define mod 1000000007
#define eps 1e-9
#define pi acos(-1)
using namespace std;
typedef pair<ll,ll>du;
ll n,ans,res;
int main(){
    ios::sync_with_stdio(0);
    cin>>n;
    ans=INF;
    for(ll i=0;(n>>i)!=0;i++){
        if((n>>i)&1){
            res=i+(n>>i)+n%((ll)1<<i);
            //cout<<(1<<i)<<endl;
            ans=min(ans,res);
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, n) for (int i = (int)(l); i < (int)(n); i++)
#define drep(i, l, n) for (int i = (int)(n); i > (int)(l); i--)
#define INF INT_MAX
#define def (200007)
#define MOD (1000000007)
typedef vector<int> veci;
typedef vector<vector<int>> Veci;
typedef vector<int64_t> vecit;
typedef vector<vector<int64_t>> Vecit;
typedef int64_t intt;
typedef vector<vector<double>> Vecd;
typedef vector<double> vecd;
typedef pair<int, int> P;
/*veci のときdist.resize(N) Veciのとき2回resize;
dp.assign(N,-1);*/

int main(){
  int a,b,c;cin>>a>>b>>c;
  int at;
  if(a<b){
    at=a;
    a=b;
    b=at;
  }
  if(b<c){
    at=b;b=c;c=at;
  }
  if(a<b){
    at=a;a=b;b=at;
  }
  if((a-b)==(b-c))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

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

typedef long double ld;
typedef long long int ll;
typedef pair<int, int> pi;
typedef pair<long long, long long> pll;

#define ff first
#define ss second
#define pb push_back
#define int long long   // Make sure to use ll everywhere while commenting this, to avoid overflow
#define sz(v) (int)v.size()
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define f(i,l,r) for(long long i=l;i<=r;i++)
#define rf(i,r,l) for(long long i=r;i>=l;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

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

const int N = 2e5 + 5, mod = 1e9 + 7, bit = 61;

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

int getRand(int l, int r)
{
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}

int p[N], dep[N], tin[N], tout[N], tim = 0;
vector<int> adj[N], store[N];
int n;

void dfs(int u, int par, int d)
{
	dep[u] = d;
	tin[u] = ++tim;
	store[dep[u]].pb(tin[u]);
	for (auto &v : adj[u])
	{
		if (v == par)
		{
			continue;
		}
		dfs(v, u, d + 1);
	}
	tout[u] = tim;
}

signed main()
{
	fast;

	int t = 1;
	// cin >> t;
	f(tc, 1, t)
	{
		cin >> n;
		f(i, 2, n)
		{
			cin >> p[i];
			adj[p[i]].pb(i);
			adj[i].pb(p[i]);
		}
		dfs(1, 0, 0);
		f(i, 0, n - 1)
		{
			sort(all(store[i]));
		}
		int q;
		cin >> q;
		f(i, 1, q)
		{
			int u, d;
			cin >> u >> d;
			int ans = upper_bound(all(store[d]), tout[u]) - upper_bound(all(store[d]), tin[u] - 1);
			cout << ans << endl;
		}
	}
	return 0;
}


//PochurSolveKortaHobaa
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b,c;
    cin>>a>>b>>c;

    if(c==0){
        while(1){
            a--;
            if(a<=0){
                    cout<<"Aoki";
                    break;
            }
            b--;
            if(b<=0){
                    cout<<"Takahashi";
                    break;
            }
        }
    }
    else{
            while(1){
                 b--;
                 if(b<=0){
                        cout<<"Takahashi";
                         break;
                 }
                a--;
                if(a <=0){
                        cout<<"Aoki";
                        break;
                }
            }
    }
    /*if(c==0){
        if(a>b)cout<<"Takahashi";
        else cout<<"Aoki";
    }
    else{
        if(a>b)cout<<"Aoki";
        else cout<<"Takahashi";
    }*/
}
/*
          -NEVER GIVE UP.
          -Recite QURAN.
          -The harder it looks the easier it'll be.
          -Remember how you started.
          -Why you doing this?                          */

#include<iostream>
using namespace std;
int main(){
    int a,b,c;cin>>a>>b>>c;
    if(a==0 && c==1 && b==0){
        cout<<"Takahashi"<<endl;
        return 0;
    }
    while(a && b){
        if(!c){
            --a;
        }else{
            --b;
        }
        c=!c;
    }
    if(a){
        cout<<"Takahashi"<<endl;
    }else{
        cout<<"Aoki"<<endl;
    }

    return 0;
}


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

int main(){
	ll N; cin >> N;
	ll a,b=0,c, ans=1e18;
	for(ll j=1; j<=N; b++,j=j*2){
		a = N/j;
		c = N%j;
		ans = min(ans, a+b+c);
	}

	cout << ans << endl;
	return 0;
}

#include<iostream>
using namespace std;

int main()
{
  	long long int num;
  	cin>>num;
    long long int ans =0;
  	long long int ans2;
    long long int one =1;
  	for(long long int i=0;num>(one<<(i-one));i++)
    {
      //(num&((2<<i)-1))
      if((ans<=(num-(num>>i)*(one<<i)))&&ans!=0)
      {
      break;
      }
      ans2=i+(num>>i)+(num-(num>>i)*(one<<i));

      if(ans>ans2||ans==0)
      {
      ans = ans2;
      }
    }
  cout<<ans;
	return 0;
}


// doot diddly donger cuckerino Hahahahahah

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

#define all(x)  (x).begin(), (x).end()
const ld PI = acos(-1);

template <typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template <typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
template <typename T, typename U>
std::ostream& operator<<(std::ostream& stream, const pair<T, U>& p) {
  return stream << p.first << " " << p.second;
}
template <typename T>
std::ostream& operator<<(std::ostream& out, const vector<T>& vec) {
  for (const T& x: vec) out << x << ' ';
  return out;
}
template <typename T>
std::istream& operator>>(std::istream& in, vector<T>& vec) {
  for (auto& x: vec) in >> x;
  return in;
}

class BVillageOfMPeople {
public:

  void solve() {
    int n, m, k;
    cin >> k >> n >> m;
    vector<long long> a(k);
    cin >> a;
    ll sum = 0;
    vector<long long> res;
    for (int i = 0; i < k; ++i) {
      ll val = abs(m * 1ll * a[i] / n);
      sum += val;
      res.push_back(val);
    }
    vector<pair<long long, int>> vec;
    for (int i = 0; i < k; ++i) {
      vec.emplace_back(a[i] * m % n, i);
    }
    sort(vec.rbegin(), vec.rend());
    for (int i = 0; i < m - sum; ++i) {
      res[vec[i].second]++;
    }
    cout << res << '\n';
  }
};

int32_t main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	BVillageOfMPeople solver;

	solver.solve();
	return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vec vector
#define psb push_back
#define ppb pop_back
#define mkp make_pair
#define fst first
#define scd second
#define ins insert
#define psf push_front
#define ppf pop_front
using namespace std;
const ll maxk = 1e5;
ll n, m, k, a[maxk], b[maxk];
bool test(ll g) {
	//cout << g << "G\n";
	ll i, avail = m;
	for(i = 0; i < k; i++) {
		ll bmin = (a[i] - g + n - 1) / n;
		bmin = max(bmin, 0ll);
		//cout << bmin << " ";
		ll bmax = (a[i] + g) / n;
		if(bmin > bmax) {
			return false;
		}
		b[i] = bmin;
		avail -= b[i];
		if(avail < 0) {
			return false;
		}
	}
	for(i = 0; i < k && avail > 0; i++) {
		ll bmax = (a[i] + g) / n;
		if(bmax - b[i] <= avail) {
			avail -= (bmax - b[i]);
			b[i] = bmax;
		}
		else {
			b[i] += avail;
			avail = 0;
		}
	}
	return avail == 0;
	/*for(i = 0; i < k; i++) {
		bmin = (a[i] - g + n - 1) / n;
		bmax = a[i] / n;
		if(bmin <= bmax) {
			b[i] = bmin;
			avail -= bmin;
			if(avail < 0) {
				return false;
			}
		}
		else {
			bmin = (a[i] + n - 1) / n + (a[i] % n == 0);
			bmax = (a[i] + g) / n;
			if(bmin <= bmax) {
				b[i] = bmin;
				avail -= bmin;
				if(avail < 0) {
					return false;
				}
			}
			else {
				return false;
			}
		}
	}*/
}
int main() {
	ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	cin >> k >> n >> m;
	for(ll i = 0; i < k; i++) {
		cin >> a[i];
		a[i] *= m;
	}

	ll high = 1e18, low = 0, mid;
	while(low < high) {
		mid = low + ((high-low) / 2);
		if(test(mid)) {
			//cout << "\ntrue "<<mid<<"\n";
			high = mid;
		}
		else {
			low = mid + 1;
		}
	}
	test(low);
	//cout << low << "\n";
	for(ll i = 0; i < k; i++) {
		cout << b[i] << " ";
	}
	return 0;
}


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

int main() {
  int n; cin >> n;
  ll f=0, s=0;
  rep(i,n) { ll a; cin >> a; f+=a; s+=a*a; }
  cout << n*s-f*f << endl;
}


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

#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll          long long
#define ull         unsigned long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
//#define endl        '\n'
#define mod        1000000007
//#define mod        998244353
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define INF         numeric_limits<ll>::max();
#define NINF        numeric_limits<ll>::min();
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))
const long double pi=3.14159265359;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

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

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

int main()
{fast;
 #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
 #endif
 int t=1,n;
 //cin>>t;
 while(t--)
 {double r,x,y;
  cin>>r>>x>>y;
  double d=sqrt(x*x+y*y);
  if(d<r){
    cout<<2;
  }
  else
  cout<<ceil(d/r);
 }
 return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll r,x,y;
  cin >> r >> x >> y;
  ll euqlid = x*x+y*y;
  if(euqlid<r*r){
    cout << 2 << endl;
    return 0;
  }
  ll i = 1;
  while(1){
    if(euqlid<=i*i*r*r) break;
    i++;
  }
  cout << i << endl;
}


//ΔARC120D
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 444444;
int n,a[N],b[N],c[N];
pair<int,int> p[N];
int sz,e[N];
int main()
{
	int i;
	scanf("%d",&n);
	for(i=1;i<=n*2;i++){
		scanf("%d",a+i);
		p[i]=make_pair(a[i],i);
	}
	sort(p+1,p+n*2+1);
	for(i=1;i<=n;i++)
		b[p[i].second]=1;
	for(i=1;i<=n*2;i++){
		if(!sz){
			e[++sz]=i;
			continue;
		}
		if(b[e[sz]]==b[i])
			e[++sz]=i;
		else
			c[i]=0,c[e[sz]]=1,sz--;
	}
	for(i=1;i<=n*2;i++){
		if(c[i])
			cout<<'(';
		else
			cout<<')';
	}
	return 0;
}

#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = long long; using ull = unsigned long long; using pll = pair<ll,ll>; const ll INF = 4e18;
// clang-format on
void print(ll v){
  cout << v << endl;
}
ll calc(vector<pll> &task, ll x){
  ll y = x;
  for(auto tsk: task){
    ll a=tsk.first;
    ll t=tsk.second;
    if(t==1){
      y += a;
    }
    if(t==2){
      y = max(y,a);
    }
    if(t==3){
      y = min(y,a);
    }
  }
  return y;
}

int main() {
    ll n;
    cin >> n;
    vector<pll> task;
    for (ll i = 0; i < n; i++) {
        ll a, t;
        cin >> a >> t;
        task.push_back({a,t});
    }
    ll ymin = calc(task, -INF);
    ll ymax = calc(task, INF);

    // yminと等しくなる最大のx
    ll l = -INF;
    ll r = INF;
    ll xmin = l;
    while(l<=r) {
      ll x=(l+r)/2;
      if(calc(task,x)==ymin){
        xmin = max(xmin, x);
        l = x+1;
      }else{
        r = x-1;
      }
    }

    // ymaxと等しくなる最小のx
    l = -INF;
    r = INF;
    ll xmax = r;
    while(l<=r) {
      ll x=(l+r)/2;
      if(calc(task,x)==ymax){
        xmax = min(xmax, x);
        r = x-1;
      }else{
        l = x+1;
      }
    }
    if(xmax<xmin) xmax=xmin;

    ll q;
    cin >> q;
    for (ll i = 0; i < q; i++) {
        ll x;
        cin >> x;
        if (x < xmin) {
            print(ymin);
        } else if (x < xmax) {
            print((x - xmin) + ymin);
        } else {
            print(ymax);
        }
    }
}


#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int N;
    cin >> N;
    double t[N], l[N], r[N], between[N];
    int ans =0;

    for (int i=0;i<N;i++) {
        cin >> t[i] >> l[i] >> r[i];

        if (t[i] == 1) {

        }
        else if (t[i] == 2) {
            r[i]-=0.2;
        }
        else if (t[i] == 3) {
            l[i]+=0.2;
        }
        else if (t[i] == 4) {
            l[i]+=0.2;
            r[i]-=0.2;
        }
        between[i] = r[i] - l[i];
    }
    for (int i=0;i<N;i++) {
        for (int j=i+1;j<N;j++) {
            if ((r[i] < l[j]) || (r[j] < l[i])) {

            }
            else {
                ans += 1;
            }
        }
    }

    cout << ans <<endl;

    return 0;
}

#include <map>
#include <cmath>
#include <ctime>
#include <queue>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define Lc(x) x << 1
#define Rc(x) x << 1 | 1
#define Int register int
#define Lowbit(x) ((x) & -(x))
#define Swap(a, b) a ^= b ^= a ^= b
#define Abs(x) ((x) < 0 ? -(x) : (x))
#define Max(x, y) ((x) < (y) ? (y) : (x))
#define Min(x, y) ((x) < (y) ? (x) : (y))
#define Isdigit(ch) (ch >= '0' and ch <= '9')

const double Pi = acos (-1.0);
const int MAXN = 1e4 + 10, MAXM = 2e2 + 10;
const LL Mod = 1e9 + 7, INF = 1LL << 60, Inv2 = 5e8 + 4;

inline LL Read () {
	LL f = 0, x = 0;
	char ch = getchar ();

	while (!isdigit (ch) ) {
		f |= (ch == '-'), ch = getchar ();
	}

	while (isdigit (ch) ) {
		x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar ();
	}

	return f ? -x : x;
}

inline void Write (const LL x) {
	if (x < 0 ) {
		putchar ('-'), Write (-x);
		return ;
	}

	if (x > 9 ) {
		Write (x / 10);
	}

	putchar ((x % 10) ^ 48);
	return ;
}

LL Answer;
int BIT[MAXN], Temp[MAXN], Left[MAXN], Right[MAXN];
int n, m, Opt;

inline void Modify (int Index, int Val) {
	while (Index <= m ) {
		BIT[Index] += Val, Index += Lowbit (Index);
	}

	return ;
}

inline LL Query (int Index) {
	LL Res = 0;

	while (Index ) {
		Res += BIT[Index], Index -= Lowbit (Index);
	}

	return Res;
}

signed main () {
	n = Read ();
	Int i, j;

	for (i = 1; i <= n; ++ i ) {
		Opt = Read (), Left[i] = Read () * 2, Right[i] = Read () * 2;

		if (Opt % 2 == 0 ) {
			-- Right[i];
		}

		if (Opt > 2 ) {
			++ Left[i];
		}
	}

	for (i = 1; i <= n; ++ i ) {
		for (j = i + 1; j <= n; ++ j ) {
			if ((Left[i] <= Left[j] and Right[i] >= Left[j]) or (Left[i] <= Right[j] and Right[i] >= Right[j]) or (Left[i] >= Left[j] and Right[i] <= Right[j]) ) {
				++ Answer;
			}
		}
	}

	printf ("%lld\n", Answer);
	return 0;
}


//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define a first
#define b second
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
#define si(x) int(x.size())

#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b;return true;}else return false;}
template<class t,class u> bool chmin(t&a,u b){if(b<a){a=b;return true;}else return false;}

template<class t> using vc=vector<t>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.fi<<","<<p.sc<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
//mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
ll modpow(ll x,ll n, ll mod){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int n, cntv, cnte, deg[400005];
vc<int>edge[400005];
bool vis[400005];
void dfs(int v){
	if(vis[v]) return;
	vis[v] = 1;
	cntv ++;
	cnte += deg[v];
	for(auto at:edge[v]) dfs(at);
}
void solve(){
	cin >> n;
	rep(i, n){
		int a, b; cin >> a >> b;
		edge[a].pb(b);
		edge[b].pb(a);
		deg[a] ++;
		deg[b] ++;
	}
	int ans = 0;
	rep(i, 400005){
		if(vis[i]) continue;
		cntv = cnte = 0; dfs(i);
		if(cntv == cnte/2+1) ans += cntv-1;
		else ans += cntv;
	}
	cout<<ans<<endl;
}
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	int t; t=1; //cin >> t;
	while(t--) solve();
}

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

namespace kuro {

template<typename Cap>
struct MaxFlow {
 public:
  MaxFlow(int n=0) : _n(0) {
    add_vertices(n);
  }
  int add_vertex() {
    ++_n;
    g.resize(_n);
    return _n-1;
  }
  vector<int> add_vertices(int size) {
    assert(size >= 0);
    vector<int> res(size);
    iota(res.begin(), res.end(), _n);
    _n += size;
    g.resize(_n);
    return res;
  }
  int add_edge(int from, int to, Cap cap) {
    assert(0 <= from && from < _n);
    assert(0 <= to && to < _n);
    assert(0 <= cap);
    int m = (int)pos.size();
    pos.emplace_back(from, (int)g[from].size());
    int from_id = (int)g[from].size();
    int to_id = (int)g[to].size();
    if (from == to) ++to_id;
    g[from].push_back(_edge{to, to_id, cap});
    g[to].push_back(_edge{from, from_id, 0});
    return m;
  }
  Cap flow(int s, int t, Cap flow_limit=numeric_limits<Cap>::max()) {
    assert(0 <= s && s < _n);
    assert(0 <= t && t < _n);
    assert(s != t);
    vector<int> level(_n), iter(_n);
    auto bfs = [&]() {
      fill(level.begin(), level.end(), -1);
      queue<int> que;
      level[s] = 0;
      que.emplace(s);
      while (!que.empty()) {
        int v = que.front(); que.pop();
        for (_edge& e : g[v]) {
          if (e.cap == 0 || level[e.to] >= 0) continue;
          level[e.to] = level[v]+1;
          if (e.to ==  t) return;
          que.emplace(e.to);
        }
      }
    };
    auto dfs = [&](auto self, int v, Cap up) {
      if (v == s) return up;
      Cap res = 0;
      int level_v = level[v];
      for (int& i = iter[v]; i < (int)g[v].size(); ++i) {
        _edge& e = g[v][i];
        if (level_v <= level[e.to]) continue;
        if (g[e.to][e.rev].cap == 0) continue;
        Cap d = self(self, e.to, min(up-res, g[e.to][e.rev].cap));
        if (d <= 0) continue;
        g[v][i].cap += d;
        g[e.to][e.rev].cap -= d;
        res += d;
        if (res == up) return res;
      }
      level[v] = _n;
      return res;
    };
    Cap flow = 0;
    while (flow < flow_limit) {
      bfs();
      if (level[t] == -1) break;
      fill(iter.begin(), iter.end(), 0);
      Cap f = dfs(dfs, t, flow_limit-flow);
      if (!f) break;
      flow += f;
    }
    return flow;
  }
 private:
  int _n;
  struct _edge { int to, rev; Cap cap;};
  vector<pair<int, int>> pos;
  vector<vector<_edge>> g;
};

} // namespace kuro
using namespace kuro;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  set<int> s;
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
    s.insert(a[i]);
    s.insert(b[i]);
  }
  int m = s.size();
  MaxFlow<int> g(n);
  auto nums = g.add_vertices(m);
  int start = g.add_vertex();
  int goal = g.add_vertex();
  map<int, int> mp;
  for (int x : s) {
    int id = mp.size();
    mp[x] = id;
  }
  for (int i = 0; i < n; ++i) {
    g.add_edge(start, i, 1);
  }
  for (int i = 0; i < m; ++i) {
    g.add_edge(nums[i], goal, 1);
  }
  for (int i = 0; i < n; ++i) {
    g.add_edge(i, nums[mp[a[i]]], 1);
    g.add_edge(i, nums[mp[b[i]]], 1);
  }
  int ans = g.flow(start, goal, n);
  cout << ans << '\n';
  return 0;
}


#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int n;
vector<pair<int,int>> ab;
int nab = 0;

bool dfs(int sti,int tab){
    bool ret = false;
  //  cout<<sti<<endl;
    if(sti>=2*n+1){
        if(tab==nab)return true;
        else{
            return false;
        }
    }

    for(int c = 1;c+sti<=2*n;c++){
        ll ttab = tab;

       int nextsti = sti+c*2;
       if(nextsti>2*n+1){
           ret = false;
           break;
       }

       bool ok = true;
       for(int i=0;i<c;i++){
           bool cs = false;
           int noru = i+sti;
           int ori = i+sti+c;
           rep(j,n){
               if(ab[j].first==noru){
                   if(ab[j].second==-1||ab[j].second==ori){
                       cs=true;
                   }else{
                       ok=false;
                   }
               }else if(ab[j].second == ori){
                   if(ab[j].first==-1||ab[j].first==noru){
                       cs=true;
                   }else{
                       ok=false;
                   }
               }else if(ab[j].first==ori||ab[j].second==noru){
                   ok = false;
               }
           }
           if(!cs)ttab++;
       }

        if(ok){
            bool s = dfs(nextsti,ttab);
            if(s==true){ret = true;break;}
            else ret = false;
        }else{
             ret = false;
        }
    }
    //cout<<"ret"<<ret<<endl;

    return ret;

}
int main(){
    cin>>n;
    set<int> f;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        ab.push_back({a,b});
        if(a!=-1){
            if(f.find(a)!=f.end()){
                cout<<"No"<<endl;
                return 0;
            }else{
                f.insert(a);
            }
        }
        if(b!=-1){
            if(f.find(b)!=f.end()){
                cout<<"No"<<endl;
                return 0;
            }else{
                f.insert(b);
            }
        }

        if(a!=-1&&b!=-1&&a>=b){
            cout<<"No"<<endl;
            return 0;
        }

        if(a==-1&&b==-1)nab++;

    }
     bool ans = dfs(1,0);

    if(ans){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define FOR(i, m, n) for (ll i(m); i < n; i++)
#define DWN(i, m, n) for (ll i(m); i >= n; i--)
#define REP(i, n) FOR(i, 0, n)
#define DW(i, n) DWN(i, n, 0)
#define F(n) REP(i, n)
#define FF(n) REP(j, n)
#define D(n) DW(i, n)
#define DD(n) DW(j, n)
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using tll = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using vtll = vector<tll>;
using gr = vector<vll>;
using wgr = vector<vpll>;
void add_edge(gr&g,ll x, ll y){ g[x].pb(y);g[y].pb(x); }
void add_edge(wgr&g,ll x, ll y, ll z){ g[x].eb(y,z);g[y].eb(x,z); }
struct d_ {
    template<typename T> d_& operator,(const T& x) {
        cerr << ' ' <<  x; return *this;}
    template<typename T,typename U> d_& operator,(const pair<T,U>& x) {
        cerr << ' ' <<  x.x << ',' << x.y; return *this;}
    template<typename T> d_& operator,(const vector<T>& x) {
        for(auto x: x) cerr << ' ' <<  x; return *this;}
} d_t;
#define dbg(args ...) { d_t,"|",__LINE__,"|",":",args,"\n"; }
#define deb(X ...) dbg(#X, "=", X);
#define EPS (1e-10)
#define INF (1LL<<61)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

const ll N = 207;
ll n;
ll A[N];
ll B[N];
ll Len[N];
ll in[N],out[N];

void end() {
    cout << "No" << endl;
    exit(0);
}

bool solve(ll i) {
    if(i==n) return 1;
    ll len = 1;
    while(i+2*len<=n) {
        bool ok = 1;
        FOR(k,i,i+2*len) {
            ok &= Len[k]==-1 || Len[k]==len;
            if(in[k]) ok &= k-i<len;
            if(out[k]) ok &= k-i>=len;
        }
        FOR(k,i,i+len) {
            if(in[k] && out[k+len]) {
                ok &= in[k]==out[k+len];
            }
        }
        if(ok && solve(i+2*len)) return 1;
        len++;
    }
    return 0;
}

int main(void) {
    ios_base::sync_with_stdio(false);
    CL(Len,-1);
    cin >> n;
    F(n) {
        cin >> A[i] >> B[i];
        if(~A[i]) A[i]--;
        if(~B[i]) B[i]--;
    }
    bool ok = 1;
    set<ll> vals;
    F(n) {
        if(~A[i] && ~B[i]) {
            ok &= A[i]<B[i];
            if(ok) FOR(k,A[i],B[i]+1) Len[k]=B[i]-A[i];
        }
        if(~A[i]) { in[A[i]]=i+1; ok&=!vals.count(A[i]); vals.insert(A[i]); }
        if(~B[i]) { out[B[i]]=i+1; ok&=!vals.count(B[i]); vals.insert(B[i]); }
    }
    n*=2;
    if(!ok) end();
    ok &= solve(0);
    if(!ok) end();
    cout << "Yes" <<endl;
    return 0;
}


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

signed main() {
    int k;
    cin >> k;
    int ans = 0;
    for (ll a = 1; a <= k; a++) {
        for (ll b = 1; a * b <= k; b++){
            for (ll c = 1; a * b * c <= k; c++){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int64_t> A(N);
  rep(i, N) cin >> A.at(i);
  sort(A.begin(), A.end());
  int64_t ans = 0, min;
  rep(i, N) {
    if (i == 0) {
      min = A.at(i);
    } else {
      ans += (A.at(i) - min) * (i - (N - i - 1));
    }
  }
  cout << ans << endl;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>
#include <cstddef>
#include <type_traits>
#include <vector>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i, n) for(int i=0;i<(int)(n);i++)

// トポソ
// O(V + E)
// [入力] 重みなし有効グラフ
// [出力] ソートされた頂点列(0-indexed) DAG じゃ無い場合は空列を返す
// verify http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_4_B
vector<int> toposort(vector<vector<int>> &g){
    int n = (int)g.size();
    vector<int> d(n, 0);     // 入次数
    for(int i = 0; i < n; i++){
        for(int j = 0; j < (int)g[i].size(); j++){
            d[g[i][j]]++;
        }
    }

    // 入次数が 0 の頂点を queue に入れる
    queue<int> que;
    for(int i = 0; i < n; i++){
        if(d[i] == 0) que.push(i);
    }

    vector<int> ret;
    while(!que.empty()){
        int cur = que.front();
        que.pop();
        ret.push_back(cur);

        for(int i = 0; i < (int)g[cur].size(); i++){
            int nxt = g[cur][i];
            d[nxt]--;
            if(d[nxt] == 0) que.push(nxt);
        }
    }

    // DAG じゃなかったら、頂点列が不足しているはず
    if(ret.size() == n) return ret;
    else return vector<int>();
}

int main() {

  lint n, m; cin >> n >> m;
  vector<vector<lint>> dp(n, vector<lint>(2, -INF));
  vector<lint> a(n);
  rep (i, n) cin >> a[i];

  vector<vector<int>> g(n);
  rep (i, m) {
    int x, y; cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
  }

  vector<int> nodes = toposort(g);
  assert(nodes.size() != 0);

  for (auto node : nodes) {
    // 買う
    dp[node][0] = max(dp[node][0], -a[node]);

    for (auto nxt : g[node]) {
      // うらない
      dp[nxt][0] = max(dp[nxt][0], dp[node][0]);

      // 売る
      dp[nxt][1] = max(dp[nxt][1], dp[node][0] + a[nxt]);
    }
  }

  lint ans = -INF;
  for (int node = 0; node < n; node++) {
    ans = max(ans, dp[node][1]);
  }
  cout << ans << endl;
  return 0;
}

#include<bits/stdc++.h>
#define int long long
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pi;
const int mod = 1e9 + 7;
const int nax = 1e6;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int a[nax], dp[nax], deg[nax], mn[nax];
vector<int> E[nax];

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        mn[i] = 2e18;
        dp[i] = -2e18;
    }
    for(int i = 1; i <= n; i++) cin >> a[i];

    for(int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        E[x].pb(y);
        deg[y]++;
    }

    queue<int> Q;
    vector<int> ord;
    for(int i = 1; i <= n; i++) {
        if(!deg[i]) {
            Q.push(i);
        }
    }

    while(Q.size()) {
        int node = Q.front();
        Q.pop();
        ord.pb(node);
        for(auto it : E[node]) {
            deg[it]--;
            if(!deg[it]) {
                Q.push(it);
            }
        }
    }

    int ans = -2e18;

    for(auto x : ord) {
        mn[x] = min(mn[x], a[x]);
        for(auto it : E[x]) {
            ans = max(ans, a[it] - mn[x]);
            mn[it] = min(mn[it], mn[x]);
        }
    }
    cout << ans << '\n';

    return 0;
}

// 9


// 论证: 差分a即可
// 构造: 把a_i平均分
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> bool chmin(T &x, const T &y) {
  return x > y ? (x = y, true) : false;
}
template<class T> bool chmax(T &x, const T &y) {
  return x < y ? (x = y, true) : false;
}

#define maxk 10005
#define maxn 105
const int inf = 0x3f3f3f3f;

char s[maxn];
int n, k = inf, a[maxn];

int main() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  for (int i = 0; i <= n; i++)
    scanf("%d", a + i);
  for (int i = 1; i <= n; i++)
    chmin(k, abs(a[i] - a[i - 1]));
  printf("%d\n", k);
  for (int i = 0; i < k; i++) {
    for (int j = 0; j <= n; j++) {
      printf("%d%c", (a[j] + i) / k, j == n ? '\n' : ' ');
    }
  }
  return 0;
}

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

#define inp 200005
#define check exit(0)
#define nl cout<<endl;
#define mod 1000000007
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(v) for(int i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

// Pick yourself up, 'cause...

int main()
{
    jaldi

    int n;
    cin>>n;

    vector<int> v(n);
    for(int i=0;i<n;i++) cin>>v[i];

    vector<ll> ans(n);
    ordered_set os;

    for(int i=0;i<n;i++)
    {
        ans[0] += v[i] - os.order_of_key(v[i]);
        os.insert(v[i]);
    }

    for(int i=1;i<n;i++)
    {
        ans[i] = ans[i-1] - v[i-1] + (n - 1 - v[i-1]);
    }

    for(ll x:ans) cout<<x<<" \n";

    return 0;
}

// Try till you are out of ideas


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

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

  if ( A*A + B*B < C*C)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <fstream>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define x first
#define y second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cerr << #x << ": " << x << '\n';
#define FOR(i, n) for (int i = 0; i < n; ++i)
#define FORN(i, n) for (int i = 1; i <= n; ++i)
#define pb push_back
#define trav(a, x) for (auto& a : x)
using vi = vector<int>;
template <typename T>
std::istream& operator >>(std::istream& input, std::vector<T>& data)
{
    for (T& x : data)
        input >> x;
    return input;
}
template <typename T>
std::ostream& operator <<(std::ostream& output, const pair <T, T> & data)
{
    output << "(" << data.x << "," << data.y << ")";
    return output;
}
template <typename T>
std::ostream& operator <<(std::ostream& output, const std::vector<T>& data)
{
    for (const T& x : data)
        output << x << " ";
    return output;
}
ll div_up(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll div_down(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down
ll math_mod(ll a, ll b) { return a - b * div_down(a, b); }
#define tcT template<class T
#define tcTU tcT, class U
tcT> using V = vector<T>;
tcT> void re(V<T>& x) {
    trav(a, x)
        cin >> a;
}
tcT> bool ckmin(T& a, const T& b) {
    return b < a ? a = b, 1 : 0;
} // set a = min(a,b)
tcT> bool ckmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0;
}
ll gcd(ll a, ll b) {
    while (b) {
        tie(a, b) = mp(b, a % b);
    }
    return a;
}
signed main() {
    #ifdef LOCAL
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int a, b, c;
    cin >> a >> b >> c;
    if (a * a + b * b < c * c) {
    	cout << "Yes" << endl;
    }
    else {
    	cout << "No" << endl;
    }
}


#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <queue>

#define	INF   1010101010LL
#define INFLL 1010101010101010101LL

using namespace std;

const int mod = 1000000007;
//const int mod = 998244353;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(m);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}

	vector<int> ans;
	for (int i = 0; i < n; i++) {
		bool ok = true;
		for (int j = 0; j < m; j++) {
			if (a[i] == b[j]) {
				ok = false;
				break;
			}
		}
		if (ok) {
			ans.emplace_back(a[i]);
		}
	}
	for (int i = 0; i < m; i++) {
		bool ok = true;
		for (int j = 0; j < n; j++) {
			if (b[i] == a[j]) {
				ok = false;
				break;
			}
		}
		if (ok) {
			ans.emplace_back(b[i]);
		}
	}
	sort(ans.begin(), ans.end());
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] << (i + 1 == ans.size() ? "\n" : " ");
	}

	return 0;
}

#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <cmath>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;

int main() {
  int n, m;
  cin >> n >> m;
  set<int> a;
  set<int> b;
  int x;
  int sa, sb, ga, gb;
  rep(i, n) {
    cin >> x;
    a.insert(x);
    if (i == 0) sa = x;
    if (i == n-1) ga = x;
  }
  rep(i, m) {
    cin >> x;
    b.insert(x);
    if (i == 0) sb = x;
    if (i == m-1) gb = x;
  }
  bool fa, fb;
  int count = 0;
  for (int i = min(sa, sb); i <= max(ga, gb); i++) {
    fa = false; fb = false;
    if ((a.count(i) && !b.count(i)) || (!a.count(i) && b.count(i))) {
      if (count != 0) cout << " ";
      cout << i;
      count++;
    }
  }
  cout << endl;
}


/***Bismillahhirrahmannirrahim***/
/***coding is fun if u enjoy it***/

#include<bits/stdc++.h>

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

#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;

/*** Input-Output ***/

#define pf   printf

#define sfi(t)     scanf("%d",&t)
#define sfi2(a,b)  scanf("%d %d",&a,&b)
#define sfl(t)     scanf("%lld",&t)
#define sfl2(a,b)  scanf("%lld %lld",&a,&b)

/*** Typedef ***/

typedef unsigned long long ull;
typedef long long ll;

/*** Some Prints ***/

#define en cout << '\n'
#define NO cout << "NO" << '\n'
#define no cout << "no" << '\n'
#define YES cout << "YES" << '\n'
#define yes cout << "yes" << '\n'
#define case(t) cout << "Case " << t << ": "

/*** Grids ***/

int drx[8]={-2,-2,-1,-1,1,1,2,2};
int dry[8]={-1,1,-2,2,-2,2,-1,1};
int dirx[4]={-1,0,1,0};
int diry[4]={0,-1,0,1};

/*** Loops ***/

#define foR0(num) for(int i=0;i<num;i++)
#define foR1(num) for(int i=1;i<=num;i++)
#define foRev(num) for(int i=num-1;i>=0;i--)
#define forIn(arr,num) for(int i=0;i<num;i++) sfi(arr[i]);
#define forIn1(arr,num) for(int i=1;i<=num;i++) sfi(arr[i]);
#define vprt(ans) for(int i=0;i<ans.size();i++) cout<< ans[i] << (i+1<ans.size() ? ' ' : '\n');
#define aprt(arr,num) for(int i=0;i<num;i++) cout<< arr[i] << (i+1<ans.size() ? ' ' : '\n');

/*** Sorts ***/

#define all(v) (v).begin(),(v).end()
#define rev(v) reverse(all(v))
#define srt(v) sort(all(v))
#define srtG(v) sort(all(v),greater<int>())

/*** STLs ***/

typedef vector <ll> vll;
typedef vector <int> vi;
typedef set <ll> sll;
typedef set <int> si;
typedef multiset <ll> msll;
typedef multiset <int> msi;
typedef stack <int> sti;
typedef stack <ll> stll;
typedef queue <ll> qll;
typedef queue <int> qi;
typedef map <ll,ll> mll;
typedef map <int,int> mii;
typedef pair <ll,ll> pll;
typedef pair <int,int> pii;
typedef vector <pll> vpll;
typedef vector <pii> vpii;

/*** Define Values ***/

#define PI 2*acos(0.0)
#define E 2.718281828
#define mod 1000000007
#define eps 1e-7
#define sz 100010
#define mx 200005

#define pb     push_back
#define pob    pob_back
#define puf    push_front
#define pof    pop_front
#define F      first
#define S      second
#define mp     make_pair
#define ins    insert

#define mem(v,val) memset(v,val,sizeof v)
#define add(v)     accumulate(v.begin(),v.end(), 0)
#define debug(x)   cout<<#x<<" = "<<x<<endl;

void solve()
{

  int a,b,c;
  cin>>a>>b>>c;
  if((a*a)+(b*b)<(c*c))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

}

int main()
{

  ///solve();

  int tc=1,cs=0;
  ///cin>>tc;
  while(tc--){

    ///cout<<"Case "<<++cs<<": ";
    solve();

  }

  return 0;
}

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

int main() {

  int A,B,C,R;
  cin >> A >> B >> C;

  R = C*C - (A*A + B*B);

  if (R > 0){
  	cout << "Yes" << endl;
  } else {
  	cout << "No" << endl;
  }

}


#include<bits/stdc++.h>
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0);
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define ll                long long
using namespace std ;
ll i , j , c =0 ;
const ll mxn = 2e5 ;
ll arr[mxn] ;
void solve()
{
    ll n  ; cin >> n ;
    ll k =200 ;
    for(i=0;i<n;i++){
        cin >> arr[i] ;
    }
    ll cnt =0 ;
    for ( i = 0; i < n; i++) {
        arr[i] = (arr[i] + k) % k;
    }

    ll hash[k] = { 0 };

    for (i = 0; i < n; i++) {
        hash[arr[i]]++;
    }

    for (i = 0; i < k; i++) {
        cnt += (hash[i] * (hash[i] - 1)) / 2;
    }

    cout << cnt << endl;
}

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

#include <bits/stdc++.h>

using namespace std;

int main(){

  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  cin >> n;

  vector<int> a(n);
  for(auto &x: a) cin >> x;

  map<int, vector<int>> graph;

  for(int i=0;2*i<n;i++) {
    graph[a[i]].push_back(a[n-i-1]);
    graph[a[n-i-1]].push_back(a[i]);
  }

  // for(auto kv: graph){
    // cout << kv.first << '\n';
    // for(auto x: kv.second)
      // cout << x << ' ';
    // cout << '\n';
  // }

  set<int> visited;
  int counter = 0;
  int cc_counter = 0;

  function<void(int)> dfs = [&](int u){
    visited.insert(u);
    cc_counter++;
    for(auto v: graph[u])
      if(!visited.count(v))
        dfs(v);
  };

  for(auto u: graph){
    if(!visited.count(u.first)){
      cc_counter = 0;
      dfs(u.first);
      counter += cc_counter - 1;
    }
  }

  cout << counter << '\n';

  return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}

void solve(){
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,x,y;
    cin >> a >> b >> x >> y;
    int ans = x;
    if(a == b || a == (b+1)){
        cout << ans << "\n";
        return 0;
    }
    int d = abs(a - b);
    if(a > b){
        ans += (d-1) * min(2*x, y);
    }else{
        ans += d * min(2*x, y);
    }
    cout << ans << "\n";

    return 0;
}

/*
このコード、と～おれ!
Be accepted!
∧＿∧
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
          　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>
#include <array>
#include <chrono>

//#pragma GCC target("arch=skylake-avx512")
#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse4")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define repeat(i, n, m) for(int i = n; i < (m); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)
#define printLdb(a) printf("%.50Lf\n", a)
#define printdbd(a) printf("%.16lf\n", a)
#define prints(s) printf("%s\n", s.c_str())
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d))

using ll = long long;
using ull = unsigned long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr ll mod = 998244353;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
    char c;
    str = "";
    scanf("%c", &c);
    if (c == '\n')scanf("%c", &c);
    while (c != '\n' && c != -1 && c != ' ') {
        str += c;
        scanf("%c", &c);
    }
}

void scanc(char& str) {
    char c;
    scanf("%c", &c);
    if (c == -1)return;
    while (c == '\n') {
        scanf("%c", &c);
    }
    str = c;
}

double acot(double x) {
    return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

template<typename T>
inline T chmin(T& a, const T& b) {
    if (a > b)a = b;
    return a;
}

template<typename T>
inline T chmax(T& a, const T& b) {
    if (a < b)a = b;
    return a;
}

//cpp_int
#if __has_include(<boost/multiprecision/cpp_int.hpp>)
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace boost::multiprecision;
#else
using cpp_int = ll;
#endif

//atcoder library
#if __has_include(<atcoder/all>)
#include <atcoder/all>
//using namespace atcoder;
#endif

/*
    random_device seed_gen;
    mt19937 engine(seed_gen());
    uniform_int_distribution dist(1, 100);
*/

/*----------------------------------------------------------------------------------*/

int main() {

    int n;
    scanf("%d", &n);
    vector<ll> a(n);
    rep(i, n)scanf("%lld", &a[i]);
    map<ll, ll> mp;
    ll ans = 0;
    ++mp[0];
    ll r = 0;
    rep(i, n) {
        r += a[i] * (i % 2 ? -1 : 1);
        ans += (mp[r]++);
    }
    printf("%lld\n", ans);

    Please AC;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long i64;
typedef unsigned long long ui64;
typedef vector<i64> vi;
typedef vector<vi> vvi;
typedef pair<i64, i64> pi;

#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)
inline void RI(i64 &i) {scanf("%lld", &(i));}
inline void RVI(vi &v) { for(i64 i=0;i<sz(v);++i) { RI(v[i]); } }
inline void RVVI(vvi &vv) { for(i64 i=0;i<sz(vv);++i) { RVI(vv[i]); } }
inline void WI(const i64 &i) {printf("%lld\n", i);}
inline void WVI(const vi &v, char sep=' ') { for(i64 i=0;i<sz(v);++i) { if(i != 0){ printf("%c", sep); } printf("%lld", v[i]);} printf("\n"); }
inline void WS(const string &s) { printf("%s\n", s.c_str()); }
inline void WB(bool b, const string &yes, const string &no) { if(b){ WS(yes);} else { WS(no);} }
inline void YESNO(bool b) { WB(b, "YES", "NO"); }
inline void YesNo(bool b) { WB(b, "Yes", "No"); }
#define BUF_LENGTH 1000000
inline void RS(string &s) {static char buf[BUF_LENGTH]; scanf("%s", buf); s = buf;}
template<typename T> inline bool IN(T &S, const typename T::key_type &key) {
  return S.find(key) != S.end();
}
template<typename T> inline bool ON(const T &b, i64 idx) {
  return ((T(1) << idx) & b) != 0;
}

int main(int argc, char *argv[]) {
  i64 i, j, k;
  i64 L, R; cin >> L >> R;

  vi F(R+1, 0), G(R+1, 0);
  i64 g = R;
  auto CT = [&](i64 x, i64 g) {
    return max(0LL, x / g - 1);
  };
  auto DT = [&](i64 x, i64 g) {
    return x / g;
  };
  while(g > 1) {
    i64 C = CT(R, g) - CT(L-1, g);
    F[g] = C * (C - 1) / 2;
    i64 D = DT(R, g) - DT(L-1, g);
    G[g] = D * (D - 1) / 2;
    //cerr << g << " " << F[g] << " ";
    i64 k = 2;
    while(k * g <= R) {
      F[g] -= G[k * g];
      G[g] -= G[k * g];
      ++k;
    }
    //cerr << F[g] << endl;
    --g;
  }

  WI(accumulate(all(F), 0LL)*2);

  return 0;
}

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

char x[66];
int l,d;

bool ok(long long ts,long long n)
{
    long long now=0;
    for(int i=0;i<l;i++)
    {
        now+=x[i];
        if(now>ts)
            return 0;
        if(i<l-1 && now>ts/n)
            return 0;
        now=now*n;
    }
    return 1;
}

int main()
{
    long long m,L,R,Mid;
    scanf("%s%lld",x,&m);
    l=strlen(x);
    d=0;
    for(int i=0;i<l;i++)
    {
        x[i]-='0';
        d=max(d,x[i]-0);
    }
    if(l==1)
    {
        if(d<=m)
            printf("1\n");
        else
            printf("0\n");
    }
    else
    {
        L=d+1;
        R=m;
        while(L<R)
        {
            Mid=(L+R+1)/2;
            if(ok(m,Mid))
                L=Mid;
            else
                R=Mid-1;
        }
        if(L==R && ok(m,L))
            printf("%lld\n",L-d);
        else
            printf("0\n");
    }
    return 0;
}


//  main.cpp
//  ervb
//
//  Created by Kanak Gautam on 21/04/20.
//  Copyright © 2020 Kanak Gautam. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <utility>
#define pb push_back
#define mk make_pair
#define endl "\n"
#define mod 1000000007
#define PI 3.1415927
using namespace std;
typedef long long int lli;
typedef long double ld;
typedef pair<lli,lli> ii;
priority_queue <lli, vector<lli>, greater<lli> > ti;
vector <lli> p[300005],b(100005,0),k;
lli f[100005],d[100005];
//vector<pair<lli,ii>>p[300005];
map<pair<lli,lli>,lli>mp;
//vector<pair<pair<lli, lli>,lli> > st;
map<lli,lli> np;
//queue<lli> qy;
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
lli bpow(lli a, lli b) {
    lli res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res%mod;
}
void fact(lli i)
{
    f[0]=1;
    for(lli k=1;k<=i;k++)
    {
        (f[k]=f[k-1]*k)%=mod;
    }
}
lli isprime(lli n)
{
    if(n==1)
        return 0;
    for(lli i=2;i<=sqrt(n);i++)
        if(n%i==0)
            return 0;
    return 1;
}
lli find(lli x)
{
    if(f[x]==x)
        return x;
    else
        return f[x]=find(f[x]);
}
bool cmp(lli x,lli y)
{
    return x<y;
}
lli comb(lli i,lli j)
{
    lli k=f[i];
    lli g=(f[j]*(f[i-j]))%mod;
    lli h=bpow(g,mod-2);
    return (k*h)%mod;
}
/*void sieve()
{
    for(lli i=2;i<=100005;i++)
    {
        if(b[i]==0)
        {
            k.pb(i);
        for(lli j=2;i*j<=100005;j++)
        {
            b[i*j]=1;
        }
        }
    }
}*/
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
        lli n;cin>>n;
        if(n%2)
        {
            cout<<"Black"<<endl;
        }
        else
        {
            cout<<"White"<<endl;
        }
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    sp(10);
    ll n;cin>>n;
    long double N=n;
    vector<long double> dp(n+1,0);
    dp[1]=0;
    rep(i,n){
        if(i==0)continue;
        long double I=i;
        dp[i+1]=dp[i]+N/(N-I);
        //cout<<N/(N-I)<<endl;
    }
    cout<<dp[n]<<endl;
}


/**
* For the brave souls who get this far: You are the chosen ones,
* the valiant knights of programming who toil away, without rest,
* fixing our most awful code. To you, true saviors, kings of men,
* I say this: never gonna give you up, never gonna let you down,
* never gonna run around and desert you. Never gonna make you cry,
* never gonna say goodbye. Never gonna tell a lie and hurt you.
*/

#include<bits/stdc++.h>

#define pb push_back
#define nw cout<<"\n";
#define srt(v) sort((v).begin(),(v).end())
#define rvrs(v) reverse((v).begin(),(v).end())
#define mpr make_pair
#define mt make_tuple
#define loop(i,j,n) for (int i = j; i < n; ++i)
#define loop1(i,j,n) for(int i=j;i<=n;++i)
#define wis(x) std::cerr << #x << " is " << x << std::endl;

using namespace std;

typedef long long  ll;

int main ( void )
{
                            time_t Time;
                            time(&Time);
                         cerr<<ctime(&Time);
                     ios_base::sync_with_stdio(false);
                       cin.tie(NULL),cout.tie(NULL);
                             cout<<fixed;
            auto starttime=chrono::steady_clock::now();

        string str;
        cin >> str;
        ll m;
        cin>> m;
       ll d=*max_element(str.begin(),str.end())-'0';

       if(str.size()==1) {
	    if(d<=m)
	     cout<< 1;
	    else
	     cout<<0;
	   }

	   else {
	    ll first = d+1, last = (ll)1e18;

	     while(first<=last) {
			 __int128 number =0;
	    __int128 mid=(first+last)/2;

		for(int i=0;i<(int)str.size();i++) {
		   number*= mid;
		   number+=str[i]-'0';
		   if(number > m)
		      break;
	       }
	        if(number<=m)
		   first = mid+1;
		  else
		   last = mid-1;
		  }
    cout<< last - d;
	   }

           auto endtime=chrono::steady_clock::now();
           cerr<<endl<<"Elapsed Time: "
               	 <<chrono::duration_cast<chrono::milliseconds> (endtime-starttime).count()
        	      <<" milliseconds"<<endl;
  return 0;
}

#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
	bool flag=1;
	int x=0;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')
			flag=0;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return (flag?x:~(x-1));
}
string s;
int k,maxx;
vector<int> v;
bool judge(__int128 x)
{
	__int128 ans=0;
	for(int i:v)
	{
		ans=ans*x+i;
		if(ans>k)
			return 0;
	}
	return 1;
}
signed main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		v.push_back(s[i]-'0');
		maxx=max(maxx,(long long)s[i]-'0');
	}
	cin>>k;
	if(v.size()==1)
	{
		cout<<(v[0]<=k);
		return 0;
	}
	int l=maxx+1;
	int r=2e18;
	while(l<=r)
	{
		__int128 mid=(l+r)>>1;
		if(judge(mid))
			l=mid+1;
		else
			r=mid-1;
	}
	cout<<(l-maxx-1);
	return 0;
}


#include <bits/stdc++.h>
#define XOX
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define Time  cerr << "Time Taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl
#define ll  long long
#define beg() begin()

#define test int t=1; cin>>t;  while(t--)
#define vll vector<long long>
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define pb push_back
#define forr(i,a,b) for (ll i = (a); i < (b); ++i)
#define rrof(i,a,b) for (ll i = (b)-1; i >= (a); --i)

#define mod 1000000007
void solve( );
void swap(ll &a, ll &b);
ll min(ll &a, ll &b);
ll max(ll &a, ll &b);
void exp(ll b);
ll sqrt(ll a);
ll  GCD(ll a, ll b) ;

struct node{
	int freq;
	node* child[26];
	node(){
		freq=0;
		for(int i=0;i<26;i++) child[i]=NULL;
	}
};

int main() {

	fast;
	#ifndef ONLINE_JUDGE
   		freopen("input.txt", "r", stdin);
   		freopen("output.txt", "w", stdout);
	#endif

   // node *root = new node() ; node *temp = root ;
   // 		string s;
   // 		cin>>s;
   // 		for(int i=0;i<s.length();i++){
   // 			 if(temp->child[(s[i]-'a')]==NULL){
   // 			 	node *t = new node();
   // 			 	temp->child[(s[i]-'a')] = t;
   // 			 	temp=t; temp->freq++;
   // 			 }else{
   // 			 	temp = temp->child[(s[i]-'a')];
   // 			 	temp->freq++;
   // 			 }
   // 		}
	// test{
	// 	string q; cin>>q;
	// 	if()

	//  }
   		solve();
Time;

  return 0;
}

void solve(){
	ll n,s,d,x,y; cin>>n>>s>>d;
	forr(i,0,n){
		cin>>x>>y; if(x<s && y>d ){cout<<"Yes"; return; }
	}
	cout<<"No";

 }
void swap(ll &a, ll &b){
	if(a==b) return ;

	a=a^b;
	b=a^b;
	a=a^b;
	return ;
}

ll min(ll &a, ll &b){
	if(a>b) return b;
	return a;
}
ll max(ll &a, ll &b){
	if(a<b) return b;
	return a;
}

ll sqrt(ll a){
	ll l=1,h=a, m=l+(h-l+1)/2;
	while(l<h){
		if(m > a/m ) h=m-1;
		else l=m;

		m=l+(h-l+1)/2;
	}

	return m;
}
ll  GCD(ll a, ll b) {
  if(b==0) return a;
  else return GCD(b, a%b) ;
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vi = vector<int>;
using vb = vector<bool>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vpll = vector<pll>;
const ll LINF = 1ll << 55;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

/// cin/cout overloading
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &vec) {
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    out << *it << " ";
  }
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const pair<T, T> &P) {
  out << P.first << " " << P.second;
  return out;
}

template <typename T>
istream &operator>>(istream &in, vector<T> &vec) {
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    in >> *it;
  }
  return in;
}

template <typename T>
istream &operator>>(istream &in, pair<T, T> &P) {
  in >> P.first >> P.second;
  return in;
}

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

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

#define all(x) (x).begin(), (x).end()
#define coutp(x, y) cout << (x) << " " << (y) << endl
#define coutn(x) cout << (x) << endl
#define coutd(x) cout << setprecision(10) << (x) << endl

/// main函数
int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  ll sqsum = 0;
  ll sumsq = 0;
  ll A;
  for (int i = 0; i < N; ++i) {
    cin >> A;
    sqsum += A * A;
    sumsq += A;
  }
  sumsq *= sumsq;
  ans = N * sqsum - sumsq;
  coutn(ans);
  return 0;
}


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

int main(){
    int N,M; cin >> N >> M;
    int a,b; char c;
    Graph g(N+1);
    rep(i,M){
        cin >> a >> b >> c;
        g[a].push_back(make_pair(b,c));
        g[b].push_back(make_pair(a,c));
    }
    queue<tuple<int,int,int>> go;
    bool vis[N+1][N+1];
    rep(i,N+1){
        rep(j,N+1){
            vis[i][j] = false;
        }
    }
    vis[1][N] = true; go.push(make_tuple(0,1,N));
    int nowk = 0; bool fin = false;
    while(!go.empty()){
        auto p = go.front(); go.pop();
        a = get<1>(p); b = get<2>(p);
        int k = get<0>(p);
        if(k>nowk){
            nowk = k;
            if(fin){
                cout << 2*k-1 << endl; return 0;
            }
        }
        if(a==b){
            cout << 2*k << endl; return 0;
        }
        for(auto q:g[a]){
            int x = q.first; char c1 = q.second; int y;
            for(auto r:g[b]){
                y = r.first; char c2 = r.second;
                if(x==b&&y==a){
                    fin = true;
                }
                if(c1!=c2||vis[x][y]) continue;
                go.push(make_tuple(k+1,x,y)); vis[x][y] = true;
            }
        }
    }
    cout << -1 << endl;
}

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << p.first << " " << p.second;
  return os;
}

template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
  is >> p.first >> p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &in : v) is >> in;
  return is;
}

template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template<typename T = int64>
vector<T> make_v(size_t a) {
  return vector<T>(a);
}

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
  t = v;
}

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template<typename F>
struct FixPoint : F {
  FixPoint(F &&f) : F(forward<F>(f)) {}

  template<typename... Args>
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward<Args>(args)...);
  }
};

template<typename F>
inline decltype(auto) MFP(F &&f) {
  return FixPoint<F>{forward<F>(f)};
}

int main() {
  int N, L;
  cin >> N >> L;
  vector< int > A(N + 2), B(N + 2);
  for(int i = 1; i <= N; i++) cin >> A[i];
  for(int i = 1; i <= N; i++) cin >> B[i];
  A[N + 1] = L + 1;
  B[N + 1] = L + 1;
  for(int i = 0; i < N + 2; i++) A[i] -= i;
  for(int i = 0; i < N + 2; i++) B[i] -= i;

  map< int, int > ls, rs;
  for(int i = 0, j; i < N + 2; i = j) {
    for(j = i; j < N + 2 and A[i] == A[j]; j++) ;
    ls[A[i]] = i;
    rs[A[i]] = j;
  }
  int64 ret = 0;
  for(int i = 0, j; i < N + 2; i = j) {
    for(j = i; j < N + 2 and B[i] == B[j]; j++) ;
    if(!ls.count(B[i])) {
      cout << -1 << endl;
      exit(0);
    }
    ret += max(ls[B[i]] - i, 0);
    ret += max(j - rs[B[i]], 0);
  }
  cout << ret << endl;
}


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

#define all(x) (x).begin(), (x).end()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

bool check_cons_zeros(string t) {
  int cons_zeros = 0;
  for (auto &c : t) {
    if (c == '0') {
      cons_zeros++;
    } else {
      cons_zeros = 0;
    }
    if (cons_zeros > 1) {
      return true;
    }
  }
  return false;
}

bool check_cons_ones(string t) {
  int cons_ones = 0;
  for (auto &c : t) {
    if (c == '1') {
      cons_ones++;
    } else {
      cons_ones = 0;
    }
    if (cons_ones > 2) {
      return true;
    }
  }
  return false;
}

bool check_one_surr(string t) {
  for (int i = 1; i < t.length() - 1; i++) {
    if (t[i] == '1' && t[i - 1] == '0' && t[i + 1] == '0') {
      return true;
    }
  }
  return false;
}

int main() {
  _upgrade;
  int n;
  cin >> n;
  string t;
  cin >> t;
  if (check_cons_zeros(t) || check_cons_ones(t) || check_one_surr(t)) {
    // cerr << check_cons_zeros(t) << "\n";
    // cerr << check_cons_ones(t) << "\n";
    // cerr << check_one_surr(t) << "\n";
    cout << 0 << "\n";
    return 0;
  }
  long long res = 1e10;  // change
  if (t.length() == 1) {
    if (t[0] == '0') {
      cout << res << "\n";
    } else {
      cout << 2 * res << "\n";
    }
  } else {
    if (t[0] == '1' && t[1] == '1') {
      cout << res - (t.length() + 2) / 3 + 1 << "\n";
    } else if (t[0] == '1' && t[1] == '0') {
      long long need = 1 + (t.length() - 2 + 2) / 3;
      cout << res - (need - 1) << "\n";
    } else {
      long long need = 1 + (t.length() - 1 + 2) / 3;
      cout << res - (need - 1) << "\n";
    }
  }
  return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << '\n'
typedef long long ll;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
//const ll MOD = 1000000007;
const ll MOD = 998244353;

template <typename T> inline bool chmax(T &a, T b) {return a < b ? a = b, true : false;}
template <typename T> inline bool chmin(T &a, T b) {return a > b ? a = b, true : false;}

const int MAX = 500000;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//xのn乗mod(m)
ll pom(ll x, ll n, ll m) {
    ll ret = 1LL;
    while (n > 0) {
        if (n & 1LL) ret = ret * x % m;
        x = x * x % m;
        n >>= 1;
    }
    return ret;
}

void solve() {
    ll n, m;    cin >> n >> m;

    //末項の値
    ll ans = 1;
    vector<bool> c(m + 1, true);
    for(ll i = 2; i <= m; i++){
        int tmp = i;
        ll k = 0;
        ll t = 1;
        for(int j = 2; j * j <= m; j++){
            if(tmp % j == 0){
                ll k = 0;
                while(tmp % j == 0){
                    k++;
                    tmp /= j;
                }
                t *= COM(n - 1 + k, k);
                t %= MOD;
            }
            if(tmp == 1) break;
        }
        if(tmp > 1){
            t *= n;
            t %= MOD;
        }
        ans += t;
    }
    print(ans % MOD);
}

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

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


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 1000000007
#define pd push_back
#define sort(v) sort(v.begin(),v.end())
#define Sort(v) sort(v.begin(),v.end(),greater<int>())
#define display(s) for(auto val:s) cout<<val<<" "; cout<<endl;
#define displayMap(mymap) for(auto val:mymap) cout<<val.first<<" -> "<<val.second<<endl;
#define Sortcom(v) sort(v.begin(),v.end(),mycompare)
#define f(a,b,c) for(int i=a;i<b;i+=c)

bool mycompare(int a,int b)
{
    return a<b;
}

int mod(int x)
{
    return (x%MOD+MOD)%MOD;
}
int mul(int a,int b)
{return mod(mod(a)*mod(b));}
int add(int a,int b)
{return mod(mod(a)+mod(b));}

int power(int a,int b)
{
    if(b==0)
    return 1;
    int smallans = power(a,b/2);
    smallans = smallans * smallans;
    if(b&1)
    smallans = smallans * a;
    return smallans;
}

int solve(){
    int n,k; cin>>n>>k;
    vector<int> v(n,0);
    map<int,int> mymap;
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
        mymap[v[i]]++;
    }
    int ans = 0;
    int boxes = 0;
    while(boxes<k)
    {
        int val = 0;
        bool flag = true;
        while(mymap[val]!=0)
        {
            mymap[val]--;
            val++;
            flag = false;
        }
        ans += val;
        boxes++;
        if(flag)
        break;
    }
    return ans;
}

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

#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>

/*
#include<vector>
#include<iostream>
//*/
using namespace std;
#define ll long long
#define yes {cout<<"Yes"<<endl;return 0;}
#define no {cout<<"No"<<endl;return 0;}
#define YES {cout<<"YES"<<endl;return 0;}
#define NO {cout<<"NO"<<endl;return 0;}
#define cyes {cout<<"Yes"<<endl;continue;}
#define cno {cout<<"No"<<endl;continue;}

#define MOD 1000000007
#define MOD2 1000000009
#define MOD3 998244353
#define INF 2147483647
constexpr double PI  = 3.141592653589793238462643383279;
#define LINF 9223372036854775807

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)

#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back

#define MP make_pair
#define MT make_tuple

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SZ(a) (int)((a).size())

#define NEXP(a) next_permutation((a).begin(),(a).end())
#define FI first
#define SE second

#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).rbegin(), (c).rend())
#define REVERSE(c) reverse((c).begin(),(c).end())

typedef long long LL;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL,LL> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;

const vector<int> dx = {1,0,-1,0,1,1,-1,-1};
const vector<int> dy = {0,1,0,-1,1,-1,1,-1};

int main(void)
{
    int i,j;
    int n,k;
    cin>>n>>k;
    VI a(n);
    VI cnt(n);
    rep(i,n){cin>>a[i];cnt[a[i]]++;}
    VI dp(n);
    int mini=cnt[0];
    rep(i,n)
    {
        dp[i]=min(mini,cnt[i]);
        mini=dp[i];
    }
    int used=0,ans=0;
    for(i=n-1;i>=0;i--)
    {
        if(min(dp[i],k)-used>0)
        {
            ans+=(i+1)*(min(k,dp[i])-used);
            used=min(dp[i],k);
        }
    }
    cout<<ans<<endl;
}


/* bimillahir rahmanir rahim...
 * AUTHOR
 * mubin_akib */
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

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

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#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) - 1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a) - 1; i >= 0; i--)
#define REP(i, a, b) for(int i = a; i <= (b); ++i)
#define trav(a,x) for(auto& a : x)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define pi acos(-1)

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

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

const int mod = 1e9 + 7;
const char nl = '\n';

void solve(){
    int n, w;
    cin >> n >> w;
    cout << n / w << nl;
}

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

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <math.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int N, W;
	cin >> N >> W;

	cout << N / W << "\n";

	return 0;
}


//pikuskd_32->42
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define fr(i,s,e) for(ll i=s;i<=e;i++)
#define rfo(i,s,e) for(ll i=s;i>=e;i--)
#define f(x,m) for(auto x : m)
#define ff first
#define ss second
const ll INF = (1LL << 60) - 1;
#define pb push_back
#define pp pop_back
#define pf push_front
#define ppf pop_front
#define m_p make_pair
#define mod 1000000007
#define TIME cerr<<"Time Taken:"<<(float)clock()/CLOCKS_PER_SEC*1000<<"ms"<<endl
// __builtin_popcount(n)
// cout << fixed << setprecision(2) << a << endl; ->'a' is floating point.

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif

	ll t = 1; //cin>>t;
	while (t--) {
		ll n; cin >> n;
		vector<pair<ll, ll>> v;
		ll x, y;
		fr(i, 0, n - 1) {
			cin >> x >> y; v.pb(m_p(x, y));
		}
		ll c = 0;
		fr(i, 0, n - 1) {
			fr(j, i + 1, n - 1) {
				if (abs(v[j].ss - v[i].ss) <= abs(v[j].ff - v[i].ff)) c++;
			}
		}
		cout << c << endl;
	}
	TIME;
	return 0;
}

#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <utility>
#include <queue>
#include <map>
#include <assert.h>
#include <stack>
#include <string>

using namespace std;
int power[31]={0};
string cmp(string s)
{
	string res="";
	for (int j=0; j<s.size(); j++)
	{
		res+='0'+(1-(s[j]-'0'));
	}
	return res;
}

vector<string> f(int x)
{
	if (x==1)
	{
		return {"01"};
	}
	vector<string> p=f(x-1);

	vector<string> v;
	string s="";
	for (int j=1; j<=power[x-1]; j++)
	{
		s+='0';
	}
	for (int j=1; j<=power[x-1]; j++)
	{
		s+='1';
	}
	v.push_back(s);

	for (int j=0; j<p.size(); j++)
	{
		string r=p[j];
		string f = r + r;
		r+=cmp(p[j]);
		v.push_back(r);
		v.push_back(f);
	}
	return v;
}

void solve()
{
	int n;
	cin>>n;

	vector<string> res = f(n);

	cout<<(int)res.size()<<"\n";
	for (auto s: res)
	{
		for (auto i : s)
		{
			cout << (char)('A' + (i-'0'));
		}
		cout << "\n";
	}
	return;
}

signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
	int t;
	//cin >> t;
	t=1;
	power[0]=1;
	for (int j=1; j<=30; j++) power[j]=power[j-1]*2;
	while (t--)
	{
		solve();
	}
	return 0;
}


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

#define save_some_time ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define ll long long int

void V_in(vector <ll> &V, int n) {
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		V.pb(a);
	}
}

void V_out(vector <ll> V) {
	for (int i = 0; i < V.size(); i++) {
		cout << V[i] << " ";
	}
}

int main() {

	save_some_time;
	int n; cin >> n;
	cout << 100-n%100;

}

#include <bits/stdc++.h>
#define ll long long
#define mod 1e9 + 7
using namespace std;
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ll n;cin>>n;
    ll rem = n%100;
    if(rem==0){
        cout<<100;
    }else{
        cout<<100-rem;
    }
    return 0;
}


#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define pii pair<ll,ll>
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define autoitr(x,it) for(auto it = x.rbegin(); it != x.rend(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

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

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

void get(ll i, ll arr[], ll n, ll xo, ll o, ll &ans)
{
    if(i == n)
    {
        ans = min(ans, xo^o);
        return;
    }

    get(i+1, arr, n, xo, o|arr[i], ans);
    get(i+1, arr, n, xo^o, arr[i], ans);
}

const ld PI = acos(-1);

int main()
{
  FAST/**/

  ll n;
  cin>>n;

  ld x0,y0,x1,y1;
  cin>>x0>>y0>>x1>>y1;

  ld cx = (x0+x1)/2, cy = (y0+y1)/2;
  x0-=cx, y0-=cy;
  ld ang = (2*PI)/n;
  ld fx = (x0*cos(ang) - y0*sin(ang)), fy = (x0*sin(ang) + y0*cos(ang));
  fx+=cx, fy+=cy;
  cout<<fixed<<setprecision(12)<<fx<<" "<<fy<<'\n';

  return 0;
}

#include <bits/stdc++.h>
#define int long long

using namespace std;

const int O = 2e5 + 5;

int tree[2][O * 4], t[2][O * 4];

vector <int> val;

void Update(int id, int l, int r, int u, int v, int k){
    if (l > u || r < u) return;
    if (l == r){
        tree[k][id] += val[l] * v;
        t[k][id] += v;
        return;
    }
    int mid = (l + r) / 2;
    Update(id << 1, l, mid, u, v, k);
    Update(id << 1 | 1, mid + 1, r, u, v, k);
    tree[k][id] = tree[k][id << 1] + tree[k][id << 1 | 1];
    t[k][id] = t[k][id << 1] + t[k][id << 1 | 1];
}

pair <int, int> Get(int id, int l, int r, int u, int v, int k){
    if (l > v || r < u) return make_pair(0, 0);
    if (u <= l && r <= v) return make_pair(tree[k][id], t[k][id]);
    int mid = (l + r) / 2;
    auto x = Get(id << 1, l, mid, u, v, k);
    auto y = Get(id << 1 | 1, mid + 1, r, u, v, k);
    return make_pair(x.first + y.first, x.second + y.second);
}

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

    int n, m, q; cin >> n >> m >> q;
    vector <vector <int>> pre(2, vector <int> (max(n, m) + 1));
    vector <vector <int>> sum(2, vector <int> (max(n, m) + 1));
    vector <tuple <int, int, int>> queries; val.push_back(0);
    for (int i = 1; i <= q; ++ i){
        int t, x, y; cin >> t >> x >> y;
        queries.push_back(make_tuple(t, x, y));
        val.push_back(y);
    }

    sort(val.begin(), val.end());
    auto cac = unique(val.begin(), val.end());
    val.resize(distance(val.begin(), cac));

    int ans = 0, h = val.size() - 1;
    Update(1, 0, h, 0, n, 0);
    Update(1, 0, h, 0, m, 1);
    for (int i = 0; i < q; ++ i){
        int t = get<0>(queries[i]);
        int r = get<1>(queries[i]);
        int x = pre[t - 1][r];
        int y = get<2>(queries[i]);

        t -= 1;
        int idx = upper_bound(val.begin(), val.end(), x) - val.begin() - 1;
        int idy = upper_bound(val.begin(), val.end(), y) - val.begin() - 1;
        auto X = Get(1, 0, h, 0, idx, t ^ 1);
        auto Y = Get(1, 0, h, 0, idy, t ^ 1);
        auto greatX = Get(1, 0, h, idx + 1, h, t ^ 1);
        auto greatY = Get(1, 0, h, idy + 1, h, t ^ 1);
        Update(1, 0, h, idx, -1, t);
        Update(1, 0, h, idy, 1, t);
        ans = ans - (x * X.second - X.first) + (y * Y.second - Y.first);
        pre[t][r] = y;
        cout << ans << "\n";
    }
}


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

ll K, N, M, A[(int)1e5], B[(int)1e5];

ll	check(ll x) {
	ll sumL = 0, sumR = 0;
	REP(i, K)
		sumL += max(0LL, (M * A[i] - x + N - 1) / N);
	REP(i, K)
		sumR += (M * A[i] + x) / N;
	return (sumL <= M && M <= sumR);
}

void	constructer(ll x) {
	ll R[K];
	REP(i, K)
		B[i] = max(0LL, (M * A[i] - x + N - 1) / N);
	REP(i, K)
		R[i] = (M * A[i] + x) / N;
	ll sumB = 0;
	REP(i, K) sumB += B[i];
	REP(i, K) {
		ll x = min(M - sumB, R[i] - B[i]);
		B[i] += x;
		sumB += x;
	}
}

int main() {
	cin >> K >> N >> M;
	REP(i, K)
		cin >> A[i];
	ll ng = -1, ok = N * M;
	while (ng + 1 < ok) {
		ll x = (ng + ok) / 2;
		if (check(x))
			ok = x;
		else
			ng = x;
	}
	constructer(ok);
	REP(i, K)
		cout << B[i] << " ";
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int maxn = 1e5+9;
int k,n,m;
ll A[maxn],B[maxn];

int main(){
    cin>>k>>n>>m;
    int sum=0;
    priority_queue<pair<int,int>>q;
    for(int i=1;i<=k;i++){
        cin>>A[i];
        B[i]=((1.0*m)/n)*A[i];
        sum+=B[i];
        q.push({abs(n*B[i]-m*A[i]),i});
    }
    int x=m-sum;
    while(x--){
        B[q.top().second]++;
        q.pop();
    }
    for(int i=1;i<=k;i++)
        cout<<B[i]<<" ";
    return 0;
}


//------------------------------------------
// C++ template
//------------------------------------------
#include <bits/stdc++.h>
#define lint long long int
using namespace std;

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    bool winner;

    if(a-b>=1||(a==b&&c==1)) winner = true;
    else                    winner = false;

    if(winner) cout << "Takahashi" << endl;
    else       cout << "Aoki"      << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main (){
	ios::sync_with_stdio(0);cin.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	if (a+c>=b+1) cout<<"Takahashi\n";
	else cout<<"Aoki\n";
}