//To debug :  g++ -g file.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
//use 1LL<<i to for 64 bit shifting , (ll)2 because by default 2 is ll
//take care of precedence rule of operators
//do not forget to change the sizes of arrays and value of contants and other things after debugging

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 ll_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 ll_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<ll>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define MOD 998244353
#define ld long double
#define pi acos(-1.0)

#define SZ(x)  (ll)(x.size())

//comment the below if not required

/*

#define ss second.second
#define ff first.first
#define f first
#define s second
#define sf second.first
#define fs first.second
*/

#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

//cout<<"Case #"<<c<<": "<<ans<<"\n" ;

ll n,N,ans,i,val,ind1,ind2,val1,val2;

int main()
{

    IOS;

    cin>>n;

    N = 1<<n;

    ll a[N];

    for(i=1;i<=N;++i)
        cin>>a[i];

    for(i=1;i<=(N/2);++i)
    {
        if(a[i]>val1)
        {
            val1 = a[i];
            ind1 = i;
        }

        if(a[i+N/2]>val2)
        {
            val2 = a[i+N/2];
            ind2 = i+N/2;
        }

    }

    if(val1>val2)
        cout<<ind2<<"\n";
    else
        cout<<ind1<<"\n";

    return 0;
}

//
// Created by Bottomline2sky on 1/10/2021.
//
#include<bits/stdc++.h>
using  namespace std;
typedef long long ll;
ll result(vector<pair<ll,ll>>&p){
           if((ll)p.size() == 2){
                  if(p[0].first>p[1].first){
                        return   p[1].second;
                  }
                  else{
                       return p[0].second;
                  }
           }
           else{
                   vector<pair<ll,ll>> q;
                    for(ll i=0;i<p.size();i=i+2){
                     //   cout<<p[i].first<<" "<<p[i+1].first<<" ";
                           if(p[i].first>p[i+1].first){
                                  q.push_back(p[i]);
                           }
                           else{
                                q.push_back(p[i+1]);
                           }
                    }
               return   result(q);
           }

   }
int main(){
      int n;
            cin>>n;
              vector<pair<ll,ll>> arr;
                    for(ll i=0;i<pow(2,n);i++){
                              ll q;
                               cin>>q;
                                 arr.push_back(make_pair(q,i+1));
                    }
                       ll coffn = result(arr);
                       cout<<coffn<<endl;
}


#include <bits/stdc++.h>
//#include "atcoder/all"
using namespace std;
using ll = long long;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
const ll mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;

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

  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;

    if (s == "OR") {
      dp[i + 1][0] = dp[i][0];
      dp[i + 1][1] = dp[i][0] + 2 * dp[i][1];
    } else {
      dp[i + 1][0] = dp[i][0] * 2 + dp[i][1];
      dp[i + 1][1] = dp[i][1];
    }
  }

  cout << dp[n][1] << endl;
}

/*      Author : Kaustubh Gangwar
        Institute : IIITA        */
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define vi vector<int>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define f(i, a, b) for (int i = a; i < b; i++)
#define fe(i, a, b) for (int i = a; i <= b; i++)
#define sz(x) (int)((x).size())
#define CODING ios_base::sync_with_stdio(false);
#define SAMRAT cin.tie(0), cout.tie(0);
#define mll map<ll, ll>
#define nl '\n'
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef pair<ll, ll> pll;

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

int32_t main()
{
    CODING SAMRAT
    int test = 1;
    //cin >> test;
    while (test--)
    {
    ll n;
    cin>>n;
    ll ans[n+5]={0};

    f(i,1,n+4)
    {
        ll temp=i;
        int flag=0;
        while(temp)
        {   if(temp%10==7)
            flag=1;
            temp=temp/10;
        }
        temp=i;
        while(temp)
        {   if(temp%8==7)
            flag=1;
            temp=temp/8;
        }

        if(flag)
        {
            ans[i]=ans[i-1];

        }
        else
        ans[i]=ans[i-1]+1;
    }

    cout<<ans[n];

    }

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  for (auto &e : a) cin >> e;
  for (auto &e : b) cin >> e;

  for (int i = 0; i + 1 < n; i++) a[i + 1] = max(a[i + 1], a[i]);

  ll r = 0;
  for (int i = 0; i < n; i++) cout << (r = max(r, a[i] * b[i])) << endl;
}

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define ull unsigned long long
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define debug(x) cerr << #x << " = " << x << '\n';
#define pll pair <ll, ll>
#define fir first
#define sec second
#define INF 0x3f3f3f3f
#define int ll

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

const int maxn = 2e5 + 10;
int n,a[maxn],b[maxn],c[maxn];
signed main() {
  IO;
  cin >> n;
  rep(i,1,n) cin >> a[i];
  rep(i,1,n) cin >> b[i];
  int mx = 0;
  rep(i,1,n){
    mx = max(mx,a[i]);
    c[i] = max(c[i-1],b[i] * mx);
  }
  rep(i,1,n) cout << c[i] << '\n';
  return 0;
}


#include <iostream>
#include <chrono>
#include <string>
#include <vector>
#include <algorithm>
class DNA {
	private:
		char base[20][20];
	public:
		void inputV(const int& i, const int& j, const std::string& s) {
			for (int k = 0; k < (int)s.size(); k++) {
				if (i + k < 20) base[i + k][j] = s[k];
				else base[i + k - 20][j] = s[k];
			}
		}
		void inputH(const int& i, const int& j, const std::string& s) {
			for (int k = 0; k < (int)s.size(); k++) {
				if (j + k < 20) base[i][j + k] = s[k];
				else base[i][j + k - 20] = s[k];
			}

		}
		void output() {
			for (int i = 0; i < 20; i++) {
				for (int j = 0; j < 20; j++) {
					std::cout << base[i][j];
				}
				std::cout << std::endl;
			}
		}
		//constructor
		DNA() {
			for (int i = 0; i < 20; i++) {
				for (int j = 0; j < 20; j++) {
					base[i][j] = '.';
				}
			}
		}
};
int main() {
	DNA alien;
	int m;
	std::cin >> m >> m;
	std::vector<std::pair<int, std::string>> sequences(m, { 0, "" });
	for (int i = 0; i < m; i++) {
		std::cin >> sequences[i].second;
		sequences[i].first = (int)sequences[i].second.size();
	}
	sort(sequences.begin(), sequences.end());
	int now = 0;;
	int k = 0;
	while(now < 20) {
		for (int i = 0; i < 20; i++) {
			alien.inputH(i, now + 1, sequences[i].second);
		}
		k++;
		now += sequences[k * 20 - 1].first;
	}
	alien.output();

	return 0;

}

#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <random>
#include <fstream>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n,m;
std::string s[888];
char ans[22][22][22];
bool nochange[22][22][22],already[22][888];

void check(int t){
	int i,j,k,l;
	bool flag;
	for(k=0; k<m; ++k){
		if(already[t][k]){
			continue;
		}
		for(i=0; i<n; ++i){
			for(j=0; j<n; ++j){
				flag = true;
				for(l=0; l<s[k].l_ength(); ++l){
					if(ans[t][i][(j+l)%n] != s[k][l]){
						flag = false;
						break;
					}
				}
				if(flag){
					already[t][k] = true;
					for(l=0; l<s[k].l_ength(); ++l){
						nochange[t][i][(j+l)%n] = true;
					}
					break;
				}
				flag = true;
				for(l=0; l<s[k].l_ength(); ++l){
					if(ans[t][(i+l)%n][j] != s[k][l]){
						flag = false;
						break;
					}
				}
				if(flag){
					already[t][k] = true;
					for(l=0; l<s[k].l_ength(); ++l){
						nochange[t][(i+l)%n][j] = true;
						break;
					}
					break;
				}
			}
			if(already[t][k]){
				break;
			}
		}
	}
}

int main(void){
	int i,j,c[22],k,t,score=0;
	std::random_device seed_gen;
	std::default_random_engine engine(seed_gen());
	std::uniform_int_distribution<> rnd('A','H');
	std::cin >> n >> m;
	for(i=0; i<m; ++i){
		std::cin >> s[i];
	}
	for(t=0; t<20; ++t){
		for(k=0; k<40; ++k){
			for(i=0; i<n; ++i){
				for(j=0; j<n; ++j){
					if(!nochange[t][i][j]){
						ans[t][i][j] = rnd(engine);
					}
				}
			}
			check(t);
		}
		c[t] = 0;
		for(i=0; i<m; ++i){
			if(already[i]){
				++c[t];
			}
		}
		score = std::max(score,c[t]);
	}
	for(t=0; t<20; ++t){
		if(score < c[t]){
			continue;
		}
		for(i=0; i<n; ++i){
			for(j=0; j<n; ++j){
				std::cout << ans[t][i][j];
			}
			std::cout << std::endl;
		}
		break;
	}
	return 0;
}


#include <bits/stdc++.h>
#include <string>
//#include <boost/multiprecision/cpp_int.hpp>
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll  long long
#define fp cout<<fixed<<setprecision(9);
#define ifor(j,n) for(int i=j ;i<n;i++)
#define jfor(k,n) for(ll j=k ;j<n;j++)
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
//using namespace boost::multiprecision;

//Compiler version g++ 6.3.0
int search (vector <long long> v,long long m,int n)
{

    int start = 0;
    int ans = -1;
    while (start <=n)
    {
     int mid = (start + n) / 2;
     if (v[mid] <= m)
         start = mid + 1;
     else
   {
   ans = mid;
   n = mid - 1;

       }

    }
    return ans;
}

int main()
{
 FAST

   int t=1;
   //in>>t;

      while(t--)
      {
       int n,k,b;
       cin>>n>>k>>b;
       cout<<n-k+b;

       }
       }

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

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

  cout << N - A + B << endl;
}


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

map<string, bool> visited;
vector<vector<string>> adj;

/*void dfs(string s, ll &k)
{
    visited[s] = 1;
    ll len = adj[a].size();

    for (int i = 0; i < len; i++)
    {
        if (!visited[adj[a][i]])
        {
            k++;
            dfs(adj[a][i], k);
        }
    }
}*/

int main()
{
    ll n, k;
    cin >> n >> k;
    map<ll, ll> m;
    vector<pair<ll, ll>> v;
    priority_queue<ll, vector<ll>, std::greater<ll>> q;
    ll x, y;
    for (int i = 0; i < n; i++)
    {
        cin >> x >> y;
        if (m[x] != 0)
            m[x] += y;
        else
        {
            m[x] = y;
            q.push(x);
        }
    }
    ll pos = 0;
    k += m[0];
    while (k > 0){
        pos += k;
        k=0;
        while(!q.empty()&&q.top() <= pos){
            k += m[q.top()];
            q.pop();
        }

    }
    cout << pos << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using ll = long long;
const int INF = 1001001001;
const ll LINF = 1002003004005006007ll;

  vector<int> G[2000];
void solve(){
  int n,m;cin >> n >> m;
  int a,b;
  rep(i,m){
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
  }
  ll cnt = 0;
  queue<int> Q;
  rep(i,n){
    Q.push(i);
    vector<bool> memo(n,0);
    memo[i] = 1;
    while(!Q.empty()){
      auto p = Q.front();Q.pop();cnt++;
      rep(j,G[p].size()){
        if(memo[G[p][j]]==0){
          memo[G[p][j]] = 1;
          Q.push(G[p][j]);
        }
      }
    }
  }
  cout << cnt << endl;
  return;
}

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

  solve();
    return 0;
}


