#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, k, m;
    cin >> n >> k >> m;

    ll sum = 0;
    rep(i, n-1) {
        ll a;
        cin >> a;
        sum += a;
    }

    ll x = m*n - sum;

    if(x > k) {
        out(-1);
    }
    else {
        out(max(0LL, x));
    }

    re0;
}

#include<stdio.h>
static inline int MPow(int a,int b,const int MOD){return b?1l*MPow(1l*a*a%MOD,b>>1,MOD)*(b&1?a:1)%MOD:1;}
int main(void){int A,B,C;if(!scanf("%d %d %d",&A,&B,&C)){return 1;}return !putchar(MPow(A,MPow(B,C,4)+4,10)+48);}


// Problem: B - Alcoholic
// Contest: AtCoder - AtCoder Beginner Contest 189
// URL: https://atcoder.jp/contests/abc189/tasks/abc189_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define double long double
#define INF 1000000000000000000
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

double pi=acos(-1.0);
int md=1e9+7;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};
const int N=3e5+5;

template<class T>
T abst(T a)
{return a<0?-a:a;}

void solve()
{
	int n;
	int x;
	cin>>n>>x;
	vp v(n);cin>>v;
	int y=0;
	//double t=100.0;
	for(int i=1;i<=n;i++)
	{
		y=y+v[i-1].f*v[i-1].se;
		if(y/100.0>x)
		{
			cout<<i;
			return;
		}
	}
	cout<<-1;
	//cout<<"\n"<<x<<"\n"<<y;
}

int32_t main(){
//ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}

#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a * a + b * b < c * c ? "Yes" : "No");
}


#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <utility>
#include <unordered_set>
#include <map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

    map<int, ll> delta;
    for (int i = 0; i < n; i++) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        delta[a] += c;
        delta[b+1] -= c;
    }

    ll ret = 0;
    ll curr = 0;
    int prev = 0;
    for (auto [day, inc]: delta) {
        ll actual = min(curr, cost);
        ll val = actual * (day - prev);
        ret += val;

        prev = day;
        curr += inc;
    }
    cout << ret << endl;
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
	int T;
	cin >> T;
	for (int i = 0; i < T; ++i) {
		int N, A, B;
		cin >> N >> A >> B;
		//よんせっと
		//まいなすよんせっと
		if ((A + B) > N) {
			cout << 0 << endl;
			continue;
		}
		mint ans = 1;
		ans *= (1 + N - B - A + 1);
		ans *= (N - B - A + 1);
		ans /= 2;
		ans *= (N - A + 1);
		ans *= (N - B + 1);
		ans *= 4;
		mint ans0 = 1;
		ans0 *= (N - B - A + 1);
		ans0 *= (N - B - A + 2);
		ans0 /= 2;
		ans0 *= ans0;
		ans0 *= 4;
		ans -= ans0;
		cout << ans << endl;
	}
	return 0;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <ctime>
#include <cmath>
#include <vector>
#include <deque>
#include <queue>
#include <string>
#include <cctype>
#include <functional>
using namespace std;

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

typedef long long LL;

void run() {
    int n;
    cin >> n;
    LL mx = 0, t = 0, q = 0, a;
    REP(i,n) {
        cin >> a;
        mx = max(mx, a);
        t += a;
        q += t;
        cout << mx * (i + 1) + q << endl;
    }
}

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

//#pragma GCC optimize(2)
//#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <utility>
#include <map>
#define rush()      int T;cin>>T;while(T--)
#define ms(a,b)     memset(a,b,sizeof a)
#define lowbit(x)   ((x)&(-x))
#define inf         0x7f7f7f7fll
#define eps         1e-11
#define sd(a)       scanf("%d",&a)
#define sll(a)      scanf("%lld",&a)
#define sll2(a,b)   scanf("%lld%lld",&a,&b)
#define sll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sdd(a,b)    scanf("%d%d",&a,&b)
#define sddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sf(a)       scanf("%lf",&a)
//#define sc(a)       scanf("%c\n",&a)
#define ss(a)       scanf("%s",a)
#define pd(a)       printf("%d\n",a)
#define pdd(a,b)    printf("%d %d\n",a,b)
#define pddd(a,b,c) printf("%d %d %d\n",a,b,c)
#define pll(a)      printf("%lld\n",a)
#define pf(a)       printf("%.1lf\n",a)
#define pc(a)       printf("%c",a)
#define ps(a)       printf("%s\n",a)
#define forn(i,a,b) for(int i=(a);i<=(b);i++)
#define pb(a)       push_back(a)
#define mp(a,b)     make_pair(a,b)
#define debug(a)    cout<<#a<<" : "<<a<<" "<<" ; "
#define dbg(a)      cout<<#a<<" : "<<a<<endl
#define show(a,b)   cout<<a<<" :\t"<<b<<"\t*"<<endl
#define IOS         ios::sync_with_stdio(0); cin.tie(0)
#define PAUSE       system("pause")
//#define print(a)    cout<<a<<endl;continue;
#define fr          first
#define sc          second
#define ceils(a,b)  ceil(ll(a)/double(b))
#define floors(a,b) floor(ll(a)/double(b))
using namespace std;
//inline void swap(int &x,int &y){x^=y^=x^=y;}
typedef long long ll;
//using ui=unsigned int;
typedef unsigned long long ull;
typedef pair<int,int> Pair;
const double pi=acos(-1.0);
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
const int limit=5e5;

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}

void write(int x)
{
	if (x<0) putchar('-'),x=-x;
	if (x<10) putchar(x+'0');
	else write(x/10),putchar(x%10+'0');
}

void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}

ll mod=1000003;
const int N=1e6+5;

    int n, m, _;
    int i, j, k;
    int a[N];
    ll pre[N];

signed main()
{
    //IOS;
    while(~sd(n)){
        for(int i=1;i<=n;i++) sd(a[i]),pre[i]=a[i]+pre[i-1];
        int maxx=0;
        ll ans=0,sum=0;
        for(int i=1;i<=n;i++){
            ans+=a[i];
            maxx=max(maxx,a[i]);
            pll((ll)maxx*i+ans+sum);
            sum+=pre[i];
        }
    }
    //PAUSE;
    return 0;
}


#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rrep(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr ll INF = 1LL << 60;
constexpr ll mod = 100000; //(ll)1e9 + 7;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
inline void init() {
    cin.tie(nullptr); cout.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}

inline int popcount(ll n) {
    n = (n & 0x5555555555555555) + (n >> 1 & 0x5555555555555555);
    n = (n & 0x3333333333333333) + (n >> 2 & 0x3333333333333333);
    n = (n & 0x0f0f0f0f0f0f0f0f) + (n >> 4 & 0x0f0f0f0f0f0f0f0f);
    n = (n & 0x00ff00ff00ff00ff) + (n >> 8 & 0x00ff00ff00ff00ff);
    n = (n & 0x0000ffff0000ffff) + (n >> 16 & 0x0000ffff0000ffff);
    n = (n & 0x00000000ffffffff) + (n >> 32 & 0x00000000ffffffff);
    return n;
}

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

int H, W, A, B;
vector<vector<bool>>v;
int dfs(int cnt = 0) {
    if (cnt == A) return 1;
    int res = 0;
    rep(i, 0, H) {
        rep(j, 0, W) {
            if (v[i][j])continue;

            rep(k, 0, 2) {
                int x = j + dx[k], y = i + dy[k];
                if (out(y, x, H, W))continue;
                if (!v[y][x]) {
                    v[y][x] = true;
                    v[i][j] = true;
                    res += dfs(cnt + 1);
                    v[y][x] = false;
                    v[i][j] = false;
                }
            }
            return res;
        }
    }

}
int main() {
    init();

    cin >> H >> W >> A >> B;
    int _n = H * W, ans = 0;
    for (int bit = 0;bit < (1 << _n);++bit) {
        vector<vector<bool>>vec(H, vector<bool>(W, false));
        if (popcount(bit) != B)continue;
        rep(i, 0, _n) {
            if ((bit >> i) & 1)vec[i / W][i % W] = true;
        }
        v = vec;
        ans += dfs();
    }
    cout << ans << "\n";

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
bool f1;
#define LL long long
#define db double
#define Max(a,b) ((a)<(b))&&((a)=(b))
#define Min(a,b) ((a)>(b))&&((a)=(b))
inline int rd() {
	int res=0;
	char ch;
	while(ch=getchar(),ch<48||ch>57);
	do res=(res<<1)+(res<<3)+(ch^48);
	while(ch=getchar(),ch>47&&ch<58);
	return res;
}
const int M=1<<18;
int n,m;
LL f[M];
struct info {
	int y,z;
};
int Sz[M];
vector<info>Q[20];
int X[M],Y[M],Z[M],sum[20];
bool f2;
int main() {
//	printf("%lf\n",(&f2-&f1)/1024.0/1024.0);
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	n=rd(),m=rd();
	for(int i=1; i<=m; ++i) {
		X[i]=rd(),Y[i]=rd(),Z[i]=rd();
		Q[X[i]].push_back((info)<%Y[i],Z[i]%>);
	}
	int t=1<<n;
	f[0]=1;
	for(int i=1; i<t;++i) {
		Sz[i]=Sz[i^(i&-i)]+1;
		memset(sum,0,sizeof sum);
		for(int j=0; j<n; ++j)if(i&(1<<j))f[i]+=f[i^(1<<j)],sum[j+1]++;
		for(int j=1; j<=n; ++j)sum[j]+=sum[j-1];
		for(int j=0; j<Q[Sz[i]].size(); ++j) {
			int yy=Q[Sz[i]][j].y,zz=Q[Sz[i]][j].z;
			if(sum[yy]>zz){f[i]=0;break;}
		}
	}
	printf("%lld",f[t-1]);
	return 0;
}


//
// Created by Anton Gorokhov
//

#ifdef lolipop
#define _GLIBCXX_DEBUG
#endif

#include <iostream>
#include <cstddef>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <ctime>
#include <unordered_map>
#include <random>
#include <iomanip>
#include <cmath>
#include <queue>
#include <unordered_set>
#include <cassert>
#include <bitset>
#include <deque>
#include <utility>

#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ld double

using namespace std;

mt19937 rnd(time(nullptr));

inline void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

const int inf = 2e9 + 123;

void solve() {
    int n, k;
    cin >> n >> k;
    vector<vector<int> > v(n, vector<int>(n, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> v[i][j];
        }
    }
    int L = -1, R = inf;
    while (L + 1 < R) {
        int M = (L + R) / 2;
        vector<vector<int> > val(n + 1, vector<int>(n + 1, 0));
        auto sum = [&] (int x1, int y1, int x2, int y2) {
            x2++, y2++;
            return val[x2][y2] + val[x1][y1] - val[x1][y2] - val[x2][y1];
        };
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                val[i + 1][j + 1] = val[i][j + 1] + val[i + 1][j] - val[i][j] + (v[i][j] <= M);
            }
        }
        bool ok = false;
        for (int i = 0; i + k - 1 < n; ++i) {
            for (int j = 0; j + k - 1 < n; ++j) {
                if (sum(i, j, i + k - 1, j + k - 1) >= (k * k + 1) / 2) {
                    ok = true;
                    break;
                }
            }
            if (ok) break;
        }
        if (ok) {
            R = M;
        } else {
            L = M;
        }
    }
    cout << R << '\n';
}

