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

int main() {
  ll N,W,S,T,P;
  cin >> N >> W;
  map<ll,ll> m;
  rep(i,N) {
    cin >> S >> T >> P;
    S--;
    T--;
    m[S] += P;
    m[T] -= P;
  }
  ll res = 0, sum = 0;
  for (auto &e: m) {
    sum += e.second;
    res = max(res,sum);
  }
  print(((res>W) ? No : Yes));
  return 0;
}

// Username: WillTheBill
// Time of creation: 2020-10-29 13:25
// Original filename: m.cp.cpp

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

// shortcuts
#define pb push_back
#define fi first
#define se second
#define all(_v) _v.begin(),_v.end()
#define ll long long

// IO
#define multitest signed __T; cin >> __T; while(__T--)
template<typename T>
void _read(T& t);
template<typename T>
void _read(vector<T>&v);
template<typename T1, typename T2>
void _read(pair<T1,T2>&p);
template<typename T>
void _read(T& t){cin >> t;}
template<typename T>
void _read(vector<T>&v){for(unsigned _i=0;_i<v.size();_i++)_read(v[_i]);}
template<typename T1, typename T2>
void _read(pair<T1,T2>&p){_read(p.first);_read(p.second);}
void _masterread(){}
template<typename T,typename... V>
void _masterread(T& t, V&... v){_read(t);_masterread(v...);}
#define re(...)_masterread(__VA_ARGS__)

template<typename T>
void _print(T t);
template<typename T>
void _print(vector<T>&v);
template<typename T1, typename T2>
void _print(pair<T1,T2>&p);
template<typename T>
void _print(T t){cout<<t;}
template<typename T>
void _print(vector<T>&v){for(unsigned _i=0;_i<v.size();_i++)_print(v[_i]),cout<<(_i==v.size()-1?"":" ");}
template<typename T1, typename T2>
void _print(pair<T1,T2>&p){_print(p.first);cout<<" ";_print(p.second);}
void _masterprint(){cout<<endl;}
template<typename T,typename... V>
void _masterprint(T t, V... v){_print(t);if(sizeof...(v))cout<<" ";_masterprint(v...);}
#define pr(...)_masterprint(__VA_ARGS__)

// DEBUG
// colored output???
template <typename T> // start forward declaration
void _debug(T t);
template<typename T1,typename T2>
void _debug(pair<T1,T2> p);
template<typename T>
void _debug(vector<T>v);
template <typename T> // end forward declaration
void _debug(T t){cerr<<t;}
template<typename T1,typename T2>
void _debug(pair<T1,T2> p){cerr<<"{";_debug(p.first);cerr<<", ";_debug(p.second);cerr<<"}";}
template<typename T>
void _debug(vector<T>v){cerr<<"(";for(unsigned _i=0;_i<v.size();_i++)_debug(v[_i]),cerr<<(_i==v.size()-1?"":", ");cerr << ")";}
void _masterdebug(){cerr<<"]\n";}
template<typename T,typename... V>
void _masterdebug(T t,V... v){_debug(t);if(sizeof...(v))cerr<<", ";_masterdebug(v...);}
#ifdef __local__
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"] = [";_masterdebug(__VA_ARGS__)
#else
#define debug(...)
#endif

// TYPES
#define int long long
int n;
vector<vector<int>> nodes;
int RES = LLONG_MAX;
map<pair<int, int>, int> mem;

int dist(int ai, int bi){
	auto& a = nodes[ai];
	auto& b = nodes[bi];
	return abs(a[0] - b[0]) + abs(a[1] - b[1]) + max(0ll, b[2] - a[2]);
}

int rec(int idx, int v, int pre){
	if(mem.count({v, pre})) {
		return mem[{v, pre}];
	}
	int res = LLONG_MAX;
	if(idx == n - 1){
		res = dist(pre, 0);
	}else{
		for(int i = 1; i < n; i++){
			if(((v >> i) & 1) == 0){
				v |= (1 << i);
				res = min(dist(pre, i) + rec(idx + 1, v, i), res);
				v &= ~(1 << i);
			}
		}
	}
	mem[{v,pre}] = res;
	return res;
}

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	re(n);
	nodes = vector<vector<int>> (n, vector<int> (3)); re(nodes);
	pr(rec(0, 0, 0));
}


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

#define MAX_N 200200
#define MAX_M 400400

int vis[MAX_N], used[MAX_N], match[MAX_M], dist[MAX_N], n, m, ans;
queue<int> q;
vector<int> v[MAX_N];

void bfs(){
    while(!q.empty()){
        int u = q.front(); q.pop();
        for(auto e : v[u]){
            if(match[e] && !dist[match[e]]){
                dist[match[e]] = dist[u]+1;
                q.push(match[e]);
            }
        }
    }
}

int dfs(int u){
    vis[u] = 1;
    for(auto e : v[u]){
        if(!match[e] || (!vis[match[e]] && dist[u]+1 == dist[match[e]] && dfs(match[e]))){
            match[e] = u;
            used[u] = 1;
            return 1;
        }
    }
    return 0;
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int a, b; scanf("%d %d",&a,&b);
        v[i].push_back(a), v[i].push_back(b);
    }
    while(1){
        for(int i=1;i<=n;i++) dist[i] = !used[i];
        for(int i=1;i<=n;i++) if(!used[i]) q.push(i);
        bfs();
        int f = 0;
        for(int i=1;i<=n;i++) vis[i] = 0;
        for(int i=1;i<=n;i++) if(!used[i]) f+=dfs(i);
        if(!f) break;
        ans += f;
    }
    printf("%d",ans);
}

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
//#define mydeb(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
#define mydeb(fmt, ...)

map<int,int>union_find_parent;
int union_find_add(int node);
int union_find_unite(int a,int b);
int union_find_root(int a);

int main()
{

	int n;
	cin >> n;
	vector<int> a(n),b(n);
	rep(i,n)
	{
		cin >> a[i] >> b[i];
	}

	map<int,int> numnode;
	map<int,int> is_cycle;

	rep(i,n)
	{
		if (union_find_root(a[i])<0)
		{
			mydeb("add %d\n",a[i]);
			union_find_add(a[i]);
			numnode[a[i]]=1;
			is_cycle[a[i]]=0;
		}
		if (union_find_root(b[i])<0)
		{
			mydeb("add %d\n",b[i]);
			union_find_add(b[i]);
			numnode[b[i]]=1;
			is_cycle[b[i]]=0;
		}

		int roota=union_find_root(a[i]);
		int rootb=union_find_root(b[i]);
		if (roota!=rootb)
		{
			mydeb("merge %d and %d\n",a[i],b[i]);
			union_find_unite(roota,rootb);
			// -> a's new root = b
			numnode[rootb]+=numnode[roota];
			is_cycle[rootb]|=is_cycle[roota];
			numnode.erase(roota);
			is_cycle.erase(roota);
		}
		else
		{
			// found cycle
			mydeb("cycle contains %d and %d\n",a[i],b[i]);
			is_cycle[roota]=1;
		}
	}

	int total=0;
	for (auto p: numnode)
	{
		total+=p.second-1;
	}
	for (auto p: is_cycle)
	{
		total+=p.second;
	}
	cout << total << endl;
}

int union_find_add(int node)
{
	assert(union_find_parent.count(node)==0);
	union_find_parent[node]=node;
	return 0;
}

int union_find_unite(int a,int b)
{
	assert( (union_find_parent.count(a)!=0) && (union_find_parent.count(b)!=0) );

	a=union_find_root(a);
	b=union_find_root(b);
	if (a!=b)
	{
		union_find_parent[a]=b;
	}
	return 0;
}

int union_find_root(int a)
{
	if (union_find_parent.count(a)==0)
	{
		return -1;
	}

	if (union_find_parent[a]==a)
	{
		return a;
	}
	else
	{
		return union_find_parent[a]=union_find_root(union_find_parent[a]);
	}
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define mod 1000000007
#define one(x)   __builtin_popcountll(x)
#define zero(x)  __builtin_ctzll(x)
#define pp pair<ll,ll>
#define all(x) (x).begin(), (x).end()
#define removeDuplicates(a) a.resize(unique(all(a))-a.begin())
template<class T> using oset =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;
typedef long long int ll;

const int mxn = 2e5 + 10;

/*
ll n,q;
ll ar[200001];
ll t[800004];

 void build(ll index,ll l, ll r){
     if(l==r){
         t[index]=ar[l];
         return ;
     }
     ll mid=(l+r)/2 ;
     build(index*2,l,mid);
     build(index*2+1,mid+1,r);
     t[index]=t[index*2]^t[index*2+1];
 }

 void update(ll index, ll l ,ll r, ll pos, ll val){
     if(pos<l || pos>r){
         return;
     }
     if(l==r){
         t[index]=val;
         ar[l]=val;
         return ;
     }
     ll mid=(l+r)/2 ;
     update(index*2,l,mid,pos,val);
     update(index*2+1,mid+1,r,pos,val);
     t[index]=min(t[index*2],t[index*2+1]);
 }

 ll query(ll index,ll l, ll r, ll lq, ll rq){
     if(rq<l || lq>r){
         return 0;
     }
     if(lq<=l && r<=rq){
         return t[index];
     }

     ll mid=(l+r)/2 ;
     return query(index*2,l,mid,lq,rq)^query(index*2+1,mid+1,r,lq,rq);
 }*/

//ll a[mxn];

void subMain(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll blue = a, red = 0;
    for(ll i = 1; i <= a; i++){
        blue+=b;
        red+=c;
        if(blue<=red*d){
            cout << i << "\n";
            return;
        }
    }
    cout << -1 << "\n";
}

int main(){

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

    /*ll t, i = 0;
	cin >> t;
	while(t--){
        //cout << "Case #" << i+1 << ": ";
        subMain();
        //i++;
	}*/
	subMain();
	cerr<<"Time : "<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n";
	return 0;
}

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

int main() {
  double Sx, Sy, Gx, Gy;
  cin >> Sx >> Sy >> Gx >> Gy;

  double a = (Gy + Sy) / (Gx - Sx);
  double c = Gy - (a * Gx);
  double b = (-1 * c) / a;

  cout << fixed << setprecision(10) << b << endl;
  return 0;
}


// #pragma GCC optimize("Ofast")

#include <vector>
#include <iostream>
#include <utility>
#include <cmath>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <utility>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<int,int> pii;
// #define int ll
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; ++i)
#define REP(i,n) for(int i = 0;i < (n) ; ++i)
#define MP(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
inline unsigned long long xor128() {
	static unsigned long long rx = 123456789, ry = 986960440, rz = 738905609, rw = 23140692;
	unsigned long long rt = (rx ^ (rx << 11));
	rx = ry;ry = rz;rz = rw;
	return (rw = (rw ^ (rw >> 19)) ^ (rt ^ (rt >> 8)));
}
inline float rand128(float min = 0, float max = 1){
	return (float)(xor128() % 0xFFFF) / 0xFFFF * (max - min) + min;
}