# pragma GCC optimize ("O3")
# pragma GCC optimize ("Ofast")
# pragma GCC optimize ("unroll-loops")
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define rep2(i,a,b) for(int i = (b) - 1; i >= (a); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define x first
#define y second
using namespace std;
using ll = long long;
using tl = tuple<ll, ll, ll, ll>;
using pl = pair<ll, ll>;
using pi = pair<int, int>;
using ld = long double;

const int MOD = 998244353;
template<class T> struct mi {
	T val;
	mi() { val = 0; }
	mi(const ll& v) {
		val = (-MOD <= v && v <= MOD) ? v : v % MOD;
		if (val < 0) val += MOD;
	}
	mi operator + (const mi& m) {
		T tmp = (val + m.val) % MOD;
		return tmp + (tmp < 0 ? MOD : 0);
	}
	mi operator - (const mi& m) {
		T tmp = (val - m.val) % MOD;
		return tmp + (tmp < 0 ? MOD : 0);
	}
	mi operator * (const mi& m) {
		T tmp = (val * m.val) % MOD;
		return tmp;
	}
	mi& operator += (const mi& m) {
		if ((val += m.val) >= MOD) val -= MOD;
		return *this;
	}
	mi& operator -= (const mi& m) {
		if ((val -= m.val) < 0) val += MOD;
		return *this;
	}
	mi& operator *= (const mi& m) {
		val = (val * m.val) % MOD;
		return *this;
	}
};
ll N, M;
mi<ll> ans, mpow[5001][5001];

int main() {
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    cin >> N >> M;
	rep(i, 0, M + 1) mpow[i][0] = 1;
	rep(i, 0, M + 1) rep(j, 1, N + 1) mpow[i][j] = mpow[i][j - 1] * i;
	ans = mpow[M][N] * N;
	rep(s, 1, N){
		mi<ll> tmp(0);
		rep(x, 1, M + 1) tmp += mpow[M - x][s - 1];
		ans -= tmp * mpow[M][N - s - 1] * (N - s);
	}
	cout << ans.val << endl;
}

#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
typedef long double ld;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define setprec cout << fixed << showpoint << setprecision(20);
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 998244353;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int power (int a, int b = mod - 2)
{
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

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

	readb(n, m);
	int one[n + 1][m + 1] = {}, zer[n + 1][m + 1] = {};
	int onesum[n + 1][m + 1] = {}, zersum[n + 1][m + 1] = {};

	int precalc[m + 1][n + 1] = {};
	FOR (i, 1, m) precalc[i][0] = 1;
	FOR (i, 1, m)
	    FOR (j, 1, n)
	        precalc[i][j] = i*precalc[i][j - 1] % mod;

	FOR (i, 1, n)
	    FOR (j, 1, m)
	    {
	        one[i][j] = (one[i][j - 1] + onesum[i - 1][j - 1] + zersum[i - 1][j - 1] + precalc[j][i] - precalc[j - 1][i]) % mod;
	        zer[i][j] = (one[i][j] + onesum[i - 1][j] + zersum[i - 1][j]) % mod;

	        onesum[i][j] = (onesum[i - 1][j]*(j + 1) + one[i][j]) % mod;
	        zersum[i][j] = (zersum[i - 1][j]*j + zer[i][j]) % mod;
	    }

    print((one[n][m] + 5*mod) % mod);
}


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;

int T, n;
string s1, s2, s3;

int main()
{
	std::ios::sync_with_stdio(0);

	cin >> T;
	while (T--) {
		cin >> n;
		cin >> s1 >> s2 >> s3;
		for (int i = 1; i <= n; i++) cout << '0';
		for (int i = 1; i <= n; i++) cout << '1';
		cout << "0\n";
	}

	return 0;
}

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

int N = 30*30;
int L = 30;
// (i,j) i個下 , j個右
int ind(int a,int b){
	return a*L + b;
}

//vector< vector<string> > S(N,vector<string>(N));
vector<vector<long double>> H(L,vector<long double>(L,5000.0));
vector<vector<long double>> V(L,vector<long double>(L,5000.0));

// 上は下より(i,j)のiが小さい　右は左より(i,j)のjが大きい

// 順路正の向きで
const int From_U = 0;//上から来た
const int From_D = 1;//下から来た
const int From_L = 2;//左から来た
const int From_R = 3;//右から来た

// 復元
string make_char = "DURL";
const int dy[] = {-1,1,0,0};
const int dx[] = {0,0,-1,1};

int main(){
	int sy,sx,ty,tx;
	int s,t;
	FOR(k,0,1000){
		cin >> sy >> sx >> ty >> tx;

		int dir_y = 1;
		int dir_x = 1;
		if(sy > ty) dir_y = -1;
		if(sx > tx) dir_x = -1;

		// (i,j) には (i - dir_y , j) or (i , j - dir_x) から行く

		vector< vector<long double> > score(L,vector<long double>(L,INF));
		vector< vector<int> > from(L,vector<int>(L,-1));

		score[sy][sx] = 0;
		for(int y=sy;(y-dir_y)!=ty;y+=dir_y){
			for(int x=sx;(x-dir_x)!=tx;x+=dir_x){
				//cout << y << " " << x << endl;

				if(y==sy && x==sx) continue;
				long double a = INF,b = INF;
				if(y != sy) a = score[y-dir_y][x] + H[min(y-dir_y,y)][x];
				if(x != sx) b = score[y][x-dir_x] + V[y][min(x,x-dir_x)];

				if(a < b){
					from[y][x] = (dir_y == 1 ? From_U : From_D );
					score[y][x] = a;
				}else{
					from[y][x] = (dir_x == 1 ? From_L : From_R );
					score[y][x] = b;
				}

			}
		}
		//return 0;
		//cout << "95" << endl;

		string T;
		int y=ty,x=tx;
		while(y!=sy || x!=sx){
			int a = from[y][x];
			T += make_char[a];
			assert(0 <= a && a <= 3);
			y += dy[a];
			x += dx[a];
			//cout << "from[" << y <<  "][" << x << "] = "  << a << endl;
		}

		//cout << "106" << endl;

		//cout << T << endl;
		REV(T);
		/*{ // チェック
			assert(T.size() == (abs(sy-ty)+abs(sx-tx)));
			int ud=0,lr=0;
			for(auto c:T){
				if(c == 'U' || c == 'D') ud++;
				if(c == 'L' || c == 'R') lr++;
			}
			assert(abs(sy-ty) == ud);
			assert(abs(sx-tx) == lr);
		}*/
		cout << T << endl;
		cout << flush;

		long double score_now,r;
		cin >> score_now;

		r = pow( score_now / score[ty][tx] , 1.0 - 1.0*(abs(sy-ty) + abs(sx-tx)) / 115.0 );

		y=ty,x=tx;
		while(y!=sy || x!=sx){
			int a = from[y][x];
			int by = y + dy[a],bx = x + dx[a];
			if(by != y){
				H[min(by,y)][x] *= r;
			}else{
				V[y][min(bx,x)] *= r;
			}
			y += dy[a];
			x += dx[a];
		}
	}
}


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

int main(void){
    // Your code here!
    long long a,b,x,y;
    cin >> a >> b;
    //y=a-b/2
    //x=a/2+b/2
    x = (a+b)/2;
    y = (a-b)/2;

    cout << x << " " << y << endl;
}

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

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

	for (int i = -100; i <= 100; i++) {
		for (int j = -100; j <= 100; j++) {
			if (i + j == a && i - j == b) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)

void solve()
{
	char s,t;
	cin>>s;
	cin>>t;
	if(s=='Y')
	{
		cout<<char(toupper(t))<<'\n';
	}
	else
	{
		cout<<t<<'\n';
	}

}

signed main()
{
	FAST;
	int tt=1;
	//cin>>tt;
	while(tt--)
	{
		solve();
	}
}

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

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

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

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;
typedef map<int,int> mii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int mod = 1e9+7;

#define fou(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define fod(a, b, c) for (int(a) = (int)(b); (a) >= (int)(c); --(a))
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define pqb priority_queue<int>
#define pqs priority_queue<int,vi,greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define ps(x,y) fixed<<setprecision(y)<<x
#define ALL(v) v.begin(), v.end()
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define SORTC(v, c) sort(ALL(v), c)
#define test(x) int x; cin>>x; while(x--)
#define endl '\n'

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

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

    char s, t;
    cin >> s >> t;

    if (s=='Y') t = toupper(t);
    cout << t << endl;
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int Maxn=100000+10;
int a[Maxn],f[Maxn<<2];
int n,m;
inline int read()
{
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0' && ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
    return s*w;
}
void build(int k,int l,int r)
{
    if(l==r)
    {
        f[k]=l;
        return;
    }
    int mid=(l+r)>>1;
    build(k<<1,l,mid);
    build(k<<1|1,mid+1,r);
    if(a[f[k<<1]]>a[f[k<<1|1]])
    f[k]=f[k<<1];
    else f[k]=f[k<<1|1];
}
int main()
{
    // freopen("in.txt","r",stdin);
    m=read();
    n=(1<<m);
    for(int i=1;i<=n;++i)
    a[i]=read();
    build(1,1,n);
    int x=f[2],y=f[3];
    if(a[x]<a[y])printf("%d\n",x);
    else printf("%d\n",y);
    return 0;
}

#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define int ll
#define each(i, a) for (auto &&i : (a))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
using vd = vector<ld>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using P = pair<int, int>;
using vp = vector<P>;
using int128 = __int128_t;//cin coutはできない
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a / gcd(a, b) * b;};
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

template <class T>
void CVEC(const T &v) {
	int c = v.size() - 1;
	for (int i = 0; i < c; i++) cout << v[i] << ' ';
	if (c > -1) cout << v[c];
	cout << '\n';
}

#pragma endregion header

signed main(){
    int n, w;
	cin >> n >> w;
	cout << n / w << endl;
}


#include <bits/stdc++.h>

#define reint int
#define coint const int

using namespace std;

typedef long long ll;

coint SIZE = 500 + 5;

int n;
ll li[SIZE][SIZE];
ll deltA[SIZE], deltB[SIZE];

int main(void) {
    scanf("%d", &n);
    for (reint i = 1; i <= n; ++i)
        for (reint j = 1; j <= n; ++j)
            scanf("%lld", &li[i][j]);
    for (reint i = 2; i <= n; ++i)
        deltB[i] = li[1][i] - li[1][i - 1];
    for (reint i = 2; i <= n; ++i)
        deltA[i] = li[i][1] - li[i - 1][1];
    ll minA = 0, minB = 0;
    for (reint i = 1; i <= n; ++i) {
        deltA[i] += deltA[i - 1];
        deltB[i] += deltB[i - 1];
        minA = min(minA, deltA[i]);
        minB = min(minB, deltB[i]);
    }
    if (-(minA + minB) > li[1][1]) {
        puts("No");
        return 0;
    }
    deltA[1] = -minA, deltB[1] = li[1][1] - deltA[1];
    for (reint i = 2; i <= n; ++i)
        deltA[i] += deltA[1], deltB[i] += deltB[1];

    int flg = 1;
    for (reint i = 1; i <= n && flg; ++i)
        for (reint j = 1; j <= n && flg; ++j)
            if (deltA[i] + deltB[j] != li[i][j])
                flg = 0;
    if (!flg) {
        puts("No");
    } else {
        puts("Yes");
        for (reint i = 1; i <= n; ++i)
            printf("%lld%c", deltA[i], " \n"[i == n]);
        for (reint i = 1; i <= n; ++i)
            printf("%lld%c", deltB[i], " \n"[i == n]);
    }
    return 0;
}

#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
vector<int> pr;
vector<int> ans;
bool prime[10001];
bool used[10001];

void dfs(int v,int sum){
	if(ans.size()==n)return;
	if(v==pr.size())return;
	//printf("%d %d %d\n",v,sum,pr[v]);
	int ko=pr[v];
	while(sum*ko<=10000 && !used[sum*ko]){
		if(v==pr.size())return;
		ans.push_back(sum*ko);
		used[sum*ko]=true;
		dfs(v+1,sum*ko);
		ko*=pr[v];
	}
	dfs(v+1,sum);
}

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

int main(void){
	scanf("%d",&n);
	memset(prime,true,sizeof(prime));
	for(int i=2;i<=5000;i++){
		if(prime[i]){
			pr.push_back(i);
			for(int j=i*2;j<=5000;j+=i){
				prime[j]=false;
			}
		}
	}
	for(int i=0;i<(1<<3);i++){
		int cnt=0;
		int res=1;
		for(int j=0;j<3;j++){
			if((i>>j) & 1){
				cnt++;
				res*=pr[j];
			}
		}
		if(cnt!=2)continue;
		ans.push_back(res);
		used[res]=true;
	}
	for(int i=0;i<3;i++){
		dfs(0,ans[i]);
	}
	for(int i=0;i<n;i++){
		printf("%d%c",ans[i],i+1==n?'\n':' ');
	}
	return 0;
}


///In the name of GOD
#include<bits/stdc++.h>
#define kill() return cout << -1, 0;
using namespace std;

typedef long long ll;
const ll MXN = 2e5 + 10;
ll n;
ll A[MXN];
vector<ll> ANS, vec;
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i ++) cin >> A[i];
    for(int i = 1; i < n; i ++){
        if(A[i] == i) kill();
        ll exp = i, j = i;
        while(j + 1 <= n && A[j] != exp) j ++;
        if(A[j] != exp) kill();
        vec.clear();
        for(int h = j - 1; h >= i; h --) vec.push_back(h);
        for(auto X : vec){
            swap(A[X], A[X + 1]);
            ANS.push_back(X);
        }
        for(int h = i; h < j; h ++){
            if(A[h] != h) kill();
        }
        i = j - 1;
    }
    for(auto X : ANS) cout << X << '\n';
    return 0;
}
/*!
    I CHOOSE TO HAVE FAITH,
    BECAUSE WITHOUT  THAT,
    I HAVE NOTHING....
    ITS THE ONLY THING THAT'S KEEPING ME GOING.
*/
//! N.N

