#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
#define scl(n) scanf("%lld", &n)
#define pcl(n) printf("%lld\n", n)
#define pcl1(n) printf("%lld ", n)
#define nln printf("\n")
#define dev(x) cout << #x << " " << x << " ";
#define PTT pair<ll, ll>

map<ll, ll> mp, mp1;
map<ll, ll>::iterator itr;

int main()
{
    ll t, n, k, x, m;
    vector<PTT> v;
    scl(n);
    scl(m);
    scl(t);
    PTT p;
    for (int i = 0; i < m; i++)
    {
        scl(p.first);
        scl(p.second);
        v.push_back(p);
    }
    ll charge = n, tmp = 0;
    bool bl = true;
    for (int i = 0; i < m; i++)
    {
        charge -= (v[i].first - tmp);
        if (charge <= 0)
        {
            bl = false;
        }

        //cout << charge << " ";
        charge += (v[i].second - v[i].first);
        if (charge >= n)
        {
            charge = n;
        }

        //cout << charge << endl;
        tmp = v[i].second;
    }
    charge -= (t - tmp);
    if (charge <= 0)
    {
        bl = false;
    }
    if (bl)
    {
        puts("Yes");
    }
    else
    {
        puts("No");
    }

    return 0;
}

#include<iostream>
#include<vector>
#include<map>
#include<stack>
#include<set>
#include<queue>
#include<stdlib.h>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<sstream>
#define endl "\n"
#define Doura() ios_base::sync_with_stdio(false),cin.tie(NULL), cout.tie(NULL)
#define ll long long
using namespace std;
const long long MXX=1e7;
int a[MXX],b[MXX];
void kajelag()
{
     int n;
     cin>>n;
     for(int i=0;i<n;i++)
          cin>>a[i];
     for(int i=0;i<n;i++)
          cin>>b[i];
     sort(a,a+n);
     sort(b,b+n);
     //cout<<b[0]<<" "<<a[n-1]<<endl;
     int ans=b[0]-a[n-1];

     if(ans<0)
          cout<<0<<endl;
     else cout<<ans+1<<endl;
}
int main()
{
      Doura();
     #ifndef ONLINE_JUDGE
          //   freopen("input.txt","r",stdin);
          //   freopen("output.txt","w",stdout);
     #endif // ONLINE_JUDGE

     int t;
     //cin>>t;
     //while(t--)
     {
          kajelag();
     }
     return 0;
}


#include <iostream>
using namespace std;
int main(){
	int N;
	cin >> N;
	cout << N-1;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define REP(i,a,b) for(int i = (a); i < (b); i++)
#define MOD 1000000007

int main(void) {
  int n;
  cin >> n;
  int ans;
  cout << n+1-2 << endl;
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=5e5+10;
int dp[N];
void solve()
{
	int n;
	cin>>n;
	dp[1]=1;
	for(int i=1;i<=n;i++)
		for(int j=i+i;j<=n;j=j+i)
			dp[j]=max(dp[j],dp[i]+1);
	for(int i=1;i<=n;i++)
		cout<<dp[i]<<" ";
	cout<<endl;
}
signed main()
{
	int t=1;
	while(t--)
		solve();
	return 0;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)((n)-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}
template <typename ... Args>
string format(const std::string& fmt, Args ... args ){
   size_t len = std::snprintf(nullptr, 0, fmt.c_str(), args ... );
   vector<char> buf(len + 1);
   snprintf(&buf[0], len + 1, fmt.c_str(), args ... );
   return string(&buf[0], &buf[0] + len);
}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    vi cnt(n,1);
    REP(i,1,n+1){
        for(int j=i*2; j<=n; j+=i){
            cnt[j-1] = max(cnt[j-1], cnt[i-1]+1);
        }
    }
    cout << join(cnt, " ") << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define lli               long long int
#define ulli              unsigned long long int
#define vi                vector<int>
#define ii                pair<int,int>
#define all(v)            v.begin(),v.end()
#define getunique(v)      {v.erase(unique(v.begin(),v.end()),v.end());}
#define pb                push_back
#define ff                first
#define ss                second
#define endl              "\n"
#define fast_io           ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MS=1000001;
const lli INF=1e9+7;

template<typename T>
 bool comp(T a, T b){
  if(a<b)
    return true;
  return false;
 }
 int vis[3000];
 set<ii > s;
 int cnt=0;
 void dfs(int cnode,vi ar[],int par){
  s.insert({par,cnode});
  vis[cnode]=1;
  cnt++;
  for(auto child:ar[cnode]){
    if(vis[child]==0)
      dfs(child,ar,par);
  }
 }
int main(){
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
   fast_io;
   int n,m;
   cin>>n>>m;
   vi ar[n+1];
   for(int i=0; i<m; i++){
    int a,b;
    cin>>a>>b;
    ar[a].pb(b);
   }
   int ans=0;
   for(int i=1; i<=n; i++){
    memset(vis,0,sizeof vis);
      dfs(i,ar,i);

   }
   // for(auto itr:s)
   //  cout<<itr.ff<<" "<<itr.ss<<endl;
   cout<<s.size();

}

#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
template <class T>
int upb(V<T> &v, const T &x) { return upper_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&...tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 60) - 1LL;
constexpr ll MOD = 998244353LL;
//@docs Docs/UnionFind.md
struct UnionFind {
    vector<int> par, sz;
    UnionFind(int n) : par(n), sz(n, 1) {
        iota(par.begin(), par.end(), 0);
    }
    inline int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }
    bool unite(int u, int v) {
        u = find(u), v = find(v);
        if (u == v) return false;
        if (sz[u] < sz[v]) swap(u, v);
        par[v] = u;
        sz[u] += sz[v];
        return true;
    }
    inline int size(int x) {
        return sz[find(x)];
    }
    inline bool same(int u, int v) {
        return find(u) == find(v);
    }
};
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    V<ll> a(n), b(n);
    read(a);
    read(b);
    UnionFind uf(n);
    for (int i = 0; i < m; i++) {
        int c, d;
        cin >> c >> d;
        --c;
        --d;
        uf.unite(c, d);
    }
    V<ll> sa(n), sb(n);
    for (int i = 0; i < n; i++) {
        sa[uf.find(i)] += a[i];
        sb[uf.find(i)] += b[i];
    }
    for (int i = 0; i < n; i++) {
        if (sa[i] != sb[i]) {
            cout << "No" << newl;
            return 0;
        }
    }
    cout << "Yes" << newl;
}


#include <iostream>
#include <vector>
#include <cstring>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;
#define ll long long
#define pb push_back
#define pp pair<long long,long long>
#define ppp pair<pair<long long,long long>, long long >
#define f first
#define s second
#define pd pair<double,long long>
#define pv pair<long long,vector<pair<long long,long long> > >
void solveTestCase() {
	ll i,j,k,n,m,x,y;
	cin>>n>>k;
	ll op1 = 2*n+k;
	ll op2 = 2+k;
	op1=min(op1,2*n);
	op2=max(op2,2ll);
	ll ans=0;
	for (i=op2;i<=op1;i++) {
		ll res=i-1;
		if (i>n)
			res=(2*n-i+1);
		j=i-k;
		ll res2=j-1;
		if (j>n)
			res2=(2*n-j+1);
		ans+=res*res2;
	}
	cout<<ans<<'\n';

}
int main() {
	ll t,n,i,j,k,l;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll p;
	t=1;
//	cin>>t;
	for (ll T=1;T<=t;T++) {
//		cout<<"Case #"<<T<<": ";
		solveTestCase();
	}
	return 0;
}

#include <iostream>
using namespace std;

typedef long long ll;

#define min(x,y) ((x)<(y)?(x):(y))
#define max(x,y) ((x)<(y)?(y):(x))

ll comb(ll n, ll k){
    if (k == 0 || k == n) return 1;
    if (k == 1 || k == n-1) return n;
    return comb(n-1,k)+comb(n-1,k-1);
}