signed main() {
#ifdef lolipop
    freopen("input.txt", "r", stdin);
#else
    fastio();
#endif
    int T = 1;
//    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}

#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0ll)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

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

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

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

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

signed main() {
  init();
  ll N, K;
  cin >> N >> K;
  vvll A(N, vll(N));
  cin >> A;

  ll l = 0, r = INF;
  while (r - l > 1) {
    ll c = (l + r) / 2;
    vvll R(N, vll(N));
    rep(i, N) rep(j, N) {
      if (c <= A[i][j]) R[i][j] += 1;
      if (i != 0) R[i][j] += R[i - 1][j];
      if (j != 0) R[i][j] += R[i][j - 1];
      if (i != 0 and j != 0) R[i][j] -= R[i - 1][j - 1];
    }
    ll cnt = INF;
    rep(i, N - (K - 1)) rep(j, N - (K - 1)) {
      ll count = R[i + K - 1][j + K - 1];
      if (i != 0) count -= R[i - 1][j + K - 1];
      if (j != 0) count -= R[i + K - 1][j - 1];
      if (i != 0 and j != 0) count += R[i - 1][j - 1];
      chmin(cnt, count);
    }
    if (cnt < (K * K) / 2 + 1)
      r = c;
    else
      l = c;
  }
  COUT(l);
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
using LL=long long;
using P=pair<int,int>;
using T=tuple<int,int,int>;
constexpr int mod=1000000007;
constexpr int inf=1e9;
constexpr double eps=1e-13;
int in(){
    int x;
    scanf("%d",&x);
    return x;
}
int main(){
    int n=in();
    string s,x;
    cin>>s>>x;
    for(int i=0;i<n;i++)s[i]-='0';
    vector<vector<int>>win(n+1,vector<int>(7));
    win[n][0]=1;
    for(int i=n-1;i>=0;i--){
        if(x[i]=='T'){
            for(int j=0;j<7;j++){
                if(win[i+1][(j*10)%7] || win[i+1][(j*10+s[i])%7])win[i][j]=1;
            }
        }
        else{
            for(int j=0;j<7;j++){
                if(win[i+1][(j*10)%7]==0 || win[i+1][(j*10+s[i])%7]==0)win[i][j]=0;
                else win[i][j]=1;
            }
        }
    }
    cout<<(win[0][0] ? "Takahashi" : "Aoki")<<endl;
    return 0;
}

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(int i=cc;i>=n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;

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

const vector<int> dx2 = {1, 1,  1, 0,  0, 0, -1, -1, -1};
const vector<int> dy2 = {1, 0, -1, 1, -1, 0,  1,  0, -1};

const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
const ll mod2 = 998244353;

const ll MAX = 1000000;
const ll MOD = 1000000007;
const ll big = (1ll<<60);

const ll moda = 1000000007;
const ll modb = 100000007;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }

ll modPow(ll a, ll n, ll p) {
  if (n == 0) return 1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  ll t = modPow(a, n / 2, p);
  return (t * t) % p;
}

ll choose(ll n, ll r, ll mod){
    ll mul = 1, div = 1;
    for(ll i = 0; i < r; i++){
        mul *= n - i;
        div *= i + 1;
        mul %= mod;
        div %= mod;
    }
    return mul * modPow(div, mod - 2, mod) % mod;
}

int main(){
  int n;
  string s, x;
  cin >> n >> s >> x;
  vector<vector<bool>>dp(7,vector<bool>(n+1,false));//takahashi_win:true
  dp[0][n] = true;
  int digit = 1;
  rep(i, 0, n){
    int temp = (s[n-1-i]-'0');
    if(x[n-1-i]=='T'){
      rep(j, 0, 7){
        dp[j][n-i-1] = dp[(temp*digit+j)%7][n-i]||dp[j][n-i];
      }
    }else{
      rep(j, 0, 7){
        dp[j][n-i-1] = dp[(temp*digit+j)%7][n-i]&&dp[j][n-i];
      }
    }
    if(i!=n-1)(digit *= 10) %= 7;
  }
  /*
  if(x[0]=='T'){
    if(dp[(s[0]-'0')*digit%7][0]||dp[0][0]){
      cout << "Takahashi" << endl;
    }else{
      cout << "Aoki" << endl;
    }
  }else{
    if(dp[(s[0]-'0')*digit%7][0]&&dp[0][0]){
      cout << "Takahashi" << endl;
    }else{
      cout << "Aoki" << endl;
    }
  }*/
  if(dp[0][0]){
    cout << "Takahashi" << endl;
  }else{
    cout << "Aoki" << endl;
  }
  return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _lint = int;
#define REP(i, n) for (_lint i = 0; i < (_lint)(n); i++)
#define FOR(i, a, b) for (_lint i = (_lint)(a); i < (_lint)(b); i++)
#define FORR(i, a, b) for (_lint i = (_lint)(b)-1; i >= (_lint)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))
#define ALL(v) (v).begin(), (v).end()

#define DEBUG(x) cerr << #x << ": " << (x) << endl
#define DEBUG_VEC(v)                                                           \
  {                                                                            \
    cerr << #v << ": ";                                                        \
    REP(__i, size(v)) cerr << ((v)[__i]) << ", ";                              \
    cerr << endl;                                                              \
  }

int main() {
  int ans = 1<<30;
  int n;
  cin>>n;
  REP(i,n) {
    int a,p,x;
    cin>>a>>p>>x;
    if(x>a) {
      CHMIN(ans, p);
    }
  }
  if(ans==(1<<30))ans=-1;
  cout<<ans<<endl;
  return 0;
}

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<iomanip>

using namespace std;

int main(){
    int n; cin >> n;
    pair<int, int> a[n];
    for(int i=0;i<n;i++) cin >> a[i].first >> a[i].second;

    for(int i=0;i<(n-1);i++){
        for(int j=i+1;j<n;j++){
            for(int k=0;k<n;k++){
                if(k == i || k == j) continue;
                else{
                    int x = (a[j].first - a[i].first) * (a[k].second - a[i].second);
                    int y = (a[j].second - a[i].second) * (a[k].first - a[i].first);
                    if(x == y){
                        cout << "Yes" << endl;
                        return 0;
                    }
                }
            }
        }
    }

    cout << "No" << endl;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'

// n acho que eu seja bom, mas eu ja fui pior

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

const int oo = 1e9;
const ll OO = 0x3f3f3f3f3f3f3f3fll;
const int MOD = 1000000007;

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

    int n, a, b, ans = oo, menor = oo, maior = -oo; cin >> n;
    vector<pii> ta, tb;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;

        ans = min(ans, a+b);

        ta.push_back({a, i});
        tb.push_back({b, i});
    }

    sort(ta.begin(), ta.end());
    sort(tb.begin(), tb.end());

    int it = 0;
    while (it < n) {
        if (tb[it].ss != ta[0].ss) {
            ans = min(ans, max(tb[it].ff, ta[0].ff));
            break;
        }

        it++;
    }

    it = 0;
    while (it < n) {
        if (tb[0].ss != ta[it].ss) {
            ans = min(ans, max(tb[0].ff, ta[it].ff));
            break;
        }

        it++;
    }

    cout << ans << endl;

    return 0;
}

#include<bits/stdc++.h>

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

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define F first
#define S second

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

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

  ll r = INF;
  rep(i, n)rep(j, n){
    if(i==j)r = min<ll>(r, a[i]+b[j]);
    else r = min<ll>(r, max<ll>(a[i], b[j]));
//cout<<i<<' '<<j<<' '<<r<<endl;
  }

  cout<<r<<endl;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxs = 2e5 + 5;

int PARENT[maxs];
int SIZE[maxs];
vector<int>a;
map<int,int>mp[maxs];
void SET(int V)
{
    SIZE[V] = 1;
    PARENT[V] = V;
}

int FIND_SET(int V)
{
    if(V == PARENT[V])
        return PARENT[V];
    else
        return PARENT[V] = FIND_SET(PARENT[V]);
}

void UNION(int A,int B)
{
    A = FIND_SET(A);
    B = FIND_SET(B);

    if(A != B)
    {
        if(SIZE[A] < SIZE[B])
            swap(A,B);
        PARENT[B] = A;
        SIZE[A] += SIZE[B];

        for(auto it : mp[B])
            mp[A][it.first] += it.second;
    }

}

signed main()
{
     int n,q;
     cin >> n >> q;
     a.resize(n + 1);

    for(int i = 1;i <= n;++i)
    {
        SET(i);
        cin >> a[i];
        mp[i][a[i]]++;//.push_back(i);
    }

    while(q--)
    {
        int type,x,y;
        cin >> type >> x >> y;

        if(type & 1)
        {
            UNION(x,y);
        }
        else
        {
            int val = FIND_SET(x);

            cout << mp[val][y];
            cout << "\n";
        }
    }

}

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

using namespace __gnu_pbds;
using namespace std;

// #define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend()
#define lb            lower_bound
#define ub            upper_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))
#define inf           (int)(1e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int>
#define vpi           vector<pii>
#define ordered_set   tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){ cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args)
{ const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2 > istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2 > ostream& operator<<(ostream& out, pair<T1, T2> &q){ out << q.F << " " << q.S; return out;}
template< typename T1, typename T2 > pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2 > pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F-p2.F, p1.S-p2.S};}
template< typename T1, typename T2 > bool operator<(pair<T1, T2> p1, pair<T1, T2> p2){ return p1 < p2 ;}

template<typename T> void Unique(vector<T> &v) {
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
}

struct Dsu {
	int n;
	std::vector<int> par, siz;
	std::vector<map<int, int> > un;

	Dsu(int c[], int _n) {
		n = _n;
		par.resize(n+1), un.resize(n+1), siz.resize(n+1);
		for(int i = 1; i <= n; i++)
			par[i] = i, un[i][c[i]]++, siz[i] = 1;;
	}
	int root(int x) {
		return (par[x] == x ? x : par[x] = root(par[x]));
	}
	void merge(int x, int y) {
		x = root(x), y = root(y);
		if(x == y) return;
		if(siz[y] > siz[x]) swap(x, y);
		par[y] = x;
		siz[x] += siz[y];
		for(auto u : un[y])
			un[x][u.F] += u.S;
		un[y].clear();
	}
};

void solve() {
	int n, q;
	cin >> n >> q;
	int c[n+1];
	for(int i = 1; i <= n; i++)
		cin >> c[i];
	Dsu ds(c, n);
	while(q--) {
		int t, x, y;
		cin >> t >> x >> y;
		if(t == 1) {
			ds.merge(x, y);
		}
		else {
			int r = ds.root(x);
			if(ds.un[r].count(y)) {
				cout << ds.un[r][y] << endl;
			}
			else cout << 0 << endl;
			// cout << ds.un[r].count(y) << endl;
		}
	}
}

signed main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    start = clock();

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

    int test = 1;
    // cin >> test;

    cout << fixed << setprecision(12);

    for(int i = 1; i <= test; ++i){
    	solve();
    }

    cerr << time(start);
    return 0;
}


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

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> vec (n);
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        vec.at(i) = x;
    }
    for(int i=0; i<m; i++){
        int x;
        cin >> x;
        vec.push_back(x);
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    stack<int> ans;
    for(int i=0; i<vec.size(); i++){
        if(ans.empty()){
            ans.push(vec.at(i));
        }
        else if(vec.at(i) == ans.top()){
            ans.pop();
        }
        else{
            ans.push(vec.at(i));
        }
    }
    while(!ans.empty()){
        cout << ans.top() << " ";
        ans.pop();
    }
}

