#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()
//#pragma GCC optimize ("-O3")
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

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

#pragma region head
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using vv = vector<vector<T>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rrepi(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bit(n) (1LL << (n))
template <class T>
inline bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const int INF = 1002003004;
const ll LINF = 1002003004005006007ll;
struct preprocess {
    preprocess() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} ____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main() {
    int h, w, n, m;
    cin >> h >> w >> n >> m;
    vv<ll> vec(h + 1, vector<ll>(w + 1));
    vector<pi> lights;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        lights.emplace_back(a, b);
    }
    vv<bool> block(h, vector<bool>(w));
    rep(i, m) {
        int c, d;
        cin >> c >> d;
        c--;
        d--;
        block[c][d] = true;
    }
    vv<int> right(h, vector<int>(w, w));
    vv<int> left(h, vector<int>(w, -1));
    vv<int> up(h, vector<int>(w, -1));
    vv<int> down(h, vector<int>(w, h));
    rep(i,h){
        int now = -1;
        rep(j,w){
            if(block[i][j]){
                now = j;
            } else {
                left[i][j] = now;
            }
        }
        now = w;
        rrep(j,w){
            if(block[i][j]){
                now = j;
            } else {
                right[i][j] = now;
            }
        }
    }
    rep(j,w){
        int now = -1;
        rep(i,h){
            if(block[i][j]){
                now = i;
            } else {
                up[i][j] = now;
            }
        }
        now = h;
        rrep(i,h){
            if(block[i][j]){
                now = i;
            } else {
                down[i][j] = now;
            }
        }
    }
    rep(i,n){
        int a, b;
        tie(a, b) = lights[i];
        int u = up[a][b];
        int d = down[a][b];
        int l = left[a][b];
        int r = right[a][b];
        vec[u+1][b]++;
        vec[u+1][b+1]--;
        vec[d][b]--;
        vec[d][b+1]++;
        vec[a][l+1]++;
        vec[a+1][l+1]--;
        vec[a][r]--;
        vec[a+1][r]++;
    }
    rep(i,h)rep(j,w){
        vec[i][j+1] += vec[i][j];
    }
    rep(j,w)rep(i,h){
        vec[i+1][j] += vec[i][j];
    }
    int ans = 0;
    rep(i,h)rep(j,w){
        if(vec[i][j]>0){
            ans++;
        }
    }
    cout << ans << '\n';

}


#include <iostream>
using namespace std;

int A, B;
double W;

int isin(double N) {
    if(N >= A and N <= B) {
        return true;
    } else {
        return false;
    }
}

int main() {
    cin >> A >> B >> W;
    int max = 0;
    int min = 0;
    for (int i = 1; i <= W * 1000; i++) {
        double pre = W * 1000 / i;

        if(isin(pre)) {
            min = i;
            break;
        }
    }

    for (int i = W * 1000; i > 0; i--) {
        double pre = W * 1000 / i;

        if(isin(pre)) {
            max = i;
            break;
        }
    }

    if (min == 0) {
        min = max;
    }
    if (max == 0) {
        max = min;
    }

    if (min == 0 and max == 0) {
        cout << "UNSATISFIABLE" << endl;
    } else {
        cout << min << " " << max << endl;
    }
}

#include<set>
#include<queue>
#include<cmath>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN (1<<18|5)
#define ENDL putchar('\n')
#define LL long long
#define DB double
#define lowbit(x) ((-x) & (x))
LL read() {
	LL f = 1,x = 0;char s = getchar();
	while(s < '0' || s > '9') {if(s=='-')f = -f;s = getchar();}
	while(s >= '0' && s <= '9') {x=x*10+(s-'0');s = getchar();}
	return f * x;
}
int n,m,i,j,s,o,k;
int main() {
	s = read();o = read();k = read()*1000;
	int l = (k+o-1)/o,r = k / s;
	if(l > r) printf("UNSATISFIABLE\n");
	else printf("%d %d\n",l,r);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

int main(){
int a[4];
    rep(i,4) cin >> a[i];
    int ans = 200;
    for(auto i : a){
    ans = min(ans,i);
    }
    cout << ans << endl;

}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int A1,A2,A3,A4;
    scanf("%d %d %d %d",&A1,&A2,&A3,&A4);
    int A[10]={A1,A2,A3,A4};
    int min=A[0];
    for(int i=0;i<4;i++){
        if(A[i]<min){
            min=A[i];
        }
    }
    printf("%d",min);

}


#include <bits/stdc++.h>
// #include <atcoder/all>
// #include <boost/multiprecision/cpp_int.hpp>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) a.begin(), a.end()
#define yn(p) cout << (p?"Yes":"No") << endl;
using namespace std;
// using namespace atcoder;
using ll = long long;
// using lll = boost::multiprecision::cpp_int;
using P = pair<int, int>;

void solve() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  ll ans = 0;
  rep(i, n) {
    ans += (b[i] * (b[i] + 1)) / 2;
    ans -= (a[i] * (a[i] - 1)) / 2;
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  solve();
  return 0;
}

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

const double pi = 3.141592653589793;
int inf = 1001001001;
ll INF = 1001001001001001001;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define rep(i, n) FOR(i, 0, n)
#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front
ll MOD = 1000000007;
using P = pair<ll, ll>;

double eps = 1e-12;

int main() {
   int N;cin >> N;
   vector<vector<ll> > color(3);
   rep(i, 2*N) {
       ll a;cin >> a;
       char c;cin >> c;
       if (c == 'R') color[0].pb(a);
       else if (c == 'G') color[1].pb(a);
       else if (c == 'B') color[2].pb(a);

   }
   ll rcnt, gcnt, bcnt;
   rcnt = (color[0].size())%2;
   gcnt = (color[1].size())%2;
   bcnt = (color[2].size())%2;
   if (rcnt == 0&&gcnt == 0&&bcnt == 0) {
       cout << 0 << endl;
       return 0;
   }
   vector<P> wa, wa2, wa3;
   ll koho = INF;
   ll koho2 = INF;
   ll koho3 = INF;

   if (rcnt == 0) {
       rep(i, color[1].size()) wa.pb(P(color[1][i], 1));
       rep(i, color[2].size()) wa.pb(P(color[2][i], 2));
       sort(all(wa));
       rep(i, wa.size()-1) {
           if (wa[i].second == wa[i+1].second) continue;
           else koho = min(koho, wa[i+1].first-wa[i].first);
       }
       rep(i, color[0].size()) wa2.pb(P(color[0][i], 0));
       rep(i, color[1].size()) wa2.pb(P(color[1][i], 1));
       sort(all(wa2));
       rep(i, wa2.size()-1) {
           if (wa2[i].second == wa2[i+1].second) continue;
           else koho2 = min(koho2, wa2[i+1].first-wa2[i].first);
       }
       rep(i, color[0].size()) wa3.pb(P(color[0][i], 0));
       rep(i, color[2].size()) wa3.pb(P(color[2][i], 2));
       sort(all(wa3));
       rep(i, wa3.size()-1) {
           if (wa3[i].second == wa3[i+1].second) continue;
           else koho3 = min(koho3, wa3[i+1].first-wa3[i].first);
       }
       ll ans = min(koho, koho2+koho3);
       cout << ans << endl;
       return 0;
    }
    else if (gcnt == 0) {
       rep(i, color[0].size()) wa.pb(P(color[0][i], 0));
       rep(i, color[2].size()) wa.pb(P(color[2][i], 2));
       sort(all(wa));
       rep(i, wa.size()-1) {
           if (wa[i].second == wa[i+1].second) continue;
           else koho = min(koho, wa[i+1].first-wa[i].first);
       }
       rep(i, color[0].size()) wa2.pb(P(color[0][i], 0));
       rep(i, color[1].size()) wa2.pb(P(color[1][i], 1));
       sort(all(wa2));
       rep(i, wa2.size()-1) {
           if (wa2[i].second == wa2[i+1].second) continue;
           else koho2 = min(koho2, wa2[i+1].first-wa2[i].first);
       }
       rep(i, color[1].size()) wa3.pb(P(color[1][i], 1));
       rep(i, color[2].size()) wa3.pb(P(color[2][i], 2));
       sort(all(wa3));
       rep(i, wa3.size()-1) {
           if (wa3[i].second == wa3[i+1].second) continue;
           else koho3 = min(koho3, wa3[i+1].first-wa3[i].first);
       }
       ll ans = min(koho, koho2+koho3);
       cout << ans << endl;
       return 0;
    }
    if (bcnt == 0) {
       rep(i, color[0].size()) wa.pb(P(color[0][i], 0));
       rep(i, color[1].size()) wa.pb(P(color[1][i], 1));
       sort(all(wa));
       rep(i, wa.size()-1) {
           if (wa[i].second == wa[i+1].second) continue;
           else koho = min(koho, wa[i+1].first-wa[i].first);
       }
       rep(i, color[0].size()) wa2.pb(P(color[0][i], 0));
       rep(i, color[2].size()) wa2.pb(P(color[2][i], 2));
       sort(all(wa2));
       rep(i, wa2.size()-1) {
           if (wa2[i].second == wa2[i+1].second) continue;
           else koho2 = min(koho2, wa2[i+1].first-wa2[i].first);
       }
       rep(i, color[1].size()) wa3.pb(P(color[1][i], 1));
       rep(i, color[2].size()) wa3.pb(P(color[2][i], 2));
       sort(all(wa3));
       rep(i, wa3.size()-1) {
           if (wa3[i].second == wa3[i+1].second) continue;
           else koho3 = min(koho3, wa3[i+1].first-wa3[i].first);
       }
       ll ans = min(koho, koho2+koho3);
       cout << ans << endl;
       return 0;
    }
    return 0;
}


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