inline uint64_t rdtsc(){
	uint32_t hi,lo;
	__asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
	return ((uint64_t)lo) | (((uint64_t)hi)<<32);
}
inline double GetSeconds() {
	// return rdtsc()/2.8e9; //Topcoder
	return rdtsc()/3.0e9; // Atcoder
}
double start_time;
const double TL = 1.90;
/*----------------------------------------------------------------*/

/*----------------------------------------------------------------*/
int h[30][29];
int v[29][30];

const int Q = 1000;
const int H = 30;
const int W = 30;

/*----------------------------------------------------------------*/
void input(){
	cerr << "in h" << endl;
	cerr << H << endl;
	cerr << W << endl;
	rep(i,H)rep(j,W-1){
		cin >> h[i][j];
		cerr << h[i][j] << endl;
	}
	cerr << "in v" << endl;
	rep(i,H-1)rep(j,W)cin >> v[i][j];
}

void solve(){
	cerr << "solve" << endl;
    int si,sj,ti,tj,a;
	rep(q,Q){
        cin >> si >> sj >> ti >> tj;
        if(si > ti)rep(i,si-ti)cout << 'U';
        if(ti > si)rep(i,ti-si)cout << 'D';
        if(sj > tj)rep(i,sj-tj)cout << 'L';
        if(tj > sj)rep(i,tj-sj)cout << 'R';
        cout << endl;
        cin >> a;
    }
}

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

int main(){
	cerr << "s" << endl;
	start_time = GetSeconds();
	solve();
}

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007;

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

vector<int> x, y, z;

int dis(int j, int k){

    return abs(x[j] - x[k]) + abs(y[j] - y[k]) + max(0ll, z[k] - z[j]);
}

signed main(){
	cout<<fixed<<setprecision(10);

    int N, M;
	vector<vector<int>> dp;
	cin>>N;

    dp.resize(N, vector<int>(1<<N, INF));

    x.resize(N);
    y.resize(N);
    z.resize(N);

    for(int i = 0; i < N; i++){
        cin>>x[i]>>y[i]>>z[i];
    }

    dp[0][0] = 0;

    for(int i = 1; i < 1<<N; i++){
        for(int j = 0; j < N; j++){
            for(int k = 0; k < N; k++){
                if(!((i>>k)&1)) continue;

                dp[k][i] = min(dp[k][i|(1<<k)], dp[j][i^(1<<k)] + dis(j, k));
            }
        }
    }

    cout<<dp[0][(1<<N)-1]<<endl;

	return 0;
}


#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
using i64 = int64_t;
using v64 = vector<i64>;

#define rep(i, s, n) for (i64 i = (s); i < (n); ++i)

template <typename T>
ostream &operator<<(ostream &os, const std::unordered_set<T> &x) {
  os << "unordered_set{";
  for (const auto &v : x) {
    os << v << ", ";
  }
  os << "}";
  return os;
}

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

template <typename F, typename S>
std::ostream &operator<<(std::ostream &os, const std::pair<F, S> &x) {
  os << "pair{" << x.first << ", " << x.second << "}";
  return os;
}

template <typename T1>
void dbg(const T1 &x1) {
  std::cerr << x1 << std::endl;
}

template <typename T1, typename T2>
void dbg(const T1 &x1, const T2 &x2) {
  std::cerr << x1 << " " << x2 << std::endl;
}

template <typename T1, typename T2, typename T3>
void dbg(const T1 &x1, const T2 &x2, const T3 &x3) {
  std::cerr << x1 << " " << x2 << " " << x3 << std::endl;
}

template <typename T1, typename T2, typename T3, typename T4>
void dbg(const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4) {
  std::cerr << x1 << " " << x2 << " " << x3 << " " << x4 << std::endl;
}

template <typename T1, typename T2, typename T3, typename T4, typename T5>
void dbg(const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5) {
  std::cerr << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5
            << std::endl;
}

template <typename T1, typename T2, typename T3, typename T4, typename T5,
          typename T6>
void dbg(const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5,
         const T6 &x6) {
  std::cerr << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << " "
            << x6 << std::endl;
}

template <typename T>
std::vector<pair<std::int64_t, std::int64_t>> factor(T n) {
  assert(1 <= n);
  std::vector<pair<std::int64_t, std::int64_t>> ret{};
  std::int64_t i{2};
  while (i * i <= n) {
    std::int64_t count{0};
    while (n % i == 0) {
      n /= i;
      ++count;
    }
    if (count) {
      ret.push_back(std::make_pair(i, count));
    }
    if (i % 2) {
      ++i;
    }
    ++i;
  }
  if (1 < n) {
    ret.push_back(std::make_pair(n, 1));
  }
  return ret;
}

template <typename T>
constexpr T ipow(T x, T n) {
  assert(0 <= n);
  T ret{1};
  while (0 < n) {
    if (n % 2 == 1) {
      ret *= x;
      --n;
    } else {
      x *= x;
      n /= 2;
    }
  }
  return ret;
}

void run() {
  i64 n;
  cin >> n;
  auto fs = factor(n);
  i64 nret{1};
  for (const auto &[f, c] : fs) {
    nret *= c + 1;
  }
  v64 ret(nret, 1);
  i64 chunk{1};
  for (const auto &[f, c] : fs) {
    rep(ir, 0, nret / (chunk * (c + 1))) {
      i64 s{1};
      rep(ic, 1, c + 1) {
        s *= f;
        rep(ichunk, 0, chunk) {
          ret[ir * chunk * (c + 1) + ic * chunk + ichunk] *= s;
        }
      }
    }
    chunk *= c + 1;
  }
  sort(begin(ret), end(ret));
  for (const auto r : ret) {
    cout << r << endl;
  };
}

int main() {
  cin.tie(nullptr);
  cout.precision(std::numeric_limits<double>::max_digits10);
  run();
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	a = a % MOD;
	while (b > 0) {
		if (b & 1) {res = (res * a) % MOD; b--;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

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

int main() {
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	vl fact;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i)
			continue;
		if (i * i != n)
			fact.pb(n / i);
		fact.pb(i);
	}
	sort(all(fact));
	for (auto i : fact)
		cout << i << "\n";
}


#include <bits/stdc++.h>

#define int long long

#define f first
#define s second
#define rep(i,a,b)for(int i=a;i<b;i++)
#define pb push_back

const int mod = 1e9 + 7;
const int INF = 1e18;
const int SIZE = 1e5 + 5;
using namespace std;

void solve() {

    int n;
    cin >> n;

    int a[n];
    rep(i, 0, n) {cin >> a[i]; a[i] %= 200;}

    int ans = 0;

    map<int, int> mp;

    rep(i, 0, n) {
        mp[a[i]]++;
    }

    for (auto it : mp) {
        int k = it.second;

        ans += (k * (k - 1)) / 2;
    }

    cout << ans << "\n";

}

signed main()
{
    ios::sync_with_stdio(0);

    cin.tie(0);
    cout.tie(0);

    int T = 1;

    // cin >> T;
    // sieve();

    // op();

    while (T--)
    {

        solve();

    }

    return 0;
}


/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 262144

int a[N];
lli b[N];
lli pre[N];
lli ans[N];

int main()
{
    int n;
    scanf("%d", &n);
    for(int i=0;i<n;++i) scanf("%d", &a[i]);
    b[0] = a[0];
    for(int i=1;i<n;++i)
        b[i] = b[i-1] + a[i];
    for(int i=0;i<n;++i)pre[i+1] = pre[i]+b[i];
    int m = 0;
    for(int i=0;i<n;++i)
    {
        m = std::max(m, a[i]);
        ans[i] = pre[i+1] + (lli)m*(i+1);
    }
    for(int i=0;i<n;++i) printf("%lld\n", ans[i]);
    return 0;
}

// Author :: <Hitesh_Saini>
#include<bits/stdc++.h>

#define __speed() ios_base::sync_with_stdio(false), cin.tie(nullptr);
#define dbg(x) cout << "(" << __LINE__ << ": "<< #x << " = " << x << ")\n"

#define Yes(x) print((x) ? "Yes" : "No")
#define tt 	int t; for (cin >> t; t--; )

#define f0(i, n)  for (i = 0; i < (int)(n); i++)
#define f1(i, n)  for (i = 1; i <=(int)(n); i++)

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

#define EB emplace_back
#define PB push_back

#define LB lower_bound
#define UB upper_bound

#define endl "\n"
#define S second
#define F first

using namespace std;
using mii = map<int, int>;
using pii = pair<int, int>;

using ll = int64_t;
using vi = vector<int>;

using vvi = vector<vi>;
using vl = vector<ll>;

const pair<int, int> DD[] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int mod = 1e9 + 7, mxN = 1e5 + 5, INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

template <typename... T> void print(T... args) { ((cout << args << " "), ...), cout << endl; }

template <typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2>& p) { in >> p.F >> p.S; return in; }
template <typename T1, typename T2> ostream& operator<<(ostream& ot, pair<T1, T2>& p) { ot << p.F << ' ' << p.S; return ot; }

template <typename T1, typename T2> bool cmax(T1& a, T2 b) { if (b > a) { a = b; return true;} return false; }
template <typename T1, typename T2> bool cmin(T1& a, T2 b) { if (b < a) { a = b; return true;} return false; }

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

void solve() {
	int n, m;
	cin >> n >> m;
	vi A(n), B(m);
	cin >> A >> B;
	mii mp;
	for (int x : A) mp[x]++;
	for (int x : B) mp[x]++;
	for (auto& [x, f] : mp) {
		if (f == 1)
			cout << x << ' ';
	}

}

signed main() {
	 __speed() solve();
	 // int t, i; for (cin >> t, i = 1; i <= t; i++) cout << "Case #" << i << ": ", solve();
}


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

int main() {

  double a,b;
  cin >> a >> b;
  double ans;

  ans = ((a-b)/a)*100;
  cout << std::fixed << std::setprecision(18) << ans;

}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <numeric>
#include <math.h>
#include <string.h>
#include <stdlib.h>

using namespace std;

#if __cplusplus >= 201103L
    #include <unordered_set>
    #include <unordered_map>
    #include <chrono>
    #include <random>
    #include <bits/stdc++.h>
    struct pairhash {
        template<class T, class U>
        size_t operator() (const pair<T,U> &p) const {
            static const uint64_t FIXED_RANDOM = (uint64_t)chrono::steady_clock::now().time_since_epoch().count();
            return splitmix64(p.first + FIXED_RANDOM) ^ splitmix64(p.second+ FIXED_RANDOM);
        }
        static uint64_t splitmix64(uint64_t x) {
            x += 0x9e3779b97f4a7c15;
            x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
            x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
            return x ^ (x >> 31);
        }
    };
    mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

    inline int randint(int l, int r) {
        return uniform_int_distribution<int>(l,r)(rng);
    }

    inline double randdouble(double l, double r) {
        return uniform_real_distribution<double>(l,r)(rng);
    }
#endif

#define fastio ios::sync_with_stdio(false); cin.tie(0);
#define ll long long
#define ll128 __int128_t
#define PI 3.14159265358979323846
#define min(a,b) ((a<b)?(a):(b))
#define max(a,b) ((a<b)?(b):(a))
#define abs(a) ((a>0)?a:-(a))
#define pii pair<int,int>
#define pll pair<ll,ll>