#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll,ll>
#define fs first
#define ss second
#define fr(i,n) for(ll i=0;i<n;i++)
#define fr1(i,a,n) for(ll i=a;i<n;i++)
#define mp make_pair
#define pb push_back
using namespace std;
const  ll mod=1e9+7;
const ll INF=LLONG_MAX;
const ll NINF=LLONG_MIN;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    while(t-->0){
    	string s;
      cin>>s;
      ll n=s.size();
      fr(i,n){
      	if(s[n-i-1]=='9')cout<<6;
      	else if(s[n-i-1]=='6')cout<<9;
      	else cout<<s[n-i-1];
      }
    }
}


#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
// #include <atcoder/all>

using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vii = V<int>;
using vvll = V<vll>;
using vvii = V< V<int> >;
using PII = P<int, int>;
using PLL = P<ll, ll>;
#define RevREP(i,n,a) for(ll i=n;i>a;i--)  // (a,n]
#define REP(i,a,n) for(ll i=a;i<n;i++)  // [a,n)
#define rep(i, n) REP(i,0,n)
#define ALL(v) v.begin(),v.end()
#define eb emplace_back
#define pb push_back
#define sz(v) int(v.size())

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; }
template< class A, class B > ostream& operator <<(ostream& out, const P<A, B> &p) {
    return out << '(' << p.first << ", " << p.second << ')';
}
template< class A > ostream& operator <<(ostream& out, const V<A> &v) {
    out << '[';
    for (int i=0;i<int(v.size());i++) {
        if (i) out << ", ";
        out << v[i];
    }
    return out << ']';
}

template<class A, class B> istream& operator >>(istream& in, P<A, B> &p) {
    return in >> p.first >> p.second;
}
template<class A> istream& operator >>(istream& in, V<A> &v) {
    for (int i = 0; i < int(v.size()); i++) in >> v[i];
    return in;
}

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    int a, b; cin >> a >> b;
    cout << double(a) * double(b) / 100.0 << '\n';
    return 0;
}

#include <bits/stdc++.h> // header file includes every Standard library
using namespace std;

int main() {
	#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif // ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	double n,d;
	cin>>n>>d;
	cout<< ((n-d)/n)*100;

	return 0;
}


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

#ifdef LOCAL
#include "../debug.h"
#else
#define debug(x...) 141
#endif
#define forn(i,x,n) for(int i = x; i < n; ++i)
#define forit(it, m) for(auto it = m.begin(); it!=m.end(); ++it)
typedef long long ll;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,aa,ans=1e18;
    char cc;

    cin>>n;
    map<char,vector<ll>> m;
    vector<ll> a,b,c;
    forn(i,0,2*n)
        cin>>aa>>cc, m[cc].push_back(aa);
    if(m['R'].size()%2==0&&m['G'].size()%2==0&&m['B'].size()%2==0){
        cout<<0;
        return 0;
    }
    debug(m['R'],m['G'],m['B']);
    for(auto [_,x]:m)
        if(x.size()%2&&a.empty())
            a=x;
        else if(x.size()%2)
            b=x;
        else
            c=x;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    for(auto x:a){
        auto it=lower_bound(b.begin(),b.end(),x);
        if(it!=b.end())
            ans=min(ans,abs(x-*it));
        if(it!=b.begin())
            ans=min(ans,abs(x-*(--it)));
    }
    vector<pair<ll,ll>> ca(c.size(),{1e18,0}),cb(c.size(),{1e18,0});
    forn(i,0,c.size()){
        auto it=lower_bound(a.begin(),a.end(),c[i]);
        if(it!=a.end())
            ca[i].first=min(ca[i].first,abs(c[i]-*it));
        if(it!=a.begin())
            ca[i].first=min(ca[i].first,abs(c[i]-*(--it)));

        it=lower_bound(b.begin(),b.end(),c[i]);
        if(it!=b.end())
            cb[i].first=min(cb[i].first,abs(c[i]-*it));
        if(it!=b.begin())
            cb[i].first=min(cb[i].first,abs(c[i]-*(--it)));
        ca[i].second=cb[i].second=i;
    }
    sort(ca.begin(),ca.end());
    sort(cb.begin(),cb.end());
    if(c.size()&&ca[0].second==cb[0].second)
        ans=min(ans,min(ca[0].first+cb[1].first,ca[1].first+cb[0].first));
    else if(c.size())
        ans=min(ans,ca[0].first+cb[0].first);
    cout<<ans<<'\n';

    return 0;
}

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

using namespace std;

ll k, n;
const ll mod = 1e9 + 7;

ll dp[200100][17], cdp[17][17];

ll nCr(ll n, ll r)
{
    if (r == 0 || r == n)
        return 1;
    if(cdp[n][r] != -1)
        return cdp[n][r];
    cdp[n][r] = (nCr(n-1, r-1) + nCr(n-1, r)) % mod;
    return cdp[n][r];
}

ll pwr(ll a, ll b)
{
    if(b == 0)
        return 1;
    if(b & 1)
    {
        return pwr(a, b - 1) * a % mod;
    }
    else
    {
        ll ret = pwr(a, b / 2);
        return ret * ret % mod;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string str;
    cin >> str;
    cin >> k;
    n = str.size();
    memset(dp, 0, sizeof(dp));
    memset(cdp, -1, sizeof(cdp));

    for(int i = 0; i < 17; i++)
    {
        for(int j = 0; j <= i; j++)
        {
            cdp[i][j] = nCr(i, j);
        }
    }

    dp[0][0] = 1;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= i && j <= k; j++)
        {
            dp[i][j] = pwr(j, i);
            for(int z = 0; z < j; z++)
            {
                dp[i][j] = (dp[i][j] - cdp[j][z] * dp[i][z] % mod + mod) % mod;
            }
        }
    }

    ll ret = 0;
    for(int i = 1; i < n; i++)
    {
        ret += 15 * dp[i - 1][k - 1] * cdp[15][k - 1] % mod;
        ret %= mod;
        ret += 15 * dp[i - 1][k] * cdp[15][k - 1] % mod;
        ret %= mod;
    }

    unordered_map<char, int> mp;
    for(int i = 0; i < 10; i++)
        mp[i + '0'] = i;
    for(int i = 10; i < 16; i++)
        mp[i - 10 + 'A'] = i;
    unordered_set<int> used;
    for(int i = 0; i < n && used.size() <= k; i++)
    {
        int sz = used.size();
        // need (k - sz) new number for
        int num = mp[str[i]];
        int start = 0;
        if(i == 0)
            start = 1;
        for(int j = start; j < num; j++)
        {
            int nsz = sz;
            if(!used.count(j))
                nsz++;
            int nk = k - nsz;
            if(nk < 0)
                continue;
            int nn = n - i - 1;
            for(int z = nk; z <= k; z++)
            {
                ret += dp[nn][z] * cdp[16 - nsz][nk] % mod * cdp[nsz][z - nk] % mod;
                ret %= mod;
            }
        }
        used.insert(num);
    }

    unordered_set<char> st;
    for(int i = 0; i < n; i++)
    {
        st.insert(str[i]);
    }
    if(st.size() == k)
        ret++;

    cout << ret << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//↓AC-library使うなら