int main(void){
    int a[4], sum = 0;
    bool flag = false;
    for(int i = 0; i < 4; i++) cin >> a[i];
    for(int i : a) sum += i;
    for(int i = 0; i < (1<<4); i++){
        int n = 0, m = sum;
        for(int j = 0; j < 4; j++){
            if((i>>j)%2==1){
                n += a[j];
                m -= a[j];
            }
        }
        if(n == m){
            flag = true;
            break;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

#include <bits/stdc++.h>
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define REPS(i, ss, nn ) for(int i = ss ; i < (int) nn; i++)
#define REV(i, ss, nn ) for(int i = ss ; i >= nn; i--)
#define deb(x) std::cout << #x << " " << x << endl;
#define debl(x) std::cout << #x << " " << x << " ";
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
namespace std{
    template<class Fun>
    class y_combinator_result{
        Fun fun_;
        public:
            template<class T>
            explicit y_combinator_result(T &&fun) : fun_(std::forward<T>(fun)){}
            template<class ...Args>
            decltype(auto) operator()(Args&&...args){
                return fun_(std::ref(*this), std::forward<Args>(args)...);
            }
    };
    template<class Fun>
    decltype(auto) y_combinator(Fun && fun){
        return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
    }
};
template<typename T>
bool u_max(T& a, T b){
    if( a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
bool u_min(T& a, T b){
    if( a > b){
        a = b;
        return true;
    }
    return false;
}
// struct edge{
//     int to, from;
//     ll cost;
//     edge(){ edge(0,0);}
//     edge(int to_, ll cost_){ edge(0, -1, 0);}
//     edge(int to_, int from_, ll cost_) : to(to_), from(from_), cost(cost_){}
// };

template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}

void solve(){
    ll n, m , T;
    read(n, m, T);
    ll cur = n;
    ll last = 0;
    REP(i, m){
        ll a, b;
        read(a, b);
        cur -=  (a - last);
        // debl(i) deb(cur)
        if(cur <= 0){
            // deb(i)
            cout << "No\n";
            return;
        }else{
            cur += (b - a);
            // deb(cur)
            if( cur >= n) cur = n;
            last = b;
        }
    }
    cur -= (T - last);
    if( cur <= 0){
        cout << "No\n";
    }else{
        cout << "Yes\n";
    }
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/
    solve();
    return 0;
}


#include "bits/stdc++.h"

using namespace std;
using ll = long long;

bool pTakahashi(int i, int j) {
    return (i + j) % 2 == 1;
}
void Main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W, 0));
    for (int i = 0; i < H; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < W; ++j) {
            A[i][j] = s[j] == '+' ? 1 : -1;
        }
    }

    if (H == 1 && W == 1) {
        cout << "Draw" << endl;
        return;
    }

    vector<vector<pair<int, int>>> p(H, vector<pair<int, int>>(W, make_pair(0, 0)));
    if (pTakahashi(H - 1, W - 1)) {
        p[H - 1][W - 1].first = A[H - 1][W - 1];
        p[H - 1][W - 1].second = 0;
    }
    else {
        p[H - 1][W - 1].first = 0;
        p[H - 1][W - 1].second = A[H - 1][W - 1];
    }
    for (int i = H - 1; i >= 0; --i) {
        for (int j = W - 1; j >= 0; --j) {
            if (i == H - 1 && j == W - 1) {
                continue;
            }
            pair<int, int>& T_A = p[i][j];
            if (pTakahashi(i, j)) {
                if (i > 0 || j > 0) {
                    T_A.first = A[i][j];
                }
                if (i == H - 1) {
                    T_A.second += p[i][j + 1].second;
                    T_A.first += p[i][j + 1].first;
                }
                else if (j == W - 1) {
                    T_A.second += p[i + 1][j].second;
                    T_A.first += p[i + 1][j].first;
                }
                else {
                    if (p[i + 1][j].second - p[i + 1][j].first > p[i][j + 1].second - p[i][j + 1].first) {
                        T_A.second += p[i + 1][j].second;
                        T_A.first += p[i + 1][j].first;
                    }
                    else {
                        T_A.second += p[i][j + 1].second;
                        T_A.first += p[i][j + 1].first;
                    }
                }
            }
            else {
                if (i > 0 || j > 0) {
                    T_A.second = A[i][j];
                }
                if (i == H - 1) {
                    T_A.first += p[i][j + 1].first;
                    T_A.second += p[i][j + 1].second;
                }
                else if (j == W - 1) {
                    T_A.first += p[i + 1][j].first;
                    T_A.second += p[i + 1][j].second;
                }
                else {
                    if (p[i + 1][j].first - p[i + 1][j].second > p[i][j + 1].first - p[i][j + 1].second) {
                        T_A.first += p[i + 1][j].first;
                        T_A.second += p[i + 1][j].second;
                    }
                    else {
                        T_A.first += p[i][j + 1].first;
                        T_A.second += p[i][j + 1].second;
                    }
                }
            }
        }
    }
    if (p[0][0].first > p[0][0].second) {
        cout << "Takahashi" << endl;
    }
    else if (p[0][0].first < p[0][0].second) {
        cout << "Aoki" << endl;
    }
    else {
        cout << "Draw" << endl;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 60);
int main(){
  int n, m;
  cin >> n >> m;
  vector<int> h(n), w(m);
  rep(i,n) cin >> h[i];
  rep(i,m) cin >> w[i];

  sort(h.begin(), h.end());
  sort(w.begin(), w.end());

  vector<int> v(n); //各生徒に対する先生の最適解
  for (int i = 0; i < n; i++) {
    int itr = lower_bound(w.begin(), w.end(), h[i]) - w.begin();
    if (itr == m) itr--;
    v[i] = abs(w[itr] - h[i]);
    itr--;
    if (itr >= 0) v[i] = min(v[i], abs(w[itr] - h[i]));
  }

  vector<ll> cum1(n / 2 + 2, 0), cum2(n / 2 + 2, 0);
  for (int i = 0; i < n; i += 2) {
    int j = i / 2;
    cum1[j + 1] = cum1[j] + abs(h[i] - h[i + 1]);
  }
  for (int i = n - 2; i >= 0; i -= 2) {
    int j = (i + 1) / 2;
    cum2[j] = cum2[j + 1] + abs(h[i] - h[i + 1]);
  }

  ll res = INF;

  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      int l = i / 2, r = (i + 2) / 2;
      res = min(res, cum1[l] + cum2[r] + v[i]);
    } else {
      int l = i / 2, r = (i + 3) / 2;
      res = min(res, cum1[l] + cum2[r] + v[i] + abs(h[i - 1] - h[i + 1]));
    }
  }

  cout << res << endl;
  return 0;
}


#include<bits/stdc++.h>
#define pb emplace_back
#define AI(i) begin(i), end(i)
using namespace std;
using ll = long long;
template<class T>
bool chmax(T &val, T nv) { return val < nv ? (val = nv, true) : false; }
template<class T>
bool chmin(T &val, T nv) { return nv < val ? (val = nv, true) : false; }
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() {cerr << endl;}
template<class T1, class ...T2>
void kout (T1 v, T2 ...e) { cerr << v << ' ', kout(e...); }
template<class T>
void debug(T L, T R) { while (L != R) cerr << *L << " \n"[next(L)==R], ++L; }
#else
#define DE(...) 0
#define debug(...) 0
#endif
// What I should check
// 1. overflow
// 2. corner cases
// Enjoy the problem instead of hurrying to AC
// Good luck !
const int MAX_N = 300010;

#define int ll
int32_t main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n, c;
	cin >> n >> c;
	map<int,ll> cnt;
	for (int a, b, c, i = 0;i < n;++i) {
		cin >> a >> b >> c;
		cnt[a] += c;
		cnt[b+1] -= c;
	}
	ll sum = 0;
	for (auto &[a, b] : cnt)
		b = sum += b;

	ll ret = 0;

	for (auto [a, b] : cnt) {
		if (b == 0) continue;
		int nxt = cnt.upper_bound(a)->first;

		ret += min(b, c) * (nxt - a);
	}
	cout << ret << '\n';

}

#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define sc3(a,b,c)  cin>>a>>b>>c
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()
#define re          return
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;

ll A[MAXN+5],B[MAXN+5],C[MAXN+5];
class cmppq{
	public: bool operator()(pll a,pll b){
		re a.fi>b.fi;
	}
};
bool cmp(ll a,ll b){
	return A[a]>A[b];
}
ll Solves(){

	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE

	sc2(n,m);
	vi vec;
	vi v2;
	f1(i,n){
		v2.pb(i);
		cin>>A[i];
		cin>>B[i];
		cin>>C[i];
		vec.pb(A[i]);
		vec.pb(B[i]);
		if(A[i]-1>0)vec.pb(A[i]-1);
	}
	sov(vec); uni(vec);
	sort(all(v2),cmp);
	priority_queue<pll,vector<pll>,cmppq> pq;
	ll last=1;
	fuv(i,vec){
		x=vec[i];
		while(sz(v2) and A[v2.back()]==x){
			sum+=C[v2.back()];
			pq.push(mp(B[v2.back()],C[v2.back()]));
			v2.pob;
		}
	//	debug(x); debug(last); debug(min(sum,m));
		ans+=(x-last+1)*min(sum,m);
		while(sz(pq) and pq.top().fi==x)sum-=pq.top().se,pq.pop();
		last=x+1;
	}
	pr(ans);

	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
}