int main(){
    ll n,k;cin >> n >> k;--k;
    for(ll xyz=3;xyz<=3*n;++xyz){
        if(xyz <= n+1){
            ll s = (xyz-1)*(xyz-2)/2;
            if(s <= k){
                k -= s;
                continue;
            }
            for(ll x=1;x<=xyz-2;++x){
                ll c = xyz-1-x;
                if(c <= k){
                    k -= c;
                    continue;
                }
                ll y=1+k;
                cout << x << " " << y << " " << (xyz-x-y) << "\n";
                return 0;
            }
        }else if(xyz < 2*n+1){
            ll s = (3*n-xyz+2)*(xyz-n-1)/2;
            if(s <= k){
                k -= s;
            }else{
                for(ll x=1;x<=xyz-n-1;++x){
                    ll c = 2*n-xyz+1+x;
                    if(c <= k){
                        k -= c;
                        continue;
                    }
                    ll y=xyz-n-x+k;
                    cout << x << " " << y << " " << (xyz-x-y) << "\n";
                    return 0;
                }
            }
            s = (xyz-2)*(2*n-xyz+1)/2;
            if(s <= k){
                k -= s;
                continue;
            }
            for(ll x=xyz-n;x<=n;++x){
                ll c = xyz-1-x;
                if(c <= k){
                    k -= c;
                    continue;
                }
                ll y=1+k;
                cout << x << " " << y << " " << (xyz-x-y) << "\n";
                return 0;
            }
        }else{
            ll s = (3*n-xyz+2)*(3*n-xyz+1)/2;
            if(s <= k){
                k -= s;
                continue;
            }
            for(ll x=xyz-2*n;x<=n;++x){
                ll c = 2*n-xyz+1+x;
                if(c <= k){
                    k -= c;
                    continue;
                }
                ll y=xyz-n-x+k;
                cout << x << " " << y << " " << (xyz-x-y) << "\n";
                return 0;
            }
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll  long long
#define int long long
#define ld  long double
#define endl "\n"
#define pb  push_back
#define fill(a,val) memset(a,val,sizeof(a))
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define all(v) v.begin(),v.end()
const ll mod     = 1000*1000*1000+7;
const ll inf     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll mod2    = 998244353;
const ll N       = 1000 * 1000 + 10;
const ld pi      = 3.141592653589793;
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
void IO(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
signed main(){
    fastio();
    cout<<fixed<<setprecision(20);
    ll n,k;
    cin>>n>>k;
    ll a[n+1][n+1];
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=n;j++){
            cin>>a[i][j];
        }
    }
    vector<ll>p;

    for(ll i=2;i<=n;i++){
        p.pb(i);
    }
    ll cnt=0;
    do{
        ll pr=1,sum=0;
        for(ll i=0;i<(ll)p.size();i++){
            sum+=(a[pr][p[i]]);
            pr=p[i];
        }
        sum+=(a[pr][1]);
        if(sum==k){
            cnt++;
        }
    }while(next_permutation(p.begin(),p.end()));
    cout<<cnt;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define LOCAL
#endif
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
const long infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
#define endl        '\n'
#define pb          push_back
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
//#define hell        998244353
#define peak        9e18
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

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

namespace Ops{
template<class y,class z> ll expo(ll b,y e,z m){ll a=1;b%=m;while(e!=0){if((e&1)==1){a=a*b;a=a%m;}b=b*b;b%=m;e>>=1;}return a%m;}
template<class y> ll power(ll b,y e){ll a=1;while(e!=0){if((e&1)==1){a=a*b;}b=b*b;e>>=1;}return a;}
template<class x,class z> ll inv(x b,z m){return expo(b,m-2,m);}
template<class x,class y> x invGeneral(x a,y b){if(a==0)return b==1?0:-1;x m=invGeneral(b%a,a);return m==-1?-1:((1-(ll)b*m)/a+b)%b;}
template<class x,class y> x min(x a,y b){x c;if(a<=b)c=a;else c=b;return c;}
template<class x,class y> x max(x a,y b){x c;if(a>=b)c=a;else c=b;return c;}
ll mul(ll x,ll y,ll m){x%=m;y%=m;if(x==0)return 0;if(x%2==0)return (mul(x/2,y,m)*2)%m;return ((mul(x/2,y,m)*2)%m+y)%m;}
}
using namespace Ops;

namespace InOp{
template<class x>istream &operator>>(istream &in,vector<x> &v) {for(auto& i:v)in>>i;return in;}
template<class x,class y> ostream &operator<<(ostream &out,pair<x,y> &p) {out<<"("<<p.F<<","<<p.S<<")";return out;}
template<class x> ostream &operator<<(ostream &out,vector<x> &v) {out<<"Size : "<<v.size()<<endl;for(auto i:v)out<<i<<" ";out<<endl;return out;}
}
using namespace InOp;

namespace Debug{
#ifdef LOCAL
#define deb(...) printall(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void printall(const char* name, Arg1&& arg1){cerr<<name<<" : "<<arg1<<endl;}
template <typename Arg1, typename... Args>
void printall(const char* names,Arg1&& arg1,Args&&... args){const char* comma=strchr(names,',');cerr.write(names,comma-names)<<" : " <<arg1<<" | ";printall(comma+1,args...);}
#else
#define deb(...) void(0)
#endif
}
using namespace Debug;

namespace Bits{
template<class x> constexpr int onbits(x a){return __builtin_popcount(a);}
constexpr int bits(long long x){return 64-__builtin_clzll(x);}//take care of 0
constexpr int bits(int x){return 32-__builtin_clz(x);}//take care of 0
constexpr int traz(int a){return __builtin_ctz(a);}
constexpr int traz(long long a){return __builtin_ctzll(a);}
}
using namespace Bits;

namespace YesNo{
//#define CAPITAL
void yes(){
    #ifdef CAPITAL
    cout<<"YES"<<"\n";
    #else
    cout<<"Yes"<<"\n";
    #endif
}
void no(){
    #ifdef CAPITAL
    cout<<"NO"<<"\n";
    #else
    cout<<"No"<<"\n";
    #endif
}
}
using namespace YesNo;

void maester();
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout<<fixed<<setprecision(6);
    cerr<<fixed<<setprecision(6);
    ll test=1;
    //cin>>test;
    for(ll tt=1;tt<=test;tt++)
    {
        //cout<<"Case #"<<tt<<": ";
    	maester();
    }
    #ifdef LOCAL
    cerr<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
    #endif
    return 0;
}
#define N  1000005

void maester()
{
    ll i,j,k,l,r,m,n,x,y;
    cin>>n;
    vi a(n),b(n),c(n);
    cin>>a>>b>>c;
    for(i=0;i<n;i++)c[i]=b[c[i]-1];
    map<ll,ll> ma;
	for(auto i:c)ma[i]++;
	ll ans=0;
	for(auto i:a)ans+=ma[i];
	cout<<ans<<endl;
}


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

struct UnionFind {
    vector<int> par;
    vector<int> sz;

    UnionFind(int n=0){ if(n>0) initialize(n); }
    void initialize(int n){
        par.resize(n);
        sz.assign(n, 1);
        for(int i=0; i<n; i++){
            par[i] = i;
        }
    }

    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }

    bool unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y) return false;
        if(sz[x] > sz[y]) swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
        return true;
    }

    bool same(int x, int y){ return find(x) == find(y); }
    int size(int x){ return sz[find(x)]; }
};

int main(){
    int N, M;
    cin >> N >> M;
    vector<int64_t> A(N), B(N);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> B[i];
    UnionFind uf(N);
    while(M--){
        int a, b;
        cin >> a >> b;
        uf.unite(a-1, b-1);
    }
    vector<int64_t> C(N), D(N);
    for(int i=0; i<N; i++){
        int r = uf.find(i);
        C[r] += A[i];
        D[r] += B[i];
    }
    cout << (C==D ? "Yes" : "No") << endl;
    return 0;
}

#include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <istream>

#include <map>
#include <math.h>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <stdint.h>

namespace asl
{
    template <typename T>
    using vec = std::vector<T>;

    template <typename T>
    std::istream &operator>>(std::istream &is, std::vector<T> &vec)
    {
        for (auto &value : vec)
            is >> value;
        return is;
    }

}

#include <experimental/optional>

#include <tuple>

namespace asl
{
    typedef long long i64;

}

#include <random>

#include <utility>

#define endl '\n'

using namespace std;
using namespace asl;

vec<int> get_diff(vec<int> &a)
{
    int l = 0;
    vec<int> res(a.size());

    for (int i = 0; i < a.size(); ++i)
    {
        res[i] = a[i] - l - 1;
        l = a[i];
    }
    return res;
}

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

    vec<int> a(n), b(n);
    cin >> a >> b;

    a.push_back(l + 1);
    b.push_back(l + 1);

    a = get_diff(a);
    b = get_diff(b);

    i64 answer = 0;

    for (int i = 0, j = 0, k; i <= n; ++i, j = k)
    {
        int s = 0;
        k = j;

        while (s < b[i])
            s += a[k++];

        while (j < k && a[j] == 0)
            ++j;

        if (s > b[i])
        {
            answer = -1;
            break;
        }

        if (b[i] > 0)
        {
            int cur = max(i - j, 0) + max(k - 1 - i, 0);
            answer += cur;

        }
    }

    cout << answer << endl;
}

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

    int t = 1;

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

    return 0;
}


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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max() / 2;
const ll mod = 1e9+7;

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

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

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

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