//型関係
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> pll;
typedef priority_queue<int, vector<int>, greater<int>> PQ;//昇順priority_queue
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<P > vpii;
typedef vector<pll > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
//repマクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//範囲関係
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define ALL(x) (x).begin(), (x).end()
//定数
#define inf 1000000000000
#define mod 1000000007
#define MAXR 100000
#define MATHPI acos(-1)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
//操作
#define PB push_back
#define PF push_front
#define MP make_pair
#define F first
#define S second
//数学関係, a<=x<=b
bool updown(ll x, ll a, ll b) { return x >= a && x <= b; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
#define SUM(x) accumulate(ALL(x), 0)
//chmin, chmax
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;}
//小数出力(f...出力したい小数, n...小数点以下の桁数)
void printd(double f, int n) { cout << fixed << setprecision(n) << f << endl; } //指定した桁で小数を出力
//YES/NO, Yes/No, yes/no出力
void YES(bool c = true) { cout << (c ? "YES" : "NO") << endl; } //YES(条件式)で記述
void Yes(bool c = true) { cout << (c ? "Yes" : "No") << endl; } //Yes(条件式)で記述
void yes(bool c = true) { cout << (c ? "yes" : "no") << endl; } //yes(条件式)で記述

//if use atcoder library:g++ main.cpp -std=c++17 -I /home/k0gane/ac-library

//累積和
//https://qiita.com/drken/items/56a6b68edef8fc605821
//point...n+1の容量のリストを作る
//
//深さ優先...push_front
//幅優先...push_backP

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k, m; cin >> n >> k >> m;
  int tar = n * m;
  rep(i, n-1){
    int a; cin >> a;
    tar -= a;
  }
  if(tar > k) cout << "-1" << endl;
  else cout << max(0, tar) << endl;
  return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N, C, a, b, c;
  cin >> N >> C;
  vector<pll> schedule;
  rep(i, N){
    cin >> a >> b >> c;
    schedule.emplace_back(a, c);
    schedule.emplace_back(b+1, -c);
  }
  sort(schedule.begin(), schedule.end());

  ll cost = 0, ans = 0, last_event = 0;
  for(auto p: schedule){
    ans += (p.first - last_event) * min(C, cost);
    last_event = p.first;
    cost += p.second;
  }
  cout << ans << endl;
  return 0;
}


//In the name of ALLAH
#include<bits/stdc++.h>
using namespace std;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
// User defined sizeof macro
# define my_sizeof(type) ((char *)(&type+1)-(char*)(&type))
#define ll long long int

int main()

{
    optimize();
    int n,a,b;
    cin>>n>>a>>b;

    cout<<n-a+b;

    return 0;
}

#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
//#define int long long
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PI = pair<pair<int,int>,int>;
using PL = pair<long long, long long>;
using PLL = pair<pair<long long, long long>, long long>;
using Pxy = pair<long double, long double>;
using Tiib = tuple<int, int, bool>;
using vvl = vector<vector<ll>>;
const int INF = 1001001007;
const int modd = 1000000007;
const long long modl = 1000000007LL;
const long long mod = 998244353LL;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

vector<vector<vector<ld>>> dp(101,vector<vector<ld>>(101,vector<ld>(101,-1.0)));

ld sik(int a, int b, int c){
    if (dp[a][b][c] >= 0.0) return dp[a][b][c];
    if (a == 100){
        dp[a][b][c] = 0.0;
        return dp[a][b][c];
    }
    if (b == 100){
        dp[a][b][c] = 0.0;
        return dp[a][b][c];
    }
    if (c == 100){
        dp[a][b][c] = 0.0;
        return dp[a][b][c];
    }
    ld i = a; ld j = b; ld k = c;
    ld ans = i * sik(a+1,b,c) + j * sik(a,b+1,c) + k * sik(a,b,c+1);
    ans /= i + j + k;
    dp[a][b][c] = ans + 1.0;
    return dp[a][b][c];
}

int main(){
    int a, b, c; cin >> a >> b >> c;
    cout << setprecision(20) << sik(a,b,c) << endl;
}


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

#define ll long long
#define endl "\n"
#define all(aa) aa.begin(), aa.end()

int main(){
	int n, ans=0;
	cin>>n;

	for(int a = 1; a <= n; a++) for(int b = 1; b <= n/a; b++) ans+=n/(a*b);

	cout<<ans<<endl;
}

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<map>
#include<set>

#define int long long
#define lowbit(x) (x&(-x))
#define mid ((l+r)>>1)
#define lc (x<<1)
#define rc (x<<1|1)
#define max Max
#define min Min
#define abs Abs

using namespace std;

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

inline void write(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x/10) write(x/10);
	putchar((char)(x%10)+'0');
}

template<typename T>inline T Abs(T a){return a>0?a:-a;};
template<typename T,typename TT>inline T Min(T a,TT b){return a>b?b:a;}
template<typename T,typename TT> inline T Max(T a,TT b){return a>b?a:b;}

const int N=105;
int n,m,a[N][N],mmin,ans;

signed main()
{
	n=read();m=read();mmin=1e18;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
		{
			a[i][j]=read();
			mmin=min(mmin,a[i][j]);
		}
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			ans+=a[i][j]-mmin;
	printf("%lld\n",ans);
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(200010);
  int ans = 0;
  for(int i = 0; i < n; i++){
    int p;
    cin >> p;
    a[p] = 1;
    while(a[ans] == 1) ans++;
    cout << ans << endl;
  }
}

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

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

    vector<int> n;

    rep(i, 0, N + 1)
    {
        n.push_back(i);
    }

    vector<int> ans;

    rep(i, 0, N)
    {
        int p;
        cin >> p;

        auto it = lower_bound(n.begin(), n.end(), p);

        if (it != n.end())
        {
            if (p == *it)
            {
                n.erase(it);
            }
        }

        ans.push_back(*n.begin());
    }

    rep(i, 0, N)
    {
        cout << ans[i] << endl;
    }
}


#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll
const long double pi = 3.14159265358979323846;

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll ans = 0;
    rep(i,0,n){
        ll a,b; cin >> a >> b;
        ans += (a + b) * (b - a + 1) / 2;
    }

    cout << ans << endl;
}

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

int main()
{
  ios_base::sync_with_stdio(false);
   cin.tie(NULL);
  int t=1;
  //cin>>t;
  while(t--){
        ll n,k;
        cin>>n>>k;
        vector<ll>a(n);
     map<ll,ll>mp;
        for(int i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]]++;
      }
        ll res=0;

      while(mp[0]>0 && k>0){
               ll pre=0;
           for(auto x:mp ){
              if( x.second>0 ){

                 if(pre ==x.first )
                       pre++;
                      else
                       break;
                        mp[x.first]--;
                           }
               else
                break;
              }
                 if(pre==0)
                 break;
                 else
                 res+=pre;
                 k--;
      }

      cout<<res;
  }
	return 0;
}


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

void sum(vector<ll>&x, vector<ll>&y, int pos, ll total){
    if(pos >= (ll)x.size()) return;
    y.push_back(total);
    sum(x, y, pos+1, total);
    y.push_back(total + x[pos]);
    sum(x, y, pos+1, total + x[pos]);
}

int main(){
    ll n, t, ans = 0;
    cin >> n >> t;

    vector<ll> a(n);
    vector<ll> b, c, d, e;

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

    for(int i = 0; i < n; i++){
        if(i%2==0) b.push_back(a[i]);
        else c.push_back(a[i]);
    }

    d.push_back(0);
    e.push_back(0);

    sum(b, d, 0, 0);
    sum(c, e, 0, 0);

    sort(d.begin(), d.end());
    d.erase(unique(d.begin(), d.end()), d.end());
    sort(e.begin(), e.end());
    e.erase(unique(e.begin(), e.end()), e.end());

    for(auto x: d){
        if(x > t) continue;
        auto maior = upper_bound(e.begin(), e.end(), t-x);
        if(maior != e.begin() && e.size() != 0) maior--;
        if(x+(*maior) <= t) ans = max(ans, x+(*maior));
    }

    cout << ans << '\n';
    return 0;
}

/*
{
######################
#       Author       #
#        Gary        #
#        2020        #
######################
*/
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
//inline int read(){
//    int x=0;
//    char ch=getchar();
//    while(ch<'0'||ch>'9'){
//        ch=getchar();
//    }
//    while(ch>='0'&&ch<='9'){
//        x=(x<<1)+(x<<3)+(ch^48);
//        ch=getchar();
//    }
//    return x;
//}
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
int n;
LL t;
LL a[44];
vector<LL> solve(int l,int r){
	int len=r-l+1;
	if(len<=0) return vector<LL> (1,0ll);
	vector<LL> rest;
	rep(i,1<<len){
		LL tot=0;
		rep(j,len){
			if((i>>j)&1)
			{
				int is=l+j;
				tot+=a[is];
			}
		}
		rest.PB(tot);
	}
	sort(ALL(rest));
	return rest;
}
int main(){
	scanf("%d%lld",&n,&t);
	rb(i,1,n)
	scanf("%lld",&a[i]);
	vector<LL> v1,v2;
	int half=(n+1)/2;
	v1=solve(1,half);
	int x=0;
	v2=solve(half+1,n);
	while(v1.back()>t){
		v1.POB();
	}
	LL rest=0;
	while(!v1.empty()){
		LL now=v1.back();
		v1.POB();
		while(x+1<v2.size()&&v2[x+1]+now<=t)
			x++;
		check_max(rest,now+v2[x]);
	}
	cout<<rest<<endl;
	return 0;
}
/** 程序框架：
  *
  *
  *
  *
  **/


#include<bits/stdc++.h>
// #include<atcoder/all>
// #include<boost/multiprecision/cpp_int.hpp>

using namespace std;
// using namespace atcoder;
// using bint = boost::multiprecision::cpp_int;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

// 2021/1/19
struct SCC{
  /*
    v := 隣接リスト有向グラフ
    rv := vの逆辺
    C := 同じ強連結成分のリスト
    H := 強連結成分分解後のDAGの隣接リスト(頂点の重複有り。)
    vs := 帰りがけ順
    blg := その頂点が属す強連結成分の番号
  */
  vector<vector<int>> v,rv,C,H;
  vector<int> vs,blg;
  vector<bool> used;
  SCC(int n) : v(n),rv(n),blg(n),used(n,0) {}