#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 200010
using namespace std;
ll n,a[N],b[N],l,r,ans=0,bit[N],nxt[N],plc[N],nm[N];
bool vis[N];
vector<pair<ll,ll> > pa,pb,rd;
void upd(ll x,ll v)
{
	x++;
	while(x<N)
	{
		bit[x]+=v;
		x+=(x&(-x));
	}
	return;
}
void update(ll x)
{
	upd(0,1);
	upd(x,-1);
	return;
}
ll query(ll x)
{
	x++;
	ll ret=0;
	while(x>0)
	{
		ret+=bit[x];
		x-=(x&(-x));
	}
	return ret;
}
int main(){
	ll i;
	scanf("%lld",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		a[i]+=i;
	}
	for(i=0;i<n;i++)
	{
		scanf("%lld",&b[i]);
		b[i]+=i;
	}
	for(i=0;i<n;i++)
	{
		pa.push_back(make_pair(a[i],i));
		pb.push_back(make_pair(b[i],i));
	}
	sort(pa.begin(),pa.end());
	sort(pb.begin(),pb.end());
	for(i=0;i<pa.size();i++)
	{
		if(pa[i].F!=pb[i].F)
		{
			puts("-1");
			return 0;
		}
		nm[pa[i].S]=pa[i].S;
		plc[pa[i].S]=pa[i].S;
		rd.push_back(make_pair(pb[i].S,pa[i].S));
	}
	sort(rd.begin(),rd.end());
	for(i=0;i<rd.size();i++)
	{
		ans+=abs((rd[i].S+query(rd[i].S))-rd[i].F);
		update(rd[i].S);
	}
	printf("%lld\n",ans);
	return 0;
}

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

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

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

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

	int N = getint();
	rep1(i, N) A[i] = ll(i) << 32 | i + getint();
	rep1(i, N) B[i] = ll(i) << 32 | i + getint();

	pakuri_sort(N, A + 1);
	pakuri_sort(N, B + 1);

	rep1(i, N) {
		if ((A[i] ^ B[i]) & (1ll << 32) - 1) {
			co(-1);
			return 0;
		}
		tmp[A[i] >> 32] = B[i] >> 32;
	}
	ll kotae = 0;
	rep1(i, N) {
		kotae += query(tmp[i]);
		add(tmp[i]);
	}
	co(kotae);

	Would you please return 0;
}


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

int main(void) {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());

  bool is_ok = true;
  for (int i = 1; i <= n; i++) {
    if (i != v[i-1]) {
      is_ok = false;
      break;
    }
  }
  cout << (is_ok ? "Yes" : "No") << endl;
}

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

const int64_t MOD = 1e9 + 7;
const int64_t MOD2 = 998244353;
const int INF = 2e9;
const long long inf = 1LL<<62;
long long gcd(long long x, long long y) {
  if (x==0||y==0) {
    return x+y;
  }
  if (x%y == 0) {
    return y;
  } else {
    return gcd(y, x%y);
  }
}

int main() {
  int n;
  cin >> n;
  vector<long long> x(n);
  for (int i=0; i<n; i++) {
    cin >> x[i];
  }
  vector<int> ep;
  vector<int> pr(51, 1);
  pr[0] = pr[1] = 0;
  for (int i=2; i<=50; i++) {
    if (pr[i]) {
      for (int x = i*2; x<=50; x += i) {
        pr[x] = 0;
      }
    }
  }
  for (int i=0; i<51; i++) {
    if (pr[i]) ep.push_back(i);
  }
  long long res = inf;
  for (long long bit = 0; bit<(1<<15); bit++) {
    long long ans = 1;
    for (int i=0; i<15; i++) {
      if ((1<<i) & bit) ans *= ep[i];
    }
    int flag = 1;
    for (int i=0; i<n; i++) {
      if (gcd(ans, x[i]) == 1) {
        flag = 0;
        break;
      }
    }
    if (flag) {
      res = min(ans, res);
    }
  }
  cout << res << endl;
}


#include<bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for(int i = 0; i < (n); ++i)
//#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(fm, ...) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout << "DEBUG PRINT ";std::printf(fm, __VA_ARGS__);}while(0)
#define DEBUG_VAL(a, b) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout <<"DEBUG VAL " << a << ":" << b << endl;}while(0)
#else
#define DEBUG_PRINT(...)do{}while(0);
#define DEBUG_VAL(a, b)do{}while(0);
#endif

using namespace std;
//using namespace atcoder;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;
ll gcd(ll x,ll y){
    if(x<y) swap(x,y);
    ll r;
    while(y>0){
        r=x%y;
        x=y;
        y=r;
    }
    return x;
}
int main(){
    int n;
    cin >> n;
    vl A(n);
    rep(i, n){
      cin >> A[i];
    }
    ll ans = gcd(A[0], A[1]);
    for(int i = 2; i < n;i++){
        ans = gcd(ans, A[i]);
    }
    cout << ans << endl;
}

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