#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>>
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("explicit.in","r",stdin);freopen("explicit.out","w",stdout)
#define pll pair <lli,lli>
#define vll vector <lli>
#define vpll vector <pll>
#define f first
#define s second
#define pb push_back
#define priq priority_queue
#define unm unordered_map
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld double
#define eb emplace_back
const long double pi = 3.1415926535898;
const lli mod=1e9+7;
//const lli mod=998244353;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
bool prime (lli k)
{
    if (k==1||k==0) return 0;
    bool flag=1;
    lli a=sqrt(k);
    for (int i=2;i<=a;i++)
    {
        if (k%i==0)
        {flag=0;break;}
    }
    return flag;
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i*i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=2*i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}

int main()
{
    fio;
    lli n;
    cin>>n;
    lli a[n],sum=0,maxi=0;
    ld avg=0;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
        a[i]=abs(a[i]);
        sum+=a[i];
        avg+=a[i]*a[i];
        maxi=max(maxi,a[i]);
    }
    avg=sqrt(avg);
    cout<<sum<<"\n"<<fixed<<setprecision(15)<<avg<<"\n"<<maxi;
    return 0;
}


#include<bits/stdc++.h>
#define R register
#define CN const
#define int long long
#define rint R int
#define cint CN int
#define sib 1048576
char buf[sib],*p1,*p2;
#define uc (p1==p2&&(p2=(p1=buf)+fread(buf,1,sib,stdin),p1==p2)?0:*p1++)
char pbuf[sib],*pp=pbuf;
inline void ph(const char s) {
	if(pp-pbuf==sib)fwrite(pbuf,1,sib,stdout),pp=pbuf;
	*pp++=s;
}
//#define uc getchar()
//#define ph putchar
#define ps ph(' ')
#define pe ph('\n')
using namespace std;
cint inf=998244353;
cint mix=1e6+5;
inline int in();
inline void out(rint x);
int n=in(),ans=0;
int fa[mix],ru[mix];
int que[mix],ft,bk;
bool vis[mix];
inline int ksm(rint x,rint y){
	rint rt=1;
	while(y){
		if(y&1)(rt*=x)%=inf;
		(x*=x)%=inf,y>>=1;
	}	return rt;
}
#undef int
int main() {
#define int long long
	for(rint i=1;i<=n;++i)++ru[fa[i]=in()];
	for(rint i=1;i<=n;++i)
	if(!ru[i])que[++bk]=i;
	while(ft<bk){
		rint x=que[++ft];
		vis[x]=1;
		--ru[fa[x]];
		if(!ru[fa[x]])
		que[++bk]=fa[x];
	}	for(rint i=1;i<=n;++i)
	if(!vis[i]){
		rint x=i;
		while(!vis[x])
		vis[x]=1,x=fa[x];
		++ans;
	}	out((ksm(2,ans)+inf-1)%inf),pe;
	fwrite(pbuf,1,pp-pbuf,stdout);
}
inline int in() {
	rint x=0;
	R bool f=0;
	R char s=uc;
	if(!s)return 0;
	while((s<'0'||'9'<s)&&s!='-')s=uc;
	if(s=='-')f=1,s=uc;
	while('0'<=s&&s<='9')(x*=10)+=s^48,s=uc;
	return f?-x:x;
}
inline void out(rint x) {
	if(x<0)ph('-'),x=-x;
	rint y=x/10;
	if(y)out(y);
	ph((x-y*10)^48);
}

/*
Solved by sid2104
on 11/11/2020  22:32
*/
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define float       long double
#define pb          push_back
#define ld          long double
#define f(i,a,b)    for(int i=a;i<b;i++)
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vpii         vector<pair<int,int> >
#define mii         map<int,int>
#define all(a)      (a).begin(),(a).end()
#define debug(x)    cout<<#x<<" is "<<(x)<<endl;cout.flush();
//#define debug(x)    ;
//#define debug(x)    ;
// === Debug macro starts here ===

int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
    os<<"[";
    for(auto& x:v){os<<x<<", ";}
    return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
    return os<<"{"<<p.first<<", "<<p.second<<"}";
}

// === Debug macro ends here ===
#define mp          make_pair
#define x           first
#define y           second
#define pb          push_back
#define endl        '\n'
#define si(x)       (int)((x).size())
#define IOS         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define txt         freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define elasped_time 1.0 * clock() / CLOCKS_PER_SEC
#define tree        vector<vector<int> >
#define PI          3.14159265358979323846
int inf=99999999999;
const int mod=1e9+7;
const int cmp=1e17;
inline int gcd(int a, int b) {
  while (a > 0 && b > 0) {
    if (a > b) a %= b;
    else b %= a;
  }
  return a + b;
}
void inp(int n,int arr[])
{
    f(i,0,n) cin>>arr[i];
}
int ans=0;
void solve()
{
  int sum=0;
  int curr=0;
  int currm=0;
  int n;
  cin>>n;
   f(i,0,n)
   {
     int k;
     cin>>k;
     curr+=k;

     currm=max(curr,currm);
     ans=max(ans,sum+currm);
     sum+=curr;

   }
   cout<<ans<<endl;

}
main()
{
    IOS;
    solve();

}


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

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

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

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

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

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

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

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

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

bool fun1(pair<pll, int> &x, pair<pll, int> &y)
{
	if (x.ff.ff == y.ff.ff)
	{
		return x.ff.ss < y.ff.ss;
	}
	return x.ff.ff < y.ff.ff;
}

bool fun2(pair<pll, int> &x, pair<pll, int> &y)
{
	if (x.ff.ss == y.ff.ss)
	{
		return x.ff.ff < y.ff.ff;
	}
	return x.ff.ss < y.ff.ss;
}

signed main()
{
	fast;

	int t = 1;
// 	cin >> t;
	f(tc, 1, t)
	{
		int n;
		cin >> n;
		pair<pll, int> a[n + 1];
		f(i, 1, n)
		{
			cin >> a[i].ff.ff >> a[i].ff.ss;
			a[i].ss = i;
		}
		vector<pll> v;
		int tk = min(n, 250LL);
		bool taken[n + 1] = {0};
		sort(a + 1, a + n + 1, fun1);
		f(i, 1, tk)
		{
			if (taken[a[i].ss])
			{
				continue;
			}
			v.pb({a[i].ff.ff, a[i].ff.ss});
			taken[a[i].ss] = 1;
		}
		reverse(a + 1, a + n + 1);
		f(i, 1, tk)
		{
			if (taken[a[i].ss])
			{
				continue;
			}
			v.pb({a[i].ff.ff, a[i].ff.ss});
			taken[a[i].ss] = 1;
		}
		sort(a + 1, a + n + 1, fun2);
		f(i, 1, tk)
		{
			if (taken[a[i].ss])
			{
				continue;
			}
			v.pb({a[i].ff.ff, a[i].ff.ss});
			taken[a[i].ss] = 1;
		}
		reverse(a + 1, a + n + 1);
		f(i, 1, tk)
		{
			if (taken[a[i].ss])
			{
				continue;
			}
			v.pb({a[i].ff.ff, a[i].ff.ss});
			taken[a[i].ss] = 1;
		}
		int mx1 = -inf, mx2 = -inf;
		f(i, 0, sz(v) - 1)
		{
			f(j, i + 1, sz(v) - 1)
			{
				int val = max(abs(v[j].ff - v[i].ff), abs(v[j].ss - v[i].ss));
				if (val > mx1)
				{
					mx2 = mx1;
					mx1 = val;
				}
				else if (val > mx2)
				{
					mx2 = val;
				}
			}
		}
		cout << mx2 << endl;
	}
	return 0;
}

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef long double db;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define np(str) next_permutation(str.begin(),str.end())
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define pi 3.14159265358979323846264338327950288419716939937510
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for(i=n-1;i>=0;i--)
#define rep(i,n) for(i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define at(s,pos) *(s.find_by_order(pos))
#define set_ind(s,val) s.order_of_key(val)
long long int M = 1e9 + 7 ;
long long int inf = 9 * 1e18;
//CLOCK
ll begtime = clock();
#define time() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//CLOCK ENDED
ll n, m;
// modular exponentiation
ll binpow(ll val, ll deg)
{
	if (deg < 0)
		return 0;
	if (!deg)
		return 1 % M;
	if (deg & 1)
		return binpow(val, deg - 1) * val % M;
	ll res = binpow(val, deg >> 1);
	return (res * res) % M;
}
//binomial
ll modinv(ll n) {
	return binpow(n, M - 2);
}
bool c1(pll a, pll b) {
	ll x = 2 * a.fi + a.se;
	ll y = 2 * b.fi + b.se;
	if (x > y) return true;
	else return false;
}
int main() {
	// your code goes here
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll i, j, t, k, x, y, z,  N;
	cin >> n;
	multiset<pair<ll, ll>, std::function<bool(const pair<ll, ll> &, const pair<ll, ll> &)>> s(c1); //c1 is a function
	ll sum = 0;
	rep(i, n) {
		cin >> x >> y;
		sum -= x;
		s.insert({x, y});
	}
	ll cnt = 0;
	// for (auto u : s) {
	// 	cout << u.fi << ' ' << u.se << '\n';
	// }
	while (sum <= 0) {
		auto itr = *s.begin();
		sum += 2 * itr.fi + itr.se;
		s.erase(s.begin());
		cnt++;
	}
	cout << cnt;

	return 0;

}