void solve(){
  ll t, n;
  cin >> t >> n;
  ll k = n * (100 + t) / t;
  if(k * t / (100 + t) == n)
    k--;
  cout << k << endl;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>
//#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;
//typedef boost::multiprecision::cpp_int ll;
typedef long long ll;

int main() {
#ifdef DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll t, N;
    cin >> t >> N;

    ll X = (100*N+t-1)/t;
    cout << X + N - 1 << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (ll i=(ll)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const ll INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(ll x=pow(10,7)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { ll d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll modpow(ll x, ll p) { ll result = 1, now = 1, pm = x; while (now<=p) { if (p&now) { result = result * pm % MOD; } now*=2; pm = pm*pm % MOD; } return result; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

vector<vector<ll>> matsum(vector<vector<ll>> A, vector<vector<ll>> B) {
  if (A.size()!=B.size()||A[0].size()!=B[0].size()) return {{}};
  ll h = A.size(), w = A[0].size();
  vector<vector<ll>> result(h,vector<ll>(w,0));
  rep(i,h) rep(j,w) result[i][j] = (A[i][j]+B[i][j])%MOD;
  return result;
}

vector<vector<ll>> matdiff(vector<vector<ll>> A, vector<vector<ll>> B) {
  if (A.size()!=B.size()||A[0].size()!=B[0].size()) return {{}};
  ll h = A.size(), w = A[0].size();
  vector<vector<ll>> result(h,vector<ll>(w,0));
  rep(i,h) rep(j,w) result[i][j] = (MOD+(A[i][j]-B[i][j])%MOD)%MOD;
  return result;
}

vector<vector<ll>> matdot(vector<vector<ll>> A, vector<vector<ll>> B) {
  if (A[0].size()!=B.size()) return {{}};
  ll h = A.size(), w = B[0].size(), x = A[0].size();
  vector<vector<ll>> result(h,vector<ll>(w,0));
  rep(i,h) rep(j,w) rep(k,x) result[i][j] = (result[i][j] + A[i][k]*B[k][j]);
  return result;
}

vector<vector<ll>> matpow(vector<vector<ll>> A, ll n) {
  if (A.size()!=A[0].size()) return {{}};
  int N = A.size();
  vector<vector<ll>> result(N,vector<ll>(N,0)), now;
  copy(all(A),back_inserter(now));
  rep(i,N) result[i][i] = 1;
  ll p2 = 1;
  while (n>=p2) {
    if (n&p2) result = matdot(result,now);
    now = matdot(now,now); p2 *= 2;
  }
  return result;
}

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

int main() {
  ll N; cin >> N;
  ll X[N], Y[N]; rep(i,N) cin >> X[i] >> Y[i];
  ll M; cin >> M;
  ll op[M][2] = {}; rep(i,M) { cin >> op[i][0]; if (op[i][0]>=3) cin >> op[i][1]; }
  ll Q; cin >> Q;
  ll A[Q], B[Q]; rep(i,Q) { cin >> A[i] >> B[i]; B[i]--; }

  vector<vector<ll>> ope = { {1,0,0}, {0,1,0}, {0,0,1} };
  vector<vector<vector<ll>>> opmat(M+1); opmat[0] = ope;
  rep(i,M) {
    vector<vector<ll>> mulmat;
    if (op[i][0]==1) {
      mulmat = {
        {0,1,0},
        {-1,0,0},
        {0,0,1}
      };
    }
    else if (op[i][0]==2) {
      mulmat = {
        {0,-1,0},
        {1,0,0},
        {0,0,1}
      };
    }
    else if (op[i][0]==3) {
      mulmat = {
        {-1,0,2*op[i][1]},
        {0,1,0},
        {0,0,1}
      };
    }
    else if (op[i][0]==4) {
      mulmat = {
        {1,0,0},
        {0,-1,2*op[i][1]},
        {0,0,1}
      };
    }
    opmat[i+1] = matdot(mulmat,opmat[i]);
  }

  // rep(i,M+1) {
  //   for (auto x: opmat[i]) debug(all(x));
  //   cout << endl;
  // }

  rep(i,Q) {
    vector<vector<ll>> resmat = matdot(opmat[A[i]],{{X[B[i]]},{Y[B[i]]},{1}});
    cout << resmat[0][0] << " " << resmat[1][0] << endl;
  }
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
//const int mod = 998244353;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/**
 * @brief Union-Find
 * @docs docs/union-find.md
 */
struct UnionFind {
  vector< int > data;

  UnionFind() = default;

  explicit UnionFind(size_t sz) : data(sz, -1) {}

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return false;
    //if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return data[k] = find(data[k]);
  }

  int size(int k) {
    return -data[find(k)];
  }

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

int main() {
  int N, Q;
  cin >> N >> Q;
  vector< int > C(N);
  cin >> C;
  for(auto &c : C) --c;
  UnionFind uf(N);
  vector< map< int, int > > mp(N);
  for(int i = 0; i < N; i++) mp[i][C[i]]++;
  while(Q--) {
    int t, a, b;
    cin >> t >> a >> b;
    --a, --b;
    if(t == 1) {
      int p = uf.find(a);
      int q = uf.find(b);
      if(p == q) continue;
      if(mp[p].size() < mp[q].size()) {
        swap(p, q);
      }
      for(auto &z : mp[q]) mp[p][z.first] += z.second;
      mp[q].clear();
      uf.unite(p, q);
    } else {
      cout << mp[uf.find(a)][b] << "\n";
    }
  }
}


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

int main() {
    int a1, a2, a3, a4; cin >> a1 >> a2 >> a3 >> a4;
    int res = a1;
    if(res > a2) res = a2;
    if(res > a3) res = a3;
    if(res > a4) res = a4;
    cout << res;
    return 0;
}

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

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

    double a,b,c,d; cin >> a >> b >> c >> d;
    d = - d;
    double A = (b - d) / (a - c);
    double B = b - A * a;
    cout.precision(17);
    cout << - B / A << endl;
}


#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18;
void print() { cout << endl; }
template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);}
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<head;print0(tail...);}
// clang-format on

const ll MODULO = 1000000007LL;
ll mod_pow(ll x, ll n, ll modval) {
    if (n == 0) {
        return 1;
    }
    ll res = mod_pow(x * x % modval, n / 2, modval);
    if (n & 1) {
        res = res * x % modval;
    }
    return res;
}
ll mod_minus(ll x, ll modval) {
    if (x >= 0) {
        return x % modval;
    } else {
        ll mm = ((-x) % modval);
        if (mm == 0) {
            return 0;
        } else {
            return modval - mm;
        }
    }
}
ll mod(ll x) {
    return mod_minus(x, MODULO);
}
ll mod_inv(ll k, ll modval) {
    return mod_pow(k, modval - 2, modval);
}
ll minv(ll k) {
    return mod_pow(k, MODULO - 2, MODULO);
}

ll mmult(ll x, ll y) {
    return mod(x * y);
}
ll sum2(ll x) {
    return mmult(mmult(mmult(x, x + 1), 2 * x + 1), minv(6));
}
ll summ2(ll x) {
    return x * (x + 1) * (2 * x + 1) / 6;
}
ll sum1(ll x) {
    return mod(x * (x + 1) / 2);
}
void solve() {
    ll N, A, B;
    cin >> N >> A >> B;

    ll x4;
    if (N - A - B < 0) {
        x4 = 0;
    } else {
        x4 = mmult(mmult(N - A - B + 2, N - A - B + 1), minv(2));
    }
    ll x3 = mmult(x4, 2);
    ll x2 = mod(mmult(N - A + 1, N - B + 1) - x3);
    ll x1 = mmult(x2, x2);
    ll result = mod(mmult(mmult(mmult(N - A + 1, N - A + 1), N - B + 1), N - B + 1) - x1);
    print(result);

    // if (A < B) {
    //     swap(A, B);
    // }
    // ll result = mmult(mmult(N - A + 1, N - A + 1), mmult(N - B + 1, N - B + 1));

    // // 重複を減らす
    // ll invalid = 0;
    // invalid = mod(invalid + mmult(A - B + 1, A - B + 1));
    // invalid = mod(invalid + mmult(mmult(A - B + 1, B - 1), 4));
    // invalid = mod(invalid + mmult(mmult(mmult(A - B + 1, B - 1), B - 1), 4));
    // result = mod(result - mmult(invalid, mmult(N - A + 1, N - A + 1)));

    // // 重複のうち起こりえないものを戻す
    // result = mod(result + mmult(mmult(sum1(B - 1), N - A + 1), 4));
    // result = mod(result + mmult(mmult(mmult(sum1(B - 1), min(N - A + 1, B - 1)), N - A + 1), 8));
    // // 戻した中に重複がある
    // result = mod(result - mmult(sum1(B - 1), 4));
    // print(result);
}
int main() {
    ll T;
    cin >> T;

    for (ll i = 0; i < T; i++) {
        solve();
    }
}

#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

const long long MOD = 1000000007;
int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int t;
    cin >> t;

    auto count = [&](long long N, long long l, long long r, long long t, long long b) {
        auto n = r - l + 1;
        auto m = b - t + 1;
        if (n <= 0 || m <= 0) {
            return 0LL;
        }
        long long x = ((N + 1 - l) + (N + 1 - r)) * n / 2 % MOD;
        long long y = ((N + 1 - t) + (N + 1 - b)) * m / 2 % MOD;
        long long res = x * y % MOD;
        res *= 4;
        res %= MOD;
        return res;
    };

    auto count2 = [&](long long N, long long A, long long B) {
        long long res = 0;

        long long cnt = (N - A - B + 1);
        long long x = (1 + cnt) * cnt / 2 % MOD;
        x = x * (B - A + 1) % MOD;
        res = x * (N - B + 1) % MOD;
        res *= 4;
        res %= MOD;
        return res;
    };

    while (t-- > 0) {
        long long N, A, B;
        cin >> N >> A >> B;
        if (N < A + B) {
            cout << 0 << '\n';
        } else {
            if (A > B) {
                swap(A, B);
            }
            long long res = 0;
            res += count(N, B + 1, A + B - 1, A + B, N);
            res += count(N, A + B, N, B + 1, A + B - 1);
            res += count(N, A + B, N, A + B, N);
            res += count2(N, A, B);
            res %= MOD;
            cout << res << '\n';
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int N=3e5+5,M=1e9+7,OO=0x3f3f3f3f;

int n,q;
int arr[N];
int seg[4*N];

void build(int si=0,int ss=0,int se=n-1){
    if(ss==se){
        seg[si]=arr[ss];
        return;
    }
    int md=ss+(se-ss)/2,lf=si*2+1,rt=si*2+2;
    build(lf,ss,md);
    build(rt,md+1,se);
    seg[si]=seg[lf]^seg[rt];
}

void update(int qi,int qv,int si=0,int ss=0,int se=n-1){
    if(ss>qi||se<qi) return;
    if(ss==se){
        seg[si]^=qv;
        return;
    }
    int md=ss+(se-ss)/2,lf=si*2+1,rt=si*2+2;
    update(qi,qv,lf,ss,md);
    update(qi,qv,rt,md+1,se);
    seg[si]=seg[lf]^seg[rt];
}

int query(int qs,int qe,int si=0,int ss=0,int se=n-1){
    if(ss>qe||se<qs) return 0;
    if(ss>=qs&&se<=qe) return seg[si];
    int md=ss+(se-ss)/2,lf=si*2+1,rt=si*2+2;
    return query(qs,qe,lf,ss,md)^query(qs,qe,rt,md+1,se);
}

int main(){

    //freopen("myfile.txt","w",stdout);

    scanf("%d%d",&n,&q);
    for(int i=0;i<n;++i)
        scanf("%d",arr+i);

    build();

    while(q--){
        int t,x,y;
        scanf("%d%d%d",&t,&x,&y);
        if(t==1){
            update(--x,y);
        }
        else{
            --x,--y;
            printf("%d\n",query(x,y));
        }
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef tuple<int,int,int> i3;
int x[105], y[105], z[105], n, m;
ll fat[20], dp[(1 << 18) + 5][105];

vector<int> mask[25];

ll solve(int curmask, int pos){
    int cursz = __builtin_popcount(curmask);
    if(pos == m) return fat[n-cursz];
    if(dp[curmask][pos] != -1) return dp[curmask][pos];

    int cnt = 0;
    for(int i = 0; i < y[pos]; i++)
        cnt += !!((1 << i) & curmask);
    ll res = 0;

    int biton = __builtin_popcount(curmask);
    if(cnt <= z[pos]){
        if(biton == x[pos])
            res = solve(curmask, pos+1);
        else{
            for(int j = 0; j < n; j++)
                if(!((1 << j) & curmask))
                    res += solve(curmask|(1 << j), pos);
        }

    }

    return dp[curmask][pos] = res;
}

int main(){

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

    memset(dp, -1, sizeof dp);
    cin >> n >> m;
    vector<i3> vec;
    for(int i = 0; i < m; i++){
        int a, b, c; cin >> a >> b >> c;
        vec.emplace_back(a, b, c);
    }
    sort(vec.begin(), vec.end());
    for(int i = 0; i < m; i++){
        int a, b, c; tie(a, b, c) = vec[i];
        x[i] = a;
        y[i] = b;
        z[i] = c;
    }

    fat[0] = 1;
    for(int i = 1; i <= n; i++)
        fat[i] = fat[i-1] * i;

    if(m == 0){
        cout << fat[n] << endl;
        return 0;
    }

    cout << solve(0, 0) << endl;

    return 0;
}


#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;
constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }

ll gcd(ll x, ll y) {	if (x == 0) return y;	return gcd(y%x, x);}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }
ll modpow(ll a, ll n, ll p) {	if(n==0) return (ll)1;  if (n == 1) return a % p;  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;  ll t = modpow(a, n / 2, p);  return (t * t) % p;}
ll modinv(ll a, ll m) {	if(m==0)return (ll)1;	ll b = m, u = 1, v = 0;	while (b) {		ll t = a / b;		a -= t * b; swap(a, b);		u -= t * v; swap(u, v);	}	u %= m;	if (u < 0) u += m;	return u;}
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {	fac[0] = fac[1] = 1;	finv[0] = finv[1] = 1;	inv[1] = 1;	for (int i = 2; i < MAX; i++) {		fac[i] = fac[i - 1] * i % MOD;		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;		finv[i] = finv[i - 1] * inv[i] % MOD;	}}
ll COM(ll n, ll k) {	if (n < k) return 0;	if (n < 0 || k < 0) return 0;	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll com(ll n,ll m){   if(n<m || n<=0 ||m<0){		return 0;	}	if( m==0 || n==m){		return 1;	}	ll k=1;	for(ll i=1;i<=m;i++){       k*=(n-i+1); 	   k%=MOD;	   k*=modinv(i,MOD);	   k%=MOD;	}	return k;}
ll rad(ll u, ll p){ ll cnt=0;	while(u%p==0){		u/=p;		cnt++;	}	return cnt;}
////////////////////////////////////////////////////////////////////

int main() {
 ios::sync_with_stdio(false);

ll n;
cin>>n;

vector <pair<ll,ll>> x;
vector <pair<ll,ll>> y;
rep(i,n){
	ll a,b;
	cin>>a>>b;
	x.pb(mp(a,i));
	y.pb(mp(b,i));
}

sort(ALL(x),greater<P>());
sort(ALL(y),greater<P>());

ll ans=0;
ll m1=x[0].second;
ll m2=x[n-1].second;
ll m3=y[0].second;
ll m4=y[n-1].second;
if((m1==m3&&m2==m4)||(m1==m4&&m2==m3)){
ans=max(max(max(x[1].first-x[n-1].first,x[0].first-x[n-2].first),y[1].first-y[n-1].first),y[0].first-y[n-2].first);
}
else{
if(x[0].first-x[n-1].first==y[0].first-y[n-1].first){
	ans=x[0].first-x[n-1].first;
}
else if(x[0].first-x[n-1].first>y[0].first-y[n-1].first){
ans=max(max(x[1].first-x[n-1].first,x[0].first-x[n-2].first),y[0].first-y[n-1].first);
}
else{
	ans=max(max(y[1].first-y[n-1].first,y[0].first-y[n-2].first),x[0].first-x[n-1].first);
}
}

cout<<ans<<endl;

return 0;
}

// Generated by 2.3.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>
// #include "atcoder/all"

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

signed main(){
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for(int i = 0; i < n; ++i){
        cin >> x[i] >> y[i];
    }
    vector<pair<int,int>> vx(n), vy(n);
    for(int i = 0; i < n; ++i){
        vx[i] = {x[i], i};
        vy[i] = {y[i], i};
    }
    sort(vx.begin(), vx.end());
    sort(vy.begin(), vy.end());

    vector<tuple<int,int,int>> v;
    for(int i = 0; i < min(10, n); ++i){
        for(int j = 0; j < min(10, n); ++j){
            int dist = abs(vx[i].first - vx[n - j - 1].first);
            if(vx[i].second == vx[n - j - 1].second)
                continue;
            v.emplace_back(dist, min(vx[i].second, vx[n - j - 1].second), max(vx[i].second, vx[n - j - 1].second));
        }
    }
    for(int i = 0; i < min(10, n); ++i){
        for(int j = 0; j < min(10, n); ++j){
            int dist = abs(vy[i].first - vy[n - j - 1].first);
            if(vy[i].second == vy[n - j - 1].second)
                continue;
            v.emplace_back(dist, min(vy[i].second, vy[n - j - 1].second), max(vy[i].second, vy[n - j - 1].second));
        }
    }
    sort(v.begin(), v.end(), greater<>());
    set<pair<int,int>> s;
    for(auto [d, i, j] : v){
        if(s.find({i, j}) == s.end()){
            s.emplace(i, j);
        }
        if(s.size() == 2){
            cout << d << endl;
            return 0;
        }
    }

    return 0;
}


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

// #include <atcoder/all>
// using namespace atcoder;

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

void solve(long long K, long long N, long long M, std::vector<long long> A){
    vector<ll> B(K);
    ll used = 0;
    vector<pair<double, int>> ps;
    rep(i, K) {
        B[i] = A[i] * M / N;
        used += B[i];

        // (BN - AM) / NM を最小化する
        double cur = abs(1.0 * (B[i] * N - A[i] * M) / (N * M));
        // double updated = abs(1.0 * ((B[i] + 1) * N - A[i] * M) / (N * M));
        // ps.emplace_back(cur - updated, i);  // 下降が大きいものから
        ps.emplace_back(cur, i);  // 大きいものから
    }
    assert(used <= M);

    // for (ll e: B) {
    //     cout << e << " ";
    // }
    // cout << endl;

    sort(ps.rbegin(), ps.rend());
    rep(i, M - used) {
        B[ps[i].second]++;
    }
    for (ll e: B) {
        cout << e << " ";
    }
    cout << endl;

}

// Generated by 2.2.0 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long K;
    scanf("%lld",&K);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(K);
    for(int i = 0 ; i < K ; i++){
        scanf("%lld",&A[i]);
    }
    solve(K, N, M, std::move(A));
    return 0;
}

#include <bits/stdc++.h>

int main(){
    int K, N, M;
    std::cin >> K >> N >> M;
    std::vector< long long > A(K);
    for(int i=0; i<K; i++){
        std::cin >> A[i];
    }

    std::vector< long long > B(K);
    std::vector< std::pair< long long, long long > > B_zan_i(K);
    long long total = 0;
    for(int i=0; i<K; i++){
        B[i] = A[i] * M / N;
        total += B[i];
        B_zan_i[i].first = (A[i] * M) % N;
        B_zan_i[i].second = i;
    }

    std::sort(B_zan_i.begin(), B_zan_i.end());
    for(int i=0; i<M-total; i++){
        B[B_zan_i[K - i - 1].second]++;
    }

    for(int i=0; i<K; i++){
        if(i == K-1){
            std::cout << B[i] << std::endl;
        }else{
            std::cout << B[i] << " ";
        }
    }

    return 0;
}


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i < n; ++i)
#define exrep(i, a, b) for (ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef vector<vector<double>> vvd;
typedef vector<vector<string>> vvs;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
ll MOD = 998244353;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;
}
template <class T>
void debug(T v)
{
    rep(i, v.size()) cout << v[i] << " ";
    cout << endl;
}
ll pcount(ll x) { return __builtin_popcountll(x); }
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{
    gearup;
    ll a, b, c;
    cin >> a >> b >> c;
    if (c % 2 == 0)
    {
        if (abs(a) > abs(b))
            out(">");
        else if (abs(a) < abs(b))
            out("<");
        else
            out("=");
    }
    else
    {
        if (a < 0)
        {
            if (b >= 0)
                out("<");
            else
            {
                if (a > b)
                    out(">");
                else if (a < b)
                    out("<");
                else
                    out("=");
            }
        }
        else
        {
            if (a > b)
                out(">");
            else if (a < b)
                out("<");
            else
                out("=");
        }
    }
}

#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t a, b, c; cin >> a >> b >> c;
  uint64_t abs_a = abs(a);
  uint64_t abs_b = abs(b);
  if (!(c & 1))
    cout << (abs_a == abs_b ? "=" : (abs_a > abs_b ? ">" : "<"));
  else
    cout << (a == b ? "=" : (a > b ? ">" : "<"));
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  int N;
  double X0, Y0, XN2, YN2;
  cin >> N >> X0 >> Y0 >> XN2 >> YN2;

  double mX = (X0 + XN2) / 2, mY = (Y0 + YN2) / 2;
  double oX = X0 - mX, oY = Y0 - mY;

  double angle = 2 * M_PI / N;
  double X1 = oX * cos(angle) - oY * sin(angle),
  	Y1 = oX * sin(angle) + oY * cos(angle);

  cout << fixed << setprecision(11) << (X1 + mX) << " " << (Y1 + mY) << endl;
}

#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <random>
#include <chrono>
#include <cassert>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

template<typename T> using maximum_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;
template<typename T> using minimum_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
std::istream& operator>>(std::istream &is, std::vector<T> &v)
{
  for (typename std::vector<T>::size_type i = 0; i < v.size(); ++i) {
    is >> v[i];
  }
  return is;
}

template<typename T>
struct Point2D {
  T x, y;

  Point2D(T x = 0, T y = 0) : x(x), y(y) {}

  bool operator==(const Point2D &p) const { return x == p.x && y == p.y; }
  bool operator!=(const Point2D &p) const { return x != p.x || y != p.y; }

  Point2D  operator+ (const Point2D &p) const { return Point2D(x + p.x, y + p.y); }
  Point2D  operator- (const Point2D &p) const { return Point2D(x - p.x, y - p.y); }
  Point2D& operator+=(const Point2D &p) { x += p.x; y += p.y; return *this; }
  Point2D& operator-=(const Point2D &p) { x -= p.x; y -= p.y; return *this; }

  Point2D  operator* (T k) const { return Point2D(x * k, y * k); }
  Point2D  operator/ (T k) const { return Point2D(x / k, y / k); }
  Point2D& operator*=(T k) { x *= k; y *= k; return *this; }
  Point2D& operator/=(T k) { x /= k; y /= k; return *this; }

  T operator*(const Point2D &p) const { return x * p.x + y * p.y; }

  T dist_pow2() const { return x * x + y * y; }

  bool operator< (const Point2D &p) const {
    return dist_pow2() == p.dist_pow2()
         ? ( y == p.y
             ? x < p.x
             : y < p.y )
         : dist_pow2() <  p.dist_pow2();
  }
  bool operator> (const Point2D &p) const {
    return dist_pow2() == p.dist_pow2()
         ? ( y == p.y
             ? x > p.x
             : y > p.y )
         : dist_pow2() >  p.dist_pow2();
  }
  bool operator<=(const Point2D &p) const { return (*this == p) || (*this < p); }
  bool operator>=(const Point2D &p) const { return (*this == p) || (*this > p); }
};

template<typename T>
bool is_parallel(const Point2D<T> &p, const Point2D<T> &q)
{
  return p.x * q.y == q.y * p.x;
}

template<typename T>
Point2D<T> orthogonal(const Point2D<T> &p)
{
  return Point2D<T>(p.y, -p.x);
}

template<typename T>
long double angle(const Point2D<T> &p, const Point2D<T> &q)
{
  T ip = p * q;
  T dist = p.dist_pow2() * q.dist_pow2();
  long double cosine = static_cast<long double>(ip) / sqrt(static_cast<long double>(dist));
  return acos(cosine);
}

auto rad2deg = [] (long double deg) { return (deg * 180.0) / M_PI; };
auto deg2rad = [] (long double deg) { return (deg * M_PI) / 180.0; };

template<typename T>
std::istream& operator>>(std::istream &is, Point2D<T> &p)
{
  is >> p.x >> p.y;
  return is;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const Point2D<T> &p)
{
  os << '(' << p.x << ", " << p.y << ')';
  return os;
}

typedef Point2D<long double> Point;

Point rotate(const Point &p, long double theta)
{
  return Point(
    p.x * cos(theta) - p.y * sin(theta),
    p.x * sin(theta) + p.y * cos(theta)
  );
}

using namespace std;

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

  Point p0, ph;
  cin >> p0 >> ph;

  Point x = (p0 + ph) / 2;

  Point v = p0 - x;
  Point u = rotate(v, deg2rad(180.0 / (N >> 1)));

  Point p1 = u + x;
  cout << fixed << setprecision(12) << p1.x << ' ' << fixed << setprecision(12) <<  p1.y << endl;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++)
#define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--)
#define all(v) v.begin(), v.end()
void chmax(ll &x, ll y) {x = max(x,y);}
void chmin(ll &x, ll y) {x = min(x,y);}
void Yes() {cout << "Yes" << endl; exit(0);}
void No() {cout << "No" << endl; exit(0);}
template<class in_Cout> void Cout(in_Cout x) {cout << x << endl; exit(0);}
template<class in_vec_cout>
void vec_cout(vector<in_vec_cout> vec) {
    for (in_vec_cout res : vec) {cout << res << " ";}
    cout << endl;
}

const ll inf = 1e18;
const ll mod = 1e9 + 7;

ll POW(ll x, ll n) {
    if (n==0) return 1;
    if (n%2) return x * POW(x,n-1);
    ll res = POW(x,n/2);
    return res * res;
}

int main() {
    ll N; cin >> N;
    ll ans = inf;
    for (ll b=0; b<=60; b++) {
        ll x = POW(2,b);
        ll a = N/x, c = N%x;
        ll res = a + b + c;
        chmin(ans,res);
    }

    cout << ans << endl;
}

#include<bits/stdc++.h>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define task "nondec"
#define pii pair<pll, ll>
using namespace std;
using ll = long long;
const int  N = 1e5+5;
const ll mod = 1e9 + 7;
const ll base = 350;
const ll cs = 331;
const long double Exp = 1e-7;
ll m, n, t, k, tong, ans, b[N], fe[N], c[N], d[N];
long double a[N];
vector<ll> adj[N];
vector<ll> kq;
ll pw(ll k, ll n)
{
    ll total = 1;
    for(; n; n >>= 1)
    {
        if(n & 1)total = total * k % mod;
        k = k * k % mod;
    }
    return total;
}
void add(ll& x, ll y)
{
    x += y;
    if(x >= mod)x -= mod;
}
long double f(long double x)
{
    long double res = 0;
    for(int i = 1; i <= n; i ++)res += x + a[i] - min(x*2,a[i]);
    return res * 1.0 / n;
}
void sol()
{
    cin >> n;
    for(int i = 1; i <= n; i ++)cin >> a[i];
    sort(a+1, a+1+n);
    ll lf = 1, rt = n, mid;
    while(lf <= rt)
    {
        mid = (lf + rt) / 2;
        if(mid < n && f(a[mid] /2.0) > f(a[mid+1] / 2.0))lf = mid + 1;
        else rt = mid - 1;
    }
    cout << fixed << setprecision(9) << f(a[lf] / 2.0);

}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen(task".in", "r"))
    {
        freopen(task".in", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    int ntest = 1;
    //cin >> ntest;
    while(ntest -- > 0)
    sol();
}
/*
4 3
3 2 1 1
2
1 2
3 4
*/


# include <iostream>
# include <vector>
# include <utility>
# include <algorithm>
using namespace std;
int main()
{
    int n,m,q;
    cin>>n>>m>>q;
    vector<pair<int,int>>v;
    for(int i=0; i<n; i++)
    {
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
    }
    sort(v.begin(),v.end());
    int c[m];
    for(int i=0; i<m; i++)
    {
        cin>>c[i];
    }
    for(int i=0; i<q; i++)
    {
        int x,y;
        cin>>x>>y;
        int s=0;
        vector<int>u;
        for(int j=0; j<m; j++)
        {
            if(j+1<x || j+1>y)
            {
                u.push_back(c[j]);
            }
        }
        sort(u.begin(),u.end());
        int visit[10000]={0};
        for(int j=0; j<u.size(); j++)
        {
                int l=0;
                int h=10000;
                for(int z=0; z<n; z++)
                {
                    if(u[j]>=v[z].first && visit[z]==0)
                    {
                        l=max(l,v[z].second);
                        if(l==v[z].second)
                        {
                            h=z;
                        }
                    }
                }
                visit[h]=1;
                s=s+l;
        }
        cout<<s<<endl;
    }
}

#include <bits/stdc++.h>

template <typename T>
T next() {
    T temp; std::cin >> temp;
    return temp;
}

template <>
int next() {
    int temp; scanf("%d", &temp);
    return temp;
}
template <>
long long next() {
    long long temp; scanf("%lld", &temp);
    return temp;
}
template <>
double next() {
    double temp; scanf("%lf", &temp);
    return temp;
}
template <>
float next() {
    float temp; scanf("%f", &temp);
    return temp;
}

template <typename T1, typename T2>
std::pair<T1, T2> next() {
    std::pair<T1, T2> temp;
    temp.first = next<T1>();
    temp.second = next<T2>();
    return temp;
}

template <typename T>
std::vector<T> next(int n) {
    std::vector<T> temp(n);
    for(int i = 0; i < n; i++)
        temp[i] = next<T>();
    return temp;
}

template <typename T1, typename T2>
std::vector<std::pair<T1, T2>> next(int n) {
    std::vector<std::pair<T1, T2>> temp(n);
    for(int i = 0; i < n; i++)
        temp[i] = next<T1, T2>();
    return temp;
}

template <typename T>
void print(const T &x, char endc = '\n') {
    std::cout << x << endc;
    return;
}
void print(const int &x, char endc = '\n') {
    printf("%d%c", x, endc);
    return;
}
void print(const long long &x, char endc = '\n') {
    printf("%lld%c", x, endc);
    return;
}
void print(const size_t &x, char endc = '\n') {
    printf("%zu%c", x, endc);
    return;
}
void print(const float &x, char endc = '\n') {
    printf("%f%c", x, endc);
    return;
}
void print(const double &x, char endc = '\n') {
    printf("%lf%c", x, endc);
    return;
}

template<typename T1, typename T2>
void print(const std::pair<T1, T2> &p, char sepc = ' ', char endc = '\n') {
    print(p.first, sepc);
    print(p.second, endc);
    return;
}

template<typename T>
void print(const std::vector<T> &v, char sepc = ' ', char endc = '\n') {
    for(const T &e : v) print(e, sepc);
    printf("%c", endc);
    return;
}

template<typename T>
class SparseGraph {
    struct Node {
        std::vector<std::pair<int, T>> adj;
        T value;
    };

private:
    std::vector<Node> nodes;
    int nodeSize;
    int edgeSize = 0;

public:
    SparseGraph(int n) {
        nodes.resize(n);
        nodeSize = n;
    }

    SparseGraph(const std::vector<T> &values) {
        int n = values.size();
        nodes.resize(n);
        nodeSize = n;
        for(int i = 0; i < n; i++)
            nodes[i].value = values[i];
    }

    void addEdge(int u, int v, const T &edgeVal = 0) {
        nodes[u].adj.push_back({v, edgeVal});
        edgeSize++;
    }

    const int &getNodeSize() const {
        return nodeSize;
    }

    const int &getEdgeSize() const {
        return edgeSize;
    }

    const T &valueOf(int here) const {
        return nodes[here].value;
    }

    const std::vector<std::pair<int, T>> &adjOf(int here) const {
        return nodes[here].adj;
    }
};

using namespace std;

double solve(int connected, int disconnected, vector<double> &memo) {
    if(disconnected == 0)
        return 0.0;

    double &ret = memo[connected];
    if(!ret) {
        ret = solve(connected+1, disconnected-1, memo) + 1.0 + 1.0*connected/disconnected;
    }

    return ret;
}

void eachTC() {
    int N = next<int>();
    vector<double> memo(N, 0.0);
    double res = solve(1, N-1, memo);
    printf("%.9lf", res);
}

int main() {
    constexpr bool multipleTC = false;
    int T = multipleTC ? next<int>() : 1;
    while(T--) eachTC();

    return 0;
}


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

const int maxn=1005*2;

int n,m;
vector<int> adj[maxn];
bool vis[maxn];

void adde(int a,int b){
    adj[a].push_back(b);
    adj[b].push_back(a);
}
int dfs(int u){
    vis[u]=1;
    int msk=1<<(u<=n);
    for(int i=0;i<(int)adj[u].size();i++){
        int v=adj[u][i];
        if(!vis[v])msk|=dfs(v);
    }
    return msk;
}
int cnt[2];
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        char _[maxn];
        cin>>_;
        for(int j=1;j<=m;j++){
            if(_[j-1]=='#')adde(i,j+n);
        }
    }
    adde(1,1+n);adde(n,1+n);adde(1,n+m);adde(n,n+m);
    for(int i=1;i<=n+m;i++)if(!vis[i]){
        int cw=dfs(i);
        for(int j=0;j<2;j++)cnt[j]+=(cw>>j)&1;
    }
    cout<<min(cnt[0],cnt[1])-1;
    return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cassert>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define li long long