int gcd(int a, int b) {return b?gcd(b, a%b):a;}
int main() {
int n; cin >> n;
  vector<int> a(n);
  for (int i=0;i<n;i++) cin >> a[i];
  int ans = a[0];
  for (int i=0;i<n;i++) ans = gcd(ans,a[i]);
  cout << ans << endl;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define REP(i,j,n) for(int i=(j);i<(n);++i)
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using vll=vector<ll>;
using GrafPair=vector<vector<P>>;
using Graf=vector<vll>;
#define MAX 1000000007
#define DOUBLE fixed << setprecision(15)

int main()
{
    ll n;
    cin >> n;
    ll num=sqrt(n+1);
    ll sum=num*(num+1)/2;
    num++;
    while(sum<=n+1){
        sum+=num;
        num++;
    }
    num--;
    if(n==2){
        cout << 1 << endl;
    }else{
        cout << n+2-num << endl;
    }
}

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

int main() {
    long long n;
    cin>>n;

    if (0==n%3) {
        cout<<"0\n";
        return 0;
    } else if (n<=2) {
        cout<<"-1\n";
        return 0;
    }

    int cnt[3]={};
    int sum=0;
    int tot=0;
    while (n) {
        int p=n%10;
        n/=10;
        sum+=p;
        tot++;
        cnt[p%3]++;
    }

    if (1==sum%3) {
        if (tot>1 && cnt[1]>=1) {
            cout<<"1\n";
        } else if (tot>2 && cnt[2]>=2) {
            cout<<"2\n";
        } else {
            cout<<"-1\n";
        }
    } else if (2==sum%3) {
        if (tot>1 && cnt[2]>=1) {
            cout<<"1\n";
        } else if (tot>2 && cnt[1]>=2) {
            cout<<"2\n";
        } else {
            cout<<"-1\n";
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

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

    vector<ll> A(n);
    vector<ll> S(n);

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

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

    S[0] = A[0];
    for (int i = 1; i < n; i++) {
        S[i] = A[i] + S[i-1];
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += (S[n-1] - S[i]) - A[i] * (n - i - 1);
    }

    cout << ans << endl;

}

int main() {

    solve();

    return 0;
}

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

#define ll long long
#define d long double

#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%Lf",&n)
#define pri(n) printf("%d ",(int)n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%Lf ",n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define dprin(n) printf("%Lf\n",n)

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define all(x) x.begin(),x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define bitcount(n) __builtin_popcount(n)
#define tc   int tt; scf(tt); while(tt--)
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264

const ll M =1e9+7;
const int N = 1e6+7;

int main()
{
    ll n;
    lscf(n);

    ll a[n+1];

    rep(i,1,n+1)
    lscf(a[i]);

    sort(a+1,a+n+1);

    ll sum=a[1];

    ll ans=0;

    rep(i,2,n+1)
    {
        ans+=((i-1)*a[i]-sum);
        sum+=a[i];
    }

    lpri(ans);
return 0;
}


#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<ll,ll>;
#define pb push_back

int main(){
  vvl tate(29, vl(30,5000));
  vvl yoko(30, vl(29,5000));
  rep(_,1000){
    int a, b, ato, bto;
    cin >> a >> b >> ato >> bto;
    int ma = a;
    int mb = b;
    string ans;
    while(a != ato || b != bto){
      if (a == ato){
        if (b < bto){
          b++;
          ans.pb('R'); continue; // continueの貼り付けを忘れると
        } else { // バグる ato btoが連続するからです
          b--; // 全てに張り付けておく必要があるので
          ans.pb('L'); continue;
        }
      }
      if (b == bto){
        if (a < ato){
          a++;
          ans.pb('D'); continue;
        } else {
          a--;
          ans.pb('U'); continue;
        }
      }
      if (a < ato && b < bto){
        // 下 右
        if (tate[a][b] < yoko[a][b]){
          a++; // 縦移動優先
          ans.pb('D'); continue;
        } else {
          b++;
          ans.pb('R'); continue;
        }
      }
      if (a < ato && b > bto){
        // 下 左
        if (tate[a][b] < yoko[a][b-1]){
          a++; // 縦移動優先
          ans.pb('D'); continue;
        } else {
          b--;
          ans.pb('L'); continue;
        }
      }
      if (a > ato && b < bto){
        // 上 右
        if (tate[a-1][b] < yoko[a][b]){
          a--; // 縦移動優先
          ans.pb('U'); continue;
        } else {
          b++;
          ans.pb('R'); continue;
        }
      }
      if (a > ato && b > bto){
        // 上 左 ここから続き
        if (tate[a-1][b] < yoko[a][b-1]){
          a--; // 縦移動優先
          ans.pb('U'); continue;
        } else {
          b--;
          ans.pb('L'); continue;
        }
      }
    }
    cout << ans << endl; // flushを炊く
    ll score;
    cin >> score;
    score /= ans.size(); // 通った数で割り一歩当たりのコスト計算
    // cout << score << endl; // debug
    ll change = (score - 5000) / (ll)ans.size();
    // cout << change << endl; // debug
    rep(i,ans.size()){
      if (ans[i] == 'U'){
        tate[ma-1][mb] += change;
        if (score < 3500) tate[ma-1][mb] += -100000;
        if (score > 6500) tate[ma-1][mb] += 100000;
        ma--;
      }
      if (ans[i] == 'D'){
        tate[ma][mb] += change;
        if (score < 3500) tate[ma][mb] += -100000;
        if (score > 6500) tate[ma][mb] += 100000;
        ma++;
      }
      if (ans[i] == 'L'){
        yoko[ma][mb-1] += change;
        if (score < 3500) yoko[ma][mb-1] += -100000;
        if (score > 6500) yoko[ma][mb-1] += 100000;
        mb--;
      }
      if (ans[i] == 'R'){
        yoko[ma][mb] += change;
        if (score < 3500) yoko[ma][mb] += -100000;
        if (score > 6500) yoko[ma][mb] += 100000;
        mb++;
      }
    }
    // for(auto x : tate){ // コスト計算debug
    //   for(auto y : x){
    //     cout << y << " ";
    //   } cout << endl;
    // }
    // for(auto x : yoko){
    //   for(auto y : x){
    //     cout << y << " ";
    //   } cout << endl;
    // }
  }
}

#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <random>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
#include <random>
#include <ctime>
#include <cassert>
#include <chrono>
#include <fstream>
using namespace std;
using LL = long long;
using LD = long double;

const LD PI = acos(-1);

int main() {
	int N;
	cin >> N;
	LD x, y, X, Y;
	cin >> x >> y >> X >> Y;
	LD phi = atan2(Y - y, X - x);
	LD theta = 2 * PI / N;
	LD hen = phi - PI / 2 + theta / 2;
	LD radius = sqrt((X - x) * (X - x) + (Y - y) * (Y - y)) / 2;
	LD length = 2 * radius * sin(theta / 2);
	LD vx = length * cos(hen);
	LD vy = length * sin(hen);
	LD ax = x + vx;
	LD ay = y + vy;
	cout.precision(20);
	cout << fixed;
	cout << ax << " "<< ay << endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cstdio>
using namespace std;
#define ll long long
const ll N = 2e5 + 5;
ll a[N];
ll b[N];
ll t[N];
ll gcd(ll a, ll b)
{
	return b == 0 ? a : gcd(b, a % b);
}
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
signed main()
{
	int a, b, w;
	cin >> a >> b >> w;
	w *= 1000;
	if (w % a > b || w%a<=(b-a)*(w/a))
	{
		printf("%d %d\n", w%b==0?(w / b):(w/b+1), w/a);
	}
	else
		puts("UNSATISFIABLE");
}

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

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

int main(void){

    int a,b,w;
    cin >> a >> b >> w;

    //最小値
    int min,max;

    //キログラムをグラムに変換
    w = w*1000;
    bool flag1=false,flag2=false;

    //iは個数
    for(int i=1;i<=1000*1000;i++){
        if((double)w/(double)i>=(double)a&&(double)w/i<=(double)b){
            flag1 = true;
            min = i;
            break;
        }
    }

    //最大値
    for(int i=1000*1000;i>0;i--){
        if((double)w/(double)i>=(double)a&&(double)w/(double)i<=(double)b){
            flag2 = true;
            max = i;
            break;
        }
    }

    if(flag1&flag2){
        cout << min << " "<< max << endl;
    }
    else{
        cout << "UNSATISFIABLE" << endl;
    }

    return 0;
}


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

/** これを翻訳している間、あなたはあなたの人生のいくつかの貴重な瞬間を無駄にしました **/
#include<bits/stdc++.h>
using namespace std;

#ifdef Zoro
  #include "headers/debug.h"
#else
  #define debug(x...)
  #define deb(x...)
#endif

#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--)
#define int long long
#define pb push_back
#define ff first
#define ss second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define memo(x,y) memset((x),(y),sizeof((x)))
#define line cout<<"[At "<<__LINE__<<"]"<<endl;

using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<pair<int, int>>;

constexpr int mod = 1e9 + 7, N = 2e5 + 5;
constexpr long long inf = 1e18;
constexpr long double eps = 1e-6;

void Onigiri() {
  int a[3];
  rep(i,0,3)cin>>a[i];

  sort(a,a+3);
  if(a[0] == a[1] ) cout<<a[2];
  else if(a[1]==a[2]) cout<<a[0];
  else cout<<0;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //cout.precision(10);cout<<fixed;
#ifdef Zoro
  freopen("/home/pritish/Competitive/io/in", "r", stdin);
  freopen("/home/pritish/Competitive/io/out", "w", stdout);
#endif

  int t = 1;
  //cin >> t;

  while(t--) {
    Onigiri();
    cout << "\n";
  }

  cerr << "\n" << (float)clock() / CLOCKS_PER_SEC * 1000 << " ms" << endl;
  return 0;
}


#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000000000000000;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

signed main(){
  string S;
  cin >> S;

  string T = "";
  for( int i = 0; i < S.size(); i++ ){
    if( S[i] == '.' ) break;
    T += S[i];
  }
  cout << T << endl;
}

// Problem: B - Round Down
// Contest: AtCoder - AtCoder Beginner Contest 196
// URL: https://atcoder.jp/contests/abc196/tasks/abc196_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const int MOD = 1e9 + 7;
//const int ULTRA = 1e14;
const int PROMAX = 1e6 + 5;
const int PRO = 1e5 + 5;

#define ll long long
#define int ll
#define all(x) x.begin(), x.end()
#define lla(x) x.rbegin(), x.rend()
#define pb push_back
#define ThinkTwice ios_base::sync_with_stdio(false); cin.tie(NULL);
int    dx[] = {-1,  0,  1,  0, -1, -1,  1,  1};
int    dy[] = { 0,  1,  0, -1, -1,  1,  1, -1};
char  dir[] = {'U','R','D','L'};
inline int powmod(int a, int b, int mod) {int res=1; while(b>0) {if(b&1) res=(res*a)%mod; a=(a*a)%mod; b>>=1; } return res;}
inline int power(int a, int b) {int res=1; while(b>0) {if(b&1) res*=a; a*=a; b>>=1;} return res; }
//__________________________________________________________________

void solve() {
    string a; cin>>a;
    for(auto x: a) {
    	if(x == '.') return ;
    	cout<<x;
    }
    cout<<endl;
}

signed main() {
	ThinkTwice
	int t;

	t = 1;
	// cin>>t;

	for(int i = 1; i<=t; i++) {
		// cout<<"Case #"<<i<<": ";
		solve();
	}
}

//__________________________________________________________________
/*
Sample Input:

Sample Output:

*/


#include<bits/stdc++.h>
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
#define ll long long
#define ull unsigned long long
#define pll pair<ll,ll>
#define y1 orzkcz
using namespace std;
int n,bi[500];
int main(){
	scanf("%d",&n);
	For(i,0,(1<<n)-1) bi[i]=bi[i/2]+(i&1);
	printf("%d\n",(1<<n)-1);
	For(i,1,(1<<n)-1){
		For(j,0,(1<<n)-1) putchar((bi[i&j]&1)?'A':'B');
		puts("");
	}
}

#include<bits/stdc++.h>
using namespace std;
vector<int>a,b;
int main(){
	int n,p,q,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		char c=getchar();
		while(c<'0')c=getchar();
		if(c=='0')a.push_back(i);
	}
	for(int i=1;i<=n;++i){
		char c=getchar();
		while(c<'0')c=getchar();
		if(c=='0')b.push_back(i);
	}
	if(a.size()==b.size()){
		for(int i=0;i<a.size();++i){
			if(a[i]!=b[i])++ans;
		}
		cout<<ans;
	}
	else cout<<-1;
}


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

const int N = 30;
const int Q = 1000;
const int di[4] = {-1, 1, 0, 0};
const int dj[4] = {0, 0, -1, 1};
const int REV[4] = {1, 0, 3, 2};
const string DIR = "UDLR";

struct Edge {
    int i, j, k;
};

struct Path {
    int cost;
    bool used[30][30][2];
    vector<Edge> edge;

    Path() : cost(0), edge(0) {
        memset(used, 0, sizeof(used));
    }

    void add_edge(const Edge& e) {
        assert(not used[e.i][e.j][e.k] and "Invalid Edge");
        used[e.i][e.j][e.k] = true;
        edge.push_back(e);
    }
};

class EstimatedGrid {
private:
    int weight[30][30][2];
    vector<Path> sample_path;

public:
    EstimatedGrid() {
        for (int i=0; i<N; ++i) {
            for (int j=0; j<N; ++j) {
                weight[i][j][0] = 5000;
                weight[i][j][1] = 5000;
            }
        }
    }

    Edge get_edge(int i, int j, int d) {
        if (DIR[d] == 'U') return Edge{i - 1, j, 0};
        if (DIR[d] == 'D') return Edge{i, j, 0};
        if (DIR[d] == 'L') return Edge{i, j - 1, 1};
        if (DIR[d] == 'R') return Edge{i, j, 1};
        assert(false and "Invalid Direction");
    }

    vector<int> estimated_shortest_path(int si, int sj, int ti, int tj) {
        struct State {
            int i, j, c;
            bool operator > (const State& o) const { return c > o.c; }
        };

        vector<vector<int>> cost(N, vector<int>(N, 1L << 30));
        vector<vector<int>> memo(N, vector<int>(N, -1));

        priority_queue<State, vector<State>, greater<State>> que;
        que.push(State{si, sj, 0});
        cost[si][sj] = 0;

        while (!que.empty()) {
            State sta = que.top(); que.pop();

            if (cost[sta.i][sta.j] < sta.c) continue;
            if (sta.i == ti and sta.j == tj) break;

            for (int d=0; d<4; ++d) {
                int ni = sta.i + di[d];
                int nj = sta.j + dj[d];

                if (ni < 0 or ni >= N) continue;
                if (nj < 0 or nj >= N) continue;

                Edge e = get_edge(sta.i, sta.j, d);
                int nc = sta.c + weight[e.i][e.j][e.k];
                if (cost[ni][nj] > nc) {
                    que.push(State{ni, nj, nc});
                    cost[ni][nj] = nc;
                    memo[ni][nj] = d;
                }
            }
        }

        vector<int> P;
        int i = ti, j = tj;
        while (memo[i][j] != -1) {
            P.push_back(memo[i][j]);
            int d = REV[memo[i][j]];
            i += di[d];
            j += dj[d];
        }
        reverse(P.begin(), P.end());
        return P;
    }

    string path_to_string(const vector<int>& P) {
        string ret = "";
        for (int d : P) ret += DIR[d];
        return ret;
    }

    void add_path(
        int si, int sj, int ti, int tj,
        const vector<int>& P, int cost
    ) {
        Path path;
        path.cost = cost;
        int i = si, j = sj;
        for (int d : P) {
            Edge e = get_edge(i, j, d);
            path.add_edge(e);
            i += di[d];
            j += dj[d];
        }
        assert(i == ti and j == tj);
        sample_path.push_back(path);
    }
};

int main() {
    EstimatedGrid G;
    for (int q=0; q<Q; ++q) {
        int si, sj, ti, tj;
        cin >> si >> sj >> ti >> tj;
        vector<int> P = G.estimated_shortest_path(si, sj, ti, tj);
        cout << G.path_to_string(P) << endl;
        int cost;
        cin >> cost;
        G.add_path(si, sj, ti, tj, P, cost);
    }
}

// This code wrote by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
#define int long long
#define ALL(x) (x).begin(),(x).end()
#define mem(x,y) memset(x,y,sizeof x)
#define sz(x) (int)(x).size()
#define ln std::puts("")
#define lsp std::putchar(32)
#define pb push_back
#define MP std::make_pair
#ifdef _LOCAL_
#define dbg(x) std::cerr<<__func__<<"\tLine:"<<__LINE__<<' '<<#x<<": "<<x<<"\n"
#define dprintf(x...) std::fprintf(stderr,x)
#else
#define dbg(x) 42
#define dprintf(x...) 42
#endif
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,b,a) for(int i=(b);i>=(a);--i)
template <class t> inline void read(t &s){s=0;
reg int f=1;reg char c=getchar();while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c))s=(s<<3)+(s<<1)+(c^48),c=getchar();s*=f;return;}
template<class t,class ...A> inline void read(t &x,A &...a){read(x);read(a...);}
template <class t> inline void write(t x){if(x<0)putchar('-'),x=-x;
int buf[21],top=0;while(x)buf[++top]=x%10,x/=10;if(!top)buf[++top]=0;
while(top)putchar(buf[top--]^'0');return;}
inline void setIn(std::string s){freopen(s.c_str(),"r",stdin);return;}
inline void setOut(std::string s){freopen(s.c_str(),"w",stdout);return;}
inline void setIO(std::string s=""){setIn(s+".in");setOut(s+".out");return;}
template <class t>inline bool ckmin(t&x,t y){if(x>y){x=y;return 1;}return 0;}
template <class t>inline bool ckmax(t&x,t y){if(x<y){x=y;return 1;}return 0;}
inline int lowbit(int x){return x&(-x);}
const int MaxN=3050;