#include <bits/stdc++.h>
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define forx(i,x,n) for(int i=x;i<(int)n;i++)
#define ce(e,i,n) cout<<e<<" \n"[i==(int)n-1];
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N=5e2+2;
int a[N][N],vis[N][N],dr[4]={1,0,-1,0},dc[4]={0,1,0,-1},n,m;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//   = 0 -  [i] {} '\n'  p  _  ? ^
	string s;
	cin>>s;
	forn(i,s.size()){
		if(s[i]=='.')break;
		else cout<<s[i];
	}
}

#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    unsigned long long int N;
    cin>>N;
    unsigned long long int minans=2100000000000000000;
    unsigned long long int rui2=1;
    for(int i=0;i<64;i++){
        minans=min(minans,N/rui2+i+(rui2-1&N));
        rui2*=2;
    }
    cout<<minans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
const int MOD = 1000000007;

int main() {
    ll n;
    cin >> n;
    vector<ll> ans;
    FOR(i,2,((ll)sqrt(n))+1){
        ll j = i*i;
        while (j <= n){
            ans.push_back(j);
            j *= i;
        }
    }

    if (ans.size()==0){
        cout << n << endl;
        return 0;
    }

    sort(ALL(ans));
    ll cnt = 1;
    REP(i,ans.size()-1){
        if (ans.at(i) != ans.at(i+1)){
            cnt ++;
        }
    }
    cout << n - cnt << endl;
}

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

#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define foru(i, l, r) for(int i = l; i <= r; i++)
#define ford(i, r, l) for(int i = r; i >= l; i--)

typedef pair<int,int> ii;

const int N = 2005;
int n,a[N];
map<int,int> last;

int gcd(int a,int b) {
	return b ? gcd(b,a % b):a;
}

void local_run() {
	cin >> n;
	for (int i = 1;i <= n;i++) cin >> a[i];
	int mn = 1e9 + 7;
	for (int i = 1;i <= n;i++) {
		mn = min(mn,a[i]);
		for (int j = 1;j * j <= a[i];j++) {
			if (a[i] % j == 0) {
				last[j] = gcd(last[j],a[i]);
				last[a[i] / j] = gcd(last[a[i] / j],a[i]);
			}
		}
	}
	int ans = 1;
	for (ii x : last) {
		if (x.fi < mn && x.fi == x.se) ans++;
	}
	cout << ans;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	#ifdef localrun
		string f = "TEST";
		freopen(((string)f + ".inp").c_str(), "r", stdin);
		freopen(((string)f + ".out").c_str(), "w", stdout);
	#endif
	local_run();
}


#include<iostream>
using namespace std;

int main()
{
  int a;
  cin>>a;
  int b;
  cin>>b;
  int c;
  cin>>c;
  int d;
  cin>>d;
  int x =0;
  x = (a*d)-(b*c);
  cout<<x;
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define    For(i,n) for(int i=0;i<n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    nl     "\n"

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //test
    {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<(a*d)-(b*c);
    }
}


#include<bits/stdc++.h>
using namespace std;
const int BS=1e5+5;
char buf[BS],*S,*T;
inline char gc(){
	if(S==T)T=(S=buf)+fread(buf,1,BS,stdin);
	return S!=T?*(S++):EOF;
}
inline int in(){
	int x=0,f=1;char c=gc();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=gc();}
	while(c>='0'&&c<='9')x=x*10+c-48,c=gc();
	return x*f;
}
const int N=2e5+5,mod=998244353;
int n,a[N],cnt,ans=1,d[N];
bool vis[N],mark[N];
stack<int> s;
int main(){
    n=in();
    for(int i=1;i<=n;i++)a[i]=in(),d[a[i]]++;
    for(int i=1;i<=n;i++){
        int p=i;
        while(!vis[p])vis[p]=1,mark[p]=1,s.push(p),p=a[p];
        if(mark[p])ans=(ans+ans)%mod;
        while(s.size())mark[s.top()]=0,s.pop();
    }
    cout<<(ans+mod-1)%mod;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1<<24;
const ll INFL = (1ll << 60);
//cout << setprecision(20) <<

int n;
int coord[17][3];
int dp[1 << 17][17];

int rec(int S, int v) {
    if (dp[S][v] >= 0) {
        return dp[S][v];
    }

    if (S == (1 << n) - 1 && v == 0) {
        return dp[S][v] = 0;
    }

    int res = INF;
    for (int u = 0; u < n; u++) {
        if (!(S >> u & 1)) {
            int a, b, c, p, q, r;
            a = coord[v][0];
            b = coord[v][1];
            c = coord[v][2];
            p = coord[u][0];
            q = coord[u][1];
            r = coord[u][2];
            int dist = abs(a - p) + abs(b - q) + max(r - c, (int)0);
            res = min(res, rec(S | 1 << u, u) + dist);
        }
    }
    return dp[S][v] = res;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        ll x, y, z; cin >> x >> y >> z;
        coord[i][0] = x;
        coord[i][1] = y;
        coord[i][2] = z;
    }
    memset(dp, -1, sizeof(dp));
    cout << rec(0, 0) << endl;
}


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

using ll = long long;
using ld = long double;

string s[505];

const int MOD = 998244353;

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, m;
    cin >> n >> m;
    for(int i=0; i<n; i++){
        cin >> s[i];
    }
    int res = 1;
    for(int sm=0; sm<=n+m-2; sm++){
        int imap = 0;
        int iman = 0;
        for(int i=0; i<n; i++){
            int j = sm-i;
            if(j < 0 || j >= m) continue;
            if(s[i][j] == 'B') imap = 1;
            if(s[i][j] == 'R') iman = 1;
        }
        res = (res*(2-imap-iman))%MOD;
    }
    cout << res;
    return 0;
}

//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define MAXN 3001
ll dp[MAXN][MAXN];

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

    ll N; cin>>N;
    ll arr[N + 1];

    for(ll i=0;i<N;++i)
        cin>>arr[i + 1];

    for(ll i=0;i<=N;++i)
    {
        for(ll j=0;j<=N;++j)
        {
            dp[i][j] = 0;
        }
    }

    dp[0][0] = 1; //base case

    for(ll k=1;k<=N;++k)
    {
        ll sum = 0;
        ll memo[N + 1] = {}; //storing transtion results for current state (i, k)
        map<ll,ll> mp;
        mp[0] = 0;

        for(ll i=1;i<=N;++i)
        {
            sum += arr[i];
            sum %= k;

            if(mp.find(sum) != mp.end())
            {
                ll j = mp[sum];
                memo[i] = memo[j] + dp[j][k - 1];
                memo[i] %= MOD;
            }
            mp[sum] = i;
        }

        for(ll i=1;i<=N;++i)
            dp[i][k] = memo[i];
    }

    ll ans = 0;
    for(ll k=1;k<=N;++k)
    {
        ans += dp[N][k];
        ans %= MOD;
    }

    cout<<ans<<endl;
}


#include <iostream>
#include <string>
#include <vector>

int main(int argc, char *argv[]) {
  int h, w;
  std::cin >> h >> w;

  std::vector<std::string> ss(h);
  for (int i = 0; i < h; ++i) {
    std::cin >> ss[i];
  }

  int count = 0;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (ss[i].at(j) == '#') {
        continue;
      }

      if (j + 1 < w && ss[i].at(j + 1) != '#') {
        ++count;
      }

      if (i + 1 < h && ss[i + 1].at(j) != '#') {
        ++count;
      }
    }
  }

  std::cout << count << std::endl;

  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 128
char s[N][N];