  void add_edge(int a,int b){
    v[a].push_back(b);
    rv[b].push_back(a);
  }

  //帰り帰りがけ順を探す
  void dfs(int ov){
    used[ov] = 1;
    for(auto nv : v[ov]){
      if(used[nv])continue;
      dfs(nv);
    }
    vs.push_back(ov);
  }

  //逆辺を移動して、scc
  void rdfs(int ov,int nu){
    used[ov] = 1;
    blg[ov] = nu;
    C[nu].push_back(ov);
    for(auto nv : rv[ov]){
      if(used[nv])continue;
      rdfs(nv,nu);
    }
  }

  int build(){
    int n = v.size();
    for(int i = 0;i < n;i++)if(!used[i])dfs(i);
    fill(used.begin(),used.end(),0);
    int nu = 0;
    for(int i = n-1;i >= 0;i--){
      if(used[vs[i]])continue;
      H.emplace_back();
      C.emplace_back();
      rdfs(vs[i],nu++);
    }

    for(int i = 0;i < n;i++){
      for(auto j : v[i]){
        if(blg[i] != blg[j])H[blg[i]].push_back(blg[j]);
      }
    }

    return nu;
  }
};

// 2020/12/06 rechecked
long long modpow(long long n,long long r,const int mod = 998244353){
  long long res = 1;
  while(r){
    if(r & 1)res = res*n%mod;
    n = n*n%mod;
    r >>= 1;
  }
  return res;
}

int main(){

  int n;
  cin >> n;
  vector<int> f(n);
  rep(i,n)cin >> f[i],f[i]--;
  SCC scc(n);
  rep(i,n)scc.add_edge(i,f[i]);
  scc.build();
  int cnt = 0;
  for(auto au : scc.C)if(au.size() >= 2 || au[0] == f[au[0]])cnt++;
  cout << (modpow(2,cnt)-1+998244353)%998244353 << "\n";

  return 0;
}

#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 998244353
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

ll Pow(ll n, ll k) {
	ll ans = 1, a = n % MOD;
	while (k > 0) {
		if (k & 1) {
			ans *= a;
			ans %= MOD;
		}
		a *= a;
		a %= MOD;
		k >>= 1;
	}
	return ans;
}

int DFS(int n, int k, vector<int>& d, vector<int>& v) {
	v[n] = k;
	if (v[d[n]] < 0)
		return DFS(d[n], k, d, v);
	else if (v[d[n]] == k)
		return 1;
	return 0;
}

int main(void) {
	int num, i, k = 0, x = 0;
	cin >> num;
	vector<int> d(num), v(num, -1);
	rep(i, num) {
		cin >> d[i];
		d[i]--;
	}
	rep(i, num) {
		if (v[i] < 0) {
			if (DFS(i, x, d, v))
				k++;
			x++;
		}
	}
	cout << Pow(2ll, k) - 1 << "\n";
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  cout << N - 1;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }
long long gcd(long long a, long long b) { return (a % b) ? gcd(b, a % b) : b; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    cout << (n - 1) << endl;
    return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define SZ(x) ((int)x.size()-1)
#define ms(a,b) memset(a,b,sizeof a)
#define F(i,a,b) for (int i=(a);i<=(b);++i)
#define DF(i,a,b) for (int i=(a);i>=(b);--i)
using namespace std;
inline int read(){
	char ch=getchar(); int w=1,c=0;
	for(;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
	for(;isdigit(ch);ch=getchar()) c=(c<<1)+(c<<3)+(ch^48);
	return w*c;
}
int calc(int x){
	int ret=0;
	while (x){
		ret+=x%10;
		x/=10;
	}
	return ret;
}
int main(){
	int a=read(),b=read();
	cout<<max(calc(a),calc(b))<<'\n';
	return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
*/

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

int fanc(string S){
    int ret=0;
    ret += S[0]-'0';
    ret += S[1]-'0';
    ret += S[2]-'0';
    return ret;
}

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

    int ans = max(fanc(A),fanc(B));

    cout<<ans<<endl;
    return 0;
    //解説を見た
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  long double
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0);
#define mod 1000000007

int main()
{
	double R,X,Y;
	cin>>R>>X>>Y;
	double K = sqrt(X*X + Y*Y);
	if(K == R)
		cout<<1<<endl;
	else if(K <= 2*R)
		cout<<2<<endl;
	else cout<<ceil(double(1.0 * K/R))<<endl;
}

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

typedef long long ll;
typedef long double ld;

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 R, X, Y;
	cin >> R >> X >> Y;

	R = R*R;

	ll ans = 0;

	ld dist = X*X + Y*Y;

	ld div = sqrt(dist / R);

	ans = ceil(sqrt(dist / R));

	if(div < 1){
		ans =2;
	}

	cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

double Sx, Sy, Gx, Gy;

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

    std::cin >> Sx >> Sy >> Gx >> Gy;

    double a = (- Gy - Sy) / (Gx - Sx),
        x = Sx - Sy / a;
    printf("%.10f\n", x);
}

/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip> //setprecision
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#include <numeric> //accumulate,,,
#include <time.h> //clock
#define endl "\n";
using namespace std;

using PLL = pair<long long,long long>;
using P = pair<int,int>;
const long long INF = 3000000000000000001;
const int inf = 1001001001;
long long MOD = 1000000007;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M, long long mod) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % mod, M / 2,mod);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % mod;
    return res %= mod;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a; else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}
long long get_mod(long long res){
    if(res < 0) res += MOD;
    return res % MOD;
}

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

    long double sx,sy,gx,gy;cin >> sx >> sy >> gx >> gy;
    cout << fixed << setprecision(7) << (gx-sx)*(sy/(sy+gy))+sx << endl;
}


#include <bits/stdc++.h>

#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x & -x)
#define FOR(i,a,b)  for(int i=(a); i< (b); ++i)
#define RFOR(i,b,a) for(int i=(b);i>=(a);i--)
#define REP(i,a,b)  for(int i=(a); i<=(b); ++i)
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
template<typename T>
void PrArr(const T a[] , int len){
	for(int i = 0;i <= len; i++)cout << a[i] << " ";
	cout << endl;
}
template<typename T>
void PrVec(const vector<T> a){
	for(auto it : a)cout << it << " ";
	cout << endl;
}
const int MAX = 0x7ffffff;
const int MIN = 0xcf;
int test;
void slove()
{
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;

	// 1. 记录一下每个字符出现的次数
	map<char, int> mp;
	for(char c : s1) mp[c] ++;
	for(char c : s2) mp[c] ++;
	for(char c : s3) mp[c] ++;
	/*
	如果出现的字母数量大于10意味着要出现10个不同数字表示
	这样是不可能成立的，所以这种情况下一定不存在解
	*/
	if(mp.size() > 10) {
		cout << "UNSOLVABLE" << endl;
		return ;
	}

	// 获取到以上出现过哪些字母并组合成一个字符串
	string s0;
	for(auto p : mp) s0 += p.first;
	int m = s0.size();

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

	auto val = [&](char c) {
		for(int i = 0; i < m; i ++)
		{
			if(c == s0[i]) {
				return v[i];
			}
		}
		return -1;
	};

	do {
		// 此时数字包含前导0需要排除这种情况。
		if(val(s1[0]) == 0 || val(s2[0]) == 0 || val(s3[0]) == 0) {
			continue;
		}

		ll x1 = 0, x2 = 0, x3 = 0;

		for(auto c : s1) {
			x1 *= 10;
			x1 += val(c);
		}

		for(auto c : s2) {
			x2 *= 10;
			x2 += val(c);
		}

		for(auto c : s3) {
			x3 *= 10;
			x3 += val(c);
		}

		if(x1 + x2 == x3)
		{
			cout << x1 << endl;
			cout << x2 << endl;
			cout << x3 << endl;
			return ;
		}
	} while(next_permutation(v.begin(),v.end()));

	cout << "UNSOLVABLE" << endl;
}
int main()
{
#ifdef LOCAL
	auto start_time = clock();
	cerr << setprecision(3) << fixed; // 在iomanip中
#endif
	SIS;slove();
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}

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

#define int int64_t