const int Mod=1e9+7;
const int Mod_Is_Prime=1;

namespace MINT
{
	inline long long exgcd(long long a,long long b,long long &x,long long &y)
	{long long c;return (!b)?(x=1,y=0,a):(c=exgcd(b,a%b,y,x),y-=a/b*x,c);}
}
struct mint
{
	int x;
	mint(){x=0;}
	template <class T> mint(T v){x=(v%Mod+Mod)%Mod;}
	inline int val() const{return x;}
	inline mint operator ++ (){return (++x)>=Mod&&(x-=Mod);}
	inline mint operator -- (){return (--x)<0&&(x+=Mod);}
	inline mint operator + (const mint &nt) const
	{return (x+nt.x)>=Mod?(x+nt.x-Mod):(x+nt.x);}
	inline mint operator - (const mint &nt) const
	{return x<nt.x?(x+Mod-nt.x):(x-nt.x);}
	inline mint operator * (const mint &nt) const{return 1LL*x*nt.x%Mod;}
	inline mint& operator += (const mint &nt){return *this=*this+nt;}
	inline mint& operator -= (const mint &nt){return *this=*this-nt;}
	inline mint& operator *= (const mint &nt){return *this=*this*nt;}
	inline mint fpow(long long b) const
	{
		assert(b>=0);
		reg mint a=*this,res=1;
		for(;b;b>>=1,a*=a)if(b&1)res*=a;
		return res;
	}
	inline mint inv() const
	{
		if(Mod_Is_Prime)return fpow(Mod-2);
		long long X,Y,G=MINT::exgcd(x,Mod,X,Y);
		assert(G==1);
		return (X%Mod+Mod)%Mod;
	}
	inline mint operator / (const mint &nt) const{return nt.inv()*x;}
	inline mint operator /= (const mint &nt){return *this=*this/nt;}
	inline mint operator == (const mint &nt)const{return x==nt.x;}
	inline mint operator != (const mint &nt)const{return x!=nt.x;}
};

int a[MaxN],s[MaxN],n;
mint f[MaxN][MaxN],w[MaxN][MaxN];
signed main(void)
{
	read(n);
	for(int i=1;i<=n;++i)read(a[i]),s[i]=s[i-1]+a[i];
	f[0][0]=1,w[1][0]=1;
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=i;++j)f[i][j]+=w[j][s[i]%j];
		if(i<n)for(int j=0;j<=i;++j)w[j+1][s[i]%(j+1)]+=f[i][j];
	}
	reg mint ans=0;
	for(int i=1;i<=n;++i)ans+=f[n][i];
	write(ans.val()),ln;
	return 0;
}

/*
 * Check List:
 * 1. Input / Output File (OI)
 * 2. long long
 * 3. Special Test such as n=1
 * 4. Array Size
 * 5. Memory Limit (OI) int is 4 and longlong is 8
 * 6. Mod (a*b%p*c%p not a*b*c%p  ,  (a-b+p)%p not a-b )
 * 7. Name ( int k; for(int k...))
 * 8. more tests , (T=2 .. more)
 * 9. blank \n after a case
*/


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

int main(){
  int N;
  cin >> N;
  vector<long long int> A(N),B(N);
  vector<vector<long long int>> C(N,vector<long long int>(N));
  vector<pair<long long int,int>> S(N);
  for(int i=0;i<N;i++){
    long long int s = 0;
    for(int j=0;j<N;j++){
      cin >> C[i][j];
      s = C[i][j];
    }
    S[i] = make_pair(s,i);
  }
  sort(S.begin(),S.end());
  A[S[0].second] = 0;
  for(int i=0;i<N;i++) B[i] = C[S[0].second][i];
  bool flag = true;
  for(int i=0;i<N;i++){
    bool ok = true;
    A[i] = C[i][0]-B[0];
    for(int j=1;j<N;j++) if(C[i][j]-B[j] != A[i]) ok = false;
    if(!ok) flag = false;
  }
  if(flag){
    cout << "Yes" << endl;
    cout << A[0];
    for(int i=1;i<N;i++) cout << " " << A[i];
    cout << endl;
    cout << B[0];
    for(int i=1;i<N;i++) cout << " " << B[i];
    cout << endl;
  }
  else cout << "No" << endl;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr long long INF = 1000000000 + 100;
constexpr long long LINF = 1000000000000000000 + 100;
#define all(x) (x).begin(),(x).end()
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using V = vector<T>;

int main(){
    int N; cin >> N;
    vector<vector<int>> C(N, vector<int>(N));
    int minId = -1, minNum = INF;
    rep(i, N){
        rep(j, N){
            cin >> C[i][j];
            if(j==0){
                if(chmin(minNum, C[i][j])){
                    minId = i;
                }
            }
        }
    }

    vector<int> sa(N-1);
    rep(i, N-1)sa[i] = C[0][i] - C[0][i+1];
    for(int i=1; i<N; i++){
        rep(j, N-1){
            if(C[i][j]-C[i][j+1] != sa[j]){
                cout << "No" << ln;
                return 0;
            }
        }
    }

    cout << "Yes" << ln;
    rep(i, N){
        cout << C[i][0] - minNum << " ";
    }
    cout << ln;
    rep(i, N){
        cout << C[minId][i] << " ";
    }
    cout << ln;
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long int
#define maxn 2000007

void solve(){
  int n,m;
  cin>>n>>m;
  vector<int> a(m);
  for(int i=0;i<m;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  int l=0;
  vector<int> diff;
  for(auto x : a){
    if(x-l-1){
        diff.push_back(x-l-1);
    }
    l=x;
  }
  if(n-l){
        diff.push_back(n-l);
    }

    if(diff.empty()){
        cout<<0<<endl;
        return ;
    }
  sort(diff.begin(),diff.end());
  ll ans=1;
  for(int i=1;i<diff.size();i++){
    ans+=(diff[i]+diff[0]-1)/diff[0];
  }
  cout<<ans<<endl;

}

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

//cin>>t;
for(int i=0;i<t;i++)
    solve();
return 0;
}

#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#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 <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <climits>

#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using ld = long double;
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int white = n - m;
  int before = 0;
  int mn = 1000000000;
  vi a(m);
  rep(i, m) cin >> a[i];
  sort(all(a));
  vi length;
  rep(i, m){
    int num = a[i] - before - 1;
    if(num){
      mn = min(mn, num);
      length.push_back(num);
    }
    before = a[i];
  }
  if(n - before){
    mn = min(mn, n - before);
    length.push_back(n - before);
  }
  int ans = 0;
  for(int num : length){
    ans += ceil((double)num / mn);
  }
  cout << ans << endl;
}


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)
#define DEB(x)	cout << #x << " " << x << endl;
#define DEB_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

typedef long long int LL;
typedef pair<int, int> PI;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VL;

const LL INF = numeric_limits<LL>::max() / 4;

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

	LL lo = -INF, hi = INF, add = 0;
	REP(i, n) {
		LL a, t;
		cin >> a >> t;

		if (t == 1) {
			lo += a;
			if (hi < LONG_MAX)
				hi += a;
			add += a;

		} else if (t == 2) {
			CHMAX(lo, a);
			CHMAX(hi, a);

		} else {
			CHMIN(lo, a);
			CHMIN(hi, a);
		}
	}

	int q;
	cin >> q;
	REP(qi, q) {
		LL x;
		cin >> x;
		x += add;
		// cout << clamp(x, lo, hi) << endl;
		cout << (x < lo ? lo : (x > hi ? hi : x)) << endl;
	}
}

int main() {

	IOS
	// int t;
	// cin >> t;

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

	return 0;
}

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