#define pii pair<int, int>
#define vi vector<int>
#define li long long

#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define fore(i, b, e) for (int i = (int)b; i <= (int)e; i++)

const int MAXN = 2005;

bool visited[MAXN];
vi edges[MAXN];
int n, m;

void dfs(int v) {
	visited[v] = true;
	for (int u : edges[v]) {
		if (!visited[u])
			dfs(u);
	}
}

void add_edge(int row, int col) {
	edges[row].pb(col + n);
	edges[col + n].pb(row);
}

int main() {
	scanf("%d%d", &n, &m);
	forn(i, n) {
		string s;
		cin >> s;
		forn(j, m) {
			if (s[j] == '#') {
				add_edge(i, j);
			}
		}
	}
	/*forn(i, n) {
		add_edge(i, 0);
		add_edge(i, m - 1);
	}
	forn(j, m) {
		add_edge(0, j);
		add_edge(n - 1, j);
	}*/
	add_edge(0, 0);
	add_edge(0, m);
	add_edge(n - 1, 0);
	add_edge(n - 1, m - 1);
	int row_comp = 0;
	forn(i, n) {
		if (!visited[i]) {
			++row_comp;
			dfs(i);
		}
	}
	memset(visited, false, sizeof(visited));
	int col_comp = 0;
	fore(i, n, n + m - 1) {
		if (!visited[i]) {
			++col_comp;
			dfs(i);
		}
	}
	//cerr << row_comp << " " << col_comp << endl;
	printf("%d", min(row_comp - 1, col_comp - 1));
}