void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template<typename T, typename V>
void __print(const pair<T, V> &x) { cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}'; }
template<typename T>
void __print(const T &x)  { int f = 0; cerr << '{'; for(auto &i: x) cerr << (f++ ? " " : ""), __print(i); cerr << "}"; }
void _print()  { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#ifndef DEBUG
#define imie(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define imie(x...)
#endif

int f(string s)
{
	int ans = 0;
	for(char c : s)
		ans = ans * 10 + c - '0';
	return ans;
}

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

	vector<string> s(3);
	for(auto &x : s)
		cin >> x;

	vector<pair<int, int>> g[26];
	set<int> idx;

	for(int i = 0; i < 3; i++) {
		for(int j = 0; j < int(s[i].size()); j++) {
			idx.insert(s[i][j] - 'a');
			g[s[i][j] - 'a'].push_back(make_pair(i, j));
		}
	}

	int N = int(idx.size());
	if(N > 10) {
		cout << "UNSOLVABLE";
		return 0;
	}

	vector<int> permute(10);
	for(int i = 0; i < 10; i++)
		permute[i] = i;

	do {
		int c = 0;
		for(int idx_in_g : idx) {
			for(auto p : g[idx_in_g])
				s[p.first][p.second] = char(permute[c] + '0');
			c++;
		}

		if(s[0][0] == '0' || s[1][0] == '0' || s[2][0] == '0')
			continue;

		vector<int> num(3);
		for(int i = 0; i < 3; i++) {
			num[i] = f(s[i]);
		}

		if(num[0] + num[1] == num[2]) {
			for(int x : num)
				cout << x << endl;
			return 0;
		}

	} while(next_permutation(permute.begin(), permute.end()));

	cout << "UNSOLVABLE";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vvii vector<vector<pair<int, int>>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = (sizeof(int) == 4 ? 1e9 : 2e18) + 1e5;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

// INDEX BY ONE ALWAYS!!!
class BIT_2D {
private:
  // row, column
  const int n, m;
  vector<vector<int>> tree;

private:
  // Returns an integer which constains only the least significant bit.
  int low(const int i) { return i & (-i); }

  void _update(const int x, const int y, const int delta) {
    for (int i = x; i < n; i += low(i))
      for (int j = y; j < m; j += low(j))
        tree[i][j] += delta;
  }

  int _query(const int x, const int y) {
    int ans = 0;
    for (int i = x; i > 0; i -= low(i))
      for (int j = y; j > 0; j -= low(j))
        ans += tree[i][j];
    return ans;
  }

public:
  // put the size of the array without 1 indexing.
  /// Time Complexity: O(n * m)
  BIT_2D(const int n, const int m) : n(n + 1), m(m + 1) {
    tree.resize(this->n, vector<int>(this->m, 0));
  }

  /// Time Complexity: O(n * m * (log(n) + log(m)))
  BIT_2D(const vector<vector<int>> &mat)
      : n(mat.size()), m(mat.front().size()) {
    // Check if it is 1 indexed.
    assert(mat[0][0] == 0);
    tree.resize(n, vector<int>(m, 0));
    for (int i = 1; i < n; i++)
      for (int j = 1; j < m; j++)
        _update(i, j, mat[i][j]);
  }

  /// Query from (1, 1) to (x, y).
  ///
  /// Time Complexity: O(log(n) + log(m))
  int prefix_query(const int x, const int y) {
    assert(0 < x), assert(x < n);
    assert(0 < y), assert(y < m);
    return _query(x, y);
  }

  /// Query from (x1, y1) to (x2, y2).
  ///
  /// Time Complexity: O(log(n) + log(m))
  int query(const int x1, const int y1, const int x2, const int y2) {
    assert(0 < x1), assert(x1 <= x2), assert(x2 < n);
    assert(0 < y1), assert(y1 <= y2), assert(y2 < m);
    return _query(x2, y2) - _query(x1 - 1, y2) - _query(x2, y1 - 1) +
           _query(x1 - 1, y1 - 1);
  }

  /// Updates point (x, y).
  ///
  /// Time Complexity: O(log(n) + log(m))
  void update(const int x, const int y, const int delta) {
    assert(0 < x), assert(x < n);
    assert(0 < y), assert(y < m);
    _update(x, y, delta);
  }
};

vvi mat;
int n;
int k;

bool check(int mid) {
  vvi mt = Mat(n + 1, n + 1, 0);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      mt[i][j] = mat[i][j] <= mid;

  BIT_2D bit(mt);
  int sz = k * k / 2 + 1;
  if (k % 2 == 0)
    sz--;
  // debug(sz);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) {
      int x2 = i + k - 1;
      int y2 = j + k - 1;
      if (x2 > n || y2 > n)
        break;
      if (bit.query(i, j, x2, y2) >= sz) {
        return true;
      }
    }
  return false;
}

// #define MULTIPLE_TEST_CASES
void solve(const int test) {
  cin >> n;

  cin >> k;

  mat = Mat(n + 1, n + 1, 0);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) {
      cin >> mat[i][j];
    }

  int l = 0, r = 1e9;
  int ans = -1;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (check(mid)) {
      r = mid - 1;
      ans = mid;
    } else {
      l = mid + 1;
    }
  }
  assert(ans != -1);
  cout << ans << endl;
}

signed main() {
  // const string FILE_NAME = "";
  // freopen((FILE_NAME + string(".in")).c_str(), "r", stdin);
  // freopen((FILE_NAME + string(".out")).c_str(), "w", stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);

  int t = 1;
#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  for (int i = 1; i <= t; ++i)
    solve(i);
}

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

const int N = 810;
typedef long long ll;

int g[N][N];
int s[N][N];
int n, k;

bool check(int x)
{
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            s[i][j] = s[i-1][j] + s[i][j-1] - s[i-1][j-1] + (g[i][j] >= x);

    for(int i=k;i<=n;i++)
        for(int j=k;j<=n;j++)
        {
            int t = s[i][j] - s[i-k][j] - s[i][j-k] + s[i-k][j-k];
            if((k*k/2) + 1 > t) return 0;
        }
    return 1;
}
int main()
{
    cin >> n >> k;

    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            cin >> g[i][j];

    int l = 0, r = 1e9;

    while(l < r)
    {
        int mid = (l + r + 1) >> 1;
        if(check(mid)) l = mid;
        else r = mid - 1;

    }
    cout << l;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
//bool vis[1000];
//int x[]={1,-1,0,0};
//int y[]={0,0,1,-1};
//int f=0;
//"'';
void dfs(int i,ll d,vector<vector<vector<ll> > > &adj,vector<ll> &v){
v[i]=d;
//cout<<i<<" "<<d<<endl;
for(int j=0;j<adj[i].size();j++){
    int u=adj[i][j][0];
   ll w=adj[i][j][1];
    if(v[u]==-1){
        dfs(u,d^w,adj,v);
    }
}
}
int main() {
int n;
cin>>n;
vector<vector<vector<ll> > > adj(n);
for(int i=1;i<n;i++){
  ll a,b,c;
    cin>>a>>b>>c;
    a--;
    b--;
    adj[a].push_back({b,c});
    adj[b].push_back({a,c});
}
vector<ll> v(n,-1);
dfs(0,0,adj,v);
int dp[62];
long long mod=1e9+7;
long long ans=0;
memset(dp,0,sizeof(dp));
for(int i=0;i<(int)v.size();i++){
        //cout<<v[i]<<endl;
    for(ll j=0;j<62;j++){
        if(v[i]&(1ll<<j)){
            dp[j]++;
        }
    }
}
for(ll i=0;i<62;i++){
    long long a=dp[i];
    long long b=v.size()-a;
    //cout<<a<<" "<<b<<endl;
    ll z=(a*b)%mod;
    ll zz=pow(2ll,i);
    zz=zz%mod;
    zz=(z*zz)%mod;
    //cout<<z<<" "<<zz<<endl;
    ans=(ans+zz)%mod;
    //cout<<i<<endl;
}
cout<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define deb(k) cerr << #k << ": " << k << "\n";
#define size(a) (int)a.size()
#define fastcin cin.tie(0)->sync_with_stdio(0);
#define st first
#define nd second
#define pb push_back
#define mk make_pair
#define int long long
typedef long double ldbl;
typedef double dbl;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef vector<int> vint;
#define MAXN 300100
#define MAXLG 20
const int inf = 0x3f3f3f3f;
const ll mod = 1000000007;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const int N = 300100;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int x[200], y[200];
int n;
vector<int>g[200];
double dist[200][200];
bool vis[210];

void dfs(int x){
	vis[x] = 1;
	for(auto v : g[x]){
		if(!vis[v]) dfs(v);
	}
}

bool check(double mid){
	for(int i=0;i<=n+1;i++) g[i].clear(), vis[i] = 0;
	for(int i=0;i<=n+1;i++){
		for(int j=i+1;j<=n+1;j++){
			if( dist[i][j] < 2*mid + 1e-7){
				g[i].pb(j);
				g[j].pb(i);
			}
		}
	}
	dfs(0);
	if(vis[n+1]) return false;
	return true;
}

void solve(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>x[i]>>y[i];
	for(int i=1;i<=n;i++){
		dist[i][i] = 0;
		for(int j=i+1;j<=n;j++){
			dist[i][j] = sqrt(1.0*((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j])) );
			dist[j][i] = dist[i][j];
		}
		dist[0][i] = y[i] + 100;
		dist[i][0] = dist[0][i];
		dist[n+1][i] = 100 - y[i];
		dist[i][n+1] = dist[n+1][i];
	}
	dist[0][n+1] = 200;
	dist[n+1][0] = 200;
	double l = 0, r = 100;
	while(r - l > 1e-9){
		double mid = (l + r)/2;
		if(check(mid)) l = mid;
		else r = mid;
	}
	cout<<setprecision(9);
	cout<<l<<"\n";

	// Have you read the problem again?
	// Maybe you understood the wrong problem
}

int32_t main(){
	fastcin;
	int t_ = 1;
	//cin>>t_;
	while(t_--)
		solve();
	return 0;
}

//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//Using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set;

#define ll              long long
#define int             long long
#define ld             long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vi>
#define vip            vector<pii>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int>
#define all(v)          v.begin(),v.end()
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define lb(x)           (x&(-x))
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define itr(it,v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fir(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ff               first
#define ss               second
#define deb(x) cout << #x << "=" << x << endl
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define check(x) (x && cout<<"Yes\n")||(cout<<"No\n");
#define fin(s)          freopen(s,"r",stdin);
#define fout(s)         freopen(s,"w",stdout);

const ld pi = 3.141592653589793238462643383279502884;
const int xd[]={-1,0,1,0};
const int yd[]={0,-1,0,1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0,  1, -1, 1, -1, 0, 1 };

int expo(int a,int b,int m);
int mmi(int a,int m);
void ipgraph(int m);

const int N=5*(1e5)+10;
vii adj(N);
int a[N];

void  solve(){

}
int32_t main()
{
    FIO
    string x; cin>>x;
    int i=0;
    while(i<x.length() && x[i]!='.') cout<<x[i],i++; cout<<"\n";
    return 0;

}

void ipgraph(int m){
    int i, u, v;
    while(m--){
          cin>>u>>v;
         u--, v--;
    adj[u].pb(v);
    adj[v].pb(u);
    }
}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}


/***************************************************************
	File name: D.cpp
	Author: ljfcnyali
	Create time: 2021年02月21日 星期日 21时00分33秒
***************************************************************/
#include<bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for ( int i = (a), _end_ = (b); i <= _end_; ++ i )
#define mem(a) memset ( (a), 0, sizeof ( a ) )
#define str(a) strlen ( a )
#define pii pair<int, int>
#define int long long
typedef long long LL;

const int maxn = 1e5 + 10;
const int Mod = 998244353;

int n, m, k, ans;

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

signed main()
{
	scanf("%lld%lld%lld", &n, &m, &k);
	if ( n == 1 || m == 1 )
	{
		printf("%lld\n", power(k, n + m - 1));
		return 0;
	}
	REP(i, 1, k) ans = (ans + (power(i, n) - power(i - 1, n)) * power(k - i + 1, m)) % Mod;
	printf("%lld\n", (ans + Mod) % Mod);
    return 0;
}

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

struct{template<class T>constexpr operator T(){return numeric_limits<T>::max();}constexpr auto operator-();}inf;
struct{template<class T>constexpr operator T(){return numeric_limits<T>::lowest();}constexpr auto operator-();}negative_inf;
constexpr auto decltype(inf)::operator-(){return negative_inf;}
constexpr auto decltype(negative_inf)::operator-(){return inf;}

#define swap(a,b) {a^=b;b^=a;a^=b;}
#define rep(i,n) for(long long i = 0; i < n; i++)
#define reps(i,s,n) for(long long i = (s); i < n; i++)
#define repr(i,n) for(long long i = (n - 1); i >= 0; i--)
#define LOOP for(long long i = 0;;i++)
#define PB push_back
#define ALL(v) v.begin(),v.end()
#define DOUBLE fixed << setprecision(15)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<vd> vvd;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
typedef pair<ll,ll> P;
typedef vector<P> vP;

#define F first
#define S second
#define SPC << " "

ll gcd(ll x,ll y){if(x<=0||y<=0)return 0;if(y>x){swap(x,y);}return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*y/gcd(x,y);}
ll factrial(int x){return x<=1?1:x*factrial(x-1);}
ll nPr(ll n,ll r){ll a=1;rep(i,n-r)a*=(n-i);return a;}
ll nCr(ll n,ll r){ll a=1;rep(i,r){a*=(n-i);a/=(i+1);}return a;}
vP factor(ll n){vP r;if(n<=1)return{};ll m=pow(n,0.5)+1;reps(i,2,m){if(n%i==0){ll c=0;
  while(n%i==0){c++;n/=i;}r.PB({i,c});}if(n<=1)break;}if(n>1)r.PB({n,1});return r;}

bool mycmp(P &a, P &b){
  return a.F < b.F;
}
bool mycmp2(pair<ll,P> &a, pair<ll,P> &b){
  return a.F > b.F;
}

int main(){
  ll n;
  cin >> n;
  vP px(n), py(n);
  rep(i,n){
    cin >> px[i].F >> py[i].F;
    px[i].S = i;
    py[i].S = i;
  }
  sort(ALL(px), mycmp);
  sort(ALL(py), mycmp);
  ll dx, dy, dx0, dxn, dy0, dyn;
  dx = px[n-1].F - px[0].F;
  dy = py[n-1].F - py[0].F;
  dx0 = px[n-1].F - px[1].F;
  dxn = px[n-2].F - px[0].F;
  dy0 = py[n-1].F - py[1].F;
  dyn = py[n-2].F - py[0].F;
  if(px[0].S == py[0].S && px[n-1].S == py[n-1].S){
    cout << max(max(dx0,dxn), max(dy0,dyn)) << endl;
  }else{
    vll d = {dx, dx0, dxn, dy, dy0, dyn};
    sort(ALL(d));
    cout << d[4] << endl;
  }
}


//* Jai shree Ram
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lli                                 long long int
#define ll                                  long long
#define FOR(i,a,b)                          for(int i=(a);i<(b);i++)
#define vi                                  vector<int>
#define vll                                 vector<ll>
#define all(a)                              a.begin(),a.end()
#define sz(a)                               (int)a.size()
#define pb                                  push_back
#define ppb                                 pop_back
#define pf                                  push_front
#define fr                                  first
#define sc                                  second
#define uniq(v)                             (v).erase(unique(all(v)),(v).end())
using namespace std;

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

template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}
// __builtin_popcountll(x);
// __builtin_clz(x) // Count Leading zeros
// __builtin_ctz(x) // Trailing zeros
const int MM = 998244353;
const int mod = 1e9 + 7;
const int INF = 1e9 + 5;
const int N = 1e5 + 5;

/* stuff you should look for
  * make sure to read the bottom part of question
  * special cases (n=1?)
  * In Game Theory Check your solution and consider all the solutions
*/

void solve()
{
    int a,b,c;
    cin >> a >> b >> c;
    cout << (21 - (a+b+c)) << "\n";
}

signed main()
{
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t;
    t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
}

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

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

  int d = 21 - (a+b+c);
  cout << d;

return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
  int arr[4],sum=0;
  for(int i=0;i<3;i++){
    cin>>arr[i];
    int x=arr[i];
    if(x==1) sum+=6;
    else if(x==2) sum+=5;
    else if(x==3) sum+=4;
    else if(x==4) sum+=3;
    else if(x==5) sum+=2;
    else if(x==6) sum+=1;
  }
  cout<<sum;
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vvii vector<vector<pair<int, int>>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = (sizeof(int) == 4 ? 1e9 : 2e18) + 1e5;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

vi arr;
int dp[MAXN][3];
int f(int idx, int val) {
  if (idx == arr.size())
    return (val == 1);

  int &ret = dp[idx][val];
  if (~ret)
    return ret;

  ret = 0;
  if (arr[idx]) {
    // AND
    ret += f(idx + 1, val & 0);
    ret += f(idx + 1, val & 1);
  } else {
    // OR
    ret += f(idx + 1, val | 0);
    ret += f(idx + 1, val | 1);
  }
  return ret;
}

// #define MULTIPLE_TEST_CASES
void solve() {
  memset(dp, -1, sizeof dp);
  int n;
  cin >> n;

  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    arr.eb(s.front() == 'A' ? 1 : 0);
  }

  cout << f(0, 0) + f(0, 1) << endl;
}