void Main() {
  ll n,T;
  R n;
  P a[n];
  rep(i,n) cin >> a[i].F >> a[i].S;
  ll Mi=-MAXL,Ma=MAXL;
  {
    rep(i,n) {
      if(a[i].S==1) Mi+=a[i].F;
      if(a[i].S==2) Mi=max(Mi,a[i].F);
      if(a[i].S==3) Mi=min(Mi,a[i].F);
    }
    rep(i,n) {
      if(a[i].S==1) Ma+=a[i].F;
      if(a[i].S==2) Ma=max(Ma,a[i].F);
      if(a[i].S==3) Ma=min(Ma,a[i].F);
    }
  }
  ll l=-MAXL,r=MAXL;
  while(l+1<r) {
    ll m=(l+r)/2;
    ll x=m;
    rep(i,n) {
      if(a[i].S==1) x+=a[i].F;
      if(a[i].S==2) x=max(x,a[i].F);
      if(a[i].S==3) x=min(x,a[i].F);
    }
    if(x<=Mi) l=m;
    else r=m;
  }
  ll z=l;
  R T;
  while(T--) {
    ll x;
    R x;
    if(x<z) pr(Mi);
    else pr(min(Ma,x-z+Mi));
  }
}

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


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

int main(){
    int n;
    cin >> n;
    vector<long long> pos, neg;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        if(a > 0) pos.push_back(a);
        else neg.push_back(a);
    }

    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());

    long long npos = pos.size();
    long long nneg = neg.size();

    vector<long long> sum_pos, sum_neg;
    sum_pos.push_back(0);
    sum_neg.push_back(0);
    for(int i = 0; i < npos; i++){
        sum_pos.push_back(pos[i] + sum_pos[i]);
    }
    for(int i = 0; i < nneg; i++){
        sum_neg.push_back(neg[i] + sum_neg[i]);
    }

    long long sum = 0;

    for(int i = 0; i < npos; i++){
        sum += sum_pos[npos] - sum_pos[i] - (npos - i) * pos[i];
    }

    for(int i = 0; i < nneg; i++){
        sum += sum_neg[nneg] - sum_neg[i] - (nneg - i) * neg[i];
        sum += sum_pos[npos] - neg[i] * npos;
    }

    cout << sum << endl;
}

#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    N = 1 << N;
    int pos[2] = {}, val[2] = {};
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        int id = i / (N / 2);
        if (A > val[id]) {
            val[id] = A;
            pos[id] = i;
        }
    }
    cout << (val[0] < val[1] ? pos[0] : pos[1]) + 1;
    return 0;
}


// Problem : B - Palindrome with leading zeros
// Contest : AtCoder - AtCoder Beginner Contest 198
// URL : https://atcoder.jp/contests/abc198/tasks/abc198_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define w(x)  int x; cin>>x; while(x--)
using namespace std;
const long long N=200005, INF=2000000000000000000;

/*------------- Modular exponentiation -------------*/
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

/*------------- Sieve --------------*/
vector <int> prime;
bool is_composite[N];

void sieve (int n) {
	fill (is_composite, false);
	for (int i = 2; i < n; ++i) {
		if (!is_composite[i]) prime.push_back (i);
		for (int j = 0; j < prime.size () && i * prime[j] < n; ++j) {
			is_composite[i * prime[j]] = true;
			if (i % prime[j] == 0) break;
		}
	}
}

/*------------ Utitlity function ---------------*/
void print(bool n){
    if(n){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    if(n==0){
    	print(1);
    	return 0;
    }
    while(n%10==0) n/=10;
    string s = to_string(n);
    bool ok=1;
    for(int i=0;i<s.size();i++){
    	int j = s.size()-1-i;
    	if(s[i]!=s[j]){
    		ok=0;
    		break;
    	}
    }
    print(ok);
}

// Written by abhidot

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
main()
{
    int n,i;
    cin>>n;
    int d=n/100;d++;
    cout<<100*d-n<<endl;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int a, b;
    cin >> a >> b;
    vector<ll> ans1, ans2;
    ll q = 0;
    for (int i = 1; i <= a; ++i) {
        ans1.emplace_back(i);
        q += i;
    }
    for (int i = 1; i <= b; ++i) {
        ans2.emplace_back(-i);
        q -= i;
    }
    if(q < 0){
        ans1.back() -= q;
    }else {
        ans2.back() -= q;
    }
    for (auto &&i : ans2) {
        ans1.emplace_back(i);
    }
    for (int i = 0; i < ans1.size(); ++i) {
        if(i) printf(" ");
        printf("%lld", ans1[i]);
    }
    puts("");
    return 0;
}

#line 2 "/home/defineprogram/Desktop/Library/template/template.cpp"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i < n; i++)
#define rev(i, n) for (int i = n - 1; i >= 0; i--)
#define REV(i, n) for (int i = n - 1; i > 0; i--)
#define all(v) v.begin(), v.end()
#define PL pair<ll, ll>
#define PI pair<int,int>
#define len(s) (int)s.size()

template <class T, class U>
inline bool chmin(T &a, U b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T, class U>
inline bool chmax(T &a, U b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
constexpr ll inf = 3e18;
#line 2 "main.cpp"

ll N, K;
ll dp[5][1 << 22];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    dp[0][0] = 1;
    dp[0][1] = -1;
    rep(i, 4) {
        rep(j, 3000000) {
            dp[i][j + 1] += dp[i][j];
            if (!dp[i][j]) continue;
            dp[i + 1][j + 1] += dp[i][j];
            if (j + N + 1 <= 3000000) dp[i + 1][j + N + 1] -= dp[i][j];
        }
    }
    ll sum = 0;
    rep(i, 1 << 22) {
        if (sum + dp[3][i] >= K) {
            for (ll j = 1; j <= i - 2; j++) {
                ll l = max(i - (j + N), 1ll), r = min(i - (j + 1), N);
                int cnt = max(r - l + 1, 0ll);
                if (sum + cnt >= K) {
                    cout << j << " " << l + (K - sum - 1) << " "
                         << i - j - (l + (K - sum - 1)) << "\n";
                    return 0;
                }
                sum += cnt;
            }
        }
        sum += dp[3][i];
    }
}


#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>

#define ll long long
#define test(t) ll int t; cin>>t; while(t--)
#define F(i,L,R) for(ll int i=L;i<R;i++)
#define F2(i,L,R) for(ll int i=L;i>=R;i--)
#define get1(a) ll int a; cin>>a;
#define get2(a,b) ll int a,b; cin>>a>>b;
#define get3(a,b,c) ll int a,b,c; cin>>a>>b>>c;
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

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

int main()
{

 ios_base::sync_with_stdio(0);

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

 get1(n);

 vector<ll int> v(n,-1);

 F(i,0,n)
 {
    cin>>v[i];
 }

 ordered_set<ll int> ms;

 vector<ll int> inversions(n,0);
 ll int total=0;

 F(i,0,n)
 {

    total+=( ms.size() - ms.order_of_key(v[i]) );
    ms.insert(v[i]);
 }

 F(i,0,n)
 {
    cout<<total<<"\n";

    total += (n - 1 - 2*v[i]);
 }

  return 0;

}

// Atcoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#define _USE_MATH_DEFINES

#include<math.h>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
#include <sstream>

using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
//#define LINF (1e18)
#define MOD (1e9+7)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define all(x) (x).begin(),(x).end()
//#define int long long
const int INF = 1e9;
const ll LINF = 1e18;
typedef pair < ll, ll> P;

//元がintの分けたものを返す p[0]は1桁目
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
//桁数を返す
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
//元がstringの分けたものを返す d[0]は一桁目
vector<int> convertstring(string s) {
	vector<int> d;
	ll n = s.size();
	reverse(s.begin(), s.end());
	rep(i, n) {
		d.push_back(s[i] - '0');
	}
	return d;
}

/*long double　は%Lf*/
//queue古い順,stack新しい
//bool operator<(const Info &another) const {return x > another.x;}//struct(構造体)内の比較演算子のオバーロード
/****Union-Find-Tree***/
int par[int(0x7ffffff)];//Parent
int Rank[int(0x7ffffff)];//Deep_of_the_Tree

//n要素で初期化
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		Rank[i] = 0;
	}
}
//木の根探し
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (Rank[x] < Rank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}

int N; int A[200005];set<int>s[200005];
int32_t main() {
	cin >> N;
	init(200005);
	rep(i, N)cin >> A[i];
	rep(i, N / 2) {
		unite(A[i], A[N - 1 - i]);
	}

	rep(i, N) {
		s[find(A[i])].insert(A[i]);
	}
	int ans = 0;
	rep(i, 200001) {
		int res =s[i].size();
		if (res == 0)continue;
		ans += res - 1;
	}
	cout << ans << endl;
}


// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;
// cout << fixed << setprecision(桁数);

int main(){
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << (Z * Y - 1) / X << endl;
}

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

int main(){
    ll t,n;
    cin>>t>>n;
    vi unused;
    ll mae=0;
    REP(i,1,101){
    	REP(j,mae+1,(100+t)*i/100) unused.eb(j);
    	mae=(100+t)*i/100;
    }
    //outv(unused);
    ll sz=unused.size();
    n--;
    out(unused[n%sz]+(100+t)*(n/sz));
}


#include<bits/stdc++.h>
using namespace std;
#pragma region atcoder
//#include <atcoder/modint>
//using namespace atcoder;
//using mint = modint998244353;
//using mint = modint1000000007;
#pragma endregion
#pragma region macros
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define overload4(_1,_2,_3,_4,name,...) name
#define overload3(_1,_2,_3,name,...) name
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i=n;i--;)
#define rrep2(i,n) for(ll i=n;i--;)
#define rrep3(i,a,b) for(ll i=b;i-->(a);)
#define rrep(...) overload3(__VA_ARGS__,rrep3,rrep2,rrep1)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#pragma endregion
#pragma region debug for var, v, vv
#define debug(var)  do{std::cerr << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cerr << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cerr << e << " "; } std::cerr << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){cerr << endl;int cnt = 0;for(const auto& v : vv){cerr << cnt << "th : "; view(v); cnt++;} cerr << endl;}
#pragma endregion
#pragma region int128
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}
#pragma endregion
const ll mod = 1000000007;
const int inf = 1001001001;
const ll INF = 1001001001001001001ll;