#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

const long long P = 1e9 + 7;
const double EPS = 1e-9;

using namespace std;

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

  vector<vector<long long>> dp(n, vector<long long>(n + 1));
  // dp[i][j]: num ways for v[0..i] with j segments
  // dp[i][j] = r[SUM(v[0..i]) % j]
  for (int i = 0; i < n; i++)
    dp[i][1] = 1;
  for (int k = 2; k <= n; k++) {
    long long s = 0;
    vector<long long> ct(k, 0);
    for (int i = 0; i < n; i++) {
      s = (s + v[i]) % k;
      dp[i][k] = ct[s];
      ct[s] = (ct[s] + dp[i][k - 1]) % P;
    }
  }
  long long res = 0;
  for (int k = 1; k <= n; k++)
    res = (res + dp[n - 1][k]) % P;
  cout << res << '\n';
}

/*
  YOU CAN DO THIS!! ;)
  1. Note the limits!
  2. Give logical, short variable names
  3. If you are stuck for a long time, skip to next problem
  4. Can't prove a pattern (Esp Game Theory)? Brute force for small numbers and observe!
*/
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  // int t;
  // cin >> t;
  while (t--) {
    solve();
  }
}

#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; debug_print(__VA_ARGS__); } while(false)
template<typename T, typename... Ts> void debug_print(const T &t, const Ts &...ts) { cerr << t; ((cerr << ", " << ts), ...); cerr << endl; }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, const T& b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, const T& b) { if (a < b) {a = b; return true; } return false; }
template<typename T, typename... Ts> void print(const T& t, const Ts&... ts) { cout << t; ((cout << ' ' << ts), ...); cout << '\n'; }
template<typename... Ts> void input(Ts&... ts) { (cin >> ... >> ts); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

template<ll MOD = 1000000007>
class ModInt {
    ll n;
    ModInt constexpr inverse() const {
        return ModInt::pow(*this, MOD - 2);
    }

public:
    ModInt() : n(0) {}
    ModInt(ll _n) : n(((_n % MOD) + MOD) % MOD) {}
    ModInt operator+=(const ModInt &m) {
        n += m.n;
        if (n >= MOD) n -= MOD;
        return *this;
    }
    ModInt operator-=(const ModInt &m) {
        n -= m.n;
        if (n < 0) n += MOD;
        return *this;
    }
    ModInt operator*=(const ModInt &m) {
        n *= m.n;
        if (n >= MOD) n %= MOD;
        return *this;
    }
    ModInt operator/=(const ModInt &m) {
        (*this) *= m.inverse();
        return *this;
    }
    friend ModInt operator+(ModInt t, const ModInt &m) {
        return t += m;
    }
    friend ModInt operator-(ModInt t, const ModInt &m) {
        return t -= m;
    }
    friend ModInt operator*(ModInt t, const ModInt &m) {
        return t *= m;
    }
    friend ModInt operator/(ModInt t, const ModInt &m) {
        return t /= m;
    }
    ModInt operator=(const ll l) {
        n = l % MOD;
        if (n < 0) n += MOD;
        return *this;
    }
    friend ostream &operator<<(ostream &out, const ModInt &m) {
        out << m.n;
        return out;
    }
    friend istream &operator>>(istream &in, ModInt &m) {
        ll l;
        in >> l;
        m = l;
        return in;
    }
    static constexpr ModInt pow(const ModInt x, ll p) {
        ModInt<MOD> ans = 1;
        for (ModInt<MOD> m = x; p > 0; p /= 2, m *= m) {
            if (p % 2) ans *= m;
        }
        return ans;
    }
    static constexpr ll mod() {
        return MOD;
    }
};
using mint = ModInt<>;
mint operator"" _m(unsigned long long m) {
    return mint(m);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    vector<ll> a(n);
    rep(i, 0, n) {
        cin, a[i];
    }
    auto dp = make_v(n + 1, n + 1, 0_m);
    dp[0][0] = 1;
    mint ans = 0;
    vector<ll> sum(n + 1, 0);
    auto mp = make_v(n + 1, n + 1, 0_m);
    rep(i, 0, n) {
        sum[i + 1] = sum[i] + a[i];
        rep(j, 0, n) {
            mp[j][sum[i] % (j + 1)] += dp[i][j];
        }
        rep(j, 0, n) {
            dp[i + 1][j + 1] += mp[j][sum[i + 1] % (j + 1)];
            /*
            rep(k, 0, i + 1) {
                if (sum[i + 1] % (j + 1) == sum[k] % (j + 1)) {
                    dp[i + 1][j + 1] += dp[k][j];
                }
            }
            //*/
        }
    }
    rep(i, 0, n + 1) {
        ans += dp[n][i];
    }
    print(ans);
    return 0;
}


#include <bits/stdc++.h>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n), b(n);
    rep(i, n) scanf("%d", &a[i]);
    rep(i, n) scanf("%d", &b[i]);
    int p[n], owner[n];
    rep(i, n) {
        scanf("%d", &p[i]);
        --p[i];
        owner[p[i]] = i;
    }

    vector<int> idx(n);
    iota(idx.begin(), idx.end(), 0);
    sort(idx.begin(), idx.end(),
         [&](const int& i, const int& j) { return a[i] < a[j]; });
    vector<pii> ans;
    for (auto i : idx) {
        int j = owner[i];
        if (i == j) continue;
        if (a[i] <= b[p[i]] || a[j] <= b[p[j]]) {
            puts("-1");
            return 0;
        }
        ans.emplace_back(i, j);
        swap(p[i], p[j]);
        swap(owner[p[i]], owner[p[j]]);
    }

    printf("%d\n", ans.size());
    for (auto [i, j] : ans) printf("%d %d\n", i + 1, j + 1);
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define INF 0x3f3f3f3f
#define pi M_PI
typedef pair<ll, ll> llPair;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef priority_queue<ll> pqll;
ll MOD = 1000000007;
/*
Really doe, like really doe
Really doe, like really doe
*/
class DisjSet {
    int *rank, *parent, *size, n;

public:
    DisjSet(int n)
    {
        rank = new int[n];
        parent = new int[n];
        size = new int[n];
        this->n = n;
        makeSet();
    }
    void makeSet()
    {
        for (int i = 0; i < n; i++) {
            parent[i] = i;
            size[i] = 1;
        }
    }
    int siz(int x)
    {
        return size[x];
    }
    int find(int x)
    {
        if (parent[x] != x) {
            parent[x] = find(parent[x]);
        }

        return parent[x];
    }
    void Union(int x, int y)
    {
        int xset = find(x);
        int yset = find(y);

        if (xset == yset)
            return;

        if (rank[xset] < rank[yset]) {
            parent[xset] = yset;
            size[yset] = size[yset] + size[xset];
        }
        else if (rank[xset] > rank[yset]) {
            parent[yset] = xset;
            size[xset] = size[yset] + size[xset];
        }
        else {
            parent[yset] = xset;
            rank[xset] = rank[xset] + 1;
            size[xset] = size[yset] + size[xset];
        }
    }
};

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

    ll t;
    t = 1;
    for (ll z = 0; z < t; ++z)
    {
        ll n;
        cin >> n;
        vll a(n);
        vll b(n);
        vll p(n);
        vll p2(n);
        vb finish(n, false);
        DisjSet obj(n);
        bool pos = true;
        ll res = n;
        for (ll i = 0; i < n; ++i)
        {
            cin >> a[i];
        }
        for (ll i = 0; i < n; ++i)
        {
            cin >> b[i];
        }
        for (ll i = 0; i < n; ++i)
        {
            cin >> p[i];
            p[i]--;
            if (obj.find(i) != obj.find(p[i]))
            {
                obj.Union(i, p[i]);
                --res;
            }
            p2[p[i]] = i;
            if (p[i] != i && a[i] <= b[p[i]])
            {
                pos = false;
            }
            else if (p[i] == i)
            {
                finish[i] = true;
            }
        }

        if (!pos)
        {
            cout << -1 << '\n';
            continue;
        }
        else if (n == 1)
        {
            cout << 0 << '\n';
            continue;
        }
        vector<tuple<ll, ll, ll>> pair(n);
        for (ll i = 0; i < n; ++i)
        {
            pair[i] = make_tuple(b[p[i]], i, p2[i]);
        }
        cout << n - res << '\n';
        ll k = n - res;
        sort(pair.begin(), pair.end());
        for (ll i = 0; i < n; ++i)
        {
            ll j = get<1>(pair[i]);
            if (!finish[obj.find(j)])
            {
                finish[obj.find(j)] = true;
                ll t = get<2>(pair[i]);
                while (t != j)
                {
                    cout << t + 1 << ' ' << p[t] + 1 << '\n';
                    t = p2[t];
                }
            }
        }

    }

    return 0;
}