template <typename T>
inline void read(T& x) {
    x = 0;
    bool f = 0;
    char ch = (char)getchar();
    while (ch < '0' || ch > '9') {  // ch 不是数字时
        if (ch == '-') f = 1;        // 判断是否为负
        ch = (char)getchar();               // 继续读入
    }
    while (ch >= '0' && ch <= '9') {  // ch 是数字时
        x = x*10 + (ch&15);  // 将新读入的数字’加’在 x 的后面, ch&15等同于ch-'0'
        ch = (char)getchar();  // 继续读入
    }
    if (f) x = -x;
}

template <typename T>
inline void write(T x) {
    static int st[35];
    int top = 0;
    do {
        st[top++] = x % 10; x /= 10;
    } while (x);
    while (top) putchar(st[--top] + '0');
}

const double pi = acos(-1.0);
const double eps = (double)1e-4;

const int mod = 1e9+7;
const int maxn = 1e5+5;
const int maxm = 2e5+10;

int main() {
    fastio;

    double a,b; cin >> a >> b;
    cout << (a-b) / a * 100 << endl;
}


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

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

using ll = long long;
using P = pair<int, int>;
using vvi = vector<vector<int>>;
using vi = vector<int>;

const ll MOD = 1e9 + 7;
const int INF = 1001001001;
const double PI = 3.14159265358979323846;

void solve() {
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i, n) cin >> A[i];

    int ans = 0;
    rep(i, n) {
        if (A[i] > 10) ans += A[i] - 10;
    }
    cout << ans << endl;
}

int main() {

    solve();

    return 0;
}

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

int main(){
	string S;
	cin >> S;
	bool flag=true;
	deque<char> ans;

	for(int i=0;i<S.size();i++){
		if(S[i]=='R')flag=(!flag);
		else if(flag){
			if(!ans.empty() && S[i]==ans.back())ans.pop_back();
			else ans.push_back(S[i]);
		}
		else{
			if(!ans.empty() && S[i]==ans.front())ans.pop_front();
			else ans.push_front(S[i]);
		}
	}

	string ANS="";
	for(auto c:ans)ANS+=c;
	if(!flag)reverse(ANS.begin(),ANS.end());
	cout << ANS << endl;
	return 0;
}


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

void recursive(vector<vector<int>>& arr, int h, int w, int& ans,int a_count, int a)
{

    if(a==a_count)
    {
        ans++;
        return;
    }
    if(a_count<a){
        for(int i=0;i<h;i++)
        {
            for(int j=0;j<w-1;j++)
            {
                if(arr[i][j] == 0 && arr[i][j+1]==0)
                {

                    arr[i][j] = 1;
                    arr[i][j+1] = 1;
                    recursive(arr, h, w, ans , a_count+1,a);
                    arr[i][j] = 0;
                    arr[i][j+1] = 0;
                }
            }
        }

        for(int i=0;i<h-1;i++)
        {
            for(int j=0;j<w;j++)
            {
                if(arr[i][j] == 0 && arr[i+1][j]==0)
                {
                    arr[i][j] = 1;
                    arr[i+1][j] = 1;
                    recursive(arr, h, w, ans , a_count+1, a);
                    arr[i][j] = 0;
                    arr[i+1][j] = 0;
                }
            }
        }
    }

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h,w,a,b;
    int ans=0;
    cin>>h>>w>>a>>b;
    vector<vector<int>> arr(h, vector<int>(w,0));
    recursive(arr, h, w, ans , 0, a);
    long fact=1;
    for(int i = 1; i <=a ; ++i){
        fact*=i;
    }
    cout<<ans/fact;

}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>
#include <set>

using namespace std;

int main(){

    long long N;
    cin >> N;

    set<long long> numSet;
    for(long long i = 2; i <= 100000; i++){
        if(i * i > N){
            break;
        }

        if(numSet.find(i) == numSet.end()){
            long long temp = i * i;
            while(temp <= N){
                numSet.insert(temp);
                temp *= i;
            }
        }
    }

    long long ans = N - (int)numSet.size();
    cout << ans << endl;

    return 0;
}

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define all(v) begin(v), end(v)
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)

using namespace std;

using ll = int_fast64_t;
using ld = long double;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
template <class T> using pq  = priority_queue<T>;
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

constexpr ll INF   = (1LL << 30);
constexpr ll INFLL = (1LL << 60);
constexpr ll MAX   = 500005;
constexpr ll MOD   = 1000000007;

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

  ll n;
  cin >> n;

  rep2(i, 1, 1e6) {
    string s = to_string(i);
    s += s;

    ll t = stol(s);
    if (t > n) {
      cout << i-1 << endl;
      return (0);
    }
  }

  return (0);
}


#include <bits/stdc++.h>
using namespace std ;
int main (){
    char a,b,c;
    cin>>a>>b>>c;
    cout<<b<<c<<a;

 return 0;
}

//x<<y=x*2^y,x>>y=x/2^y
//1e5+3 is prime
// in a matrix, all elements of a primary diagonal have constant diff of coordinates
// and a secondary diagonal has constant sum of coordinates
//use ll() for using an integer in self-built fn
//(x&-x) bitwise and of (x and its 2's complement) returns (last set bit)
//eg if x=1010 then it will return 0010
// careful dont print empty container(run time error)
//v.erase O(n)
//use ("\n") instead of endl as endl flushes the output buffer
//every time so takes more time than \n (TLE)
//stoll() and to_string((less than 1e19))
//INT_MAX is approx 3e10
//For sets use set_name.lower_bound(x)(strictly O(logn))
//NOT lb(all(s),x)(O(logn) for random access (eg vector) but for sets it is O(n));
#include<bits/stdc++.h>
typedef long long int ll;
#define ull unsigned long long int
#define lld long double
#define endl "\n"
#define fi first
#define sec second
#define sp setprecision
#define lb lower_bound
#define ub upper_bound
#define For(i, a, b) for(long long int i = (a); i <= (b); i++)
#define Forr(i, a, b) for(long long int i = (a); i >= (b); i--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vlld vector<lld>
#define vi vector<int>
#define vch vector<char>
#define sll set<ll>
#define sch set<ch>
#define vpll vector< pair<ll,ll> >
#define vpii vector< pair<int,int> >
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mll map<ll, ll>
#define mcll map<char,ll>
#define sz(container) ll((container).size())
#define fill(a,b) memset(a, b, sizeof(a))
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
using namespace std;
lld pi=3.1415926535897932;
const ll mod=1000000007;
const ll dx[4]={-1, 0, 1, 0} , dy[4]={0, 1, 0, -1};
const ll dxx[8]={-1, -1, 0, 1, 1, 1, 0, -1} , dyy[8]={0, 1, 1, 1, 0, -1, -1, -1};
string ds="RLDU";

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

ll binpow(ll a, ll b,ll m)
{
    a %= m;
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll Pow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a;
        a = a * a ;
        b >>= 1;
    }
    return res;
}
ll modinv(ll n,ll mod)
{
    return binpow(n, mod - 2,mod);
}

/*******************************************coding********/
ll gcdExtended(ll a, ll b, ll &x, ll &y){
    if(a == 0){
        x = 0;
        y = 1;
        return b;
    }
    ll x1, y1;
    ll gcd = gcdExtended(b%a, a, x1, y1);
    x = y1 - (b/a) * x1;
    y = x1;
    return gcd;
}

ll modInverse(ll a, ll m){
    ll x, y;
    ll g = gcdExtended(a, m, x, y);
    ll res = (x%m + m) % m;
    return res;
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast_io;
    ll T=1;cin>>T;
    For(i,1,T)
    {
        ll n,s,k;cin>>n>>s>>k;
        s=n-s;
        ll d=__gcd(__gcd(s,k),n);
        s/=d;k/=d;n/=d;
        if(__gcd(k,n)==1)
        {
            cout<<(s*modInverse(k,n))%n<<endl;
        }
        else cout<<-1<<endl;
    }
}


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

using namespace std;

int main()
{
  long long int N, C_SUNUKE;
  scanf("%lld %lld", &N, &C_SUNUKE);
  getchar();

  vector<pair<int,int>> events;
  for (int i=0; i < N; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    events.emplace_back(a-1, c);
    events.emplace_back(b, -c);
    getchar();
  }

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

  long long int cost = 0, total_cost = 0, t = 0;
  for (auto [x,y] : events)
  {
    if (t != x) {
      total_cost += min(cost, C_SUNUKE) * (x-t);
      t = x;
    }
    cost += y;
  }
  cout << total_cost << endl;
}

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

typedef long long ll;

bool ll_sqrt(ll x, ll& lower_bound, ll& upper_bound)
{
	constexpr ll ll_max = numeric_limits<ll>::max();

	bool first_boost = true;

	lower_bound = 0;
	upper_bound = x;
	while (upper_bound - lower_bound > 1)
	{
		if (first_boost)
		{
			ll guess = (ll)sqrt((double)x);
			lower_bound = max(guess - 1, (ll)0);
			upper_bound = lower_bound + 3;
			first_boost = false;
		}

		ll newval = (lower_bound + upper_bound) / 2;
		if ((newval != 0) && (newval > ll_max / newval))  // newval*newval becomes overflow
			upper_bound = newval;  // because overflow means newval is too big
		else
		{
			ll newval_sqr = newval * newval;
			if (newval_sqr < x)
				lower_bound = newval;
			else
				upper_bound = newval;
		}
	}

	if ((upper_bound != 0) && (upper_bound > ll_max / upper_bound))
	{
		if (lower_bound * lower_bound == x)
			upper_bound = lower_bound;
	}
	else
	{
		if (lower_bound * lower_bound == x)
			upper_bound = lower_bound;
		else if (upper_bound * upper_bound == x)
			lower_bound = upper_bound;
	}
	bool is_exact = (lower_bound == upper_bound);
	return is_exact;
}

ll ll_ceil(ll x, int digit);
ll ll_floor(ll x, int digit);

ll ll_floor(ll x, int digit)
{
	if (x < 0)
		return -ll_ceil(-x, digit);

	ll div = 1;
	while (digit != 0)
	{
		div *= 10;
		digit--;
	}
	ll modval = x % div;
	ll ans = x - modval;
	return ans;
}