int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
template<class T, class K>bool chmax(T &a, const K b) { if (a<b) { a=b; return 1; } return 0; }
template<class T, class K>bool chmin(T &a, const K b) { if (b<a) { a=b; return 1; } return 0; }
ll rudiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } //  20 / 3 == 7
ll rddiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // -20 / 3 == -7
ll power(ll a, ll p){ll ret = 1; while(p){if(p & 1){ret = ret * a;} a = a * a; p >>= 1;} return ret;}
ll modpow(ll a, ll p){ll ret = 1; while(p){if(p & 1){ret = ret * a % mod;} a = a * a % mod; p >>= 1;} return ret;}
/*---------------------------------------------------------------------------------------------------------------------------------*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(20);
    int n; cin >> n;
    V<int> dp(n + 1);
    dp[1] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 2*i; j <= n; j += i){
            dp[j] = max(dp[j], dp[i] + 1);
        }
    }
    rep(i,1,n+1) cout << dp[i] << " ";
}
/*
   * review you code when you get WA (typo? index?)
   * int overflow, array bounds
   * special cases (n=1?)
*/

//ye moh moh ke dhaage,tere ungliyon se ja uljhe

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

void gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
    }
    else{
        gcd(b,a%b,x,y);
        ll te=y;
        y=x-(a/b)*y;
        x=te;
    }
}

int main(){
    ll t;
    cin>>t;
    while(t--){
        ll n,s,k;
        cin>>n>>s>>k;

        ll q=n-s;
        ll g=__gcd(k,n);
        if(g!=1){
            if(q%g!=0){
                cout<<"-1"<<endl;
                continue;
            }
            q/=g;
            n/=g;
            k/=g;
        }
        ll x,y;
        gcd(k,n,x,y);
        x=(x+n)%n;
        cout<<(x*q)%n<<endl;
    }
}


#include <bits/stdc++.h>
#include <unordered_set>
#include <algorithm>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repll(i,n) for (ll i = 0; i < (ll)(n); i++)
#define fore(x,a) for(auto&(x) : (a))

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

#define ALL(a) (a).begin(), (a).end()

const ll INFL = 1e18;
const int INFI = 1e9;
const int MOD = 1e9 + 7;

int main(){
  ll N;
  cin >> N;
  vector<pll> x(N),y(N);
  repll(i,N) {
    ll X,Y;
    cin >> X >> Y;
    x[i] = make_pair(X,i);
    y[i] = make_pair(Y,i);
  }
  sort(ALL(x));
  sort(ALL(y));
  ll a,ax,ay,b;
  a = abs(x[N-1].first-x[0].first);
  ax = x[0].second;
  ay = x[N-1].second;
  if(abs(x[N-2].first-x[0].first)>abs(x[N-1].first-x[1].first)) {
    b = abs(x[N-2].first-x[0].first);
  }
  else {
    b = abs(x[N-1].first-x[1].first);
  }
  ll c,cx,cy,d;
  c = abs(y[N-1].first-y[0].first);
  cx = y[0].second;
  cy = y[N-1].second;
  if(abs(y[N-2].first-y[0].first)>abs(y[N-1].first-y[1].first)) {
    d = abs(y[N-2].first-y[0].first);
  }
  else {
    d = abs(y[N-1].first-y[1].first);
  }
  if(b > c) cout << b << endl;
  else if(d > a) cout << d << endl;
  else if(ax == cx && ay == cy) {
    cout << max(b,d) << endl;
  }
  else if(ax == cy && ay == cx) {
    cout << max(b,d) << endl;
  }
  else {
    cout << min(a,c) << endl;
  }
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mpi map<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define pl pair<ll,ll>
#define pi pair<int,int>
#define forn(i,n) for(ll i=0;i<n;i++)
#define ff first
#define ss second
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inf       1000000000000
#define MOD       1000000007
ll binpow(ll a,ll b,ll m){
    a%=m;
    ll res=1;
    while(b>0){
        if(b&1)
            res=res*a%m;
        a=a*a%m;
        b>>=1;
    }
    return res;
}
void solve(){
    ll a,b;
    cin>>a>>b;
    for(ll i=b;i>=1;i--){
        ll k=b/i;
        if(k>=2){
            ll x=k-1;
            if(x*i>=a){
                cout<<i;
                return;
            }
        }
    }
}

int main(){
    ll t=1;
   // cin>>t;
    while(t--){
        solve();
		cout<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=1e4+7;
const int mod=998244353;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    vc<vi> dp(n+1,vi(maxn));
    int sum=0;
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        sum+=a[i-1];
        for(int j=n-1;j>=0;j--)
        {
            for(int k=a[i-1];k<maxn;k++)
                dp[j+1][k]=(dp[j+1][k]+dp[j][k-a[i-1]])%mod;
        }
    }
    if(sum%2!=0) print(0);
    else{
        ll ans=0;
        for(int i=0;i<=n;i++)
        {
            ll cur=dp[i][sum/2];
            //dbg(i,cur);
            for(int j=1;j<=i;j++) cur=cur*j%mod;
            for(int j=1;j<=n-i;j++) cur=cur*j%mod;
            ans=(ans+cur)%mod;
        }
        print(ans);
    }
}


#include <iostream>
using namespace std;

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

    int difference = b - c;

    cout << difference << endl;
}

/** Seek God..Trust God..Praise God..**/

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

#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>
#define endl            "\n";

#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())

#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;

#define Yes cout << "YES" << endl;
#define No cout << "NO" << endl;

#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);

///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{

    return a.second>b.second;

    /*

    2 89
    1 20
    9 11
    5 10
    5 9
    4 7
    4 6

    */

}

///..................Sort by second element in a pair in increasing order............. ///
bool SortbySecInc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second<b.second;

    /*

    4 6
    4 7
    5 9
    5 10
    9 11
    1 20
    2 89

    */
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
    return (a.first > b.first);

    /*

    9 11
    5 10
    5 9
    4 6
    4 7
    2 89
    1 20

    */
}

///..................................Binary Search in Pair(Pair er 1st element er upor binary search korbe)..................//////

struct compare
{
    bool operator()(const pair<int,int> & value, const int &key)
    {
        return (value.first<key);
    }

    bool operator()(const int &key, const pair<int,int> &value)
    {
        return (key<value.first);
    }
};

///.............................................................TEMPLATE................................................./////

/// Convert String to Int ////

int String_to_int(string s)
{

    stringstream geek(s);

    int ans = 0;

    geek >> ans;

    return ans;
}

/// string to int ///
int S_I(string s)
{

    return stoi(s);
}

/*
/// int to string ///
string I_S(int n)
{
    return atoi(n);
}
*/

/*
long long  Prime[3000000],nPrime;
long long  mark[10000002];

void seive(long long int n)
{
	long long int i,j,limit=sqrt(n*1.0)+2;
	mark[1]=1;
	for(i=4; i<=n ;i+=2)
	mark[i]=1;
	Prime[nPrime++]=2;
	for(i=3; i<=n; i+=2)
	{
		if(!mark[i])
		{
			Prime[nPrime++]=i;
			if(i<=limit)
			{
				for(j=i*i; j<=n ;j+=i*2)
				{
					mark[j]=1;
				}
			}
		}
	}
}
*/

///std::cin.ingore() used for line of a string///

int main()
{
     FASTIO;

  ll a , b , c , d;

  cin >> a >> b >> c >> d;

  cout << max(a,b)-min(c,d) << endl;

    return 0;
}


/**
*    author:  tomo0608
*    created: 06.02.2021 20:59:55
**/

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;

#define all(x) x.begin(),x.end()
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
template<class T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T1, class T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> ostream& operator << (ostream& os, set<T>& set_var) {os << "{"; for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {os << *itr;++itr;if(itr != set_var.end()) os << ", ";itr--;}os << "}";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, map<T, U> &map_var) {os << "{";for(auto itr = map_var.begin(); itr != map_var.end(); itr++) {os << *itr;itr++;if (itr != map_var.end()) os << ", ";itr--;}os << "}";return os;}
template<class T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
#define pb push_back
#define eb emplace_back
#define elif else if
#define mp make_pair
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template<typename T> T gcd(T x, T y){if(x%y == 0)return y;return gcd(y, x%y);}
template<typename T> T gcd(vector<T> a){T res = a[0];for(auto &x: a)res = gcd(res, x);return res;}
template <typename T>T mypow(T x, ll n){T ret = 1;while(n > 0){if(n & 1)(ret *= x);(x *= x);n >>= 1;}return ret;}
#define endl '\n'
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

// Primality test
class Prime {
    public:
    const int N;
    vector<int> min_prime;
    vector<int> primes;
    Prime(int size): N(size), min_prime(N+1){
        rep(i,N+1)min_prime[i] = i;
        min_prime[0] = -1;
        min_prime[1] = -1;
        for(int i = 2;i<=N;i++){
            if(min_prime[i]!=i)continue;
            primes.push_back(i);
            int tmp = 2*i;
            while(tmp <= N){
                if(min_prime[tmp]==tmp)min_prime[tmp] = i;
                tmp += i;
            }
        }
    }
    bool check(int x){ return min_prime[x] == x;}
};