#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll=int;
using ld=long double;
using pll=pair<ll, ll>;
//using mint = modint1000000007;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo 2e18
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
//priority_queue<ll, vector<ll>, greater<ll>> Q;
/*
01234でタイルの方向管理？
*/
#define TIMEOVER_M 20000
#define TIMEOVER 1950000

ll T[50][50];
bool B[50][50];
ll P[50][50];
ll D[50][50];
char *ans;
char *W;
ll score=0;
ll high=0;
ll dx[]={0, 1, 0, -1};
ll dy[]={-1, 0, 1, 0};
char dc[]={'U', 'R', 'D', 'L'};
bool all_fin;
bool fin;
clock_t start;
clock_t start_m;
ll loop;

void steped(ll y, ll x, bool b){
  ll d=D[y][x];
  if (d){
    --d;
    ll ny=y+dy[d];
    ll nx=x+dx[d];
    B[ny][nx]=b;
  }
  B[y][x] = b;
}

// 行き止まりになったら、その時点でのstringを出力
void dfs(ll y, ll x, ll c){// {y, x, 歩数}
  bool used[4]={};
  rep(i, 4){
    clock_t now = clock();
    if(now-start_m>TIMEOVER_M) fin=true;
    if(now-start>TIMEOVER) all_fin=true;
    ll r=now%4;
    while(used[r]) (r+=1)%=4;
    used[r]=true;
    ll ny=y+dy[r];
    ll nx=x+dx[r];
//    cout << "time:" << now-start << endl;
    if(ny<0 || nx<0 || ny>49 || nx>49 || B[ny][nx] || fin || all_fin){
      if(chmax(high, score)){
        if(ans) free(ans);
        ans=strdup(W);
      }
    }
    else{
      //反映
      score+=P[ny][nx];
      W[c]=dc[r];
      steped(ny, nx, true);

      dfs(ny, nx, c+1);
      //復元
      score-=P[ny][nx];
      W[c]='\0';
      steped(ny, nx, false);
    }
  }

}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  W=(char*)calloc(2000, 1);
  start = clock();
  ll si, sj;
  cin >> si >> sj;
  rep(i, 50) rep(j, 50) cin >> T[i][j];
  rep(i, 50) rep(j, 50) cin >> P[i][j];
  // タイルの方向D
  rep(i, 50) rep(j, 50){
    rep(k, 4){
      ll ny=i+dy[k];
      ll nx=j+dx[k];
      if(ny<0 || nx<0 || ny>49 || nx>49) continue;
      if(T[i][j]==T[ny][nx]) D[i][j]=k+1;
    }
  }
  while(!all_fin){
    loop++;
    fin=false;
    start_m = clock();
    score = P[si][sj];
    chmax(high, score);
    rep(y, 50) rep(x, 50) B[y][x]=false;
    rep(i, 2000) W[i]='\0';
    steped(si, sj, true);
    dfs(si, sj, 0);
  }