ll ll_ceil(ll x, int digit)
{
	if (x < 0)
		return -ll_floor(-x, digit);

	ll div = 1;
	while (digit != 0)
	{
		div *= 10;
		digit--;
	}
	ll modval = x % div;
	ll ans = x - modval;
	if (modval != 0)
		ans += div;
	return ans;
}
int main() {
	ll N, C;
	cin >> N >> C;

	ll a[N];
	ll b[N];
	ll c[N];

	map<ll, list<ll>> start;
	map<ll, list<ll>> stop;
	unordered_set<ll> visited;
	priority_queue<ll,vector<ll>,greater<ll>> q;

	for (ll i = 0; i < N; i++)
	{
		cin >> a[i] >> b[i] >> c[i];
		start[a[i]].push_front(i);
		stop[b[i]].push_front(i);
		if(!visited.count(a[i])){
		q.push(a[i]);
		visited.insert(a[i]);
		}
		if(!visited.count(b[i])){
		q.push(b[i]);
		visited.insert(b[i]);
		}
	}

	ll ans = 0;
	ll payPday = 0;
	ll pre=0;

	while(!q.empty()){
		ll day = q.top();q.pop();
		ans+=min(payPday, C)*(day-pre-1);
		if(start.count(day)>0){
			for(ll service:start[day]){
				payPday+=c[service];
			}
		}
		ans+=min(payPday, C);
		if(stop.count(day)>0){
			for(ll service:stop[day]){
				payPday-=c[service];
			}
		}
		pre=day;

	}

	cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
//reverse(s.begin(),s.end())
ll gcd(ll a,ll b){
    ll s=1,c;
    while(a&&b){
        if((~a&1)&&(~b&1))
            a>>=1,b>>=1,s<<=1;
        else if(~a&1)a>>=1;
        else if(~b&1)b>>=1;
        else if(a>b)a=a-b;
        else c=b-a,b=a,a=c;
    }
    if(!a)return b*s;
    if(!b)return a*s;
}
int main(){
	ll n=1;cin>>n;
	ll k;ll ans = 6987268688401;
	cout<<ans;
}

/* Basic Inclusion */
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
/* definition */
#define rep(i, N) for (ll i = 0; i < (ll)(N); i++)
#define repp(i, N) for (ll i = 1; i <= (ll)(N); i++)
#define per(i, N) for (ll i = (ll)(N)-1; i >= 0; i--)
#define pper(i, N) for (ll i = (ll)(N); i > 0; i--)
#define pub(n) push_back(n)
#define pob(n) pop_back(n)
#define all(v) (v).begin(), (v).end()
#define grsort(v) sort((v).begin, (v).end, greater<>())
#define setpre(i) cout << fixed << setprecision((ll)(i))
#define tstr to_string
#define bpop(n) __builtin_popcount(n)
/* I am lazy XD */
#define co(ans) cout << (ans)
#define out(ans) << (ans)
#define margin << " "
#define fin << endl
#define enter cout << endl
/* Common */
#define ll long long
#define dd double
#define cc char
#define ss string
ll cin_long_long(){ ll value; cin >> value; return value; }
dd cin_double(){ dd value; cin >> value; return value; }
cc cin_char(){ cc value; cin >> value; return value; }
ss cin_string(){ ss value; cin >> value; return value; }
#define cinl cin_long_long()
#define cind cin_double()
#define cinc cin_char()
#define cins cin_string()
#define mod 1000000007
#define inf 9223372036854775807
#define minf -9223372036854775807
#define pi 3.1415926535897932384626433832795028
ll bit(ll N){ return (1 << N); }
/* template functions */
ll ctol(char c){
   switch (c){
   case '1': return 1; break;
   case '2': return 2; break;
   case '3': return 3; break;
   case '4': return 4; break;
   case '5': return 5; break;
   case '6': return 6; break;
   case '7': return 7; break;
   case '8': return 8; break;
   case '9': return 9; break;
   case '0': return 0; break;
   default: return 0; break;
   }
}
/* main functions*/
/* main */
int main(void){
   ll N = cinl; vector<ll> A(N);
   vector<ll> note(N,1);
   rep(i,N) A[i] = cinl;
   rep(i,N){
      if(A[i] <= 0 || A[i] > N){
         co("No") fin;
         return 0;
      }
      else{
         if(note[A[i]-1] == 0){
            co("No") fin;
            return 0;
         }
         note[A[i]-1]=0;
      }
   }
   co("Yes") fin;
}
// /* fin */


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>

using namespace std;

typedef long long LL;

const int N = 200010;

int n;
char a[N], player[N];
int w[N];

int f[N][7];
int dfs(int u, int k)
{
    if(f[u][k] != -1)  return f[u][k];
    if(u == n)
    {
        if(player[u] == 'T')
        {
            if((k + w[u]) % 7 == 0)  return f[u][k] = 1;
            if(k % 7 == 0)  return f[u][k] = 1;
            return f[u][k] = 0;
        }
        else
        {
            if((k + w[u]) % 7)  return f[u][k] = 0;
            if(k % 7)  return f[u][k] = 0;
            return f[u][k] = 1;
        }
    }

    if(player[u] == 'T')
    {
        if(dfs(u + 1, (k + w[u]) * 10 % 7))  return f[u][k] = 1;
        if(dfs(u + 1, k * 10 % 7))  return f[u][k] = 1;
        return f[u][k] = 0;
    }
    else
    {
        if(!dfs(u + 1, (k + w[u]) * 10 % 7))  return f[u][k] = 0;
        if(!dfs(u + 1, k * 10 % 7))  return f[u][k] = 0;
        return f[u][k] = 1;
    }
}

int main()
{
    scanf("%d%s%s", &n, a + 1, player + 1);
    for(int i = 1; i <= n; i ++)  w[i] = a[i] - '0';

    memset(f, -1, sizeof f);
    if(dfs(1, 0))  puts("Takahashi");
    else  puts("Aoki");
    return 0;
}

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

#define fastio                  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define input_output            freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

template <typename Arg1>
void prn(Arg1&& arg1) { cout<<arg1<<"\n";}
template <typename Arg1, typename... Args>
void prn(Arg1&& arg1, Args&&... args) { cout<<arg1<<" "; prn(args...); }

template <typename Arg1>
void prs(Arg1&& arg1) { cout<<arg1<<" ";}
template <typename Arg1, typename... Args>
void prs(Arg1&& arg1, Args&&... args) { cout<<arg1<<" "; prs(args...); }

template <typename Arg1>
void read(Arg1&& arg1) { cin>>arg1; }
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) { cin>>arg1; read(args...); }

#define int                     long long
#define all(ds)                 ds.begin(), ds.end()
#define uniq(v)                 (v).erase(unique(all(v)),(v).end())
#define gcd(x,y)                __gcd(x,y)
#define rep(i,a,b)              for(int i=a;i<b;i++)
#define precise(x)              cout<<fixed<<setprecision(x)
#define endl                    "\n"

const long long INF = 1e18;
const int32_t MOD = 1e9+7;
const int N = 5e5+5;

int n, m, k, q, r, l, x, y, z;
int a[N], b[N], c[N];
string s, t;
int ans = 0;

void solve(){
    int n;
    string s, x;
    read(n,s,x);
    vector<int>dp(7);
    dp[0] = 1;
    int ten = 1;
    for(int i = n-1; i >= 0; --i){
        vector<int> old(7);
        swap(old, dp);
        // rem = (rem*10)%7;
        for(int j = 0; j < 7; ++j){
            int nj = (ten * (s[i]-'0') + j)%7;
            if(x[i] == 'T'){
                dp[j] = old[j] | old[nj];
            }
            else{
                dp[j] = old[j] & old[nj];
            }
        }
        ten = (ten*10)%7;
    }
    if(dp[0] == 1) {
        prn("Takahashi");
    }
    else{
        prn("Aoki");
    }

}

signed main()
{
#ifndef ONLINE_JUDGE
    input_output
#else
    fastio
#endif

#ifdef SIEVE
    sieve();
#endif

#ifdef NCR
    init();
#endif

    int t = 1;
    // cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ff   first
#define ss   second
#define ll  long long
#define pb   push_back
#define mii  map<int,int>
#define pqb  priority_queue<int>
#define pqs  priority_queue<int,vi,greater<int> >
#define mod  1000000007
#define sp(x,y)  fixed<<setprecision(y)<<x
#define t(x)  int x; cin>>x; while(x--)
mt19937     rng(chrono::steady_clock::now().time_since_epoch().count());
#define setbits(x)  __builtin_popcountll(x)
#define zerobits(x)  __builtin_ctzll(x)
#define fo(i,n) for(i=0;i<n;i++)
#define PI 3.1415926535897932384626
#define vinput(p,x) for(int i=0;i<x;i++) cin>>p[i].ff>>p[i].ss;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
void SOE(int n)
{
        bool pr[n+1];
    memset(pr, true, sizeof(pr));

    for (int p=2; p*p<=n; p++)
    {
        if (pr[p] == true)
        {
            for (int i=p*2; i<=n; i += p)
                pr[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (pr[p])
          cout << p << " ";
}
bool isP(int n)
{  bool flag=1;
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0) {
            flag = 0;
            break;
        }
    }
    if(n<=1)
    flag=0;
    else if(n==2)
    flag=1;
    return flag;
}

double convt(string s,string a)
{
   double x=(s[0]-'0')*10 + (s[1]-'0');
   x=(double)((int)x%12);
   if(a[0]=='P')
    x+=12;
   double y=(s[3]-'0')*10 + (s[4]-'0');
   x=x+(y/100);
   return x;
}

void aks()
{
 ll a, b,c ,d;
 cin>>a>>b>>c>>d;
 ll ans=-300;
 for(ll i=a;i<=b;i++)
    for(ll j=c;j<=d;j++)
      {
          if(ans<=i-j)
            ans=i-j;
      }
 cout<<ans<<"\n";

}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    // code here
      //  t(x)
           aks();
    return 0;
}

#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<cstring>
#include<tuple>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;

const int INF = 1 << 30;

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

    cout << b - c<< endl;
}


#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

#define MOD 1000000007

int main() {
	int n = ri();
	int a[n];
	for (auto &i : a) i = ri();
	std::sort(a, a + n);

	int prev = 0;
	int res = 1;
	for (auto i : a) {
		res = (int64_t) res * (1 + i - prev) % MOD;
		prev = i;
	}
	printf("%d\n", res);
	return 0;
}

/*
author: madhav_1999 aka orthodoxparadox
18 April 2021 at 5:38 PM
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define dbl long double
#define int ll
#define ll long long
#define pii pair<int, int>
#define len(x) (int) x.size()
#define rev(a) reverse(all(a))
#define oiint ostream_iterator<int>(cout, " ")
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define onlyunique(v) v.erase(unique(all(v)), v.end()); //only for sorted vector
#define inf 2e18
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef MADHAV
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define dbg(...) 42
#endif
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(int i=0;i<(int)v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const multiset<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
struct pair_hash {inline std::size_t operator()(const std::pair<int, int> & v) const {return v.first*31+v.second;}};
const int MOD = 1e9 + 7;

int takemod(int a, int mod = MOD){a%=mod;if(a<0)a+=mod;return a;}

int fast_exp(int base, int expo, int mod = MOD) {
	int res=1;
	while(expo>0) {
		if(expo&1) res=(res*base)%mod;
		base=(base*base)%mod;
		expo>>=1;}
	return res;}

int modinv(int a, int mod = MOD){return takemod(fast_exp(takemod(a, mod), mod-2, mod), mod);}

void solve() {
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n, greater<int>());
	int ans = 1;
	for(int i = 1; i < n; i++) {
		ans = takemod(ans * (a[i - 1] - a[i] + 1));
	}
	ans = takemod(ans * (a[n - 1] + 1));
	cout << ans << endl;
}

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifdef MADHAV
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
	clock_t t1, t2;
	t1 = clock();

	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
#ifdef MADHAV
	t2 = clock(); cout << "\n\ntime taken: " << (t2-t1)/(dbl)CLOCKS_PER_SEC;
#endif
	return 0;
}


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

int main()
{
    long long N, A, P, X, s=0, a[100000];
    cin>>N;

    for(int i=0; i<N; i++)
    {
        cin>>A>>P>>X;
        if(X>A)
        {
            a[i]=P;
        }
        else
        {
            a[i]=0;
        }
    }

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

    if(s==0)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        sort(a, a+N);
        for(int i=0; i<N; i++)
        {
            if(a[i]>0)
            {
                cout<<a[i]<<endl;
                i=N;
            }
        }
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    int n;
    cin>>n;
    ll a[n];
    ll p[n];
    ll x[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>p[i]>>x[i];
    }
    ll ans = INT_MAX;
    for(int i=0;i<n;i++){
        int diff = x[i]-a[i];
        if(diff>0){
            ans = min(ans,p[i]);
        }
    }
    if(ans==INT_MAX)ans = -1;
    cout<<ans<<endl;
     return 0;
}


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

#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())
#define INT(...) int __VA_ARGS__; IN(__VA_ARGS__);
#define LL(...) ll __VA_ARGS__; IN(__VA_ARGS__);
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__);
#define CHR(...) char __VA_ARGS__; IN(__VA_ARGS__);
#define LD(...) ld __VA_ARGS__; IN(__VA_ARGS__);

/* const ll mod = 1e9 + 7; */
const ll mod = 998244353;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;