signed main() {
  // const string FILE_NAME = "";
  // freopen((FILE_NAME + string(".in")).c_str(), "r", stdin);
  // freopen((FILE_NAME + string(".out")).c_str(), "w", stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);

  int t = 1;
#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}


#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#define lli long long int
#define loop(i,x,n) for(int i=x;i<n;i++)
#define loopr(i,x,n) for(int i=n-1;i>=x;i--)
#define st set<lli>
#define v vector<lli>
#define um unordered_map<lli,lli>
#define vpl vector<pair<lli,lli>>
#define llu long long unsigned
#define ms multiset<int,greater<int>>
#define ums unordered_map<string,lli>
#define pb push_back
#define time ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout.setf(ios::fixed); cout.setf(ios::showpoint);
#define test lli t; cin>>t; while(t--)
using namespace std;
int main()
{
    time
    // test
    {
        int a,b,c;
        cin>>a>>b>>c;
        if(a==b) cout<<c;
        else if(a==c) cout<<b;
        else if(b==c) cout<<a;
        else cout<<0;
    }
    return 0;
}

/* これを翻訳している間、あなたはあなたの人生のいくつかの貴重な瞬間を無駄にしました */

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define ld long double
#define mem(x,y) memset(x,y,sizeof x)

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

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b) cout<<c<<'\n';
	else if(b==c) cout<<a<<'\n';
	else if(c==a) cout<<b<<'\n';
	else cout<<0<<'\n';
}

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


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

static const bool LOCAL_TEST = false;

vector<vector<int>> h(30, vector<int>(30, 5000));
vector<vector<int>> v(30, vector<int>(30, 5000));

int si, sj, ti, tj;
int b, result;
double a, e;

int prev_result;
double score;
string path;

void read_h_v()
{
  for (int i = 0; i < 30; ++i)
    for (int j = 0; j < 29; ++j)
      cin >> h.at(i).at(j);
  for (int i = 0; i < 29; ++i)
    for (int j = 0; j < 30; ++j)
      cin >> v.at(i).at(j);
}

void read_s_t_a_e()
{
  cin >> si >> sj >> ti >> tj;
  cin >> a >> e;
}

void read_s_t()
{
  cin >> si >> sj >> ti >> tj;
}

void read_result()
{
  cin >> result;
}

int compute_path_length(int x, int y, char ch)
{
  if (ch == 'L' || ch == 'R')
    return h.at(y).at(x);
  return v.at(y).at(x);
}

int compute_total_path_length(string path)
{
  int x = sj;
  int y = si;

  int len = 0;
  for (char ch : path)
  {
    if (ch == 'L') --x;
    if (ch == 'R') ++x;
    if (ch == 'D') ++y;
    if (ch == 'U') --y;
    len += compute_path_length(x, y, ch);
  }
  return len;
}

void set_avg_path_length(string path, int result, int k)
{
  size_t len = path.size();
  int average = result + (len - 1) / len;
  int x = sj, y = si;
  for (char ch : path)
  {
    if (ch == 'L') --x;
    if (ch == 'R') ++x;
    if (ch == 'D') ++y;
    if (ch == 'U') --y;
    if (ch == 'L' || ch == 'R')
      if (k < 200)
        h.at(y).at(x) = min(h.at(y).at(x), average);
      else
        h.at(y).at(x) = (h.at(y).at(x) + average) / 2;
    else
      if (k < 200)
        v.at(y).at(x) = min(v.at(y).at(x), average);
      else
        v.at(y).at(x) = (v.at(y).at(x) + average) / 2;
  }
}

string query(int prev_result)
{
  string ver = "", hor = "";
  int x = ti - si;
  for (int i = 0; i < x; ++i) ver += "D";
  for (int i = 0; x < i; --i) ver += "U";
  int y = tj - sj;
  for (int i = 0; i < y; ++i) hor += "R";
  for (int i = 0; y < i; --i) hor += "L";

  x = sj, y = si;
  string answer = "";
  while (ver.size() && hor.size())
  {
    char s1 = ver.back(), s2 = hor.back();
    int x1 = x + (s2 == 'R' ? 1 : -1);
    int y1 = y + (s1 == 'D' ? 1 : -1);
    int b1 = compute_path_length(x, y1, s1);
    int b2 = compute_path_length(x1, y, s2);
    char ch;
    if (b1 < b2)
    {
      ch = s1;
      ver.pop_back();
    }
    else if (b2 < b1)
    {
      ch = s2;
      hor.pop_back();
    }
    else
    {
      if (ver.size() < hor.size())
      {
        ch = s2;
        hor.pop_back();
      }
      else
      {
        ch = s1;
        ver.pop_back();
      }
    }
    answer += ch;
    if (ch == 'L') --x;
    if (ch == 'R') ++x;
    if (ch == 'D') ++y;
    if (ch == 'U') --y;
  }
  answer = answer + ver + hor;
  return answer;
}