//  cout << high << " " << loop << endl;
  printf("%s\n", ans);
}

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

const int Mod = 998244353;
int n, s, w[105];
long long ans, fac[105], dp[105][10005];

int main(){
	scanf("%d", &n);
	for(int i=1; i<=n; ++i){
		scanf("%d", &w[i]);
		s += w[i];
	}
	if(s&1){
		puts("0");
		return 0;
	}
	dp[0][0] = 1;
	for(int i=1; i<=n; ++i){
		for(int j=i; j>=1; --j){
			for(int k=s/2; k>=w[i]; --k){
				dp[j][k] += dp[j-1][k-w[i]];
				dp[j][k] %= Mod;
			}
		}
	}
	fac[0] = 1;
	for(int i=1; i<=n; ++i) fac[i] = fac[i-1] * i % Mod;
	for(int i=1; i<=n; ++i) ans = (ans+fac[i]*dp[i][s/2]%Mod*fac[n-i]%Mod) % Mod;
	printf("%lld\n", ans);
	return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 1001001001;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main() {
    long double n,d,h;
    cin >> n >> d >> h;
    double mx=0,dx=0;
    rep(i,n){
        double di,hi;
        cin >> di >> hi;
        double k = (hi-h)/(di-d);
        double b = h-(k*d);
        mx = max(b,mx);
    }
    if(mx<=0.0){
        cout << 0.0 <<endl;
    }else{
        cout << mx << endl;
    }
    return 0;
}

#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map> //http://vivi.dyndns.org/tech/cpp/map.html
#include <set> //http://vivi.dyndns.org/tech/cpp/set.html
#include <vector>
#include <deque>
#include <queue>
#include <numeric> //gcd,lcm c++17
#include <tuple>
#include <iomanip> //setprecision
#include <unordered_map>
#include <chrono>
//#define _GLIBCXX_DEBUG
using namespace std;
template <typename T>
using vc = vector<T>;
template <typename T>
using vv = vc<vc<T>>;
template <typename T>
using PQ = priority_queue<T, vc<T>, greater<T>>;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
//typedef __uint128_t Int;
using vi = vc<int>;
using vl = vc<ll>;
using vd = vc<double>;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define ALL(a) (a).begin(), (a).end()
#define sz(x) (int)(x).size()
template <class T1, class T2, class Pred = std::less<T2>>
struct sort_pair_second
{
    //sort_pair_second<ll,ll,greater<ll>>()
    bool operator()(const std::pair<T1, T2> &left, const std::pair<T1, T2> &right)
    {
        Pred p;
        return p(left.second, right.second);
    }
};
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
int MOD = 1e9 + 7;
double EPS = 1e-9;
int INF = 2000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
int rdx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int rdy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

vi G[200000];
int mx, mn;
vc<pi> A(200000);
bool visited[200000] = {};
int ans = -INF;

void dfs(int v)
{
    if (sz(G[v]))
        visited[v] = true;
    for (auto x : G[v])
    {
        if (visited[x])
            continue;
        chmax(ans, A[x].first - mn);
        dfs(x);
    }
}

int main()
{
    int N, M;
    cin >> N >> M;
    A.resize(N);
    FOR(i, 0, N)
    {
        cin >> A[i].first;
        A[i].second = i;
    }
    auto B = A;
    sort(ALL(B));
    FOR(i, 0, M)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        G[x].push_back(y);
    }
    FOR(i, 0, N)
    {
        if (visited[B[i].second])
            continue;
        mn = B[i].first;
        dfs(B[i].second);
    }
    cout << ans << endl;
}


#include<iostream>
#include<cstdio>
#include<cstring>
typedef long long ll;
typedef unsigned un;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
ll read()
{
	ll f=1,x=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();
	return f*x;
}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
bool umin(int& a,int t){if(t<a)return a=t,1;return 0;}
bool umin(ll& a,ll t){if(t<a)return a=t,1;return 0;}
bool umax(int& a,int t){if(t>a)return a=t,1;return 0;}
bool umax(ll& a,ll t){if(t>a)return a=t,1;return 0;}