int main(){
	int h, w; scanf("%d%d", &h, &w);
	REP(i, h) scanf("%s", s[i]);
	int ans = 0;
	REP(k, 2){
		REP(i, h) REP(j, w-1) if(s[i][j] == '.' && s[i][j+1]=='.') ans++;
		REP(i, N) REP(j, i) swap(s[i][j], s[j][i]);
		swap(h, w);
	}
	printf("%d\n", ans);
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const int INF = 1LL<<30;
struct edge{int to, cost;};
typedef pair<int,int> P;
struct graph{
  int V;
  vector<vector<edge> > G;
  vector<int> d;

  graph(int n){
    init(n);
  }

  void init(int n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(int s, int t, int cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }
  void add_edges(int s, int t, int cost){
    add_edge(s,t,cost);
    add_edge(t,s,cost);
  }

  void dijkstra(int s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      int v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
int main(){
  int R,C;cin>>R>>C;
  graph G(R*C);

  rep(i,R){
    rep(j,C-1){
      int A;cin>>A;
      G.add_edges(i*C+j,i*C+j+1,A);
    }
  }
  rep(i,R-1){
    rep(j,C){
      int A;cin>>A;
      G.add_edge(i*C+j,(i+1)*C+j,A);
    }
  }
  rep(j,C){
    rep(i,R){
      rep(k,i){
        G.add_edge(i*C+j,k*C+j,i-k+1);
      }
    }
  }
  G.dijkstra(0);
  cout<<G.d[(R*C)-1];
}

/*                                بِسْمِ اللَّـهِ الرَّحْمَـٰنِ الرَّحِيمِ

                                    ( إِنِ الْحُكْمُ إِلَّا لِلَّهِ )

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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef unsigned long long ull;
typedef long double ld;
const long double pi=acos(-1);
#define x           first
#define y           second
#define read(n,a)   for(int i=0;i<n;i++)cin>>a[i];
#define rep(i,z,n)  for(ll i=z;i<n;i++)
#define rrep(i,z,n) for(ll i=z-1;i>=n;i--)
#define all(v)      v.begin(),v.end()
#define clr(v,d)    memset(v,d,sizeof(v));

int  a[502][502];
int  b[502][502];

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

string s, ss;

ll n,m,k,w;
ll  ans ,ans1;
ll mod = 1e9 +7;

vector< vector<int> > ad[2][502][502]; //layer n m
int  an[2][502][502];
int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        cin>>n>>m;
        rep(i,1,n+1)rep(j,1,m)cin>>a[i][j];
        rep(i,1,n)rep(j,1,m+1)cin>>b[i][j];
        rep(i,1,n+1)
        {
            rep(j,1,m+1)
            {
                if(j<m)ad[0][i][j].push_back( {0,i,j+1,a[i][j]} );
                if(j>1)ad[0][i][j].push_back( {0,i,j-1,a[i][j-1]} );
                if(i<n)ad[0][i][j].push_back( {0,i+1,j,b[i][j]} );
                ad[0][i][j].push_back( {1,i,j,1} );
                if(i>1)ad[1][i][j].push_back( {1,i-1,j,1} );
                ad[1][i][j].push_back( {0,i,j,0} );
            }
        }
        clr(an,-1);
        priority_queue<vector<int> , vector<vector<int> > , greater<vector<int> > >q; //co , la ,i , j
        q.push({0,0,1,1});
        while(!q.empty())
        {
            int la = q.top()[1];
            int cost = q.top()[0];
            int i = q.top()[2];
            int j = q.top()[3];
            q.pop();
            if(~an[la][i][j])continue;
            an[la][i][j]=cost;
            for(vector<int> p : ad[la][i][j])if(an[p[0]][p[1]][p[2]] == -1)
            {
                q.push( { cost+p[3] , p[0] , p[1] , p[2] });
            }
        }
        cout<<an[0][n][m];
    }
    return 0;
}


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

int main() {

	int a,b,c;
	string ans;
	cin >> a >> b >> c;
	if(a * a + b * b < c * c)
	ans = "Yes";
    else
      ans = "No";

	cout << ans << endl;
}

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

int main(){
	long long int a,b,c;
	cin>>a>>b>>c;
	if((a*a + b*b)<(c*c)){
		cout<<"Yes\n";
	}else
	cout<<"No\n";
}


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

#define int           long long
#define ld            long double
const int mod =       1e9 + 7;
const int inf =       1e18;
#define vi            vector<int>
#define vs            vector<string>
#define pii           pair<int, int>
#define ump           unordered_map
#define pq_max        priority_queue<int>
#define pq_min        priority_queue<int, vi, greater<int>>
#define ff            first
#define ss            second
#define pb            emplace_back
#define loop(i, a, b)  for(int i = a; i < b; ++i)
#define rev(i, a, b)  for(int i = a; i > b; --i)
#define all(x)        x.begin(), x.end()
#define range(a, b)   substr(a, b - a + 1)
#define ps(x, y)      fixed << setprecision(y) << x
#define setbits(n)    __builtin_popcountll(n)
#define zerobits(n)   __builtin_ctzll(n)
mt19937               rng(chrono::steady_clock::now().time_since_epoch().count());

#define log(args...)  { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss);                  err(_it, args); }
#define logarr(arr)   for(auto &i : arr) cout << i << ' '; cout << '\n';
#define token(str,ch) (std::istringstream var((str)); vs v; string t; while(getline((var), t, (ch))) { v.pb(t); } return v;)
vs tokenizer(string str, char ch) { std::istringstream var((str)); vs v; string t; while (getline((var), t, (ch))) { v.pb(t); } return v; }

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

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

void solve() {
	double a, b;
	cin >> a >> b;

	double disc = (a - b);

	cout << disc / a * 100;
}

int32_t main() {
	clock_t begin = clock();
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

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

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

#ifndef ONLINE_JUDGE
	clock_t end = clock();
	cout << "\n\nExecuted In: " << double(end - begin) / CLOCKS_PER_SEC * 1000 << " ms";
#endif
	return 0;
}

#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T,class Size=typename vector<T>::size_type>inline auto vector_2d(Size h,Size w,T v){return vector<vector<T>>(h,vector<T>(w,v));}
template<class T>auto comp_pairs_by_second(){return[](const T&p1,const T&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);};}

int main()
{
    ll n=in(),m=in();
    vector<pair<ll,ll>>cond(m);
    for(ll i=0;i<m;++i){
        ll a=in(),b=in();
        cond[i]={a-1,b-1};
    }
    ll k=in();
    vector<pair<ll,ll>>person(k);
    for(ll i=0;i<k;++i){
        ll a=in(),b=in();
        person[i]={a-1,b-1};
    }
    ll ans=0;
    for(ll i=0;i<(1<<k);++i){
        ll tmp=0;
        vector<ll>foo(n);
        for(ll j=0;j<k;++j)++foo[(i>>j)&1?person[j].first:person[j].second];
        for(auto c:cond)if(foo[c.first]&&foo[c.second])++tmp;
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
}


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

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

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
typedef tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define cntleadz(x) __builtin_clz(x) // or add ll at the end for long long
#define cnttrailz(x) __builtin_ctx(x)
#define cntpop(x) __builtin_popcount(x)
#define binparity(x) __builtin_parity(x)
#define pb push_back
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
// #define mod 998244353
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)

int binExp(int x,int n)
{
    int res=1;
    while(n)
    {
        if(n&1) res=(res*x);
        x=(x*x);
        n>>=1;
    }
    return res;
}

// int fact[100001];
// int modInv(int i) {return binExp(i,mod-2);}
// int ncr(int n,int r) {return (n>=r?(fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod:0);}

int water[200005];

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

    int st,en;

    int flow;
    f1(i,1,n)
    {
        cin>>st>>en>>flow;
        st++;
        en++;
        water[st] += flow;
        water[en] -= flow;
    }

    bool yes = 1;
    f1(i,1,200003)
    {
        water[i] += water[i-1];
        yes &= water[i] <= w;
    }

    cout<<(yes ? "Yes" : "No");
}

signed main()
{
    fast

    clock_t start,end;
    #ifndef ONLINE_JUDGE
        freopen("inputf.txt","r",stdin);
        freopen("outputf.txt","w",stdout);
    #endif
    start = clock();

    // int z;
    // cin>>z;
    // f1(i,1,z)
    solve();

    end = clock();
    double time_taken = double(end-start) / double(CLOCKS_PER_SEC);
    // cout<<time_taken<<" sec";
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll N=1000000007;
//ll power(ll a,ll b,ll mod)
//{
//    ll result=1;
//    while(b>0)
//    {
//        if(b%2==1)
//            result=(result*a)%mod;
//        a=(a*a)%mod;
//        b=b/2;
//    }
//    return result;
//}
//ll d,x,y;
//void extendedEuclid(ll a,ll b)
//{
//    if(b==0)
//    {
//        d=a; x=1; y=0;
//    }
//    else
//    {
//        extendedEuclid(b,a%b);
//        ll temp=x; x=y; y=temp-(a/b)*y;
//    }
//}
//ll modInverse(ll a,ll m)
//{
//    extendedEuclid(a,m);
//    return (x%m+m)%m;
//}
//ll lcm(ll a,ll b)
//{
//    if(a==0||b==0)
//        return 0;
//    return (a*b)/(__gcd(a,b));
//}
//void sieve(ll n)
//{
//    bool isPrime[n+1];
//    isPrime[0]=false; isPrime[1]=false;
//    for(ll i=2;i<=n;i++)
//        isPrime[i]=true;
//    for(ll i=2;i*i<=n;i++)
//    {
//        if(isPrime[i]==true)
//        {
//            for(ll j=i*i;j<=n;j+=i)
//                isPrime[j]=false;
//        }
//    }
//}
//bool isPowerOfTwo(ll n)
//{
//    return (n&&!(n&(n-1)));
//}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,w,i,j=0,s,t,p,ans=0; cin>>n>>w;
    vector<pair<ll,ll> >v;
    for(i=0;i<n;i++){
        cin>>s>>t>>p;
        v.push_back(make_pair(s,p));
        v.push_back(make_pair(t,-p));
    }
    sort(v.begin(),v.end());
    for(i=0;i<v.size();i++){
        ans+=v[i].second;
        if(ans>w){
            cout<<"No"; j=1; break;
        }
    }
    if(j==0) cout<<"Yes";
}


#include <bits/stdc++.h>

#define kyou using
#define mo namespace
#define kawaii std

kyou mo kawaii; // hi honey~

#define ll long long
#define ld long double
#define endl "\n"
const int MX = 100005;
const int LG = (int)log2(MX) + 1;
const int BLOCK = 205;
const int inf = 1000000069;
const ll inf_ll = 8000000000000000069ll;
const ll mod = 1000000007;
const int alpha = 30;
const int dxh[] = {1, 1, -1, -1, 2, 2, -2, -2};
const int dyh[] = {2, -2, 2, -2, 1, -1, 1, -1}; // horse
const int dx[] = {1, -1, 0, 0, 0, 0};
const int dy[] = {0, 0, 1, -1, 0, 0}; // adj
const int dz[] = {0, 0, 0, 0, 1, -1}; // 3d
const int dxd[] = {1, 1, 1, 0, -1, -1, -1, 0};
const int dyd[] = {1, 0, -1, -1, -1, 0, 1, 1}; // diag
mt19937 rng(time(NULL));

bool untied = 0;
void setIn(string s){freopen(s.c_str(), "r", stdin);}
void setOut(string s){freopen(s.c_str(), "w", stdout);}
void unsyncIO(){cin.tie(0) -> sync_with_stdio(0);}
void setIO(string s = ""){
    if(!untied) unsyncIO(), untied = 1;
    if(s.size()){
        setIn(s + ".in");
        setOut(s + ".out");
    }
}

map<ll, int> mp[2];

int main(){
	setIO();

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

	vector<ll> owo(n + 1);
	owo[n] = 0; mp[n % 2][0] ++;
	for(int i = n - 1; i >= 0; i --){
		owo[i] = v[i] - owo[i + 1];
		mp[i % 2][owo[i]] ++;
	}

	ll ans = 0ll;

	for(int tp = 0; tp < 2; tp ++)
		for(auto i : mp[tp])
			ans += i.second * 1ll * (i.second - 1) / 2;

	for(auto i : mp[0]){
		int cntL = i.second, cntR = mp[1][-i.first];
		ans += cntL * 1ll * cntR;
	}

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

#include <bits/stdc++.h>
using namespace std;
#define fo(a,b) for(int64_t a=0;a<b;a++)
#define sor(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define ll int64_t
#define mod 1000000007
#define vl vector<int64_t>
#define vc vector<char>
#define vs vector<string>
#define np(vec) next_permutation(vec.begin(),vec.end())==true
#define en endl
#define vvl vector<vector<int64_t>>
#define stl stack<int64_t>
#define qul que<int64_t>
#define ms(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pq priority_queue
#define pql priority_queue<int64_t>
#define pu push
#define pop pop()
#define top top()
#define pqr priority_queue<ll,vector<ll>,greater<ll>>
#define co cout
#define ci cin
#define wh while
#define size size()
#define front front()

int main() {
 ll n,a;
  cin>>n;
  vl vec(n);
  fo(i,n){
    cin>>a;
    if(i%2==0){vec.at(i)=a;}
    else{vec.at(i)=-a;}
  }
  ll s=0;
  vl list;
  fo(i,n){
    s+=vec.at(i);
    list.push_back(s);
  }
  list.push_back(0);
   list.push_back(pow(10,17));
  sor(list);
  ll t=1;
  vl ans;
  fo(i,n+1){
    if(list.at(i)==list.at(i+1)){t++;}
    else{

      ans.push_back(t);
      t=1;
    }
  }
  ll si=ans.size;
  ll k=0;
  fo(i,si){
    k+=ans.at(i)*(ans.at(i)-1)/2;
  }
  cout<<k<<en;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
   ll n ; cin>>n;
   ll x = ((1.08)*(n));
   if(x == 206){
       cout<<"so-so"<<endl;
   }
   else{
        if(x > 206){
       cout<<":("<<endl;
   }
   else{
         cout<<"Yay!"<<endl;
   }
   }

}
int main(){

       solve();

}

/* -> Written by <-
   -----------
  |K_A_Z_A_M_A|
  |___________|
  |    ___    |
  |   (^_^)   |
  |  /( | )\  |
  |____|_|____|
    H O A N G
*/

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

#define Task            ""
#define F               first
#define S               second
#define eb              emplace_back
#define bit(x, i)       ((x >> (i)) & 1)
#define debug(x)        cerr << #x << " is " << x << "\n";
//#define int             ll

using namespace std;
using ll = long long;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

const ll MOD = 1e9 + 7;
const int base = 1000;
const int B = 32;
const int inf = 1e9 + 7;
const ll INF = 1e18 + 7;
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
const int dy8[] = {1, -1, 0, 1, -1, 0, 1, -1};
const int dx4[] = {0, 0, 1, -1};
const int dy4[] = {1, -1, 0, 0};

int n;

void solve(int test_case) {
    cin >> n;
    n = 108 * n / 100;
    if (n < 206)
        cout << "Yay!";
    else if (n == 206)
        cout << "so-so";
    else
        cout << ":(";
}

signed main(){
    cin.tie(0)->sync_with_stdio(0);
    if (fopen(".inp", "r")) {
        freopen(".inp", "r", stdin);
        freopen(".out", "w", stdout);
        freopen(".ou", "w", stderr);
    }
    else if (fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    int test_case = 1;
//    cin >> test_case;
//    prepare();
    for (int i = 1; i <= test_case; ++ i) {
        solve(i);
//        bf();
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define ld long double
#define rep(i,n) for (ll i = 0;i<(n);++i)
#define all(v) v.begin(),v.end()

template <typename T>bool chmax(T &a, const T& b) {if (a < b) {a = b;return true;}return false;}
template <typename T>bool chmin(T &a, const T& b) {if (a > b) {a = b;return true;}return false;}
vector<long long> divisor(long long n){vector<long long> res;long long i = 1;while (i*i<=n){if(n%i==0){res.push_back(i);}i++;}if(res.size()==0)return res;for(long long i = res.size()-1-(res.back()*res.back()==n);i>=0;--i){res.push_back(n/res[i]);}return res;}
long long safe_mod(long long x,long long m){x%=m;if(x<0){x+=m;}return x;}
long long modpow(long long x,long long n,long long mod){long long ans=1;while(n>0){if(n&1){ans*=x;ans%=mod;}n>>=1;x*=x;x%=mod;}return ans;}
long long intpow(long long x,long long n){long long ans=1;while(n>0){if(n&1){ans*=x;}n>>=1;x*=x;}return ans;}
template<typename T>T intpow(T x,T n){T ans=1;while(n>0){if(n&1){ans*=x;}n>>=1;x*=x;}return ans;}
vector<pair<long long,long long>> factor_lst(long long n){vector<pair<long long,long long>> factor_lst;long long d=2;while(d*d<=n){if(n%d==0){long long num=0;while(n%d==0){num+=1;n/=d;}factor_lst.push_back({d,num});}d+=1;}if(n!=1){factor_lst.push_back({n,1});}return factor_lst;}
#define Uniq(a) sort(all(a));a.erase(unique(all(a)),end(a))

int msb(int x){return x==0 ? -1:32-__builtin_clz(x);}//1-indexed
int lsb(int x){return x==0 ? 32:__builtin_ctz(x)+1;}//1-indexed
int popcnt(int x){return __builtin_popcount(x);}
int popcnt(long long x){return __builtin_popcount(x);}

bool ingrid(int i,int j,int H,int W){
    return 0<=i&&i<H&&0<=j&&j<W;
}

const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
template<typename T> void print(vector<T> &v){for(int i=0;i<v.size();++i){if(i)cout<<" ";cout<<v[i];}cout<<endl;}
template<typename T> void print(T* v,int size){for(int i=0;i<size;++i){if(i)cout<<" ";cout<<v[i];}cout<<endl;}
template<typename T,typename S>void print(pair<T,S>&p){cout<<p.first<<" "<<p.second<<endl;}
const ll LINF=4*1e18;
const ll MINF=5*1e15;
const int INF=2*1e9;
const ld PI=acosl(-1);

void Main();
int main(){cout<<fixed<<setprecision(15);Main();}

void Main(){

ll t,N;cin>>t>>N;
for(ll x=100*N;x<100*N+99;++x){
  if(x%t==0){
    x/=t;
    cout<<x+t*x/100-1<<endl;
    return;
  }
}

}

#include "bits/stdc++.h"

using namespace std;

#define endl '\n'
#define debug(x) cerr << #x << " == " << (x) << '\n';
#define all(x) begin(x), end(x)

using ll = long long;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

template<ll mod>
struct Mint {
    ll x;
    Mint(ll x = 0) : x((x %= mod) < 0 ? x + mod : x) { }
    Mint& operator+=(Mint rhs) { return (x += rhs.x) >= mod ? x -= mod : 0, *this; }
    Mint& operator-=(Mint rhs) { return (x -= rhs.x) < 0 ? x += mod : 0, *this; }
    Mint& operator*=(Mint rhs) { return (x *= rhs.x) %= mod, *this; }
    Mint& operator/=(Mint rhs) { return *this *= rhs.power(-1); }
    Mint power(ll p) const {
        p %= mod - 1;
        if (p < 0) p += mod - 1;
        Mint res = 1;
        for (Mint y = *this; p; p >>= 1, y *= y) if (p & 1) res *= y;
        return res;
    }
    bool operator==(Mint rhs) const { return x == rhs.x; }
    bool operator<(Mint rhs) const { return x < rhs.x; }
    friend Mint operator+(Mint lhs, Mint rhs) { return lhs += rhs; }
    friend Mint operator-(Mint lhs, Mint rhs) { return lhs -= rhs; }
    friend Mint operator*(Mint lhs, Mint rhs) { return lhs *= rhs; }
    friend Mint operator/(Mint lhs, Mint rhs) { return lhs /= rhs; }
    friend ostream& operator<<(ostream& out, Mint a) { return out << a.x; }
    friend istream& operator>>(istream& in, Mint& a) {
        ll x;
        in >> x;
        a = Mint(x);
        return in;
    }
};

constexpr ll mod = 998244353;
using mint = Mint<mod>;

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

    int H, W;
    cin >> H >> W;

    vector<string> S(H);
    for (auto& s : S) cin >> s;

    vector<array<int, 3>> cnt(H + W - 1);

    map<char, int> Id = {{'.', 0}, {'B', 1}, {'R', 2}};

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cnt[i + j][Id[S[i][j]]] += 1;
        }
    }

    mint ans = 1;
    for (int d = 0; d < H + W - 1; ++d) {
        if (cnt[d][1] && cnt[d][2]) {
            ans = 0;
            break;
        }
        if (cnt[d][0] > 0 && max(cnt[d][1], cnt[d][2]) == 0) ans *= 2;
    }

    cout << ans << endl;

    exit(0);
}


#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
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;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

//for(i=0; i<N; i++) cin >> a[i];

int main(void) {
  ll i, j, k, l;

  ll N, M;
  cin >> N >> M;
  ll h[MAX*2], w[MAX*2];
  ll s[MAX*2]={}, t[MAX*2]={};

  h[0]=-INF; h[N+1]=INF;
  for(i=1; i<=N; i++) cin >> h[i];
  sort(h+1, h+N+1);
  for(i=0; i<M; i++) cin >> w[i];

  for(i=2; i<=N; i++) {
    if(i&1)
      s[i]=s[i-1];
    else
      s[i]+=s[i-2]+abs(h[i]-h[i-1]);
  }

  for(i=3; i<=N; i++) {
    if(i&1)
      t[i]+=t[i-2]+abs(h[i]-h[i-1]);
    else
      t[i]=t[i-1];

  }

  ll ans=INF;
  for(i=0; i<M; i++) {
    ll p=upper_bound(h, h+N+2, w[i])-h-1;

    if(p==0)
      chmin(ans, abs(w[i]-h[1])+t[N]);
    else if(p==N+1)
      chmin(ans, s[N-1]+abs(w[i]-h[N]));
    else if(p&1)
      chmin(ans, s[p-1]+abs(w[i]-h[p])+t[N]-t[p]);
    else
      chmin(ans, s[p]+abs(w[i]-h[p+1])+t[N]-t[p+1]);

  }
  pt(ans);

}

// Template
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <tuple>
#include <utility>
#include <queue>
#include <set>
#include <map>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll infll = 3003003003003003003LL;
template <typename T>
inline bool chmin(T &x, const T &y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T>
inline bool chmax(T &x, const T &y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &element : vec) is >> element;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    for (int i = 0, vec_len = (int)vec.size(); i < vec_len; ++i) {
        os << vec[i] << (i + 1 == vec_len ? "" : " ");
    }
    return os;
}
struct IOSET {
    IOSET() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
    }
} ioset;

// Mod-Int
#include <iostream>

template <unsigned int mod>
struct ModInt {
    static_assert(mod >= 1 && mod < (1u << 31));

    unsigned int val;

    ModInt() : val(0) {}

    ModInt(long long x) : val(x < 0 ? x % mod + mod : (unsigned long long)x % mod) {}

    ModInt<mod> &operator+=(const ModInt<mod> &x) {
        val += x.val;
        if (val >= mod) val -= mod;
        return *this;
    }

    ModInt<mod> &operator-=(const ModInt<mod> &x) {
        if (val < x.val) val += mod;
        val -= x.val;
        return *this;
    }

    ModInt<mod> &operator*=(const ModInt<mod> &x) {
        unsigned long long s = (unsigned long long)val * x.val;
        val = (unsigned int)(s % mod);
        return *this;
    }

    ModInt<mod> operator+() const {
        return *this;
    }

    ModInt<mod> operator-() const {
        return ModInt<mod>(0u) - *this;
    }

    friend ModInt<mod> operator+(const ModInt<mod> &x, const ModInt<mod> &y) {
        return ModInt<mod>(x) += y;
    }

    friend ModInt<mod> operator-(const ModInt<mod> &x, const ModInt<mod> &y) {
        return ModInt<mod>(x) -= y;
    }

    friend ModInt<mod> operator*(const ModInt<mod> &x, const ModInt<mod> &y) {
        return ModInt<mod>(x) *= y;
    }

    friend std::istream &operator>>(std::istream &is, ModInt<mod> &x) {
        is >> x.val;
        // x.value %= mod;
        return is;
    }

    friend std::ostream &operator<<(std::ostream &os, const ModInt<mod> &x) {
        os << x.val;
        return os;
    }

    ModInt<mod> pow(unsigned long long x) const {
        ModInt<mod> res(1), s(*this);
        while (x) {
            if (x & 1) res *= s;
            s *= s;
            x >>= 1;
        }
        return res;
    }

    // --- prime number ---
    ModInt<mod> &operator/=(const ModInt<mod> &x) {
        *this *= x.pow(mod - 2);
        return *this;
    }

    friend ModInt<mod> operator/(const ModInt<mod> &x, const ModInt<mod> &y) {
        return ModInt<mod>(x) /= y;
    }
};

// Main
int main() {
    constexpr unsigned mod = 1000000007;
    int n, p;
    cin >> n >> p;
    cout << ModInt<mod>(p - 1) * ModInt<mod>(p - 2).pow(n - 1) << "\n";
}


#include <bits/stdc++.h>

using namespace std;
template <typename T> using triple = std::tuple<T, T, T>;

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

  int n;
  cin >> n;
  vector<int> X(n), Y(n);
  for(int i = 0; i < n; i++) {
    cin >> X[i] >> Y[i];
  }

  vector<triple<int>> edges;
  int st = n, en = n + 1;

  for(int i = 0; i < n; i++) {
    for(int j = i + 1; j < n; j++) {
      int dx = X[i] - X[j], dy = Y[i] - Y[j];
      int d = dx * dx + dy * dy;
      edges.emplace_back(d, i, j);
    }
    int top = Y[i] + 100, bottom = 100 - Y[i];
    top *= top, bottom *= bottom;
    edges.emplace_back(top, st, i);
    edges.emplace_back(bottom, i, en);
  }
  sort(edges.begin(), edges.end());

  vector<int> p(n + 2), si(n + 2, 1);
  iota(p.begin(), p.end(), 0);

  auto trace = [&](int u) {
    while(u != p[u]) u = p[u] = p[p[u]] = p[p[p[u]]] = p[p[p[p[u]]]];
    return u;
  };

  auto unite = [&](int u, int v) {
    if((u = trace(u)) != (v = trace(v))) {
      if(si[u] > si[v]) swap(u, v);
      p[u] = v;
      si[v] += si[u];
    }
  };

  for(auto [d, x, y] : edges) {
    unite(x, y);
    if(trace(st) == trace(en)) {
      cout << sqrt(d) / 2 << '\n';
      return 0;
    }
  }
  assert(false);
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

struct UnionFind{
  vi par;
  vi rank;
  vi sz;

  UnionFind(int n=1){
    init(n);
  }

  // n要素で初期化
  void init(int n=1){
    par.resize(n);
    rank.resize(n);
    sz.resize(n);
    REP(i, n){
      par[i]=i;
      rank[i]=0;
      sz[i]=1;
    }
  }

  // xの根を求める
  int find(int x){
    if(par[x]==x){
      return x;
    }
    else{
      return par[x]=find(par[x]);
    }
  }

  // xとyが属する集合を併合
  bool unite(int x, int y){
    x=find(x);
    y=find(y);
    if(x==y){
      return false;
    }
    int szx=sz[x], szy=sz[y];
    if(rank[x]<rank[y]){
      par[x]=y;
      sz[y]=szx+szy;
    }
    else{
      par[y]=x;
      sz[x]=szx+szy;
      if(rank[x]==rank[y]){
        ++rank[x];
      }
    }
    return true;
  }

  // xとyが同じ集合に属するか判定
  bool issame(int x, int y){
    return find(x)==find(y);
  }
};

struct edge{
  double d;
  int from;
  int to;
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(10)<<fixed;
  int n;
  double x[125], y[125];
  cin>>n;
  vector<edge> es;
  REP(i, n){
    cin>>x[i]>>y[i];
    es.push_back({(100-y[i])/2, 0, i+1});
    es.push_back({(y[i]-(-100))/2, i+1, n+1});
  }
  REP(i, n){
    FOR(j, i+1, n){
      es.push_back({hypot(x[i]-x[j], y[i]-y[j])/2, i+1, j+1});
    }
  }
  sort(ALL(es), [](edge a, edge b){
    return a.d<b.d;
  });
  UnionFind uf(n+2);
  for(auto& e : es){
    uf.unite(e.from, e.to);
    // DEBUG(e.from);
    // DEBUG(e.to);
    // DEBUG(e.d);
    // DEBUG(uf.sz[uf.find(e.from)]);
    if(uf.issame(0, n+1)){
      cout<<e.d<<'\n';
      return 0;
    }
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ullvect2d = vector<vector<ull>>;
using pairsull = pair<string,ull>;
#define loop(i,n) for(ull i=0;i<n;i++)

ull x,y;
ullvect2d tile(50, vector<ull>(50));
ullvect2d score(50, vector<ull>(50));
vector<ull> tap;

bool has(ull x){
  auto itr = find(tap.begin(),tap.end(),x);
  size_t idx = distance(tap.begin(),itr);
  return idx != tap.size();
}
bool canUp(){
  if(y==0){ return false; }
  return !has(tile[y-1][x]);
}
bool canDown(){
  if(y==49){ return false; }
  return !has(tile[y+1][x]);
}
bool canLeft(){
  if(x==0){ return false; }
  return !has(tile[y][x-1]);
}
bool canRight(){
  if(x==49){ return false; }
  return !has(tile[y][x+1]);
}
bool canMove(){ return canUp() || canDown() || canLeft() || canRight(); }
void moveUp(){ y--; cout << "U"; }
void moveDown(){ y++; cout << "D"; }
void moveLeft(){ x--; cout << "L"; }
void moveRight(){ x++; cout << "R"; }
void move1(){  // 右下
  if(canDown()){ moveDown(); }
  else if(canRight()){ moveRight(); }
  else if(canUp()){ moveUp(); }
  else if(canLeft()){ moveLeft(); }
}
void move2(){  // 左下
  if(canDown()){ moveDown(); }
  else if(canLeft()){ moveLeft(); }
  else if(canUp()){ moveUp(); }
  else if(canRight()){ moveRight(); }
}
void move3(){  // 右上
  if(canUp()){ moveUp(); }
  else if(canRight()){ moveRight(); }
  else if(canDown()){ moveDown(); }
  else if(canLeft()){ moveLeft(); }
}
void move4(){  // 左上
  if(canUp()){ moveUp(); }
  else if(canLeft()){ moveLeft(); }
  else if(canDown()){ moveDown(); }
  else if(canRight()){ moveRight(); }
}
void move5(){  // 上
  if(canUp()){ moveUp(); }
  else if(canDown()){ moveDown(); }
  else if(canRight()){ moveRight(); }
  else if(canLeft()){ moveLeft(); }
}
void move6(){  // 左
  if(canLeft()){ moveLeft(); }
  else if(canRight()){ moveRight(); }
  else if(canUp()){ moveUp(); }
  else if(canDown()){ moveDown(); }
}
void move7(){  // 下
  if(canDown()){ moveDown(); }
  else if(canUp()){ moveUp(); }
  else if(canRight()){ moveRight(); }
  else if(canLeft()){ moveLeft(); }
}
void move8(){  // 右
  if(canRight()){ moveRight(); }
  else if(canLeft()){ moveLeft(); }
  else if(canUp()){ moveUp(); }
  else if(canDown()){ moveDown(); }
}
void bestmove(){
  vector<pairsull> a;
  if(canUp()){ a.push_back(make_pair("U",score[y-1][x])); }
  if(canDown()){ a.push_back(make_pair("D",score[y+1][x])); }
  if(canLeft()){ a.push_back(make_pair("L",score[y][x-1])); }
  if(canRight()){ a.push_back(make_pair("R",score[y][x+1])); }
  sort(a.begin(),a.end(),[](const pairsull &b,const pairsull &c){return b.second > c.second;});
  pairsull bestMove = a[0];
  if(bestMove.first == "U"){ moveUp(); }
  else if(bestMove.first == "D"){ moveDown(); }
  else if(bestMove.first == "L"){ moveLeft(); }
  else if(bestMove.first == "R"){ moveRight(); }
}

int main(){
  cin >> y >> x;
  loop(i,50){
    loop(j,50){
      cin >> tile[i][j];
    }
  }
  loop(i,50){
    loop(j,50){
      cin >> score[i][j];
    }
  }
  while(true){
    tap.push_back(tile[y][x]);
    if(canMove()){
      if(x<20 && y<20){ move1(); }
      else if(x<30 && y<20){ move7(); }
      else if(x<50 && y<20){ move2(); }
      else if(x<20 && y<30){ move8(); }
      else if(x<30 && y<30){ bestmove(); }
      else if(x<50 && y<30){ move6(); }
      else if(x<20 && y<50){ move3(); }
      else if(x<30 && y<50){ move5(); }
      else if(x<50 && y<50){ move4(); }
    }
    else{ break; }
  }
  cout << endl;
  return 0;
}

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

#define F                   first
#define S                   second
#define int                 long long int
#define pb                  push_back
#define mp                  make_pair
#define pii                 pair<int,int>
#define vi                  vector<int>
#define mii                 map<int,int>
#define pqb                 priority_queue<int>
#define pqs                 priority_queue<int,vi,greater<int> >
#define mod                 1000000007
#define endl                '\n'
#define rep(i,a,b)            for(int i=a;i<b;i++)
#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void solve() {
	int n, k;
	cin >> n >> k;
	int a[n];
	int b[n];
	vector<pii> v;

	rep(i, 0, n) {
		cin >> a[i] >> b[i];
		v.pb({a[i], b[i]});
	}
	sort(v.begin(), v.end());
	int cur = 0;
	int left = k;
	rep(i, 0, n) {
		//db(cur, left);
		if (v[i].F - cur > left) {
			break;
		}
		else {
			left = left - (v[i].F - cur) + v[i].S;
			cur = v[i].F;
		}
	}
	//db(cur, left);
	int ans = cur + left;
	cout << ans << endl;
}
int32_t main()
{
	//c_p_c();
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
struct Node;
vector<Node> V;
int cnt = 0;
struct Node {
  int idx;
  int d = 0;
  int ans = 0;
  int next = -1;
  vector<int> nbr;
  bool vst = false;
  void dfs(int _d) {
    vst = true;
    d = _d;
    for(int x : nbr) if(!V[x].vst) V[x].dfs(d+1);
  };
  int dfs2(int _t) {
    vst = true;
    for(int x : nbr) if(!V[x].vst) {
      int ret = V[x].dfs2(_t);
      if(ret != -1) next = ret;
    }
    if(idx == _t || next != -1) return idx;
    else return -1;
  }
  void dfs3() {
    vst = true;
    cnt++;
    ans = cnt;
    for(int x : nbr) if(x != next && !V[x].vst) {
      V[x].dfs3();
      cnt++;
    }
    if(next != -1) V[next].dfs3();
  }
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  V = vector<Node>(N);
  REP(i, N) V[i].idx = i;
  REP(i, N-1) {
    int A, B;
    cin >> A >> B;
    A--; B--;
    V[A].nbr.push_back(B);
    V[B].nbr.push_back(A);
  }
  V[0].dfs(0);
  int s = 0;
  int ma = -1;
  REP(i, N) if(V[i].d > ma) {
    ma = V[i].d;
    s = i;
  }
  REP(i, N) V[i].vst = false;
  V[s].dfs(0);
  int t = 0;
  ma = -1;
  REP(i, N) if(V[i].d > ma) {
    ma = V[i].d;
    t = i;
  }
  REP(i, N) V[i].vst = false;
  V[s].dfs2(t);
  REP(i, N) V[i].vst = false;
  V[s].dfs3();
  REP(i, N) cout << V[i].ans << (i!=N-1 ? " " : "");
  cout << "\n";
}

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

const int maxn=200005;

int n;
vector<int>adj[maxn];
int dp[maxn],dpt[maxn];
int mxv,mu,mv;
void dfs(int u,int f){
    dp[u]=0;dpt[u]=u;
    for(int v:adj[u])if(v!=f){
        dfs(v,u);
        if(dp[u]+dp[v]+1>mxv){
            mxv=dp[u]+dp[v]+1;
            mu=dpt[u];mv=dpt[v];
        }
        if(dp[v]+1>dp[u]){
            dp[u]=dp[v]+1;
            dpt[u]=dpt[v];
        }
    }
}
bool dfs1(int u,int f){
    int id=-1;
    for(int v:adj[u])if(v!=f){
        if(dfs1(v,u)){
            id=v;
        }
    }
    if(id!=-1){
        adj[u].erase(find(adj[u].begin(),adj[u].end(),id));
        adj[u].push_back(id);
    }
    return u==mv||id!=-1;
}
int cnt=0;
int ans[maxn];

void dfs2(int u,int f){
    ans[u]=cnt+1;
    for(int v:adj[u])if(v!=f){
        cnt++;
        dfs2(v,u);
        cnt++;
    }
}
int main(){
    cin>>n;
    for(int i=1;i<n;i++){
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);adj[v].push_back(u);
    }
    mxv=0;mu=mv=1;
    dfs(1,0);
    dfs1(mu,0);
    dfs2(mu,0);
    for(int i=1;i<=n;i++)cout<<ans[i]<<' ';
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io;

#pragma GCC optimize(2)
#define int ll
using ll = long long;
using db = long double;
using pi = pair<int, int>;
using mi = map<int, int>;
using vi = vector<int>;
#define fi first
#define se second
#define eb emplace_back
#define vt vector
#define sz size()
#define be begin()
#define rbe rbegin()
#define all(x) x.begin(), x.end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)
#define per(i, r, l) for (int i = (r); i >= (l); --i)

void prl() {cout << '\n';} template <class T, class ...U> void prl(T x, U ...y) {cout << x << ' ', prl(y...);}

template <class T, class U> ostream &operator << (ostream &out, pair<T, U> p) { return out << "(" << p.fi << ", " << p.se << ")"; }
template <class T> ostream &operator << (ostream &out, vt<T> &v) { out << "{"; rep(i, 0, v.sz) { if (i) out << ", "; out << v[i]; } return out << "}"; }
#ifdef LOCAL
#define dbg(...) prl(__VA_ARGS__), cout.flush()
#define __int128 ll
#else
#define dbg(...) 233
#endif

const int N = 2e5 + 5, M = 1e9 + 7;
using ull = unsigned long long;

int a[N], fa[N];

int Find(int x) {
	if (fa[x] == x) return x;
	return fa[x] = Find(fa[x]);
}
map<int, int> cnt[N];

signed main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		cnt[i + 1][x] = 1;
	}
	iota(fa, fa + n + 1, 0);
	while (m--) {
		int op, x, y;
		cin >> op >> x >> y;
		if (op == 1) {
			x = Find(x), y = Find(y);
			if (x == y) continue;
			fa[x] = y;
			if (cnt[y].sz < cnt[x].sz) swap(cnt[x], cnt[y]);
			for (auto &p : cnt[x]) {
				cnt[y][p.fi] += p.se;
			}
		} else {
			x = Find(x);
			if (cnt[x].count(y)) {
				cout << cnt[x][y];
			} else {
				cout << 0;
			}
			cout << '\n';
		}
	}
}

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)

//#define ATCODER
#ifdef ATCODER
#include<atcoder/all>
using namespace atcoder;
#endif

#include <algorithm>
#include <utility>
#include <vector>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>
#include <numeric>
#include <type_traits>

using namespace std;

#ifdef _MSC_VER
#include"stdafx.h"
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << (H);
	debug_out(T...);
}
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define DEBUG(...) 42
#endif

#define ll long long
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREVERSE(v) reverse(v.begin(), v.end())

#define print(x) cout << (x) << '\n'
#define spa <<" "<<
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline bool chmin(T1 & a, T2 b) { if (a > b) { a = b; return true; }return false; }
template <typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return true; }return false; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 400040;
const double pi = acos(-1);
constexpr long double EPS = 1e-14;
const int dx[4] = { 0,0,-1,1 }, dy[4] = { -1,1,0,0 };
using ld = long double;