template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

void IN() {}

template <class Head, class... Tail>
void IN(Head &head, Tail &... tail) {
  cin >> head;
  IN(tail...);
}

class mint {
  private:
    ll x;

  public:
    constexpr mint(const ll x = 0) noexcept : x((x % mod + mod) % mod) {}
    constexpr ll value() noexcept { return x; }
    constexpr mint operator += (const mint right) noexcept {
      if ((x += right.x) >= mod) x -= mod;
      return *this;
    }
    constexpr mint operator -= (const mint right) noexcept {
      if ((x += mod - right.x) >= mod) x -= mod;
      return *this;
    }
    constexpr mint operator *= (const mint right) noexcept {
      x = x * right.x % mod;
      return *this;
    }
    constexpr mint operator /= (const mint right) noexcept {
      return *this *= right.inv();
    }
    constexpr mint operator + (const mint right) const noexcept {
      return mint(*this) += right;
    }
    constexpr mint operator - (const mint right) const noexcept {
      return mint(*this) -= right;
    }
    constexpr mint operator / (const mint right) const noexcept {
      return mint(*this) /= right;
    }
    constexpr mint operator * (const mint right) const noexcept {
      return mint(*this) *= right;
    }
    constexpr mint inv() const {
      return pow(mod-2);
    }
    constexpr mint pow(ll n) const {
      if (n == 0) return 1;
      mint a = pow(n>>1);
      a *= a;
      if (n & 1) a *= *this;
      return a;
    }
};

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  LL(a, b, c);

  mint aa = (a * (a + 1)) / 2;
  mint bb = (b * (b + 1)) / 2;
  mint cc = (c * (c + 1)) / 2;

  cout << (aa * bb * cc).value() << endl;

}

/*
 * @date:2021-04-24 20:37:33
 * @source:https://atcoder.jp/contests/abc199/tasks/abc199_f
*/
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 100 + 5;
const int MOD = 1e9 + 7;

int N, M, K;
long long A[MAXN];
int Num[MAXN];

struct Matrix {
    long long A[MAXN][MAXN];
    Matrix() {
        memset(A, 0, sizeof A);
    }
    Matrix operator * (const Matrix &x) const {
        Matrix c = Matrix();
        for (int i = 1; i <= N; ++i) {
            for (int j = 1; j <= N; ++j) {
                for (int k = 1; k <= N; ++k) {
                    c.A[i][j] = (c.A[i][j] + A[i][k] * x.A[k][j] % MOD) % MOD;
                }
            }
        }
        return c;
    }
} a;

long long poww(long long x, int t) {
    long long res = 1;
    for (; t; t >>= 1) {
        if (t & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

Matrix poww(Matrix &x, int t) {
    Matrix res = x;
    for (--t; t; t >>= 1) {
        if (t & 1) res = res * x;
        x = x * x;
    }
    return res;
}

int main() {
    scanf("%d%d%d", &N, &M, &K);
    for (int i = 1; i <= N; ++i) scanf("%lld", &A[i]);
    if (!K) {
        for (int i = 1; i <= N; ++i) {
            printf("%lld\n", A[i]);
        }
        return 0;
    }
    long long p = poww(M, MOD - 2), two = poww(2, MOD - 2);
    for (int i = 1, u, v; i <= M; ++i) {
        scanf("%d%d", &u, &v);
        ++Num[u], ++Num[v];
        a.A[u][v] = a.A[v][u] = p * two % MOD;
    }
    for (int i = 1; i <= N; ++i) {
        a.A[i][i] = p * (M - Num[i] + two * Num[i]) % MOD;
    }
    a = poww(a, K);
    for (int i = 1; i <= N; ++i) {
        long long x = 0;
        for (int j = 1; j <= N; ++j) {
            x = (x + A[j] * a.A[i][j]) % MOD;
        }
        printf("%lld\n", x);
    }
    return 0;
}


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

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

    int x0, y0, xn, yn;
    cin >> x0 >> y0;
    cin >> xn >> yn;

    double pi_n = 2.0 * M_PI / static_cast<double>(N);

    double cx = static_cast<double>(x0 + xn) / 2.0;
    double cy = static_cast<double>(y0 + yn) / 2.0;

    double x1 = x0 - cx;
    double y1 = y0 - cy;

    double xx1 = cos(pi_n) * x1 - sin(pi_n) * y1;
    double yy1 = sin(pi_n) * x1 + cos(pi_n) * y1;

    x1 = xx1 + cx;
    y1 = yy1 + cy;

    printf("%.11f %.10f\n", x1, y1);

    return 0;
}

#include <math.h>

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() { int N;
    cin >> N ;
    vector<int> X(N);
    long long M=0, C=0;
    long double U = 0.0;
    for (int i = 0; i < N; i++){
        int temp;
        cin >> temp;
        M += abs(temp);
        U += pow(abs(temp), 2);
        if (C < abs(temp)) C = abs(temp);
    }
    U = pow(U, 0.5);
    cout << M << endl;
    cout << setprecision(20) << fixed << U << endl;
    cout << C << endl;
    }


#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define nl "\n"
#define sp " "

void solve()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    int arr1[n]={0};
    for(int i=0;i<n;i++)
    {
        arr1[arr[i]-1]++;
    }
    for(int i=0;i<n;i++)
    {
        if(arr1[i]!=1)
        {
            cout<<"No"<<nl;
            return;
        }
    }
    cout<<"Yes"<<nl;
}

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

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

using ll = long long;
using db = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;

template<typename T> using pqg = priority_queue<T, vector<T>, greater<T> >;

#define FOR(i, a, n) for(int i=(a); i<(n); ++i)
#define ROF(i, a, n) for(int i=(n)-1; i>=(a); --i)

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int((x).size())
#define ins insert
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define endl '\n'

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

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

#define ts to_string
string ts(char c) { return string(1, c); }
string ts(const char* s) { return (string)s; }
string ts(const string& s) { return '"' + s + '"'; }
string ts(bool b) { return (b ? "true" : "false"); }

string ts(vector<bool> v) {
    string res = "{";
    FOR(i, 0, sz(v))
        res += char('0' + v[i]);
    res += "}";
    return res;
}

template <size_t SZ> string ts(bitset<SZ> b) {
    string res;
    FOR(i, 0, SZ)
        res += char('0' + b[i]);
    return res;
}

template <typename A, typename B> string ts(pair<A, B> p);
template <typename A> string ts(A v) {
    bool first = 1; string res = "{";
    for (const auto& x: v) {
        if (!first) res += ", ";
        first = 0; res += ts(x);
    }
    res += "}"; return res;
}

template <typename A, typename B> string ts(pair<A, B> p) {
    return "(" + ts(p.fi) + ", " + ts(p.se) + ")";
}

void dbgOut() { cerr << "]" << endl; }
template <typename H, typename... T> void dbgOut(H h, T... t) {
    cerr << ts(h); if (sizeof...(t)) cerr << ", ";
    dbgOut(t...);
}

#ifdef LOCAL
    #define dbg(...) cerr << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", dbgOut(__VA_ARGS__)
#else
    #define dbg(...) 0
#endif

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

void solve() {
    int n; cin >> n;
    vi a(n);
    FOR(i, 0, n) cin >> a[i];

    sort(all(a));
    FOR(i, 0, n) {
        if (a[i] != i + 1) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

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

#ifdef LOCAL
    auto begin = std::chrono::high_resolution_clock::now();
#endif

    solve();

#ifdef LOCAL
    auto end = std::chrono::high_resolution_clock::now();
    cerr << "\nExecution time: " << std::chrono::duration_cast<std::chrono::duration<double>> (end-begin).count() << " seconds\n";
#endif
}


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

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

using ll=long long;
ll d[1234567];

signed main(){
  ll ans=0;
  ll l,r;cin>>l>>r;
  for(ll g=2;g<=r;g++){
    d[g]++;
    if(d[g]){
      ll A=(r/g-(l-1)/g)*(r/g-(l-1)/g);
      ans+=d[g]*A;
      for(int i=2;g*i<=r;i++)d[g*i]-=d[g];
    }
    if(g>=l){
      ans-=((r/g-(l-1)/g)*2-1);
    }
  }
  cout<<ans<<endl;
}
/*
4,4 4,6 6,4 6,6
6,6
-4,4
*/

//header{{{
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) begin(x),end(x)
#define Fixed fixed << setprecision(12)
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7;
constexpr int mod2 = 998244353;

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

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

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
template <class T> using Set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class K, class V> using Umap = gp_hash_table<K, V>;
using Trie = trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update>;

inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

//}}}
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    int n, cnt = 0;
    string s;

    cin >> n >> s;

    for(int i = 0; i < n; ++i){
        int a, t, c, g;
        a = t = c = g = 0;
        for(int j = i; j < n; ++j){
            a += (s[j] == 'A');
            t += (s[j] == 'T');
            c += (s[j] == 'C');
            g += (s[j] == 'G');
            cnt += (a == t && c == g);
        }
    }

    cout << cnt << '\n';

    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<complex>
#include<cstdio>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 100005
#define mid(l,r) l+(r-l)/2
#define removeduplicates(vec) vec.erase( unique( vec.begin(), vec.end() ), vec.end() )
#define memset1(v) memset(v,-1,sizeof(v))
#define memset0(v) memset(v,0,sizeof(v))
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}

void solve(){
	map<int,vector<int>>id;
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		id[x].pb(y);
	}
	map<int,int>vis;
	vis[n]=1;
	for(auto p:id){
		int x=p.fi;
		map<int,int>vis1;
		for(int y:p.se){
			if(vis.find(y+1)!=vis.end())vis1[y]=1;
			if(vis.find(y-1)!=vis.end())vis1[y]=1;
		}
		for(int y:p.se)if(vis.find(y)!=vis.end())vis.erase(y);
		for(pii p1:vis1)vis[p1.fi]=1;
	}
	cout<<vis.size();
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