#define MAXN 511
bool a[MAXN][MAXN];
char s[MAXN];
int main()
{
	int n=read();
	for(int i=1;i<=n;++i)
	{
		scanf("%s",s+1);
		for(int j=1;j<=n;++j)a[i][j]=(s[j]=='1');
		a[i][i]=1;
	}
	for(int k=1;k<=n;++k)
		for(int i=1;i<=n;++i)
			for(int j=1;j<=n;++j)a[i][j]|=(a[i][k]&a[k][j]);
	double ans=0;
	for(int u=1;u<=n;++u)
	{
		int c=0;
		for(int s=1;s<=n;++s)c+=a[s][u];
		ans+=1.00/c;
	}
	printf("%.11lf\n",ans);
	return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define ll long long
#define VV(t) vector<vector<t>>
using namespace std;
using Graph = VV(int);
const int INF = 1<<29;

int factorial(int n) {
   if (n<=1) return 1;
   else return n*factorial(n-1);
}

int main() {
   int N; cin >> N;
   Graph G(N, vector<int>(N, INF));
   rep(i, N) {
      rep(j, N) {
         char c; cin >> c;
         if (c == '1') G[i][j] = 1;
      }
      G[i][i] = 0;
   }
   rep(k, N) {
      rep(i, N) {
         rep(j, N) {
            G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
         }
      }
   }
   double v = 0;
   rep(i, N) {
      int nonInf = 0;
      rep(j, N) if (G[j][i] < INF/2) nonInf += 1;
      v += (double)1 / nonInf;
   }
   cout << fixed << setprecision(20) << v << endl;
}


//
//  a.cpp
//
//
//  Created by Sagar Singh on 13/12/20.
//

#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
typedef unsigned long long ul;
typedef long double ld;
typedef long long ll;
using namespace std;

int check(int a,int b,int c,int d){
    if( a+b == c+d || a-b == c-d || abs(a-c)+abs(b-d) <= 3 ){
        return 1;
    }
    return 0;
}
int main() {
    ll a,b,c,d; cin >> a >> b >> c >> d;
    int ans = 2 + ( (a+b)%2 != (c+d)%2 );
    for(int dx=-3;dx<=+3;++dx){
        for(int dy=-3;dy<=+3;++dy){
            int x = a + dx, y = b + dy;
            if( check(a,b,x,y) && check(x,y,c,d) ){
                ans = 2;
            }
        }
    }
    if( check(a,b,c,d) ){
        ans = 1;
    }
    if( a == c && b == d ){
        ans = 0;
    }
    cout << ans << endl;
}

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    double a = (double)(sy+gy) / (double)(gx-sx);
    double b = (double)gy - a*(double)gx;
    double x = -b / a;
    cout << fixed << setprecision(10);
    cout << x;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define YES cout<<"YES"
#define NO cout<<"NO"
#define Yes cout<<"Yes"
#define No cout<<"No"
#define yes cout<<"yes"
#define no cout<<"no"
#define FOR(S , E) for(ll i=S;i<=E;i++)
#define ROF(E , S) for(ll i=E;i>=S;i--)
// V.push_back() // V.pop_front()// V.top()
//V.pop()//V.front() // V.back() // pop_back()
//second // first // insert // continue // break
// erase // St.push() // V.size() // S.length()
// clear() // S.length() // reverse // greater // push
bool IsPalind(string S)
{
	int L =0  , R = S.length()-1;
	while(R > L)
	{
		if(S[L++]!=S[R--])
		{
			return 0;
		}
	}
	return 1;
}
int main()
{

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

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

 	string S;
 	cin>>S;
 	if(IsPalind(S))
 	{
 		Yes;
 		return 0;
 	}
 	for(int i=1;i<=15;i++)
 	{
 		string S2 = "";
 		for(int j=1;j<=i;j++)S2+='0';
 		for(char C : S)S2+=C;

 		if(IsPalind(S2))
 		{
 			Yes;
 			return 0;
 		}
 	}
 	No;
    return 0;

}

#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=200010,mod=1e9+7;
char s[100][10];
int main()
{
    int n;
    cin >> n;
    long long ans = 1;
    for (int i = 1; i <= n;i++)
    {
        string s;
        cin >> s;
        if(s=="OR")
        {
            ans += 1LL << i;
        }
    }
        printf("%lld", ans);
    return 0;
}


#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int a[100000];
int main() {
    int i;
    int T,N;
    scanf("%d",&T);
    while (T--) {
        scanf("%d",&N);
        for (i = 0; i < N; i++) scanf("%d",&a[i]);
        sort(a,a+N);

        if (!(N & 1)) {
            for (i = 0; i < N; i += 2) {
                if (a[i] != a[i+1]) break;
            }
            if (i >= N) printf("Second\n");
            else printf("First\n");
        }
        else printf((N & 1) ? "Second\n":"First\n");
    }

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, a, b) for(int i = a; i <= b; ++i)
const int N = 300007;
const int mod = 1e9 + 7;
int n;
int a[N];
int main()
{
	int T;
	cin >> T;
	while(T--){
		cin >> n;
		int key = 0;
		rep(i, 1, n)cin >> a[i], key ^= a[i];
		if(n & 1){
			puts("Second");
		}
		else {
			map<int, int>mp;
			rep(i, 1, n){
				if(mp.count(a[i]))mp[a[i]]++;
				else mp[a[i]] = 1;
			}
			int flag = 0;
			for(auto v : mp)if(v.second % 2 == 1)flag = 1;
			if(flag)puts("First");
			else puts("Second");
		}
	}
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;

#define rep(i, l, r) for(int i=(l), i##_end_=(r); i<=i##_end_; ++i)
#define drep(i, l, r) for(int i=(l), i##_end_=(r); i>=i##_end_; --i)
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define Endl putchar('\n')
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T>inline T fab(T x){ return x<0? -x: x; }
template<class T>inline T readin(T x){
    x=0; int f=0; char c;
    while((c=getchar())<'0' || '9'<c) if(c=='-') f=1;
    for(x=(c^48); '0'<=(c=getchar()) && c<='9'; x=(x<<1)+(x<<3)+(c^48));
    return f? -x: x;
}

const int maxn=1e5;

ll n;

int vis[maxn+5];

signed main(){
    n=readin(1ll);
    ll ans=0;
    vis[1]=1;
    for(int i=2; 1ll*i*i<=n; ++i) if(!vis[i]){
        vis[i]=1;
        for(ll cur=1ll*i*i; cur<=n; cur=1ll*cur*i){
            if(cur<=maxn) vis[cur]=1;
            ++ans;
        }
    }
    printf("%lld\n", n-ans);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5;
const ll mod = 998244353;

/*  I should look for
	* if WA, check the code from very top until bottom.
	* always write observations if problem is hard.
	* keep thought process clear.
	* special cases (n=1?)
	* stay organized.
	* DON'T GET STUCK ON ONE APPROACH
*/

int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	set <ll> s;
	for(ll i = 2;i <= sqrt(n);i++)
	{
		ll x = i;
		while((x * i) <= n)
			s.insert(x * i), x = x * i;
	}
	cout << n - s.size();
	return 0;
}


#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Pll = pair<ll, ll>;

int main() {
    ll n, w;
    cin >> n>> w;
    vector<Pll> v;
    rep(i, n){
        ll s, t, p;
        cin >> s >> t >> p;
        v.emplace_back(s, p);
        v.emplace_back(t, -p);
    }

    sort(v.begin(), v.end());
    ll now = 0;
    string res = "Yes";

    rep(i, 2*n){
        now += v[i].second;
        if(now > w){
            res = "No";
            break;
        }
    }

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

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

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

ll v[225816];

int main(void){
	int n,s,t,i;
	ll w,p;
	std::cin >> n >> w;
	for(i=0; i<n; ++i){
		std::cin >> s >> t >> p;
		v[s] += p;
		v[t] -= p;
	}
	for(i=1; i<225816; ++i){
		v[i] += v[i-1];
	}
	for(i=0; i<225816; ++i){
		if(v[i]>w){
			std::cout << "No" << std::endl;
			return 0;
		}
	}
	std::cout << "Yes" << std::endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

const int N = 2000000 + 5, Mod = 1000000007;
int n = 0, m = 0, k = 0;
long long arr[N] = {}, x = 0, y = 0;

long long f(int num, int cnt){
	if(cnt == 0) return 1;
	long long temp = f(num, cnt / 2);
	if(cnt % 2 == 0) return (temp * temp) % Mod;
	else return ((temp * temp) % Mod) * num % Mod;
}

int main(){
	cin >> n >> m >> k;
	if(n > m + k){
		cout << 0;
		return 0;
	}
	arr[0] = 1;
	for(int i = 1 ; i <= m + n + 3 ; i ++) arr[i] = (arr[i - 1] * i) % Mod;
	x = (((arr[m + n] * f(arr[m], Mod - 2)) % Mod) * f(arr[n], Mod - 2)) % Mod;
	if(k != n) y = (((arr[m + n] * f(arr[m + k + 1], Mod - 2)) % Mod) * f(arr[n - k - 1], Mod - 2)) % Mod;
	cout << (x + Mod - y) % Mod;
	return 0;
}

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

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

// using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const int N=2000005;
ll fact[N],invfact[N];
ll power(ll x,ll y){
  if(y<=0) return 1LL;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  return (z*z)%mod;
}

void pre(){
  fact[0]=invfact[0]=invfact[1]=fact[1]=1;
  rep(i,2,N) fact[i]=(i*fact[i-1])%mod;
  rep(i,2,N) invfact[i]=(invfact[i-1]*power(i,mod-2))%mod;
}
ll nCr(ll n,ll k){ return (((fact[n]*invfact[n-k])%mod)*invfact[k])%mod; }

const int N1=1e6+1;
vector<int> isprime(N1,1),prime;
void seive(){
  rep(i,2,sqrt(N1)+1){
      if(isprime[i]){
        for(int j=i*i;j<N1;j+=i) isprime[j]=0;
        prime.pb(i);
      }
  }
  rep(i,sqrt(N1)+1,N1) if(isprime[i]) prime.pb(i);
}

struct dsu {
    vector<int> par, rank;
    dsu(int n): par(n+1), rank(n+1) {
        for (int i = 0; i <= n; i++) {
            par[i] = i;
            rank[i]= 1;
        }
    }
    int root(int a) {
        if (a == par[a]) return a;
        return par[a] = root(par[a]);
    }
    void merge(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] > rank[b]) swap(a, b);
        par[b] = a;
    }
    set<int> parent(int n){
        set<int> s;
        for(int i=1;i<=n;i++){
            s.insert(root(i));
        }
        return s;
    }
};
ll solve1(ll x,ll y){
  if(x<0 || y<0) return 0;
  return nCr(x+y,x);
}
void solve(){
  int n,m,k;
  cin>>n>>m>>k;
//  (0,0) to (m,n)
//  -k-1,k+1
  if(n>m+k) cout<<0<<endl;
  else cout<<(solve1(n,m)-solve1(n-(k+1),m-(-k-1))+mod)%mod<<endl;
}

int main(){
    optimizeIO();
    int r=1;
    pre();
    {solve();}
}


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

#define int long long
#define fi first
#define se second
#define max Max
#define min Min
#define abs Abs
#define lc (x<<1)
#define rc (x<<1|1)
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define fan(x) (((x-1)^1)+1)
#define mp(x,y) make_pair(x,y)
#define clr(f,n) memset(f,0,sizeof(int)*(n))
#define cpy(f,g,n) memcpy(f,g,sizeof(int)*(n))

using namespace std;

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

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

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

const int N=3e3+5;
int n,now,a[N];

signed main()
{
	n=read()-3;
	printf("10 15 6 ");
	a[1]=10;a[2]=15;a[3]=6;
	now=3;
	for(int i=7;i<=100000&&n;++i)
	{
		int flag=1;
		for(int j=1;j<=now;++j)
			if(__gcd(a[j],i)==1||a[j]==i)
				flag=0;
		if(flag)
		{
			a[++now]=i;--n;
			printf("%lld ",i);
		}
	}
	printf("\n");
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

inline int read()
{
    register int x=0,f=1,ch=getchar();
    while(!isdigit(ch))
	{
		if(ch=='-') f=-1;
		ch=getchar();
	}
    while(isdigit(ch)) x=x*10 +ch-'0',ch=getchar();
    return x*f;
}

int n,k;

int main()
{
	n=read(),k=read();
	printf("%d\n",(n+1)*n/2*k*100+(k+1)*k/2*n);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n, m;
    cin >> n >> m;

    vector<int> g(n);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u] |= 1 << v;
        g[v] |= 1 << u;
    }

    vector<int> dp(1 << n, LLONG_MAX);
    dp[0] = 1;
    for (int i = 0; i < (1 << n); i++) {
        for (int j = 0; j < n; j++) {
            if (dp[i] == 1 && (g[j] & i) == i)
                dp[i | 1 << j] = 1;
        }
    }

    for (int i = 1; i < (1 << n); i++) {
        for (int j = i; --j &= i;) {
            dp[i] = min(dp[i], dp[i ^ j] + dp[j]);
        }
    }

    cout << dp.back();
}

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(int i = (m); i < (n); ++i)
#define REPN(i, m, n) for(int i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(int i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(int i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
template <class T1, class T2>
bool chmax(T1 &a, const T2 b) { return a < b ? a = b, true : false; }
template <class T1, class T2>
bool chmin(T1 &a, const T2 b) { return a > b ? a = b, true : false; }
template <class T>
istream &operator>>(istream &is, vector<T> &v) { for (T &i : v) is >> i; return is; }
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &i : v) os << i << ' '; return os; }
void _co() { cout << '\n'; }
template <class Head, class... Tail>
void _co(Head&& head, Tail&&... tail) { cout << ' ' << head; _co(forward<Tail>(tail)...); }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) { cout << head; _co(forward<Tail>(tail)...); }
void ce() { cerr << '\n'; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) { cerr << head << ' '; ce(forward<Tail>(tail)...); }
void sonic() { ios::sync_with_stdio(false); cin.tie(nullptr); }
void setp(const int n) { cout << fixed << setprecision(n); }
constexpr int64_t INF = 1000000000000000001;
constexpr int64_t MOD = 1000000007;
constexpr int64_t MOD_N = 998244353;
constexpr long double EPS = 1e-11;
const double PI = acos(-1);

int main(void) {
    int n, m;
    cin >> n >> m;
    const int N = 1 << n;

    vector<bitset<18>> g(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a][b] = true;
        g[b][a] = true;
    }
    rep(i, n) g[i][i] = true;

    vector<int> dp(1 << n, 1e9);
    dp[0] = 0;

    rep(bit, N) {
        bool flg = true;
        rep(i, n) {
            rep(j, n) {
                if ((bit >> i) & (bit >> j) & 1)
                    flg &= g[i][j];
            }
        }
        if (flg)
            dp[bit] = 1;
    }

    rep(bit, N) {
        for (int i = bit; --i &= bit; ) {
            chmin(dp[bit], dp[i] + dp[bit ^ i]);
        }
    }
    co(dp.back());

    return 0;
}