struct edge {
	int from, to;
};
vector<edge>es;
vector<int>G[200020];
int par[200020];
void init_dfs(int n) {
	for (auto nxt : G[n]) {
		if (nxt == par[n])continue;
		par[nxt] = n;
		init_dfs(nxt);
	}
}

int C[200020];

void dfs(int n) {
	for (auto nxt : G[n]) {
		if (nxt == par[n])continue;
		C[nxt] += C[n];
		dfs(nxt);
	}
}

void solve() {
	int N; cin >> N;
	REP(_, N - 1) {
		int u, v; cin >> u >> v;
		u--, v--;
		G[u].push_back(v);
		G[v].push_back(u);
		es.push_back({ u,v });
	}
	init_dfs(0);
	int Q; cin >> Q;
	REP(_, Q) {
		int t, e, x; cin >> t >> e >> x;
		e--;
		int a = es[e].from, b = es[e].to;
		if (t == 2)swap(a, b);
		DEBUG(a+1, b+1, x);
		if (a == par[b]) {
			C[0] += x;
			C[b] -= x;
		}
		else {
			C[a] += x;
		}
	}
	dfs(0);
	REP(i, N) {
		print(C[i]);
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}


/*
problem :
algorithm :
created : Programmer_juruo
*/

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

#define int unsigned long long
#define N 100005
#define lowbit(x) x & (-x)
#define Rep2(i, n) for(int i = 1; i <= n; i++)
#define rep(i, a, n) for(int i = a; i <= n; i++)
#define Rep(i, n) for(int i = 0; i < n; i++)
#define dbg(x) cout << #x << ":" << x << endl;
#define Se second
#define Fi first
#define Mp make_pair
#define Pb push_back
typedef pair<int, int> Pii;
typedef priority_queue<int> Pq;
typedef long long ll;

int n, m;

inline ll Read() {
	ll y = 0, f = 1;char c = getchar();
	while(!isdigit(c)){if(c == '-') f = -1;c = getchar();}
	while(isdigit(c)) {y = y*10 + (c - '0'), c = getchar();}
	return y*f;
}
inline void read(int &x){x = Read();}
int y[N];
char x[N];
int Max() {
	int d = 0;
	Rep(i, n) d = max(d, y[i]);
	return d;
}

bool Check(int M) {
	int Ret = 0;
	int base = 1;
	Rep(i, n) {
		if(base * y[i] > m) return false;
		Ret += base * y[i];
		if(Ret > m) return false;
		if(i < n-1) {
			if(base > m/M) return false;
			base *= M;
		}
	}
	return Ret <= m;
}

void work() {
	scanf("%s", x);
	cin >> m;
	n = strlen(x);
	reverse(x, x+n);
	Rep(i, n) y[i] = x[i]-'0';
	if(n == 1) {
		if(y[0] <= m) cout << 1 << endl;
		else cout << 0 << endl;
		return ;
	}
	int l = Max()+1, r = m, ans = 0;
	while(l <= r) {
		int M = (l+r) / 2;
		if(Check(M)) {
			l = M+1;
			ans = M-Max();
		} else {
			r = M-1;
		}
	}
	cout << ans << endl;
}

signed main() {
  //freopen("1.in", "r", stdin);
  //freopen("1.out", "w", stdout);
  int T = 1;

  //cin >> T;

  while(T--) {
  	work();
  }

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

int mul(int a,int b,int m){
	int cur=0;

	while(b>0){
		if(b&1)cur+=a;
		if(cur > m){
			return -1;
		}
		a*=2;
		b/=2;
		if(b>0 and a > m){
			return -1;
		}
	}

	return cur;
}

bool solve(int base,string &x,int m){
	int num=0;
	int curPow=1;
	for(int i=0;i<x.size();i++){

		int temp = mul((x[i]-'0'),curPow,m);
		if(temp<0)return 0;

		num += temp;

		if(num > m){
			return 0;
		}
		temp=mul(curPow,base,m);

		if(temp<0 and i+1<x.size()){

			return 0;
		}

		curPow=temp;
	}

	return 1;
}

signed main(){
//	ios_base::sync_with_stdio(0) , cin.tie(0);

	string x;
	int m;

	cin>>x;
	cin>>m;
	if(x.size()==1){
		if(x[0]-'0' > m){
			cout<<0<<endl;
		}else cout<<1<<endl;
		return 0;
	}
	int freq[10]{0};
	reverse(x.begin(),x.end());

	for(int i=0;i<x.size();i++){
		freq[x[i]-'0']++;
	}

	int maxy=0;
	for(int i=9;i>=0;i--){
		if(freq[i]>0){
			maxy=i;
			break;
		}
	}
	int l=maxy,r=1e18;
	r++;
	while(l+1<r){
		int mid=(l+r)/2;
		if(maxy != mid and solve(mid,x,m)){
			l=mid;
		}else{
			r=mid;
		}
	}
	cout<<l-maxy<<endl;

	return 0;
}


///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           nd(a,b,c)                   mp(mp(a,b),c)
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=2e18;
const int mod=1e9+7;
const int M=200005;
int n,x[M],y[M];
bool cmp1(int i,int j)
{
    if(x[i]==x[j])return y[i]<y[j];
    else return x[i]<x[j];
}
bool cmp2(int i,int j)
{
    if(y[i]==y[j])return x[i]<x[j];
    else return y[i]<y[j];
}
set< pair<int,pi> >s;
set< pair<int,pi> >::iterator it;
void work(int i,int j)
{
    int cost=max(abs(x[j]-x[i]),abs(y[j]-y[i]));
    if(i<j)s.insert({cost,{i,j}});
    else s.insert({cost,{j,i}});
}
void solve()
{
   cin>>n;
   vector<int>vec;
   f(i,1,n)
   {
       cin>>x[i]>>y[i];vec.pb(i);
   }
   sort(vec.begin(),vec.end(),cmp1);
   work(vec[0],vec[n-1]);
   work(vec[0],vec[n-2]);
   work(vec[1],vec[n-1]);

   sort(vec.begin(),vec.end(),cmp2);
   work(vec[0],vec[n-1]);
   work(vec[0],vec[n-2]);
   work(vec[1],vec[n-1]);

   it=s.end();
   it--;it--;
   cout<<it->fi<<endl;
}

 main()

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

}

#include <bits/stdc++.h>

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; ++i)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; --i)

template <typename Tp> void in(Tp &x) {
  char ch = getchar(), f = 1; x = 0;
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') f = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= f;
}

template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}
template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}

LL n; int m;

int power(int x, LL y, int p) {
  int ret = 1; x %= p;
  while (y) {
    if (y & 1) ret = 1ll * ret * x % p;
    x = 1ll * x * x % p;
    y >>= 1;
  }
  return ret;
}

int main() {
  in(n); in(m);

  int t = power(10, n, m);
  int sb = (power(10, n, m * m) - t + m * m) % (m * m);

  printf("%d\n", (sb / m) % m);

  return 0;
}