void solve(){
    int h,w;cin >> h >> w;
    V<string> S(h);cin >> S;
    VV<int> T(h, V<int>(w,0));
    rep(i,h)rep(j,w)if(S[i][j] == '#')T[i][j]++;
    ll ans = 0;
    rep2(i,1,h)rep2(j,1,w){
        if((T[i][j] + T[i-1][j] + T[i][j-1] + T[i-1][j-1])%2){
            ans++;
            //cout << i << ' ' << j << endl;
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << setprecision(20);
    int codeforces = 1;
    //cin >> codeforces;
    while(codeforces--){
        solve();
    }
    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(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;
//using mint = modint;

const vector<int> dx = {1, 1,  1, 0,  0, 0, -1, -1, -1};
const vector<int> dy = {1, 0, -1, 1, -1, 0,  1,  0, -1};
const double PI = 3.141592653589793;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
const ll mod2 = 998244353;

const int MAX = 1000000;
const ll MOD = 998244353;
const ll big = 1ll<<60;

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

int main(){
    int k;
    ll n, m;
    cin >> k >> n >> m;
    vector<ll>a(k), b(k);
    rep(i, 0, k)cin >> a[i];
    ll ng = -1, ok = big, mid;
    while(ok-ng > 1){
        mid = (ok+ng)/2;
        ll left = 0, right = 0;
        rep(i, 0, k){
            left += (m*a[i]-mid+(n-1))/n;
            right += (m*a[i]+mid)/n;
        }
        if(left<=m && m<=right){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    mid = ok;
    ll sum = 0, rest;
    rep(i, 0, k){
        b[i] = (m*a[i]-mid+(n-1))/n;
        sum += b[i];
    }
    rest = m-sum;
    rep(i, 0, k){
        ll temp = (m*a[i]+mid)/n;
        if(temp-b[i]<rest){
            rest -= (temp-b[i]);
            b[i] = temp;
        }else{
            b[i] += rest;
            rest = 0;
        }
        cout << b[i] << " ";
    }
    cout << endl;
    return 0;
}


/*
    Author: Ritik Patel
*/

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& LIBRARIES &&&&&&&&&&&&&&&&&&&&&&&&&&&

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

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEFINES &&&&&&&&&&&&&&&&&&&&&&&&&&&

#define int long long int
// #define ll long long int
#define all(i) i.begin(), i.end()
#define sz(a) (int)a.size()

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& CODE &&&&&&&&&&&&&&&&&&&&&&&&&&&

const int MAXN = 55;
vector<int> rows[MAXN], col[MAXN];
int g[MAXN][MAXN];
int N, K;

void checkr(int r1, int r2) {
    bool poss = true;
    for(int c = 1; c <= N; ++c) {
        poss &= g[r1][c] + g[r2][c] <= K;
    }
    if(poss) {
        rows[r1].push_back(r2);
        rows[r2].push_back(r1);
    }
}

void checkc(int c1, int c2) {
    bool poss = true;
    for(int r = 1; r <= N; ++r) {
        poss &= g[r][c1] + g[r][c2] <= K;
    }
    if(poss) {
        col[c1].push_back(c2);
        col[c2].push_back(c1);
    }
}

bool rvis[MAXN], cvis[MAXN];
int len = 0;

void dfs(int v) {
    rvis[v] = 1;
    ++len;
    for(auto &to: rows[v]) {
        if(!rvis[to])
            dfs(to);
    }
}

void dfs0(int v) {
    cvis[v] = 1;
    ++len;
    for(auto &to: col[v]) {
        if(!cvis[to])
            dfs0(to);
    }
}

const int MOD = 998244353;

void solve() {
    cin >> N >> K;
    for(int r = 1; r <= N; ++r)
        for(int c = 1; c <= N; ++c)
            cin >> g[r][c];

    for(int r = 1; r <= N; ++r)
        for(int rr = r + 1; rr <= N; ++rr)
            checkr(r, rr);

    for(int r = 1; r <= N; ++r)
        for(int rr = r + 1; rr <= N; ++rr)
            checkc(r, rr);

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

    int ans = 1;
    for(int r = 1; r <= N; ++r) {
        if(!rvis[r]) {
            len = 0;
            dfs(r);
            ans *= fact[len]; ans %= MOD;
        }
        if(!cvis[r]) {
            len = 0;
            dfs0(r);
            ans *= fact[len]; ans %= MOD;
        }
    }

    cout << ans << '\n';

}

int32_t main(){
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int T = 1;
    // cin >> T;
    for(int i = 1; i <= T; ++i){
        // cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}

/*
Sample inp
*/

#include<bits/stdc++.h>
#define N 60
#define A(i,m,n) for(int i=m;i<=n;++i)
using namespace std;
typedef long long LL;
const LL mod=998244353;
int a[N][N],n,k;
inline bool check1(int x,int y){
	A(i,1,n)if(a[x][i]+a[y][i]>k)return 0;
	return 1;
}
inline bool check2(int x,int y){
	A(i,1,n)if(a[i][x]+a[i][y]>k)return 0;
	return 1;
}
LL fc[N];
int fa[N],siz[N];
int findfa(int x){
	if(fa[x]!=x)fa[x]=findfa(fa[x]);
	return fa[x];
}
inline void mer(int x,int y){
	int tx=findfa(x),ty=findfa(y);
	if(tx!=ty){
		fa[tx]=ty;
		siz[ty]+=siz[tx];
	}
}
int main(){
	cin>>n>>k;
	fc[1]=1;
	A(i,2,n)fc[i]=(fc[i-1]*i)%mod;
	A(i,1,n){
		A(j,1,n)cin>>a[i][j];
		fa[i]=i;
		siz[i]=1;
	}
	A(i,1,n)
		A(j,i+1,n)
			if(findfa(i)!=findfa(j)&&check1(i,j)==1)mer(i,j);
	LL ans=1;
	A(i,1,n)
		if(findfa(i)==i)ans=ans*fc[siz[i]]%mod;
	A(i,1,n)fa[i]=i,siz[i]=1;
	A(i,1,n)
		A(j,i+1,n)
			if(findfa(i)!=findfa(j)&&check2(i,j)==1)mer(i,j);
	A(i,1,n)
		if(findfa(i)==i)ans=ans*fc[siz[i]]%mod;
	printf("%lld\n",ans);
	return  0;
}


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

int N;
vector<int> C;
vector<vector<int>> T;

void input(){
    cin >> N;
    C.resize(N);
    REP(i,N) cin >> C[i];
    T.resize(N);
    REP(i,N-1){
        int A,B;
        cin >> A >> B;
        A--; B--;
        T[A].push_back(B);
        T[B].push_back(A);
    }
}

void DFS(int s,vector<bool> &flag,vector<int> &memo,priority_queue<int,vector<int>,greater<int>> &res){
    flag[s] = true;
    if(memo[C[s]] == 0) res.push(s);
    memo[C[s]]++;
    for(auto v : T[s]){
        if(!flag[v]) DFS(v,flag,memo,res);
    }
    memo[C[s]]--;
}

int main(){
    input();
    vector<bool> flag(N,false);
    vector<int> memo(100010,0);
    priority_queue<int,vector<int>,greater<int>> res;
    DFS(0,flag,memo,res);
    while(!res.empty()){
        cout << res.top()+1 << endl;
        res.pop();
    }
    return 0;
}

/*
author: Yash Gupta
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define IOS                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define endl "\n"
#define mem(x, y) memset(x, y, sizeof(x))
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
const int N = 2e5 + 5;
const int inf = 9e18 + 9;
const int mod = 1e9 + 7;
struct node
{
	int x, y;
};
int n, m;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
vector<vector<node>> v(26, vector<node>{});
bool vis[2005][2005];
int dist[2005][2005];
vector<bool> used(26, false);
char a[2005][2005];
bool check(node p)
{
	if (vis[p.x][p.y])
		return false;
	if (a[p.x][p.y] == '#')
		return false;
	if (p.x < 0 || p.y < 0)
		return false;
	if (p.x >= n || p.y >= m)
		return false;
	return true;
}
void solve()
{
	mem(vis, false);
	mem(dist, 0);
	cin >> n >> m;
	node start, end;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> a[i][j];
			if (a[i][j] == 'S')
			{
				start = {i, j};
			}
			else if (a[i][j] == 'G')
			{
				end = {i, j};
			}
			else if (a[i][j] == '#')
			{
				vis[i][j] = true;
			}
			else if (a[i][j] == '.')
			{
				continue;
			}
			else
			{
				v[a[i][j] - 'a'].pb({i, j});
			}
		}
	}
	queue<node> q;
	q.push(start);
	vis[start.x][start.y] = true;
	dist[start.x][start.y] = 0;
	bool f = false;
	while (!q.empty())
	{
		node curr = q.front();
		q.pop();
		if (end.x == curr.x && end.y == curr.y)
		{
			f = true;
			break;
		}
		else
		{
			for (int i = 0; i < 4; i++)
			{
				if (check({curr.x + dx[i], curr.y + dy[i]}))
				{
					q.push({curr.x + dx[i], curr.y + dy[i]});
					vis[curr.x + dx[i]][curr.y + dy[i]] = true;
					dist[curr.x + dx[i]][curr.y + dy[i]] = 1 + dist[curr.x][curr.y];
				}
			}
			if (a[curr.x][curr.y] != 'S' && a[curr.x][curr.y] != '.' && !used[a[curr.x][curr.y] - 'a'])
			{
				used[a[curr.x][curr.y] - 'a'] = true;
				for (auto p : v[a[curr.x][curr.y] - 'a'])
				{
					if (!vis[p.x][p.y])
					{
						q.push(p);
						vis[p.x][p.y] = true;
						dist[p.x][p.y] = 1 + dist[curr.x][curr.y];
					}
				}
			}
		}
	}
	if (f)
	{
		cout << dist[end.x][end.y] << endl;
	}
	else
	{
		cout << "-1" << endl;
	}
}

int32_t main()
{
	IOS;
	int t = 1;
	// cin>>t;
	for (int i = 1; i <= t; i++)
	{
		solve();
	}
}


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

int main() {
  double X, Y, Z;
  cin >> X >> Y >> Z;
  int ans = 0;
  bool flag = true;
  while (flag) {
    if (Y / X <= ans / Z) {
      flag = false;
    } else {
      ans++;
    }
  }
  cout << ans - 1 << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  ll               long long int
#define  pb               push_back
#define  MAX              100007
#define  End              return 0;
#define  pi               acos(-1)
#define  no               cout<<"NO"<<endl
#define  yes              cout<<"YES"<<endl
int const N=1e7+3;
ll MOD=1e9+7,fact[N];
const long long inf=(long long)1e18;
const long double PI=3.14159265358979;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main()
{
    fast
    ll n,m,j,i,k,tc=1,p,r;
    ll x,y,z;
    //cin>>tc;
    while(tc--)
    {
        vector<ll>v,v1;
        map<ll,ll>mp;
        map<ll,ll>mp2;
        cin>>x>>y>>z;

        cout<<(y*z-1)/x<<endl;

    }
    return 0;
}