int main()
{
  if (LOCAL_TEST)
  {
    read_h_v();
  }

  prev_result = 0;
  score = 0.0;

  for (int k = 0; k < 1000; ++k)
  {
    if (LOCAL_TEST)
      read_s_t_a_e();
    else
      read_s_t();

    path = query(prev_result);
    cout << path << endl;

    if (LOCAL_TEST)
    {
      b = compute_total_path_length(path);
      score = score * 0.998 + a / b;
      prev_result = round(b * e);
    }
    else
    {
      read_result();
      prev_result = result;
      set_avg_path_length(path, prev_result, k);
    }
  }
  if (LOCAL_TEST)
  {
    cout << setprecision(32) << round(2312311 * score) << endl;
  }
  return 0;
}

#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i=a; i >=b; i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(), (x).end()

using namespace std;
void _main(); int main() {cin.tie(0); ios::sync_with_stdio(false); _main();}
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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;}

string S1, S2, S3;
#define NOANS "UNSOLVABLE"
vector<char> chars;
char used[10];

bool check() {
    map<char, char> mapping;
    rep(i, 0, 10) {
        if (used[i] != 0) {
            mapping[used[i]] = char('0' + i);
        }
    }

    string SS1, SS2, SS3;
    fore(c, S1) {
        SS1 += mapping[c];
    }
    fore(c, S2) {
        SS2 += mapping[c];
    }
    fore(c, S3) {
        SS3 += mapping[c];
    }

    if (to_string(stoll(SS1)) != SS1) return false;
    if (to_string(stoll(SS2)) != SS2) return false;
    if (to_string(stoll(SS3)) != SS3) return false;
    if(stoll(SS1) + stoll(SS2) != stoll(SS3)) return false;
    if(stoll(SS1) == 0) return false;
    if(stoll(SS2) == 0) return false;
    if(stoll(SS3) == 0) return false;

    cout << SS1 << endl;
    cout << SS2 << endl;
    cout << SS3 << endl;
    return true;
}

bool dfs(int cu) {
    if (cu == chars.size()) return check();

    rep(i, 0, 10) {
        if(used[i] == 0) {
            used[i] = chars[cu];
            if (dfs(cu+1)) return true;
            used[i] = 0;
        }
    }

    return false;
}

void _main() {
    cin >> S1 >> S2 >> S3;

    fore(c, S1) chars.push_back(c);
    fore(c, S2) chars.push_back(c);
    fore(c, S3) chars.push_back(c);
    sort(all(chars));
    chars.erase(unique(all(chars)), chars.end());

    if (10 < chars.size()) {
        cout << NOANS << endl;
        return;
    }

    bool res = dfs(0);
    if(res == false) {
        cout << NOANS << endl;
    }
}


#include<bits/stdc++.h>
#define ll              long long int
#define ld              long double
#define ff              first
#define ss              second
#define mod             1000000007
#define ull             unsigned long long
#define vll             vector<ll>
#define uom             unordered_map
#define uos             unordered_set
#define pll             pair<ll, ll>
#define INF             9223372036854775807
#define w(t)            ll tests;    cin>>tests;        while(tests--)
#define endl            "\n"
#define pb(x)           push_back(x)
#define ppb()			pop_back()
#define all(x)          x.begin(), x.end()
#define mp(a, b)        make_pair(a, b)
#define setp(x, y)      fixed << setprecision(x) << y
#define f(i, a, b)      for(ll i = a ; i < b ; i++)
#define fo(j, a, b)     for(ll j = a ; j >= b ; j--)
#define fill(a, n, x)   f(i, 0, n)     a[i]=x;
using namespace std;

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

int main() {

	init();
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	ll n;
	cin >> n;
	ll a[200] = {0};

	f(i, 0, n)
	{
		ll x;
		cin >> x;
		a[x % 200]++;
	}

	ll ans = 0;
	f(i, 0, 200)
	ans += a[i] * (a[i] - 1) / 2;

	cout << ans;

	return 0;
}

#include "bits/stdc++.h"
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef __int128 lll;
typedef vector<int> vi;
typedef vector<ll> vl;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
const ll inf=0x3f3f3f3f3f3f3f3f;
const int mn=101;
const ll mod=998244353;

string g[mn];
bool vis[mn];
int n;
void dfs(int x){
    vis[x]=1;
    for(int y=0;y<n;y++)if(!vis[y]&&g[y][x]=='1'){
        dfs(y);
    }
}
int main(){
#ifdef LOCAL
    freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
freopen("error.txt","w",stderr);
#endif
    cin.tie(0);
    cin.sync_with_stdio(0);
    cin>>n;
    for(int i=0;i<n;i++)cin>>g[i];
    double ans=0;
    for(int i=0;i<n;i++){
        memset(vis,0,sizeof(vis));
        dfs(i);
        int num=0;
        for(int j=0;j<n;j++)num+=vis[j];
        //cerr<<num<<endl;
        ans+=1./num;
    }
    printf("%.20lf\n",ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(),a.end()
typedef pair<ll,ll> pi;

//__builtin_popcountll(2) (the number of ones in the binary representation)
//__builtin_clz(2) (number of leading zeroes)
//__builtin_ctz(2) (number of trailing zeroes)

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

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>*/
// s.find_by_order(k)(returns iterator to kth element), s.order_of_key(k)(number of elements less than number)

ll mod = 1e9+7;
vector<ll> fact(1);
/*vector<ll> spf(10000005), cntPrime(10000005);

void spff(){
    int i;
    for(i=1;i<10000005;i++) spf[i] = i;
    for(i=2;i*i<10000005;i++)
    {
        if(spf[i] != i) continue;
        for(int j = i*i; j < 10000005; j+= i){
            if(spf[j]==j) spf[j] = i;
        }
    }
    for(i=1;i<10000005;i++){
        if(spf[i] != spf[i/spf[i]]){
            cntPrime[i] = cntPrime[i/spf[i]]+1;
        }
        else cntPrime[i] = cntPrime[i/spf[i]];
    }
}
while(spf[a[i]]!=a[i]){
              z=spf[a[i]];
              while(a[i]%z==0) a[i]/=z;
              m[z]++;
          }
          if(a[i]>1) m[a[i]]++;*/

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

ll power(ll x, ll y)
{
    ll temp;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}

ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;

    while (y > 0) {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

ll modInv(ll n, ll p)
{
    return power(n, p - 2, p);
}

ll ncr(ll n, ll r) {return (n>=r?(fact[n]*modInv(fact[r],mod))%mod*modInv(fact[n-r],mod)%mod:0);}

ll add(ll a, ll b) {ll z=a+b; if(z>=mod) z -= mod; return z;}
ll sub(ll a, ll b) { return (a-b+mod)%mod;}
// LLONG_MAX

vector<pi> v[105];
vector<ll> dp((1<<18), -1);
ll n;

ll solve(ll mask){
    ll z=0, cnt = __builtin_popcountll(mask);
    if(cnt==0) return 1;
    if(dp[mask] != -1) return dp[mask];

    for(auto i: v[cnt]){
        ll pre = mask%(1<<i.fi);
        pre = __builtin_popcountll(pre);
        if(pre > i.se) return 0;
    }
    for(ll i=0;i<n;i++){
        if(mask&(1<<i)){
            z += solve(mask^(1<<i));
        }
    }
    return dp[mask] = z;
}

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  ll t=1,i,j,m,x,y,z;
  //cin>>t;
  //fact[0]=1;
  //for(i=1;i<300003;i++)fact[i]=(fact[i-1]*i)%mod;
  while(t--)
  {
      cin>>n>>m;
      for(i=0;i<m;i++){
          cin>>x>>y>>z;
          v[x].pb(mp(y,z));
      }
      cout<<solve((1<<n)-1);
  }
}

#include<bits/stdc++.h>
using namespace std;
const int N=20;
int n,m,s[N],g[N][N];
long long dp[N][1<<N];
int main()
{
	cin>>n>>m;
	memset(g,0x3f,sizeof g);
	//前x个 最多有z个小于等于y
	//y-1 映射到二进制的0 ~ n-1
	for(int i=1,x,y,z; i<=m; ++i)
		cin>>x>>y>>z,--y,g[x][y]=min(g[x][y],z);
	dp[0][0]=1;

	for(int i=0; i<n; ++i)
		for(int s=0; s<1<<n; ++s)
		{
			long long v=dp[i][s];
			if(!v)
				continue;
			for(int j=0; j<n; ++j)
				if(!(s>>j&1))//如果第j个数没用过
				{
					int t=s|1<<j;//用过之后的状态
					bool ok=1;
					for(int k=0,s=0; k<n; ++k)
					{
						if((t>>k&1))
							++s;
						//
						if(s>g[i+1][k])
							ok=0;
					}
					if(ok)
						dp[i+1][t]+=v;
				}
		}
	printf("%lld\n",dp[n][(1<<n)-1]);
	return 0;
}


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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
#define TRACE(x) cerr << #x << " = " << x << endl

typedef long long ll;
typedef pair<int, int> point;

const int mod = 1e9 + 7;

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

const int MAXN = 105;

int n, k, m;

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

  cin >> n >> k >> m;
  int sum = 0;
  REP(i, n - 1){
    int x; cin >> x;
    sum += x;
  }
  if(sum / n >= m)
    cout << 0;
  else if((sum + k) / n < m)
    cout << -1;
  else
    cout << m * n - sum;
}

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000000
#define endl "\n"
#define PI 3.14159265358979323846264338327950288

using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;

int main(){
    FAST_IO ;
    int N , K , M ; cin >> N >> K >> M ;
    int sum = 0 ;
    for( int i = 0 ; i < N - 1 ; i++ ){
        int x ; cin >> x ;
        sum += x ;
    }
    int ans = N * M - sum ;
//    cout << ans << endl ;
    if( ans > K ){
        cout << "-1" << endl ;
        return 0 ;
    }
    cout << max( 0 ,ans ) << endl ;
    return 0 ;
  }