#include <bits/stdc++.h>
#define INF LLONG_MAX/2
#define rep(i,n) for(int i = 0; i <(n) ; i++)
using namespace std;
typedef long long ll;
typedef  __int128_t LL; //入出力では使えないことに注意が必要. 計算過程で途中64bitを超える可能性があるときに使う
typedef pair<ll,ll> pll;
#define all(x) (x).begin(), (x).end()
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; }

// vector<vector<ll> > dp(N+1, vector<ll>(2, 0));
// vector<vector<vector<ll> > > dp(N, vector<vector<ll> >(M, vector<ll>(L, 0)));
int main(){
    ll N, M;
    cin >> N >> M;
    ll offset = 300010;
    vector<vector<bool> > dp(2, vector<bool>(600020, false));

    vector<pll> p;
    for(ll i=0; i<M; i++){
        ll x, y;
        cin >> x >> y;
        y-=N;
        if(y<-200010 || 200010<y){
            continue;
        }
        p.push_back(pll(x,y));
    }
    if(p.size()==0){
        cout << 1 << endl;
        return 0;
    }
    sort(all(p), greater<pll>());
    dp[0][0+offset] = true;
    dp[1][0+offset] = true;
    ll now_x= 0;
    while(p.size()>0) {
        pll point = p.back();
        p.pop_back();
        now_x = point.first;
        vector<ll> ys;
        ys.push_back(point.second);
        while(p.size()>0 && p.back().first==now_x){
            ys.push_back(p.back().second);
            p.pop_back();
        }
        for(ll pawn: ys){
            dp[1][pawn+offset] = dp[0][pawn-1+offset] || dp[0][pawn+1+offset];
        }

        dp[0] = dp[1];
    }
    ll ans = 0;
    for(ll i = 0; i<dp[0].size(); i++){
        ans += dp[0][i];
    }

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


//By Vasu Agrawal
#include<iostream>
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define pob pop_back
#define mk make_pair
#define fr first
#define sc second
#define pu push
#define ins insert
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))
#define V(a) vector<a>
#define pp pair<ll,ll>
#define lb(a,n) lower_bound(a.begin(),a.end(),n)-a.begin()
#define ub(a,n) upper_bound(a.begin(),a.end(),n)-a.begin()
#define F(i,n) for(ll i=0;i<n;i++)
#define in(a,n) F(i,n) cin>>a[i]
#define in1(a,n) f(i,n) cin>>a[i]
#define out1(a,n); f(i,n) cout<<a[i]<<" ";cout<<endl;
#define out(a,n); F(i,n) cout<<a[i]<<" ";cout<<endl;
#define f(i,n) for(ll i=1;i<=n;i++)
#define all(a) a.begin(),a.end()
#define vasu2907 ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
bool isprime(ll n) //Time Complexity--->sqrt(n)
{   if (n <= 1)  return false; if (n <= 3)  return true;
  	if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false;
    return true;
}
vector<ll> prime;
void sieve(ll n)
{	bool bakh[n+1];memset(bakh, true, sizeof(bakh));
    for (ll p=2; p*p<=n; p++)
    {	if (bakh[p] == true)
        {	for (ll i=p*p; i<=n; i += p)    bakh[i] = false; } }
  	for (ll p=2; p<=n; p++)    if (bakh[p])
	  	prime.pb(p);
}//Taken from https://www.geeksforgeeks.org/eulers-totient-function-for-all-numbers-smaller-than-or-equal-to-n/
ll eulertotient(ll z)   //Time--->n/logn
{	ll fac=z;
	for(ll i=0;prime[i]*prime[i]<=z;i++)
	{	if(z%prime[i]==0)
		{	fac-=(fac/prime[i]);	while(z%prime[i]==0)	z/=prime[i];	}
	}	if(z>1)	fac-=(fac/z);
	return fac;
}
//Taken from https://www.geeksforgeeks.org/modular-exponentiation-power-in-modular-arithmetic/
ll power(ll x,ll y,ll p)
{	ll res = 1; x = x % p;	while (y > 0)  {	if (y & 1)	res = (res*x) % p; 	y = y>>1;	x = (x*x) % p; }return res; }
//Taken from https://www.geeksforgeeks.org/euclidean-algorithms-basic-and-extended/
ll gcd(ll a,ll b)
{	if (a == 0)    return b; 	return gcd(b % a, a); }
ll lcm(ll a,ll b)
{	ll g=gcd(a,b); ll ans=(a*b)/g; return ans;	}
//Taken from https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/
ll modInverse(ll a, ll m)
{	ll hvf=gcd(a,m);	if(hvf==1)	return power(a,m-2,m);	return -1;}
void multiply(ll F[2][2], ll M[2][2])
{ ll x =  F[0][0]*M[0][0] + F[0][1]*M[1][0];  ll y =  F[0][0]*M[0][1] + F[0][1]*M[1][1];
  ll z =  F[1][0]*M[0][0] + F[1][1]*M[1][0];  ll w =  F[1][0]*M[0][1] + F[1][1]*M[1][1];
  F[0][0] = x;   F[0][1] = y;   F[1][0] = z;   F[1][1] = w;
}
void powermat(ll F[2][2], ll n)
{	if( n == 0 || n == 1)
    return; ll M[2][2] = {{1,1},{1,0}};   powermat(F, n/2);   multiply(F, F);   if (n%2 != 0)      multiply(F, M);
}
ll fib(ll n)
{ ll F[2][2] = {{1,1},{1,0}};
  if (n == 0) return 0; powermat(F, n-1);   return F[0][0];
}
V(ll) merge(V(ll) v1,V(ll) v2)
{	V(ll) temp;
	ll i=0,j=0;
	while(i<v1.size() && j<v2.size())
	{	if(v1[i]<v2[j])
			temp.pb(v1[i]),i++;
		else
			temp.pb(v2[j]),j++;
	}
	while(i<v1.size())
		temp.pb(v1[i]),i++;
	while(j<v2.size())
		temp.pb(v2[j]),j++;
	return temp;
}
//id=(id&(id+1))-1
//ll fetch(ll id)
//{
//}
//id=(id|(id+1))
//void update(ll id)
//{
//}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// Code Starts Here
int main()
{	vasu2907;
	ll n,a=0,b=0,ans=0;
	cin>>n;
	string st;
	cin>>st;
	map<char,ll> mp;
	mp['A']=0, mp['T']=1,mp['C']=2,mp['G']=3;
	ll ar[4];
	F(i,n)
	{	a=0;b=0;
		mem(ar,0);
		for(ll j=i;j<n;j++)
		{	ar[mp[st[j]]]+=1;
			if(ar[0]==ar[1] && ar[2]==ar[3])	ans+=1;
		}
	}
	cout<<ans<<endl;
}

#include <cstdio>
using namespace std;

const int MAX_N = 5010;
int A[MAX_N], Prefix[4][MAX_N];
int N;

char GetChar()
{
	char c;
	do
		c = getchar();
	while (c == ' ' || c == '\n' || c == '\r');
	return c;
}

void ReadA()
{
	const char *s = "ATCG";
	for (int i = 1; i <= N; i++)
	{
		char c = GetChar();
		for (int j = 0; j < 4; j++)
			if (c == s[j])
				A[i] = j;
	}
}

void GetPrefix()
{
	for (int i = 1; i <= N; i++)
	{
		for (int j = 0; j < 4; j++)
			Prefix[j][i] = Prefix[j][i - 1];
		Prefix[A[i]][i]++;
	}
}

int GetAns()
{
	int ans = 0;
	for (int i = 1; i < N; i++)
		for (int j = i + 1; j <= N; j++)
			if (
				Prefix[0][j] - Prefix[0][i - 1] == Prefix[1][j] - Prefix[1][i - 1] &&
				Prefix[2][j] - Prefix[2][i - 1] == Prefix[3][j] - Prefix[3][i - 1])
				ans++;
	return ans;
}

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	scanf("%d", &N);
	ReadA();
	GetPrefix();
	printf("%d\n", GetAns());
	return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int inf = 100100101;
const ll ll_inf = 1e9+7;
const int mod = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }

int main(){
  int n, x;
  cin >> n >> x;
  vector<int> v(n), p(n);
  rep(i,n) cin >> v[i] >> p[i];

  x *= 100;
  double al = 0;
  rep(i,n) {
    al += v[i]*p[i];
    if(al > x) {
      cout<<i+1<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;

  return 0;
}

#include <bits/stdc++.h>
#include <time.h>
#include <queue>
#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define forr(i,a,n) for(ll i=a;i<n;i++)
#define ford(i,a,n) for(ll i=n-1;i>=a;i--)
#define all(v) v.begin(),v.end()
#define testc  ll ts;\
               cin>>ts;\
               while(ts--)
#define arn ll n;\
            cin>>n;\
            ll a[n];\
            forr(i,0,n)cin>>a[i];\

#define arr(a,n) ll a[n];\
                 forr(i,0,n)cin>>a[i];\

#define sss <<" "<<
#define nnn <<"\n"
#define nl cout<<"\n";
#define prtitr(v) for(auto itr=v.begin(); itr!=v.end() ; itr++)cout<<*itr<<" ";
#define fitr(v) for(auto itr=v.begin(); itr!=v.end() ; itr++)
using namespace std;
ll M=1e9+7;
ll cdiv(ll a,ll b){
    return (a%b==0)?a/b:a/b+1;
}
ll myMod(ll a, ll b){
    ll r = a % b;
    return r < 0 ? r + b : r;
}
ll ModPow(ll a,ll b,ll M)
{
    if(M==1)return 0;
    a%=M;
    ll ans=1,t=1;
    while(t>0&&t<=b)
    {
        if(t&b)
        {
            ans*=a;
            ans%=M;
        }
        t<<=1;
        a*=a;
        a%=M;
    }
    return ans;
}

ll Pow(ll a,ll b)
{
    if(M==1)return 0;
    ll ans=1,t=1;
    while(t>0&&t<=b)
    {
        if(t&b)
        {
            ans*=a;
        }
        t<<=1;
        a*=a;
    }
    return ans;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int countSetBits(int n)
{
    int count = 0;
    while (n > 0)
    {
        count++;
        n &= (n-1);
    }
    return count;
}

// Function that return count of
// flipped number
int FlippedCount(int a, int b)
{
    // Return count of set bits in
    // a XOR b
    return countSetBits(a^b);
}

struct Point{
    int x,y;
};

bool isPrime(ll n){
    if (n <= 1)
        return false;
    for (ll i = 2; i*i <= n; i++)
        if (n % i == 0)
            return false;
    return true;
}
ll modInverse(ll n, ll p)
{
    return ModPow(n, p - 2, p);
}

ll nCrModP(ll n, ll r, ll p)
{
    if (n < r)
        return 0;
    if (r == 0)
        return 1;

    ll fac[n + 1];
    fac[0] = 1;
    for (int i = 1; i <= n; i++)
        fac[i] = (fac[i - 1] * i) % p;

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,x;
    cin>>n>>x;
    ll v[n], p[n];
    forr(i,0,n)cin>>v[i]>>p[i];
    ll ans=-1;
    ll s=0;
    forr(i,0,n){
        s+=v[i]*p[i];
        if(s>x*100){
            ans=i;
            break;
        }
    }
    if(ans!=-1)cout<<ans + 1 nnn;
    else cout<< - 1 nnn;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60; // 十分大きな値に
typedef long long ll;
typedef long double ld;

int main() {
    ll N, K;
    cin >> N >> K;

    for (ll i=0; i<K; i++) {
        if (N%200==0) {
            N /= 200;
        }
        else {
            N *= 1000;
            N += 200;
        }
    }
    cout << N << endl;
}

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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }

void Solve()
{
	ll N;
	cin >> N;

	ll cnt = 0;
	vector<P> two;
	ll multi = 1;
	while (multi <= N) {
		two.emplace_back(cnt, multi);
		multi *= 2;
		cnt++;
	}

	VL ans;
	for (auto t : two) {
		ll b = N / t.second;
		ll a = t.first;
		ll c = N % t.second;
		ll ansOne = a + b + c;
		ans.emplace_back(ansOne);
	}

	sort(ALL(ans));
	cout << ans.front() << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	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<<endl
#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;

vector<string> C(vector<string> s) {
  ll n=s.size();
  rep(i,n)REP(j,i+1,n) swap(s[i][j],s[j][i]);
  return s;
}

ll n,m;
string s[1000];

ll calc(vector<string> t) {
  ll cnt=0;
  rep(k,m) {
    ll f=0;
    rep(l,2) {
      rep(i,n) {
        rep(j,n) {
          if(t[i].substr(0,s[k].size())==s[k]) f=1;
          rotate(t[i].begin(),t[i].begin()+1,t[i].end());
        }
      }
      t=C(t);
    }
    cnt+=f;
  }
  return cnt;
}

vector<string> ans;
ll MM;

void solve(vector<string> t) {
  ll d=calc(t);
  if(MM<d) {
    MM=d;
    ans=t;
  }
  rep(k,5) {
    random_shuffle(all(t));
    rep(i,n) rotate(t[i].begin(),t[i].begin()+rand()%n,t[i].end());
    ll d=calc(t);
    if(MM<d) {
      MM=d;
      ans=t;
    }
  }
}

void Main() {
  srand((unsigned)time(NULL));
  cin >> n >> m;
  rep(i,m) R s[i];
  vector<string> v[15];
  rep(i,m) v[s[i].size()].pb(s[i]);
  rep(e,30) {
    vector<string> t(n);
    rrep(i,15) {
      random_shuffle(all(v[i]));
      rep(j,v[i].size()) {
        ll M=MAX,x=0;
        string rr;
        rep(k,n) {
          rep(l,t[k].size()+1) {
            string r1=t[k].substr(l);
            if(r1.size()<=v[i][j].size()) {
              string r2=v[i][j].substr(0,r1.size());
              if(r1==r2) {
                ll d=t[k].size()+v[i][j].size()-r1.size();
                if(d<=n&&M>d) {
                  M=d;
                  x=k;
                  rr=t[k]+v[i][j].substr(r1.size());
                }
              }
            }
          }
        }
        if(rand()%9==0) M=MAX;
        if(M!=MAX) t[x]=rr;
      }
    }
    rep(i,n) {
      while(t[i].size()<n) {
        //t[i]+='.';
        t[i]+=(char)(rand()%8+'A');
      }
    }
    solve(t);
  }
  rep(i,n) pr(ans[i]);
}

int main(){Main();return 0;}

//#include<bits/stdc++.h>
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define endl '\n'
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
//namespace first_space
//{
//	int a=10;
//	void func()
//	{
//		cout << "Inside first_space" << endl;
//	}
//}
int read()
{
	int res=0,ch,flag=0;
	if((ch=getchar())=='-')             //判断正负
		flag=1;
	else if(ch>='0'&&ch<='9')           //得到完整的数
		res=ch-'0';
	while((ch=getchar())>='0'&&ch<='9')
		res=res*10+ch-'0';
	return flag?-res:res;
}

typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int N=2e5+10;
int ans1=0;
int ans2=0;
int ans3=0;
ll a[N], mx[N], mi[N], b[N], c[N];
ll n,m,k;
bool check(ll mid)
{
	ans1=ans2=ans3=0;
	rep (i, 1, k)
	{ans1=ans2=ans3=0;
		ll cur = a[i] + mid;ans1=ans2=ans3=0;
		mx[i] = min((a[i] + mid) / n, (ll)m) + mx[i - 1];
		if (a[i] <= mid) mi[i] = mi[i - 1];
		else mi[i] = max(0ll, (a[i] - mid - 1) / n + 1) + mi[i - 1];
	}
	return mi[k] <= m && mx[k] >= m;
	ans1=ans2=ans3=0;
}

int main()
{
ans1=ans2=ans3=0;
	cin >> k >> n >> m;
	rep (i, 1, k) cin >> a[i], a[i] *= m;
	ll l = 0, r = 1e18+ans1+ans2+ans3;
	while (l < r)
	{ans1=ans2=ans3=0;
		ll mid = l + r >> 1;
		if (check(mid))
			r = mid, memcpy(b, mx, sizeof b), memcpy(c, mi, sizeof c);
		else l = mid + 1;
		ans1=ans2=ans3=0;
	}
	for(int i=k;i>=1+ans1+ans2+ans3;i--)
	{ans1=ans2=ans3=0;
		a[i] = min(m - c[i - 1], b[i] - b[i - 1]);
		m -= a[i];
		ans1=ans2=ans3=0;
	}
	rep (i, 1, k) cout << a[i]+ans1+ans2+ans3 << ' ';
	return 0;
}


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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define float			double
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vc				vector<char>
#define vb				vector<bool>
#define vf				vector<float>
#define vs				vector<string>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define hashmap         unordered_map
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

template<class T>
void printV(vector<T> a) {for (auto v : a)cout << v << " ";}
template<class T>
void readV(vector<T>& a) {int n = a.size(); for (int i = 0 ; i < n ; i++)cin >> a[i];}
template<class T>
void printA(T* a , int n) {for (int i = 0; i < n  ; i++)cout << a[i] << " ";}
template<class T>
void readA(T* a , int n) {for (int i = 0 ; i < n ; i++)cin >> a[i];}
auto clk = clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
void run_time() {cout << endl<<"Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;}

void aryan_pandeya() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {
	aryan_pandeya();
	FIO;

    int n ;
    cin>>n;
    vi a(n),b(n);
    vi v(n);
    int ans = 0 ;
    for(int i = 0 ;i<n ; i++){
        cin>>a[i]>>b[i];
        ans+=(-a[i]);
        v[i] = (2*a[i]+b[i]);
    }
    sort(all(v),greater<int>());
    int count = 0 ;
    for(int i = 0 ; i<n ; i++){
        count++;
        ans+=v[i];
        if(ans>0){
            break;
        }
    }
    cout<<count;

	return 0;
}

// FIRST THINK THEN CODE.

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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pll, null_type,less<>, rb_tree_tag,tree_order_statistics_node_update>

#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define cld complex<ld>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vld vector<ld>
#define vvld vector<vector<ld>>
#define vpll vector<pll>
#define vcld vector<cld>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define eb emplace_back
#define PI acos(-1)
#define endl "\n"
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define mset(a,val) memset(a,val,sizeof(a));
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
#define FOR(i,a,b)  for(ll i=a;i<=b;i++)
#define FORR(i,a,b)  for(ll i=a;i>=b;i--)
const ll M = 1000000007;
const ll MM = 998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename T, typename F>
void chmax( T &a, F b) {
	if (b > a)a = b;
}

template<typename T, typename F>
void chmin( T &a, F b) {
	if (b < a)a = b;
}

const ll N = 2e5 + 5;

void OJ() {

#ifndef ONLINE_JUDGE

	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);

#endif

}

int main() {

	IOS;

	OJ();

	ll n, d, h;
	cin >> n >> d >> h;
	ld ans = 0;
	for (ll i = 1; i <= n; i++) {
		ll dd, hh;
		cin >> dd >> hh;
		ld temp = (1.0 * (d * hh - h * dd)) / (d - dd);
		//cout << temp << endl;
		chmax(ans, temp);
	}
	//chmax(ans, 0ll);
	cout << fix(ans, 9) << endl;

	return 0;

}


//clear adj and visited vector declared globally after each test case
//check for long long overflow
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Incase of close mle change language to c++17 or c++14
/**#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops”)**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod  998244353ll
#define lld long double
#define mii map<int, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
int dp[13][5005];
int fact[N],inv[N];
void pre()
{
    fact[0]=1;
    inv[0]=1;
    for(int i=1;i<N;i++)
    fact[i]=(i*fact[i-1])%mod;
    for(int i=1;i<N;i++)
    inv[i]=power(fact[i], mod-2, mod);
}
int nCr(int n, int r, int p)
{
    if(r>n)
    return 0;
    if(n==r)
    return 1;
    if (r==0)
    return 1;
    return (((fact[n]*inv[r]) % p )*inv[n-r])%p;
}
int32_t main()
{
    IOS;
    pre();
    int n, m;
    cin>>n>>m;
    for(int i=0;i<=n;i+=2)
    dp[0][i]=nCr(n, i, mod);
    for(int i=1;i<13;i++)
    {
        int lim=(m/(1 << i));
        for(int j=0;j<=lim;j+=2)
        {
            int ad=(j*(1 << i)), mul=nCr(n, j, mod);
            for(int k=0;(k+ad)<=m;k++)
            {
                dp[i][k+ad]+=(dp[i-1][k]*mul)%mod;
                if(dp[i][k+ad]>=mod)
                dp[i][k+ad]-=mod;
            }
        }
    }
    cout<<dp[12][m];
}


#include <cstdio>
int a,b;

int main() {
	scanf("%d %d",&a,&b);
	printf("%d",a/b);
	return 0;
}

#include<iostream>
using namespace std;
int main(){
	int a,b;
  	cin>>a>>b;
    cout<<(2*a+100-b);
  return 0;
}


#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
template<typename T> using V = std::vector<T>;
template<typename T> void fill(V<T>&v) { for(T&e:v) std::cin >> e; }
/*-*/

int main() {
	int x;
	std::cin >> x;
	print(std::max(x,0));
}

#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <map>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)

const ll INF = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    string s;
    map<string, int> mp1, mp2;
    rep(i, n) {
        cin >> s;
        mp1[s]++;
        if (mp1[s] == 1) {
            if (s[0] == '!') {
                s.erase(0,1);
            }
            mp2[s]++;
        }
    }
    string ans = "satisfiable";
    for (auto u : mp2) {
        if (u.second >= 2) {
            ans = u.first;
        }
        //cout << u.first << endl;
    }

    cout << ans << endl;

    return 0;
}


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

bool palindrome (string s) {
    string t = s;
    reverse(t.begin(), t.end());
    return t == s;
}

int main() {
    string S, T, s;
    cin >> S;
    T = S;
    reverse(T.begin(), T.end());
    int n = stoi(T);
    string t = to_string(n);
    if (palindrome(t)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
  string S; cin>>S;
  if(S=="0"){
    cout<<"Yes\n";
  }
  else{
    string SS = S;
    while(SS.back()=='0') SS.pop_back();
    string rS = SS;
    reverse(rS.begin(),rS.end());
    if(SS==rS) cout<<"Yes\n";
    else cout<<"No\n";
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
#define ERASE(a)  (a).erase(unique((a).begin(), (a).end()), (a).end()); // sortしてから
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; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;

#define pu(x) cout << (x) << endl
int main()
{
	int n, x; cin >> n >> x;
	int v, p, sum;
	x *= 100;
	rep(i, n)
	{
		cin >> v >> p;
		sum += v * p;
		if (sum > x)
		{
			pu(i + 1);
			return (0);
		}
	}
	pu(-1);
}

#include<bits/stdc++.h>

using namespace std;

const int maxN = 5009;
int N, M, p[maxN], pM[maxN];
const int mod = 998244353;

int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;}
int subtract (int x, int y) {if (x >= y) return x - y; return x - y + mod;}
int mul (int x, int y) {return 1LL * x * y % mod;}
void adto (int &x, int y) {x += y; if (x >= mod) x -= mod;}

int power (int a, int b)
{
    int p = 1;
    for (int i=0; (1<<i) <= b; i++)
    {
        if (b & (1 << i)) p = mul (p, a);
        a = mul (a, a);
    }
    return p;
}

int fac[2000009], inv[2000009];
void Prec (int lim){fac[0] = inv[0] = 1;for (int i=1; i<=lim; i++)fac[i] = mul (fac[i - 1], i);
inv[lim] = power (fac[lim], mod - 2);for (int i=lim - 1; i>=0; i--)inv[i] = mul (inv[i + 1], i + 1);}
int comb (int N, int K){if (K > N || N < 0 || K < 0) return 0; int ans = mul (fac[N], inv[N - K]);ans = mul (ans, inv[K]);return ans;}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &M);
pM[0] = 1;
for (int i=1; i<=N; i++)
    pM[i] = mul (pM[i - 1], M);
for (int i=1; i<=M; i++)
    p[i] = 1;
int ans = 0;
for (int l=1; l<=N; l++)
{
    for (int j=1; j<=M; j++)
        p[j] = mul (p[j], j);
    int s0 = 0, s1 = 0, s2 = 0;
    for (int j=1; j<=M; j++)
    {
        int curr = subtract (p[M - j + 1], p[M - j]); ///how many arrays of length n have the minimum precisely j
        adto (s2, mul (curr, mul (j - 1, j - 1)));
        adto (s1, mul (curr, j - 1));
        adto (s0, curr);
    }
    for (int i=1; i + l - 1 <= N; i++)
        if (i == 1 && i + l - 1 == N)
            adto (ans, s0);
        else
        if (i == 1 || i + l - 1 == N)
            adto (ans, mul (s1, pM[N - l - 1]));
        else
            adto (ans, mul (s2, pM[N - l - 2]));
}
printf ("%d\n", ans);
return 0;
}


#include<bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
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; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int t;
	cin >> t;
    rep(ti, t) {
        ll n;
        cin >> n;
        if (n%4==0) cout << "Even" << endl;
        else if (n%2==0) cout << "Same" <<endl;
        else cout << "Odd" << endl;
    }
	return 0;
}

#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <string> vs;
typedef vector <vector <int>> vvi;
typedef vector <vll> vvll;
typedef map<int, int> mi;
typedef map<string, int> ms;
typedef map<char, int> mc;
typedef map <int, bool> mb;
typedef map<ll, ll> mll;
typedef unordered_map<int, int> umi;
typedef unordered_map<string, int> ums;
typedef unordered_map<char, int> umc;
typedef unordered_map <int, bool> umb;
typedef unordered_map<ll, ll> umll;
typedef vector <ld> vld;
typedef vector <bool> vb;
typedef pair <int, int> pii;
typedef pair<ll, ll> pll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
#define FOR(i,N) for(ll i = 0 ; i < N;i++)
#define eFOR(i,a,b) for(ll i = a; i <=b;i++)
#define dFOR(i,N) for(ll i = N - 1; i>=0;i--)
#define edFOR(i,b,a) for(ll i = b ; i >=a;i--)
#define all(x) x.begin(),x.end()
#define SORT(x) sort(all(x))
#define RSORT(x) sort(x.rbegin(),x.rend())
#define UNQ(x)  unique(all(x))
#define mine(x) min_element(all(x))
#define maxe(x) max_element(all(x))
#define lb(v, x) lower_bound(all(v) , x)
#define ub(v , x) upper_bound(all(v) , x)
#define pb push_back
#define FIX cout << fixed << setprecision(15)
#define g(i , a) get<i>(a)
const long double PI = 3.141592653589793;
const ll mod = 3628800;
int CASE = 1;
const int mxn = 2e5 + 1;
const ll infll = 1e18;
const int infi = 1e9;
bool prime(int n)
{
	if (n <= 1)
		return false;
	if (n == 2 or n == 3)
		return true;
	if (n % 2 == 0 or n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
		if (n % i == 0 || n % (i + 2) == 0)
			return false;
	return true;
}
ll __gcd(ll a, ll b)
{
	return !b ? a : __gcd(b, a % b);
}
ll power(ll a, ll b ,ll MOD)
{
	ll x = a, res = 1, p = b;
	while (p > 0)
	{
		if (p & 1)
			res *= x;
		x *= x;
		res %= MOD;
		x %= MOD;
		p >>= 1;
	}
	return res;
}
ll factorial(ll n)
{
	ll f = 1;
	eFOR(i, 1, n)
		f *= i, f %= mod;
	return f;
}
void solve()
{
	mi mp;
	int n;
	cin >> n;
	vi v(n);
	FOR(i, n)
		cin >> v[i], mp[v[i]]++;
	SORT(v);
	int x = n - mp[v[0]];
	ll ans = x;
	int p = v[0];
	eFOR(i, 1, n - 1)
	{
		if (v[i] == p)
		{
			ans += x;
		}
		else
		{
			x -= mp[v[i]];
			p = v[i];
			ans += x;
		}
	}
	cout << ans;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T = 1;
	while (T--)
	{
		solve();
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define FOR(i, x, y) for(int i = (int)(x); i < (int)(y); ++i)
#define MP make_pair
#define fst first
#define snd second
typedef pair<int, int> pii;

const int maxn = 4e5 + 5;

int n, top = 0;
int a[maxn], ord[maxn], rev[maxn], stk[maxn];
char s[maxn];

inline bool cmp(const int &i, const int &j){ return a[i] < a[j]; }

int main(){
	scanf("%d", &n);
	FOR(i, 0, n << 1){
		scanf("%d", a + i);
		ord[i] = i;
	}
	sort(ord, ord + (n << 1), cmp);
	FOR(i, 0, n << 1)
		rev[ord[i]] = i;
	FOR(i, 0, n << 1){
		if(top && (rev[stk[top]] < n) != (rev[i] < n)){
			s[stk[top]] = '(', s[i] = ')';
			--top;
		}
		else
			stk[++top] = i;
	}

	puts(s);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,q,ans,cnt;
string s;
map<ll,ll> mp;
vector<ll> v,v1;
int main(void){
    cin>>n;
    for(int i=0;i<2*n;i++){
        cin>>a;
        v.push_back(a);
        v1.push_back(a);
    }
    sort(v1.begin(),v1.end());
    for(int i=0;i<n;i++){
        mp[v1[i]]++;
    }
    for(int i=0;i<2*n;i++){
        if(mp[v[i]]){
            s+='A';
            mp[v[i]]--;
        }
        else s+='B';
    }
    //cout<<s<<endl;
    for(int i=0;i<2*n;i++){
        if(s[i]=='A'){
            if(cnt<0){
                cnt++;
                cout<<')';
            }
            else{
                cnt++;
                cout<<'(';
            }
        }
        else{
            if(cnt>0){
                cnt--;
                cout<<')';
            }
            else{
                cnt--;
                cout<<'(';
            }
        }
    }
    cout<<endl;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv){vprint(v)};

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

    string S1, S2, S3;
    cin >> S1 >> S2 >> S3;

    set<char> s;
    for(char c : S1) s.insert(c);
    for(char c : S2) s.insert(c);
    for(char c : S3) s.insert(c);

    vector<char> v;
    for(char c : s) v.push_back(c);

    set<char> nz;
    nz.insert(S1[0]);
    nz.insert(S2[0]);
    nz.insert(S3[0]);

    ll n = s.size();
    if(n>10){
        cout << "UNSOLVABLE" << endl;
        return 0;
    }

    vll m(27, -1);

    function<vll(ll)> solve = [&](ll idx){
        if(idx>=n){
            ll n1 = 0, n2 = 0, n3 = 0;
            rep(i, S1.size()) n1 = n1*10 + m[S1[i]-'a'];
            rep(i, S2.size()) n2 = n2*10 + m[S2[i]-'a'];
            rep(i, S3.size()) n3 = n3*10 + m[S3[i]-'a'];
            if(n1+n2==n3){
                return vll{n1, n2, n3};
            }
            else{
                return vll{};
            }
        }
        if(m[v[idx]-'a']>=0){
            return solve(idx+1);
        }
        rep(i, 10){
            bool ok = true;
            for(auto e : m){
                if(e==i){
                    ok = false;
                    break;
                }
            }
            if(!ok) continue;
            if(i==0 && (nz.find(v[idx])!=nz.end())) continue;
            m[v[idx]-'a'] = i;
            vll a = solve(idx+1);
            m[v[idx]-'a'] = -1;
            if(a.size()>0){
                return a;
            }
        }
        return vll{};
    };

    vll ans = solve(0);
    if(ans.size()>0){
        cout << ans[0] << endl;
        cout << ans[1] << endl;
        cout << ans[2] << endl;
    }
    else cout << "UNSOLVABLE" << endl;
}

#include<bits/stdc++.h>
using namespace std;
template<typename T>inline bool read(T&x){
x=0;char c=getchar();int f=1;while(!isdigit(c)&&(c!='-')&&(c!=EOF))c=getchar();
if(c==EOF)return 0;if(c=='-')f=-1,c=getchar();
while(isdigit(c)){x=(x<<1)+(x<<3)+(c&15);c=getchar();}x*=f;return 1;
}template<typename T,typename...Args>inline bool read(T&x,Args&...args){bool res=1;res&=read(x);res&=read(args...);return res;}
typedef long long LL;typedef unsigned long long u64;typedef unsigned u32;typedef long double LD;
#define il inline
#define pln puts("")
#define For(i,a,b)  for(int i=(a),(i##i)=(b);i<=(i##i);++i)
#define Rep(i,n)    for(int i=0,(i##i)=(n);i<(i##i);++i)
#define Fodn(i,a,b) for(int i=(a),(i##i)=(b);i>=(i##i);--i)
const int M=1000000007,INF=0x3f3f3f3f;const long long INFLL=0x3f3f3f3f3f3f3f3fLL;
const int N=1000010;const double EPS=1e-6;

double ans=0;
LL n;
inline void init(){
	read(n);
	Fodn(k,n-1,1){
		ans+=(double)n/(n-k);
	}
}
inline void solve(){
	printf("%.7lf\n",ans);
}
signed main(){
	init();solve();
	return 0;
}