#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <complex>
#include <regex>

#define Debug cout << "line: " << __LINE__ << "Debug" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;
#define ALL(a) (a).begin(), (a).end()
#define MP make_pair
#define MOD 1000000007
#define PI 3.14159265358979323846

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vd = vector<double>;
using vl = vector<long long>;

void set_FPD(int n){
    cout << fixed << setprecision(n);
    return;
}

ll func(vl a,vl b,vl c){
    ll abmin=1e15,acmin=1e15,bcmin=1e15;
    for(ll &x:a){
        auto itr=lower_bound(ALL(b),x);
        abmin=min({abs(x-*itr),abs(x-*(itr-1)),abmin});
    }
    for(ll &x:a){
        auto itr=lower_bound(ALL(c),x);
        acmin=min({abs(x-*itr),abs(x-*(itr-1)),acmin});
    }
    for(ll &x:b){
        auto itr=lower_bound(ALL(c),x);
        bcmin=min({abs(x-*itr),abs(x-*(itr-1)),bcmin});
    }
    return min(abmin,acmin+bcmin);
}

ll func(vl a,vl b){
    ll abmin=1e15;
    for(ll &x:a){
        auto itr=lower_bound(ALL(b),x);
        abmin=min({abs(x-*itr),abs(x-*(itr-1)),abmin});
    }
    return abmin;
}

void Main(){
    int n;
    cin>>n;
    vl r,g,b;
    for(int i=0;i<2*n;i++){
        ll a;
        char c;
        cin>>a>>c;
        if(c=='R') r.push_back(a);
        else if(c=='G') g.push_back(a);
        else b.push_back(a);
    }
    ll rsize=r.size(),gsize=g.size(),bsize=b.size();
    if(rsize%2==0 && gsize%2==0 && bsize%2==0){
        cout<<0<<endl;
        return;
    }
    if(rsize!=0) sort(ALL(r));
    if(gsize!=0) sort(ALL(g));
    if(bsize!=0) sort(ALL(b));
    if(rsize%2==1 && gsize%2==1){
        if(bsize==0) cout<<func(r,g);
        else cout<<func(r,g,b);
    }
    else if(gsize%2==1 && bsize%2==1){
        if(rsize==0) cout<<func(g,b);
        else cout<<func(g,b,r);
    }
    else if(bsize%2==1 && rsize%2==1) {
        if(gsize==0) cout<<func(b,r);
        else cout<<func(b,r,g);
    }
    cout<<endl;
    return;
}

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

#pragma region Macros
#include <bits/stdc++.h>
// #include <atcoder/all>

using std::cin;
using std::cout;
using std::endl;
using std::sort;
using std::string;
using std::vector;
// using namespace atcoder;
typedef long long ll;
#define int long long

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl;
#else
#define DEBUG(x)
#endif

#define ALL(obj) (obj).begin(), (obj).end()
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define YesNo(bool)            \
    if (bool)                  \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define PRINTARR(arr)     \
    for (auto e : arr)    \
        cout << e << " "; \
    cout << endl;

constexpr ll MOD = (ll)1e9 + 7;
constexpr ll INF = (ll)1e18;
constexpr double EPS = 1e-9;
const double PI = std::acos(-1);

#pragma endregion

#pragma region Library

#pragma endregion

int calc(vector<int> arr1, vector<int> arr2)
{
    if (arr1.size() == 0 || arr2.size() == 0)
    {
        return INF;
    }
    auto it1 = 0;
    auto it2 = 0;
    int ret = std::abs(arr1[0] - arr2[0]);
    while (!(it1 == (int)arr1.size() - 1 && it2 == (int)arr2.size() - 1))
    {
        ret = std::min(ret, std::abs(arr1[it1] - arr2[it2]));

        if (it1 == (int)arr1.size() - 1)
        {
            it2++;
        }
        else if (it2 == (int)arr2.size() - 1)
        {
            it1++;
        }
        else if (arr1[it1] < arr2[it2])
        {
            it1++;
        }
        else
        {
            it2++;
        }
    }

    ret = std::min(ret, std::abs(arr1[it1] - arr2[it2]));

    return ret;
}

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

    int n;
    cin >> n;

    vector<int> red, green, blue;
    REP(i, 2 * n)
    {
        int c;
        string color;
        cin >> c >> color;
        if (color == "R")
        {
            red.push_back(c);
        }
        if (color == "G")
        {
            green.push_back(c);
        }
        if (color == "B")
        {
            blue.push_back(c);
        }
    }

    if (red.size() % 2 == 0 && green.size() % 2 == 0 && blue.size() % 2 == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        vector<int> even, odd1, odd2;
        if (red.size() % 2 == 0)
        {
            even = red;
            odd1 = green;
            odd2 = blue;
        }
        if (green.size() % 2 == 0)
        {
            even = green;
            odd1 = red;
            odd2 = blue;
        }
        if (blue.size() % 2 == 0)
        {
            even = blue;
            odd1 = green;
            odd2 = red;
        }

        std::sort(ALL(even));
        std::sort(ALL(odd1));
        std::sort(ALL(odd2));

        cout << std::min(calc(odd1, odd2), calc(odd1, even) + calc(even, odd2)) << endl;

        // cout << calc(odd1, even) << " " << calc(even, odd2) << endl;
        // PRINTARR(even);

        return 0;
    }
}


#include <bits/stdc++.h>

using i32 = std::int32_t;
using i64 = std::int64_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
using usize = std::size_t;

const i32 INF = 1001001001;
const i64 LINF = 1001001001001001;
const u32 MOD1 = 1000000007;
const u32 MOD2 = 998244353;

i64 ntop(i64 x, i64 m) {
    if(x < 0) x += std::ceil((double)std::abs(x) / m) * m;
    return x % m;
}

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

i64 lcm(i64 a, i64 b) {
    if(a == 0 || b == 0) return -1;
    return a / gcd(a, b) * b;
}

i64 ext_gcd(i64 a, i64& x, i64 b, i64& y) {
    if(b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    i64 g = ext_gcd(b, y, a % b, x);
    y -= a / b * x;
    return g;
}

std::vector<std::pair<i64, i64>> prime_factor(i64 n) {
    std::vector<std::pair<i64, i64>> pf;
    i64 e = 0;
    while(n % 2 == 0) {
        e++;
        n /= 2;
    }
    if(e > 0) pf.emplace_back(std::make_pair(2, e));
    for(i64 i = 3; i * i <= n; i += 2) {
        e = 0;
        while(n % i == 0) {
            e++;
            n /= i;
        }
        if(e > 0) pf.emplace_back(std::make_pair(i, e));
    }
    if(n > 1) pf.emplace_back(std::make_pair(n, 1));
    return pf;
}

i64 euler_totient(i64 n) {
    std::vector<std::pair<i64, i64>> pf = prime_factor(n);
    i64 res = n;
    for(const auto& x : pf) {
        res -= res / x.first;
    }
    return res;
}

i64 linear_congruence_equation(i64 a, i64 c, i64 m) {
    i64 u, v;
    i64 g = ext_gcd(a, u, m, v);
    if(c % g != 0) return -1;
    i64 res = c / g * u % m;
    return ntop(res, m);
}

i64 chinese_remainder_theorem(i64 b, i64 m, i64 c, i64 n) {
    return m * linear_congruence_equation(m, ntop(c - b, n), n) + b;
}

using namespace std;

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

    i64 n;
    cin>>n;
    i64 ans=1;
    for(i64 i=2;i<=n;i++){
        ans=lcm(ans,i);
    }
    cout<<ans+1<<endl;
}

#include <bits/stdc++.h>
using namespace std;
////////////////////////////////////////////////////////////////////////////<editor-fold desc="macros">
#define endl "\n"
#define long long long
#define all(v) (v).begin(),(v).end()
#define makeset(v) (v).resize(unique((v).begin(),(v).end())-(v).begin())
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define filein freopen("input.txt", "r", stdin);
#define fileout freopen("output.txt", "w", stdout);
#define getline(x) getline(cin,x)
#define makelower(s) transform(s.begin(),s.end(),s.begin(),::tolower)
bool sortby(pair<int,int> a,pair<int,int> b){
    double x=(double )a.first/a.second;
    double y=(double )b.first/b.second;
     return x<y;}
long Pow(long x, long y) {
    if(y == 0)return 1;
    long tmp=Pow(x,y/2);
    tmp*=tmp;
    if(y&1)tmp*=x;
    return tmp;
}
#define printcase(x)  cout<<"Case "<<in++<<": "<<x<<endl
#define memset(a,b) memset(a,b,sizeof(a))
#define print1d(ary) cout<<"[";for(auto x:(ary)){cout<<x<<",";}cout<<"]"<<endl;
#define print2d(x) for(int m = 0; m <sizeof(x)/sizeof(x[0]) ; ++m){for(int l = 0; l <sizeof(x[0])/sizeof(x[0][0]) ; ++l){cout<<x[m][l]<<" ";}cout<<endl;}
#define pi acos(-1)
#define esp 1e-9
////////////////////////////////////////////////////////////////////////////</editor-fold>

int main() {
///<editor-fold desc="ios">
    IOS
#ifdef _AD_
    filein //fileout
#endif
///</editor-fold>
    int in=1,o;
    long t,n,m,q,tmp;
    cin>>n;
    if(n&1)cout<<"Black"<<endl;
    else cout<<"White"<<endl;
}


#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <array>
typedef long long ll;
using namespace std;

const int logn = 17;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<vector<int> > f(n+1, vector<int>(logn, 0));
	vector<int> ans(n + 1, 0);
	for (int i = 1; i <= n; i++)
	{
		ans[i] = -1;
		for (int j = 0; j < logn; j++)
		{
			if (!f[i][j])
			{
				ans[i] = j;
				break;
			}
		}
		for (int j = i; j <= n; j += i)
		{
			f[j][ans[i]]++;
		}
	}
	for (int i = 1; i <= n; i++) cout << ans[i] + 1 << " ";
	cout << "\n";
	return 0;
}

#include <bits/stdc++.h>
//#include <cmath>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
//#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define bs(yup,x) binary_search(yup.begin(),yup.end(),x) //it will return bollean value
#define lb(yup,x) lower_bound(yup.begin(),yup.end(),x)  //it will return the adress of the number which is equal to or just greater than x ,and if it is equal to yup.end() than their in no such number exist
#define ub(yup,x) upper_bound(yup.begin(),yup.end(),x)
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
using namespace std;
const long long N=100005, INF=2000000000000000000;
const long double EPS= 0.000000000001;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
vi prime;
bool isprime[N];
void pre()
{
    for(int i=2;i<N;i++)
    {
        if(isprime[i])
        {
            for(int j=i*i;j<N;j+=i)
            {
                isprime[j]=false;
                prime.pb(i);
            }
        }
    }
    return;
}

int32_t main()
{

    IOS;
    //fill(isprime, true);
    //pre();
    int qter=1;
    //cin>>qter;
    for(int wert=1;wert<=qter;wert++)
    {
        //cout<<"Case #"<<wert<<": ";
        int n;
        cin>>n;
        int ans[n+1];
        ans[1]=1;
        rep(i,2,n+1) ans[i]=2;
        rep(i,2,n+1)
        {
            int val=ans[i];
            for(int j=i*2;j<=n;j+=i)
            {
                ans[j]=max(ans[j],ans[i]+1);
            }
        }
        rep(i,1,n+1) cout<<ans[i]<<" ";
        //cout<<ans<<"\n";

    }
}


#include<bits/stdc++.h>
#define rei register int
#define ll long long
#define PLL pair<ll,ll>
#define mk make_pair
using namespace std;

const int N=1e5+100;
ll k,n,m;
ll a[N],b[N];
priority_queue<PLL>p;

int main(){
	scanf("%d%d%d",&k,&n,&m);
	ll sum=0;
	for(rei i=1;i<=k;++i){
		scanf("%d",&a[i]);
		b[i]=(m*a[i])/n;
		sum+=b[i];
		ll temp=m*a[i]-n*b[i];
		p.push(mk(temp,i));
	}
	while(sum<m){
		++b[p.top().second];
		p.pop();
		++sum;
	}
	for(rei i=1;i<=k;++i)
		printf("%d ",b[i]);
	puts("");
	return 0;
}

/*
@author: Saurav Sihag
*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define ff first
#define ss second
#define lld long double

template <class T>
void print(vector<T>& v){
    for(T x:v) cout<<x<<" ";
    cout<<"\n";
}

void inp(vector<ll>& v, int n){
    for (int i=0; i<n; ++i) scanf("%lld", &v[i]);
}

// const int nax=1e+5+5;
// const int inf=1e+9+5;
const ll mod=1e+9+7;
// const ll mod=998244353;
const ll nax=1e+17+5;
// const int dx[4]={0,0,-1,1};
// const int dy[4]={1,-1,0,0};

lld dp[101][101][101];

lld recur(int a, int b, int c){
    if (a==100 || b==100 || c==100) return 0;
    if (dp[a][b][c]!=-1) return dp[a][b][c];
    lld res=0, aa=a, bb=b, cc=c, d=(aa+bb+cc);
    if (a>0){
        res+=aa*(recur(a+1, b, c)+1.0);
    }
    if (b>0){
        res+=bb*(recur(a, b+1, c)+1.0);
    }
    if (c>0){
        res+=cc*(recur(a, b, c+1)+1.0);
    }
    res/=d;
    // cout<<a<<" "<<b<<" "<<c<<" res="<<res<<endl;
    return dp[a][b][c]=res;
}

void sol(){
    int a, b, c;
    cin>>a>>b>>c;
    // memset(dp, -1, sizeof(dp));
    for (int i=0; i<101; ++i) for (int j=0; j<101; ++j) for (int k=0; k<101; ++k) dp[i][j][k]=-1;
    lld res=recur(a, b, c);
    cout<<res<<endl;
    return ;
}

int main() {
    int t;
    t=1;
    // cin>>t;
    t++;
    std::cout << std::setprecision(20);
    for (int i=1; i<t; ++i){
        // printf("Case #%d: ", i);
        sol();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long int
#define s(x)	cin>>x
#define p(x)	cout<<x<<"\n"
#define goog(x, y)  cout<<"Case #"<<x<<": "<<y<<"\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 100000000000
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpi;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
typedef long double ld;

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);
int gcd(int a, int b) ;

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve() {
  int n,a,b;cin>>n>>a>>b;
  p(n-a+b);
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

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

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    //u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

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

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

#define ll                 long long
#define pb                 push_back
#define ppb                pop_back
#define endl               '\n'
#define mii                map<ll, ll>
#define pii                pair<ll, ll>
#define vi                 vector<ll>
#define all(a)             (a).begin(), (a).end()
#define mem0(x)            memset(x, 0, sizeof(x))
#define mem1(x)            memset(x, -1, sizeof(x))
#define F                  first
#define S                  second
#define sz(x)              ((ll)x.size())
#define DECIMAL(n)         cout<<fixed<<setprecision(n);
#define rep(i, a, b)       for (ll i=a; i<b; i++)
#define repr(i, a, b)      for (ll i=a-1; i>=b; i--)
#define bitcount(a)        (ll)__builtin_popcount(a)
#define lbnd               lower_bound
#define ubnd               upper_bound
#define ios                ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define trace(...)         __f(#__VA_ARGS__, __VA_ARGS__)

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k) returns iterator to kth element starting from 0
// order_of_key(k) returns count of elements strictly smaller than k

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    std::cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names+1, ','); std::cerr.write(names, comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1, args...);
}

const long double PI=3.14159265358979323846264338;
const double eps=1e-10;
ll hell=1e9+7;
ll inf=((ll)5e18+5);

void solve() {
    ll n;
    cin>>n;
    ll arr[n];
    cin>>arr[0];
    ll ans=arr[0];
    rep(i, 1, n) {
        cin>>arr[i];
        ans=__gcd(ans, arr[i]);
    }
    cout<<ans<<endl;
}

signed main() {
    ios
    ll test=1;
    // cin>>test;
    while (test--) solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long ll;
typedef long double ld;
const ll mod = 1e9+7;
const ll INF = 1e18;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using V = vector<ll>;
using P = pair<ll,ll>;
using Graph = vector<V>;

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

  ll s, p;
  cin >> s >> p;
  for (ll i = 1; i <= sqrt(p) + 100; ++i) {
    if (p%i == 0) {
      ll j = p/i;
      if (i+j == s) {
        cout << "Yes\n";
        return 0;
      }
    }
  }
  cout << "No\n";
}

#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define eb emplace_back
#define Field(T) vector<vector<T>>
#define pq(T) priority_queue<T,vector<T>,greater<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<vector<ll>> cnt(n+1);
  cnt[n].eb(0);
  set<int> st;
  st.emplace(n);
  rep(i,0,n) {
    ll x;
    int c;
    cin >> x >> c;
    --c;
    cnt[c].eb(x);
    st.emplace(c);
  }
  ll a1 = 0, a2 = 0;
  ll ps = 0, pt = 0;
  for (auto e : st) {
    vector<ll> &v = cnt[e];
    sort(all(v));
    ll ns = v.front(), nt = v.back();
    ll na1 = min(a1 + abs(ps - nt), a2 + abs(pt - nt)) + nt - ns;
    ll na2 = min(a1 + abs(ps - ns), a2 + abs(pt - ns)) + nt - ns;
    a1 = na1, a2 = na2;
    ps = ns, pt = nt;
  }
  cout << min(a1, a2) << endl;
  return 0;
}


#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using namespace std;
using ll = long long;
struct Edge
{
    ll to;
    ll cost;
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, ll>;
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), v.end()
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = LLONG_MAX;
const int MAX = 510000;
bool graph[nmax][nmax];
long long 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(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;

    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}
ll A, B;

bool isOK(ll key)
{
    ll cnt = 0;
    for (int i = A; i <= B; i++)
    {
        if (i % key == 0)
        {
            cnt++;
        }
    }
    if (cnt >= 2)
    {
        return true;
    }
    else
    {
        return false;
    }
}

int main()
{
    scanf("%lld", &A);
    scanf("%lld", &B);
    ll ans = -1;
    for (int i = 1; i < 200010; i++)
    {
        ll mi = ceil(A, i);
        ll div = mi * i;
        ll div2 = (mi +1) * i;

        if (A <= div && div2 <= B)
        {
            ans = i;
        }
    }
    cout << ans << endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=3010;
const int INF=1e9;
int n,a[maxn][5];
int dp[maxn][32][5];
bool solve(int mid) {
	memset(dp,0,sizeof(dp));
	dp[0][0][0]=1;
	for (int id=1;id<=n;id++) {
		int now=0;
		for (int i=0;i<=4;i++) if (a[id][i]>=mid) now|=(1<<i);
		for (int i=0;i<=3;i++) {
			for (int t=0;t<32;t++) if (dp[id-1][t][i]) {
				dp[id][t|now][i+1]=dp[id][t][i]=1;
			}
		}
	}
	return dp[n][31][3];

}
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++)
	for (int j=0;j<=4;j++) read(a[i][j]);
	int l=0,r=INF+10,res,mid;
	while (l<=r) {
		mid=(l+r)>>1;
		if (solve(mid)) res=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",res);
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?

  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?

  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/


#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;
template <typename T1, typename T2> bool mini(T1 &a, T2 b) {
	if (a > b) {a = b; return true;} return false;
}
template <typename T1, typename T2> bool maxi(T1 &a, T2 b) {
	if (a < b) {a = b; return true;} return false;
}
const int N = 1e5 + 5;
const int oo = 1e9;

vector <long long> s[100];
vector <int> val;

long long l, r, ans;

bool used[100];
bool cop[100][100];

void backtrack(int i, vector <long long> &a) {
	if (i == (int) val.size()) {
		ans++;
		return;
	}
	backtrack(i + 1, a);
	for (long long x : s[val[i]]) {
		bool ok = true;
		for (long long y : a) if (!cop[x - l][y - l]) {
			ok = false;
			break;
		}
		if (!ok)
			continue;
		a.push_back(x);
		backtrack(i + 1, a);
		a.pop_back();
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> l >> r;
	for (long long i = l; i <= r; i++)
	for (long long j = l; j <= r; j++)
		if (__gcd(i, j) == 1)
			cop[i - l][j - l] = true;

	for (int i = 2; i <= 80; i++)
	for (long long j = l; j <= r; j++) if (!used[j - l] && j % i == 0) {
		s[i].push_back(j);
		used[j - l] = true;
	}

	for (int i = 2; i <= 80; i++)
		if (s[i].size())
			val.push_back(i);

	vector <long long> a;
	backtrack(0, a);
	for (int i = 0; i <= r - l; i++)
		if (!used[i])
			ans <<= 1;
	cout << ans;
	return 0;
}

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

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

const int CM = 320000;
char cn[CM], * ci = cn, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
const int MAX = 10000;
class shuturyoku_unko {
public:
	char C[MAX * 5];
	constexpr shuturyoku_unko() : C() {
		rep(i, MAX) {
			int X = i;
			rep(j, 4) {
				C[i * 5 + 3 - j] = '0' + X % 10;
				X /= 10;
			}
			C[i * 5 + 4] = '\n';
		}
	}
};
constexpr shuturyoku_unko f;
const int dm = 260000;
char dn[dm], * di = dn;
void putint(ll A) {
	int dig = 1;
	if (A >= 100000000) {
		if (A >= 100000000000) dig = 4;
		else if (A >= 10000000000) dig = 3;
		else if (A >= 1000000000) dig = 2;
		memcpy(di + 4 + dig, f.C + A % 10000 * 5, 5);
		A /= 10000;
		memcpy(di + dig, f.C + A % 10000 * 5, 4);
		memcpy(di, f.C + A / 10000 * 5 + 4 - dig, dig);
		di += 9 + dig;
	}
	else {
		if (A >= 10000) {
			if (A >= 10000000) dig = 4;
			else if (A >= 1000000) dig = 3;
			else if (A >= 100000) dig = 2;
			memcpy(di + dig, f.C + A % 10000 * 5, 5);
			memcpy(di, f.C + A / 10000 * 5 + 4 - dig, dig);
			di += 5 + dig;
		}
		else {
			if (A >= 1000) dig = 4;
			else if (A >= 100) dig = 3;
			else if (A >= 10) dig = 2;
			memcpy(di, f.C + A * 5 + 4 - dig, dig + 1);
			di += 1 + dig;
		}
	}
}

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

	fread(cn, 1, 320000, stdin);
	int T = getint();

	rep(t, T) {
		int L = getint(), R = getint();

		ll tmp = R - L - L;
		if (tmp >= 0) putint((tmp + 2) * (tmp + 1) >> 1);
		else putint(0);
	}
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}


//-- In the name of ALLAH --
// We're nothing and you're everything.
// Ya Ali!
#include<bits/stdc++.h>
using namespace std;

#define      pai              acos(-1)
#define      ff               first
#define      ss               second
#define      ll               long long
#define      pb               push_back
#define      mp               make_pair
#define      pll              pair<ll,ll>
#define      sz(a)            (ll)a.size()
#define      endl             "\n"
#define      gcd(a, b)        __gcd(a, b)
#define      lcm(a, b)        ((a)*((b)/gcd(a,b))
#define      all(vec)         vec.begin(),vec.end()
#define      ms(a, b)         memset(a,b,sizeof(a))
#define      rep(i,n)         for(int i= 0; i < int(n); i++)
#define      rep1(i,n)        for(int i= 1; i <= n; i++)
#define      rev(i,n)         for(int i= (int)(n-1);i>=0;i--)
#define      rev1(i,n)        for(int i= (int) n;i>= 1;i--)
#define      TEST_CASE(t)     for(int zz=1;zz<=t;zz++)
#define      PRINT_CASE       printf("Case %d: ",zz)
#define      fii              freopen("input.txt","r",stdin);
#define      foo              freopen("output.txt","w",stdout);
#define      FAST             ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

const ll M   = 1e9+7;
const ll mxn = 2e5+7;

int  main()
{
    ll i,j,k,a,b,c,d,n,m,t,x,y,z,u,v;
    set<ll>st;
    for(i=0;i<=mxn;i++)
    {
        st.insert(i);
    }
    ll ans;
    map<ll,bool>vis;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>m;
        auto p = st.begin();
        if(*p!=m)
        {
            ans=*p;
            if(!vis[m]&&(st.find(m)!=st.end()))
            {
                st.erase(st.find(m));
                vis[m]=true;
            }
        }
        else
        {
            st.erase(st.begin());
            p = st.begin();
            ans=*p;
        }
        cout<<ans<<endl;
    }

    return 0;
}

/*------------------------------------
.......Bismillahir Rahmanir Rahim.....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <utility>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int>
#define   co(x)  cout << x << '\n'
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   bitcount(x)  (int)__builtin_popcount(x)
#define   fast  ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end()
#define   ff   first
#define   ss   second
#define   pi   acos(-1.0)
#define   pii  pair<int,int>
#define   lcm(a,b) (a*b)/__gcd(a,b)
using namespace std;

inline void solve(){
    int n; cin>>n;
    map <int,int> c;
    int cur = 0 ;
    while (n--){
        int x; cin >> x;
        c[x] = 1;
        while (c.count(cur)) cur++;
        co(cur);
    }
}

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


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <fstream>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589

#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};
typedef vector<vector<Edge>> Graph;
typedef unsigned long long ull;

void end(){
    cout << "No" << endl;
    exit(0);
}

#define IKI 1000
int main(){
    int n;
    cin >> n;
    vector<int> p(n * 2);
    REP(i,n){
        int a,b;
        cin >> a >> b;
        a--,b--;
        if(a != -2){
            if(p[a]) end();
            p[a] = i+1;
        }
        if(b != -2){
            if(p[b]) end();
            p[b] = -i-1;
        }
        if(a != -2 && b != -2){
            p[a] += IKI;
            p[b] -= IKI;
        }
    }

    bool dp[201][201] = {};
    rep(len,1,n + 1){
        REP(st, n*2){
            int en = st + len * 2;
            if (en > n*2) continue;

            rep(i, 1, len){
                dp[st][en] |= dp[st][st + i*2] & dp[st + i*2][en];
            }

            bool ok = true;
            REP(i,len){
                if(p[st + i] < 0 || p[st + i + len] > 0) ok = false;
                else if(p[st + i] == 0){
                    if(abs(p[st + i + len])>IKI) ok = false;
                }
                else if(p[st + i] > IKI){
                    if(p[st + i + len] != -p[st + i]) ok =false;
                }
                else {
                    if(p[st + i + len] != 0) ok =false;
                }
            }
            dp[st][en] |= ok;
        }
    }

    cout << (dp[0][n * 2] ? "Yes" : "No") << endl;
}

#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
#include <cstdint>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF=1001001001;
const int mod = 1000000007;

int main() {
  int N;
  cin>>N;
  vector<int>type(2*N);//iが誰かの　始点=1 終点=-1 なんでもいい=0　になっているか
  vector<vector<int>>p(2*N,vector<int>(2*N));//A,Bを ペアにしていい={1,0} ダメ=-1
  vector<int>xs,ps;
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    if(a!=-1){
       a--;
       if(type[a]!=0){cout<<"No"<<endl;return 0;}
       type[a]=1;
       xs.push_back(a);
    }
    if(b!=-1){
       b--;
       if(type[b]!=0){cout<<"No"<<endl;return 0;}
       type[b]=-1;
       xs.push_back(b);
    }
    if(a!=-1&&b!=-1){p[a][b]=1;ps.push_back(a);ps.push_back(b);}
  }
  for(int a:xs){//xs:-1ではない物なのでそれ同士は(元からペアになっているものを除いて）ペアにならない。
    for(int b:xs){
        if(p[a][b]!=1){p[a][b]=-1;}
    }
  }
  for(int a:ps){//ps:元からペアになっているものの片方。元からペアのものがある場合は、その相手以外はペアにできないようにする。
    for(int i=0;i<2*N;i++){
       if(!p[a][i]){p[a][i]=-1;}
       if(!p[i][a]){p[i][a]=-1;}
    }
  }
  vector<bool>dp(2*N+1,false);
  dp[0]=true;
  for(int i=0;i<2*N;i+=2){//区間の左側を0~2N-2まで試す。奇数だと以前の区間にペアにできないマスがあるので偶数。
    if(!dp[i]){continue;}
    for(int j=1;j<=N;j++){//ある区間の中の人数をN人まで試す。これで区間が定まる(2j人分の空きマスが必要なので)。
      int id=i+j*2;//len:区間の終わりのid。
      if(id>2*N){break;}
      bool ok=true;
      for(int l=i;l<i+j;l++){//l:区間の中のA（入ってくる方）のid（始点）。0インデックスなので<。
        int r=l+j;//r:区間の中のB(出ていく方)のid（終点）
        if(type[l]==-1){ok=false;}//始点を当てはめるとき終点がすでに書き込まれている場合は駄目
        if(type[r]==1){ok=false;}//終点を当てはめるとき始点がすでに書き込まれている場合は駄目
        if(p[l][r]==-1){ok=false;}//ペアにしてはいけない場合。
      }
      if(ok){dp[id]=true;}
    }
  }
  if(dp[2*N]){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  return 0;
}//お試し


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

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

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

const ll LINF=4*1e18;
const ll MINF=5*1e15;
const int INF=2*1e9;

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

void Main(){

int H,W,X,Y;
cin>>H>>W>>X>>Y;
X--;Y--;
vector<string> S(H);
rep(i,H)cin>>S[i];
int cnt=-3;
for(int i=X;i>=0;--i){
    if(S[i][Y]=='#')break;
    ++cnt;
}
for(int i=X;i<H;++i){
    if(S[i][Y]=='#')break;
    ++cnt;
}
for(int j=Y;j>=0;--j){
    if(S[X][j]=='#')break;
    ++cnt;
}
for(int j=Y;j<W;++j){
    if(S[X][j]=='#')break;
    ++cnt;
}
cout<<cnt<<endl;
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusive
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long;
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>;

long long LLINF = 1e18;
int INF = 1e9+1e6;
#define MAXN (200006)
int h, w;
string A[1002], B[1002];
int p[1002], sz[1002];
void init() {
	FOR(i,0,1001) p[i]=i, sz[i]=1;
}
int find(int x) { return p[x] == x ? x : p[x] = find(p[x]); }
void merge(int a,int b) {
	a = find(a), b = find(b);
	if(a==b) return;
	if(sz[a]>sz[b]) swap(a, b);
	sz[b]+=sz[a], p[a]=b;
}
ll solve() {
	init();
	int ans = 0;
	A[0][0] = A[0].back() = A[h-1][0] = A[h-1].back() = '#';
	FOR(j,0,w-1) {
		ll pre = -1;
		FOR(i,0,h-1) {
			if(A[i][j] != '#') continue;
			if(~pre) merge(pre, i);
			pre = i;
		}
	}
	FOR(i,0,h-1) if(find(i) == i) ++ ans;
	-- ans;
	return ans;
}
void copy() {
	FOR(i,0,h-1) A[i]=B[i];
}
int main() {
	FAST
	cin>>h>>w;
	FOR(i,0,h-1) cin>>B[i];
	copy();
	ll ans = solve();
	// invert
	for(auto&i:A) i.clear();
	FOR(i,0,w-1) A[i].resize(h);
	FOR(i,0,h-1) FOR(j,0,w-1) A[j][i]=B[i][j];
	swap(h, w);
	ans = min(ans, solve());
	cout<<ans<<'\n';
}


#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using ll = int64_t;
using db = double;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define show(x) cout << #x << " = " << (x) << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define YesNo {cout<<"Yes";}else{cout<<"No";}
#define YESNO {cout<<"YES";}else{cout<<"NO";}
#define v(T) vector<T>
#define vv(T) vector<vector<T>>

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> bool lcmp(const pair<T, T>& l, const pair<T, T>& r) {
  return l.first < r.first;
}
template<class T> istream& operator>>(istream& i, v(T)& v) {
  F0R(j, sz(v)) i >> v[j];
  return i;
}
template<class A, class B> istream& operator>>(istream& i, pair<A, B>& p) {
  return i >> p.first >> p.second;
}
template<class A, class B, class C> istream& operator>>(istream& i, tuple<A, B, C>& t) {
  return i >> get<0>(t) >> get<1>(t) >> get<2>(t);
}
template<class T> ostream& operator<<(ostream& o, const pair<T, T>& v) {
  o << "(" << v.first << "," << v.second << ")";
  return o;
}
template<class T> ostream& operator<<(ostream& o, const vector<T>& v) {
  F0R(i, v.size()) {
    o << v[i] << ' ';
  }
  o << newl;
  return o;
}
template<class T> ostream& operator<<(ostream& o, const set<T>& v) {
  for (auto e : v) {
    o << e << ' ';
  }
  o << newl;
  return o;
}
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& m) {
  for (auto& p : m) {
    o << p.first << ": " << p.second << newl;
  }
  o << newl;
  return o;
}

#if 1

int red = 1, gre = 2, blu = 4, all = 7;

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M; cin >> N >> M;
  vvi es(N);
  F0R(i, M) {
    int a, b; cin >> a >> b;
    a--; b--;
    es[a].push_back(b);
    es[b].push_back(a);
  }
  ll re = 1;
  v(bool) vs(N);
  F0R(i, N) {
    if (vs[i]) continue;
    vi as;  // 連結になっている頂点リスト
    auto arrange = [&](auto arrange, int v)->void {
      vs[v] = true;
      as.push_back(v);
      for (auto to : es[v]) {
        if (!vs[to]) {
          arrange(arrange, to);
        }
      }
    };
    arrange(arrange, i);
    vi cs(N, 0);
    auto calc = [&](auto calc, int ai)->ll {
      if (ai == sz(as)) return 1;
      int v = as[ai], a = 0;
      for (auto to : es[v]) {
        a |= cs[to];
      }
      ll re = 0;
      F0R(c, 3) {
        if ((a >> c) & 1) continue;
        cs[v] = 1 << c;
        re += calc(calc, ai+1);
      }
      cs[v] = 0;
      return re;
    };
    re *= calc(calc, 0);
  }
  cout << re << newl;
}
#endif

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

const int N = 2e3+5 ;

int n ,m ,u ,v ;
char ch ;
vector<int> adj[128][N] ;
bool edge[N][N] ;
long long dis[N][N] ;
long long bfs(){
    long long ret = 1e18 ;
    memset(dis,'?',sizeof dis);
    queue<pair<int,int>> q ;
    q.push({1,n});
    dis[1][n] = 0 ;
    while(q.size()){
        int a = q.front().first ;
        int b = q.front().second ;
        q.pop() ;
        if(a==b){
            ret = min(ret ,dis[a][b]*2);
            continue ;
        }
        if(edge[a][b]){
            ret = min(ret ,dis[a][b]*2+1);
            continue ;
        }
        for(int ch='a';ch<='z';++ch){
            if(!adj[ch][a].size() || !adj[ch][b].size()) continue ;
            for(int i:adj[ch][a]) for(int j:adj[ch][b]){
                long long to = dis[a][b]+1 ;
                if(dis[i][j]<=to) continue ;
                dis[i][j] = to ;
                if(i==j){
                    ret = min(ret,to*2) ;
                    continue ;
                }
                if(edge[i][j]){
                    ret = min(ret,to*2+1) ;
                    continue ;
                }
                q.push({i,j});
            }
        }
    }
    if(ret>1e9) ret = -1 ;
    return ret ;
}
int main(){
    scanf("%d%d",&n,&m);
    while(m--){
        scanf("%d%d %c",&u,&v,&ch);
        edge[u][v] = edge[v][u] = 1 ;
        adj[ch][u].push_back(v);
        adj[ch][v].push_back(u);
    }
    printf("%lld",bfs());
    return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using ll=long long;
using ld=long double;
ll I=1167167167167167167;
ll Q=1e9+7;
#define rep(i,a) for (ll i=0;i<a;i++)
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
template<class T> void print_tate(vector<T> &v) {rep(i,v.size()) cout<<v[i]<<"\n";}
void yneos(bool a){if(a) cout<<"Yes"<<"\n"; else cout<<"No"<<"\n";}

ll Range=2000000;
vector<ll> Kai(Range+1,1);
vector<ll> Kai_re(Range+1,1);
vector<ll> Kai_g(Range+1,1);
void Re(int potato){//Re(0)で初期化
  for(int i=1;i<=Range;i++){
    if(i!=1){
      Kai_g[i]=((Q-Q/i)*Kai_g[Q%i])%Q;
    }
    Kai_re[i]=(Kai_g[i]*Kai_re[i-1])%Q;
  }
  for(int i=1;i<=Range;i++){
    Kai[i]=(i*Kai[i-1])%Q;
  }
}
ll si(ll x,ll y){
	if(y<0) return 0;
  ll C;
  C=(Kai_re[y]*Kai_re[x-y])%Q;
  C=(C*Kai[x])%Q;
  return C;
}

//おちこんだりもしたけれど、私はげんきです。
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	ll N,M,K;
	cin>>N>>M>>K;
	Re(0);
	if(N>M+K) cout<<"0"<<endl;
	else cout<<(Q+si(N+M,N)-si(N+M,N-K-1))%Q<<endl;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <cstdlib>
#include <cfloat>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#define ll long long
#define lp pair<ll, ll>
#define max(a,b)((a)>(b)?(a):(b))
#define min(a,b)((a)<(b)?(a):(b))
#define ALL(obj) (obj).begin(), (obj).end()
using namespace std;

#define DIV 1000000007
//#define LLONG_MAX 9223372036854775807
//#define LLONG_MIN -9223372036854775808

int main(){
	ll i,j,n,a,b,c;
	cin >> a >> b >> c;

	if ((-1*a == b && c%2==0) || a == b) {
		cout << "=" << endl;//
	} else if (a == 0) {
		if (b < 0 && c%2 == 1) {
			cout << ">" << endl;
		} else {
			cout << "<" << endl;
		}//
	} else if(b==0) {
		if (a < 0 && c%2 == 1) {
			cout << "<" << endl;
		} else {
			cout << ">" << endl;
		}//
	} else if (a > 0 && b > 0) {
		if (a>b) {
			cout << ">" << endl;
		} else {
			cout << "<" << endl;
		}
	} else if (a > 0 && b < 0) {
		if (c%2 == 1) {
			cout << ">" << endl;
		} else {
			if (a > -1*b) {
				cout << ">" << endl;
			} else {
				cout << "<" << endl;
			}
		}//
	} else if (a < 0 && b > 0) {
		if (c%2 == 1) {
			cout << "<" << endl;
		} else {
			if (-1*a > b) {
				cout << ">" << endl;
			} else {
				cout << "<" << endl;
			}
		}//
	} else {//a<0 && b<0
		if (c%2==1) {
			if (-1*a > -1*b) {
				cout << "<" << endl;
			}else {
				cout << ">" << endl;
			}//
		} else {
			if (-1*a > -1*b) {
				cout << ">" << endl;
			}else {
				cout << "<" << endl;
			}
		}
	}

	return 0;
}


//#undef DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll llinf = (1ll<<61)-1;
#define sz(a) int(a.size())
#define all(x) begin(x), end(x)
#ifdef DEBUG
const int DEBUG_END = 26;
#define DOS cout
#include <debug.h>
#else
#define bug(args...) void()
#define cbug(a, args...)
#endif
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define fi first
#define se second
int TC = 1, CN;
const int inf = 1000000007;
const int H = 1005;
int h, w, d[2];
string grid[H];
bitset<H> vstd[H], visd[2];
vector<pair<int, int>> g[2][H];

void dfs(pair<int, int> u) {
    auto [r, c] = u;
    int p[2] = {r, c};
    for (int i = 0; i < 2; i++) {
        if (visd[i][p[i]]) continue;
        visd[i][p[i]] = 1;
        for (auto &j : g[i][p[i]]) {
            if (!vstd[j.fi][j.se]) vstd[j.fi][j.se] = 1, dfs(j);
        }
    }
}

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    //cin >> TC;// inputAll + resetAll -> solution
    auto kase = [&]()->void {
        cin >> h >> w;
        d[0] = h, d[1] = w;
        for (int i = 0; i < h; i++) {
            cin >> grid[i];
            for (int j = 0; j < w; j++) {
                if (grid[i][j] == '#') g[0][i].push_back({i, j}), g[1][j].push_back({i, j});
            }
        }

        queue<pair<int, int> > q;
        for (int i = 0; i < 2; i++) {
            for (auto &j : g[i][0]) {
                if (!vstd[j.fi][j.se]) vstd[j.fi][j.se] = 1, dfs(j);
            }
            for (auto &j : g[i][d[i]-1]) {
                if (!vstd[j.fi][j.se]) vstd[j.fi][j.se] = 1, dfs(j);
            }
        }

        int cnt = 0, cntr = h-2, cntc = w-2;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (!vstd[i][j] and grid[i][j] == '#') ++cnt, dfs({i, j});
            }
        }
        for (int i = 1; i < h-1; i++) {
            bool ok = 0;
            for (int j = 0; j < w; j++) {
                ok |= vstd[i][j];
            }
            cntr -= ok;
        }
        for (int i = 1; i < w-1; i++) {
            bool ok = 0;
            for (int j = 0; j < h; j++) {
                ok |= vstd[j][i];
            }
            cntc -= ok;
        }
        cout << cnt+min(cntr, cntc) << '\n';
    };
    while (CN++!=TC) kase();
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;}
#define all(x) (x).begin(),(x).end()
#define debug(x)  cerr << #x << " = " << (x) << endl;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,L;
    cin >> N >> L;
    vec<int> A(N+2),B(N+2);
    for(int i=1;i<=N;i++) cin >> A[i];
    for(int i=1;i<=N;i++) cin >> B[i];
    A[N+1] = B[N+1] = L+1;
    vec<int> C(N+1),D(N+1);
    for(int i=0;i<=N;i++){
        C[i] = A[i+1]-A[i]-1;
        D[i] = B[i+1]-B[i]-1;
    }
    ll ans = 0;
    int sum = 0,r = 0;
//    for(int i=0;i<=N;i++) cerr << C[i] << " " << D[i] << "\n";
    for(int i=0;i<=N;i++) if(D[i]){
        while(C[r]==0) r++;
        int l = r;
        while(r<=N && sum+C[r]<=D[i]){
            sum += C[r++];
            if(sum==D[i]) break;
        }
        if(sum!=D[i]){
            cout << "-1\n";
            return 0;
        }
//        cerr << l << " " << r << "\n";
        if(r<=i) ans += i-l;
        else if(i<=l) ans += r-i-1;
        else ans += r-l-1;
        sum = 0;
    }
    cout << ans << "\n";
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vt<int>>;

int main(){

  int n, num = 0, t_n;
  cin >> n;
  num = pow(2,n);
  t_n = num;
  vt<int> a(num);
  vt<int> tp(num);
  rep(i,num){
    cin >> a[i];
    tp[i] = a[i];
  }

  while(num != 2) {
    rep(i,num){
      if (a[i] > a[i+1]) {
        a.erase(a.begin() + i+1);
      } else {
        a.erase(a.begin() + i);
      }
      num--;
    }
  }

  int p = a[0] > a[1] ? a[1] : a[0];

  rep(i,t_n){
    if(p == tp[i]){
      cout << i+1 << endl;
      break;
    }
  }

  return 0;
}

#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <map>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    long nNum = 1;
    for(int i = 0; i < n; i++){
        nNum *= 2;
    }
    vector<int> viNum(nNum);

    for(int i = 0; i < nNum; i++){
        scanf("%d", &viNum[i]);
    }
    vector<int> viNumTmp = viNum;
    long nNumTmp = nNum;
    while(nNumTmp > 2){
        nNumTmp /= 2;
        for(int i = 0; i < nNum; i++){
            viNumTmp[i] = max(viNumTmp[2*i], viNumTmp[2*i+1]);
        }
    }

    int nAns = min(viNumTmp[0], viNumTmp[1]);
    for(int i = 0; i < nNum; i++){
        if(viNum[i] == nAns){
            printf("%d", i+1);
        }
    }
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;

#define MOD 998244353
#define PI 3.1415926535897932
#define INF 1e9
#define rep(i, n) for (int i = 0; i < n; i++)
#define repe(i, j, n) for (int i = j; i < n; i++)
#define repi(i, n) for (int i = 0; i <= n; i++)
#define repie(i, j, n) for (int i = j; i <= n; i++)
#define all(x) x.begin(), x.end()
#define println() cout << endl
#define P pair<int, int>
#define fi first
#define se second
typedef long long ll;
using Graph = vector<vector<ll>>;

void solve1() {
    ll a, b; cin >> a >> b;
    ll sum = 0;
    if(a == b) {
        rep(i, a) {
            cout << i + 1 << " ";
        }

        rep(i, b) {
            if(i == b-1) {
                cout << -b << endl;
                break;
            }
            cout << -(i+1) << " ";
        }

    } else if(a > b) {
        for(ll i = 1; i <= a; i++) {
            sum += i;
            cout << i << " ";
        }

        sum *= -1;
        ll sumb = 0;
        for(ll i = 1; i <= b; i++) {
            if(i == b) {
                cout << sum - sumb << endl;
                break;
            }

            sumb -= i;

            cout << -i << " ";
        }
    } else if(b > a) {
        for(ll i = 1; i <= b; i++) {
            sum += i;
            cout << -i << " ";
        }

        ll sumb = 0;
        for(ll i = 1; i <= a; i++) {

            if(i == a) {
                cout << sum - sumb << endl;
                break;
            }

           sumb += i;

            cout << i << " ";
        }
    }
}

int main()
{
    solve1();
}

#include <bits/stdc++.h>
#define fo(i, k, n) for (ll i = k; i < n; i++)
#define ll long long
#define ld long double

using namespace std;

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

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

    vector<int> pos(a);
    vector<int> neg(b);
    if (a > b)
    {
        fo(i, 0, a)
            pos[i] = i + 1;
        int sum = 0;
        if (b == 1)
        {
            fo(i, 0, a)
                sum = sum + pos[i];

            neg[0] = -(sum);
        }
        else
        {
            fo(i, 0, b - 1)
                neg[i] = -(i + 1);

            fo(i, b - 1, a)
                sum = sum + pos[i];

            neg[b - 1] = -(sum);
        }
    }
    else
    {
        fo(i, 0, b)
            neg[i] = -(i + 1);
        int sum = 0;
        if (a == 1)
        {
            fo(i, 0, b)
                sum = sum + neg[i];

            pos[0] = -(sum);
        }
        else
        {

            fo(i, 0, a - 1)
                pos[i] = (i + 1);

            fo(i, a - 1, b)
                sum = sum + neg[i];

            pos[a - 1] = -(sum);
        }
    }

    fo(i, 0, a)
            cout
        << pos[i] << " ";
    fo(i, 0, b)
            cout
        << neg[i] << " ";
    cout << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define inin(a, n, i) memset(a, i, sizeof(a[0])*(n))
#define ccont(c, i) ((c).find(i) != (c).end())
#define lcont(c, i) (find(all(c), i) != (c).end())

#define trav(x, c) for(auto& x : c)
#define readv(c) for(auto& x : c) read(x)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repa(i, b, e) for(int i = b; i < e; i++)
#define repd(i, b, e) for(int i = b-1; i >= e; i--)

template<class T> bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }
template<class T> bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }
template<class A, class B> A cvt(B x) { stringstream s; s << x; A r; s >> r; return r; }

void read() {}
void print() {}
template<class T, class... Args> void read(T& a, Args&... args) { cin >> a; read(args...); }
template<class T, class... Args> void print(T a, Args... args) { cout << a << (sizeof...(args) > 0 ? " " : ""); print(args...); }
template<class... Args> void println(Args... args) { print(args...); cout << '\n'; }

#define debug(args...) { string s_(#args); replace(all(s_), ',', ' '); stringstream ss_(s_); istream_iterator<string> it_(ss_); cerr_(it_, args); }
void cerr_(istream_iterator<string> it) { (void) it; }
template<class T, class... Args> void cerr_(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; cerr_(++it, args...); }

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

const int INF = 0x3F3F3F3F;
const int MAXN = (int) 1e6;
const int MOD = (int) 1e9+7;

//=========================

void run_test() {
	int n; read(n);
	string s; read(s);

	if(s[0] != s[n-1]) {
		println(1);
		return;
	}

	repa(i, 1, n-2) {
		if(s[0] != s[i] && s[i+1] != s[n-1]) {
			println(2);
			return;
		}
	}

	println(-1);
}

//=========================

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//int t_ = 1, t__; cin >> t__; while(t_ <= t__) { cout << "Case #" << t_++ << ": "; run_test(); }
	// int t_; cin >> t_; while(t_--) run_test();
	run_test();
	return 0;
}

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

#define int long long
#define forn(i,a,n) for (int i=a; i<n; i++)

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

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	string s;
	cin>>s;
	if (s[0]==s[1] && s[1]==s[2])
		cout<<"Won"<<endl;
	else cout<<"Lost"<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
#define INF 10000000000000000
#define F first
#define S second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pie 3.141592653589793238462643383279
#define PYES cout<<"YES"<<endl
#define PNO cout<<"NO"<<endl
#define SB(a) sort(a.begin(),a.end(),greater<ll>());
#define SS(a) sort(a.begin(),a.end());
#define vll vector<ll>
#define vpll vector<pll>
vector<bool> prime;
vector<ll> fact,inv,primes,factors;
void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}
void factorize(ll a)
{
	factors.clear();
	for(ll i=1;i*i<=a;i++)
	{
		if (i*i==a) factors.pb(i);
		else if (a%i==0)
		{
			factors.pb(i);
			factors.pb(a/i);
		}
	}
	sort(factors.begin(),factors.end());
}
ll power(ll a,ll b)
{
	if(a==1||b==0)	return 1;
	ll c=power(a,b/2);
	ll res=1;
	res=c*c;
	if(res>=mod)	res%=mod;
	if(b%2)	res*=a;
	if(res>=mod)	res%=mod;
	return res;
}
ll modInv(int a)
{
	return power(a,mod-2);
}
void factorial(ll n)
{
	fact.resize(n+1);
	fact[0]=1;
	for(ll i=1;i<=n;i++)
	{
		fact[i]=fact[i-1]*i;
		if(fact[i]>=mod)	fact[i]%=mod;
	}
}
void InvFactorial(ll n)
{
	inv.resize(n+1);
	inv[0]=1;
	for(ll i=1;i<=n;i++)	inv[i]=modInv(fact[i]);
}
ll ncr(ll n,ll r)
{
	if(n<r||n<0||r<0)	return 0;
	ll b=inv[n-r];
	ll c=inv[r];
	ll a=fact[n]*b;
	if(a>=mod)	a%=mod;
	a*=c;
	if(a>=mod)	a%=mod;
	return a;
}
void remove_duplicates(vector<pair<ll,ll> > &v)
{
	sort(v.begin(),v.end());
	ll _size=unique(v.begin(),v.end())-v.begin();
	v.resize(_size);
}
unsigned ll gcd(unsigned ll u, unsigned ll v)
{
    if(u==0||v==0) return max(u,v);
    unsigned ll shift=__builtin_ctz(u|v);
	u>>=__builtin_ctz(u);
    do{
    	v>>=__builtin_ctz(v);
    	if(u>v)	swap(u,v);
    	v-=u;
    }while(v!=0);
    return u<<shift;
}
void sieve(int n)
{
    prime.assign(n+1,1);
	prime[1]=false;
    for(ll p=2;p*p<=n;p++) if(prime[p])	for(ll i=p*p;i<=n;i+=p)	prime[i]=false;
    for(ll i=2;i<n+1;i++) if(prime[i]) primes.push_back(i);
}
ll size(ll l)
{
	ll p=l;
	ll count=0;
	while(p) p/=10,count++;
	return count;
}
//--------------------------------------------------------------------------------------------------------------------------------------------------
// Always remember: if (condition) if (condition) statement; This doesn't work !!
// Always increase boundaries for global or frequency questions
// pow((int)10,i) doesn't work sometimes. It is better to use multiple of 10 in arrays. Always remember this.
// delete values when defining global if there are multiple testcases
// don't try to be smart and make stupid mistakes
ll n,m;
vector<string> a(2005);
vector<vll> dp(2005,vll(2005,-INF));
ll cont(ll i,ll j)
{
	if (a[i][j]=='+') return 1;
	else return -1;
}
ll func(ll i,ll j)
{
	if (i==n-1 && j==m-1) return 0;
	ll &ans=dp[i][j];
	if (ans>-INF) return ans;
	if ((i-j)%2==0)
	{
		ll t=-INF;
		if (i<n-1) t=max(t,func(i+1,j)+cont(i+1,j));
		if (j<m-1) t=max(t,func(i,j+1)+cont(i,j+1));
		ans=t;
	}
	else
	{
		ll t=INF;
		if (i<n-1) t=min(t,func(i+1,j)-cont(i+1,j));
		if (j<m-1) t=min(t,func(i,j+1)-cont(i,j+1));
		ans=t;
	}
	return ans;
}
void solve()
{
	cin>>n>>m;
	rep(i,n) cin>>a[i];
	ll ans=func(0,0);
	if (ans>0) cout<<"Takahashi";
	else if (ans<0) cout<<"Aoki";
	else cout<<"Draw";
}
signed main()
{
	fast();
	ll T=1;
	//cin>>T;
	for(ll i=1;i<=T;i++) solve();
}

// Always remember that you are absolutely unique, just like everyone else!

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

// DEBUGGING SECTION
void __print(int x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

#define MOD     1000000007
#define INF     3e18
#define pb      push_back
#define endl    '\n' // Remove if interactive
#define ff      first
#define ss      second
#define FOR(i, a, b)   for(int i = a; i < b; i++)

//#include <algorithm>
//#include <cstring>
//#include <map>
//#include <set>
//#include <queue>
//#include <stack>
//#include <math.h>

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

#define int     long long
#define pii     pair<int, int>
#define vi      vector<int>
#define vvi     vector<vi>
#define vpii    vector<pii>
#define all(x)  x.begin(), x.end()

int power(int x, int y) {
	int ans = 1; x %= MOD;
	while (y) {
		if (y & 1)
			ans = (x * ans) % MOD;
		x = (x * x) % MOD;
		y >>= 1;
	}
	return ans;
}

// comparator(A, B) -> should return true if A needs to come before B!
// ALWAYS RETURN FALSE IF A == B

// USE INTEGERS TO REDUCE RUNTIME!

const int maxn = 2010;
int n, m;
vvi arr(maxn, vi(maxn));
vector<vpii> dp(maxn, vpii(maxn, { -1, -1}));

pii helper(int x, int y) {
	if (dp[x][y].ff != -1)
		return dp[x][y];
	if (x == n && y == m)
		return {0, 0};
	pii curr = { -INF, INF};

	if (x + 1 <= n) {
		pii a = helper(x + 1, y);
		if (a.ss + arr[x + 1][y] - a.ff > curr.ff - curr.ss) {
			curr = {a.ss + arr[x + 1][y], a.ff};
		}
	}
	if (y + 1 <= m) {
		pii a = helper(x, y + 1);
		if (a.ss + arr[x][y + 1] - a.ff > curr.ff - curr.ss) {
			curr = {a.ss + arr[x][y + 1], a.ff};
		}
	}

	dp[x][y] = curr;
	return curr;
}

void solve() {
	cin >> n >> m;
	FOR(i, 1, n + 1) {
		FOR(j, 1, m + 1) {
			char c;
			cin >> c;

			arr[i][j] = (c == '+') ? 1 : -1;
		}
	}

	pii ans = helper(1, 1);
	debug(ans);
	if (ans.ff == ans.ss) {
		cout << "Draw\n";
	} else if (ans.ff > ans.ss) {
		cout << "Takahashi\n";
	} else {
		cout << "Aoki\n";
	}
}

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

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


#include<bits/stdc++.h>
using namespace std;
int a[102],b[102];
int c[20],d[20];
int ans = 0;
void solve(int n,int m,bool flag[],int k,int l){
  if(l>=k){
    int cnt = 0;
    for(int i=0;i<m;i++)
    {
      if(flag[a[i]] == true && flag[b[i]] == true)
       cnt++;
    }
   ans = max(ans,cnt);
   return ;
  }
  bool temp =flag[c[l]];
    flag[c[l]] = true;
    solve(n,m,flag,k,l+1);
    flag[c[l]] = temp;
  temp = flag[d[l]];
    flag[d[l]] = true;
    solve(n,m,flag,k,l+1);
  	flag[d[l]] = temp;
}
int main(){
int n,m;
  cin >> n >> m;
  for(int i=0;i<m;i++)
    cin >> a[i] >> b[i];
  int k;
  cin >> k;
  for(int i=0;i<k;i++)
  {
    cin >> c[i] >> d[i];
  }
  bool flag[105] = {false,};
  solve(n,m,flag,k,0);
  cout<<ans<<endl;

}

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

int main() {
    ll N, M; cin >> N >> M;
    vector<pair<ll,ll>> m(M);
    rep(i,M) {
        ll a, b; cin >> a >> b;
        a--; b--;
        m[i] = {a,b};
    }
    ll K; cin >> K;
    vector<pair<ll,ll>> k(K);
    rep(i,K) {
        ll c, d; cin >> c >> d;
        c--; d--;
        k[i] = {c,d};
    }

    ll ans = 0;
    rep(bit,1<<K) {
        vector<ll> vec(N);
        rep(i,K) {
            ll x = k[i].first, y = k[i].second;
            if ((bit>>i)&1) vec[x]++;
            else vec[y]++;
        }
        ll cnt = 0;
        rep(i,M) {
            ll x = m[i].first, y = m[i].second;
            if (vec[x]>=1 && vec[y]>=1) cnt++;
        }
        ans = max(ans,cnt);
    }

    cout << ans << endl;
}


#include <bits/stdc++.h>

#define int long long

using namespace std;

const int MAXN = 4e5 + 100;

int A[MAXN];

char res[MAXN];

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

    int N;
    cin >> N;

    vector<pair<int,int>> vect;

    for(int i = 1 ; i <= 2*N ; i++)
    {
    	int n;
    	cin >> n;
    	vect.push_back({n,i});
    }

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

    for(int i = 1 ; i <= N ; i++)
    {
    	A[vect[i-1].second] = 1;
    }

    vector<int> vvv;

    bool flag = false;

    for(int i = 1 ; i <= 2*N ; i++)
    {
    	if(flag == false)
    	{
    		if(A[i])
    		{
    			vvv.push_back(i);
    		}
    		else
    		{
    			if(vvv.size())
    			{
    				res[vvv.back()] = '(';
    				res[i] = ')';
    				vvv.pop_back();
    			}
    			else
    			{
    				flag = true;
    				vvv.push_back(i);
    			}
    		}
    	}
    	else
    	{
    		if(!A[i])
    		{
    			vvv.push_back(i);
    		}
    		else
    		{
    			if(vvv.size())
    			{
    				res[vvv.back()] = '(';
    				res[i] = ')';
    				vvv.pop_back();
    			}
    			else
    			{
    				flag = false;
    				vvv.push_back(i);
    			}
    		}
    	}
    }

    for(int i = 1 ; i <= 2*N ; i++)
    {
    	cout << res[i];
    }
    cout << '\n';

    return 0;
}

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define pre(i,a,b) for(int i=a;i>=b;i--)
#define N 400005
using namespace std;
int n,a[N],c[N],ans[N],sta[N],top;pair<int,int>u[N];
int main(){
	scanf("%d",&n);n<<=1;
	rep(i,1,n)scanf("%d",&a[i]),u[i]=make_pair(a[i],i);
	sort(u+1,u+n+1);
	rep(i,1,n/2)c[u[i].second]=1;
	rep(i,1,n){
		if(!top||c[sta[top]]==c[i])sta[++top]=i;
		else{
			ans[sta[top--]]=0;ans[i]=1;
		}
	}
	rep(i,1,n)if(ans[i])putchar(')');else putchar('(');
	return 0;
}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> Pair;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

int N,M;
VL dp(8,-1);
ll L[8][8];

ll rec(int v){
    if(dp[v] != -1) return dp[v];
    ll ret = 0;
    FOR(to,v+1,N){
        chmax(ret, rec(to) + L[v][to]);
    }
    return dp[v] = ret;
}

void Main(){
    cin >> N >> M;
    ll MINV = LINF, MAXW = 0;
    VL w(N); REP(i,N) cin >> w[i], chmax(MAXW,w[i]);
    VL l(M),v(M); REP(i,M) cin >> l[i] >> v[i], chmin(MINV, v[i]);
    if(MINV<MAXW){
        cout << -1 << en;
        return;
    }

    VI p(M); REP(i,M) p[i] = i;
    auto cmp = [&](int i, int j){return v[i]<v[j];}; sort(ALL(p), cmp);
    VL mx(M+1,0); REP(i,M) chmax(mx[i+1], max(mx[i],l[p[i]]));

    ll ans = LINF;
    VI q(N); REP(i,N) q[i] = i;
    do{
        VL ww(N); REP(i,N) ww[i] = w[q[i]];
        VL sum(N+1,0); REP(i,N) sum[i+1] = sum[i] + ww[i];

        REP(i,N-1)FOR(j,i+1,N){
            ll s = sum[j+1] - sum[i];
            int l = -1, r = M;
            while(r-l>1){
                int x = (l+r)/2;
                if(v[p[x]]<s) l = x;
                else r = x;
            }
            L[i][j] = mx[r];
        }
        REP(i,N) dp[i] = -1;
        chmin(ans, rec(0));
    }while(next_permutation(ALL(q)));

    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

#include<cstdio>
#include<vector>
int w[15];
struct Element{
    int l,v;
};
struct Edge{
    int v,w;
    Edge(int v,int w):v(v),w(w){}
};
std::vector<Edge>g[15];
int f[15];
Element e[100005];
int seq[15];
int vis[15];
int pos[15];
int ans = -1;
int dis[1<<10];

void dfs(int p,int n,int m){
    if(p==n+1){
        for(int i = 1; i <= n; i++){
            g[i].clear(), f[i] = 0;
            pos[seq[i]] = i;
        }
        for(int i = 0; i < (1<<n); i++){
            int l = n+1, r = -1;
            int mask = i;
            for(int j = 1; j <= n; j++){
                if(mask%2){
                    int p = pos[j];
                    if(l>p) l = p;
                    if(r<p) r = p;
                }
                mask /= 2;
            }
            if(l<=n && r>=1 && l<r) g[l].push_back(Edge(r,dis[i]));
        }
        for(int i = 1; i <= n; i++){
            if(f[i]<f[i-1]) f[i] = f[i-1];
            for(Edge e: g[i]){
                int j = e.v, w = e.w;
                if(f[j]<f[i]+w) f[j] = f[i]+w;
            }
        }
        if(ans==-1 || ans>f[n]) ans = f[n];
    }
    else{
        for(int i = 1; i <= n; i++){
            if(vis[i]==0){
                seq[p] = i;
                vis[i] = 1;
                dfs(p+1,n,m);
                vis[i] = 0;
            }
        }
    }
}

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int maxn = -1;
    for(int i = 1; i <= n; i++){
        scanf("%d",&w[i]);
        if(maxn<w[i]) maxn = w[i];
    }
    int ok = 1;
    for(int i = 1; i <= m; i++){
        scanf("%d%d",&e[i].l,&e[i].v);
        if(e[i].v<maxn) ok = 0;
    }
    if(!ok){
        printf("-1\n");
        return 0;
    }
    for(int i = 0; i < (1<<n); i++){
        int sum = 0, mask = i;
        for(int j = 1; j <= n; j++){
            if(mask%2) sum += w[j];
            mask /= 2;
        }
        dis[i] = 0;
        for(int j = 1; j <= m; j++){
            if(e[j].v<sum && dis[i]<e[j].l) dis[i] = e[j].l;
        }
    }
    dfs(1,n,m);
    printf("%d\n",ans);
    return 0;
}


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

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

  int n;
  cin >> n;
  vector<pair<int, int>> pos(n);
  for (auto &&[x, y] : pos) {
    cin >> x >> y;
  }
  auto judge = [&](double r) -> bool {
    queue<int> q;
    for (auto i = 0; i != n; ++i) {
      if (100 - r < pos[i].second + r) {
        q.push(i);
      }
    }
    vector<bool> used(n);
    while (!q.empty()) {
      auto id = q.front();
      q.pop();
      if (used[id]) continue;
      used[id] = true;
      for (auto i = 0; i != n; ++i) {
        if (hypot(pos[i].first - pos[id].first,
                  pos[i].second - pos[id].second) < 2 * r) {
          q.push(i);
        }
      }
    }
    for (auto i = 0; i != n; ++i) {
      if (used[i]) {
        if (r - 100 > pos[i].second - r) {
          return false;
        }
      }
    }
    return true;
  };
  constexpr double eps = 1e-4;
  double ok = 0, ng = 100;
  while (ng - ok > eps) {
    auto r = (ok + ng) / 2;
    if (judge(r))
      ok = r;
    else
      ng = r;
  }
  cout << ok << endl;
}

#include              <bits/stdc++.h>
#define ll            long long int
#define w(t)          int t; cin>>t; while(t--)
#define F             first
#define S             second
#define pb            push_back
#define mp            make_pair
#define pii           pair<int,int>
#define mii           map<int,int>
#define sp(x,y)       fixed<<setprecision(y)<<x
using namespace std;

// ll modular(ll base, unsigned long long int exp, unsigned int mod)
// {
//     ll x = 1;
//     ll power = base % mod;

//     for (ll i = 0; i < sizeof(long long int) * 8; i++) {
//         ll least_sig_bit = 0x00000001 & (exp >> i);
//         if (least_sig_bit)
//             x = (x * power) % mod;
//         power = (power * power) % mod;
//     }

//     return x;
// }
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ll a,b,c;
    // cin>>a>>b>>c;
    // if(modular(a,c,1000000007)==modular(b,c,1000000007))cout<<"=";
    // else if(modular(a,c,1000000007)<modular(b,c,1000000007))cout<<"<";
    // else if(modular(a,c,1000000007)>modular(b,c,1000000007))cout<<">";
    // return 0;
    float a,b;
    cin>>a>>b;
    float ans=b/100;
    ans*=a;
    cout<<ans;
    return 0;
}


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

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

typedef tree<long long, null_type, less<long long>, rb_tree_tag,
          tree_order_statistics_node_update>
 is;*/

#define fb find_by_order
#define ok order_of_key

#define mem(x,y) memset(x,y,sizeof x)

typedef long long ll;
typedef int ii;

typedef pair<ll,ll> pi;
typedef vector<pi> vii;

#define map unordered_map

#define INF 1000000000000007
#define pi 3.141592654

#define T while(t--)
#define for2(i,a,b) for(i=a;i>=b;i--)
#define for3(i,a,b) for(i=a;i<=b;i=i+2)
#define for1(i,a,b) for(i=a;i<=b;i=i+1)
#define for4(i,a,b) for(i=a;i>=b;i=i-2)

#define pb push_back
#define pf push_front
#define mp make_pair

#define ff first
#define ss second

#define si set<ll>
#define se multiset<ll>

typedef double ld;
typedef vector<ll> vi;

#define all(v) sort(v.begin(),v.end())
#define all1(v) sort(v.rbegin(),v.rend())

#define pff(uuv) printf("%lld\n",uuv)

#define pf1(uu) printf("%.20Lf\n",uu)

bool comp(pair<ll,char> aa, pair<ll,char> bb) {
    if (aa.ff != bb.ff) return aa.ff > bb.ff;
    return aa.ss < bb.ss;
}
bool comp1(pair<ll,char> aa, pair<ll,char> bb) {
    if (aa.ff != bb.ff) return aa.ff < bb.ff;
    return aa.ss > bb.ss;
}
bool comp2(pair<ll,ll> aa, pair<ll,ll> bb) {
    if (aa.ff != bb.ff) return aa.ff > bb.ff;
    return aa.ss < bb.ss;
}
bool comp3(pair<ll,ll> aa, pair<ll,ll> bb) {
    if (aa.ff != bb.ff) return aa.ff < bb.ff;
    return aa.ss > bb.ss;
}

ll rup(ll ik,ll ikk){

 if(ik%ikk==0) return ik/ikk;
 else return (ik/ikk)+1;

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

 return gcd(b,a%b);

}
ll lcm(ll a ,ll b){

 return (a*b)/gcd(a,b);

}

ii main(){

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--){
        ld n;
        cin>>n;
        n*=1.08;

        n=ll(n);

        if(n<206) cout<<"Yay!\n";
        else if(n==206) cout<<"so-so\n";
        else cout<<":(\n";

     }

}

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

using namespace std;

int main()
{
  int N;
  cin >> N;
  int v = N * 1.08;

  if (v == 206) {
    puts("so-so");
  } else if (v < 206) {
    puts("Yay!");
  } else {
    puts(":(");
  }
  return 0;
}


#include<iostream>
#include<math.h>
#include<map>
#include<vector>
using namespace std;
 int  main()
{
    long long int  n;
    cin>>n;
    long long int  ans= n*(n-1)/2;
    map<long long int ,long long int > count;
    long long int  y;
    for (long long int  i = 0; i < n; i++)
    {
        cin>>y;
        count[y]++;
    }

   for (auto it = count.begin();it != count.end(); ++it)

       {
           if(it->second>0)
        ans= ans- ((it->second)*((it->second)-1))/2;
        }

         cout<<ans;

}

#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <unordered_set>
#include <queue>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stack>
#include <valarray>
#include <typeinfo>
#include <array>

using namespace std;
using ll=long long;
using P = pair<ll,ll>;

#define rep(i,n) for (int i=0; i<(n);++i)
//ll mod=998244353,fac[1000001],finv[1000001],inv[1000001];
int MOD = 1e9+7,ans=0,n,m;
unordered_set<char> tops;
const double PI = acos(-1);
vector<vector<int>> dir = {{0,1},{1,0},{0,-1},{-1,0}};
const int MAX = 1e5+5;

vector<ll> fac,finv,inv;

int ser(int i,int j,int w,vector<vector<int>> &par){
  if(par[i][j]==i*w+j) return par[i][j];
  else return par[i][j]=par[par[i][j]/w][par[i][j]%w];
}

int main()
{
  int n;
  cin >> n;
  vector<int> pw(n),sp(n),te(n),kn(n),id(n);
  rep(i,n){
    cin >> pw[i] >> sp[i] >> te[i] >> kn[i] >> id[i];
  }
  int l=0,r=1e9+1;
  while(r-l>1){
    int mid=(r+l)/2,out=1;
    vector<int> cnt(32);
    rep(i,n){
      int p=0;
      if(pw[i]>=mid) p+=1;
      if(sp[i]>=mid) p+=2;
      if(te[i]>=mid) p+=4;
      if(kn[i]>=mid) p+=8;
      if(id[i]>=mid) p+=16;
      cnt[p]++;
    }
    //rep(i,32) cout << cnt[i] << ' ';
    //cout << endl;
    rep(i,32){
      rep(j,32){
        rep(k,32){
          if(cnt[i]==0 || cnt[j]==0 || cnt[k]==0) continue;
          rep(l,5){
            if(!((i& (1<<l)) || (j& (1<<l)) || (k& (1<<l)))) break;
            if(l==4) out=0;
          }
        }
      }
    }
    if(out==0) l=mid;
    else r=mid;
    //cout << mid << endl;
  }
  cout << l << endl;
}


//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
// #define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}

signed main()
{
	fio
	inp(n) inp(k) inp(mod)
	vector<int> posl={1}, posr={1};

	// TODO
	for(int i=1;i<=n;i++)
	{
		vector<int> tposr(posr.size()+i*k), rem(i);
		fo(j,posr.size()+i*k)
		{
			if(j<posr.size())
			{
				rem[j%i]+=posr[j];
				rem[j%i]%=mod;
			}
			tposr[j]=rem[j%i];
			if(j-i*k>=0)
			{
				rem[j%i]-=posr[j-i*k];
				rem[j%i]%=mod;
			}

		}
		swap(posr,tposr);
		// cout<<posr<<endl;
	}

	vector<int> fans(n/2+n%2);
	for(int i=1;i<=n/2+n%2;i++)
	{
		int x=n-i+1;
		vector<int> rem(x);
		fo(j,posr.size())
		{
			posr[j]=posr[j]-rem[j%x];
			posr[j]%=mod;
			rem[j%x]+=posr[j];
			rem[j%x]%=mod;
			if(j-x*k>=0)
				rem[j%x]-=posr[j-x*k];
			rem[j%x]%=mod;
		}

		// cerr<<posl<<'\n';
		// cout<<posr<<"\n\n";

		int ans=0;
		fo(j,min(posr.size(),posl.size()))
			ans=(ans+((int)posl[j]*posr[j])%mod)%mod;

		vector<int> tposl(posl.size()+i*k);
		rem.clear();
		rem.resize(i);
		fo(j,posl.size()+i*k)
		{
			if(j<posl.size())
			{
				rem[j%i]+=posl[j];
				rem[j%i]%=mod;
			}
			tposl[j]=rem[j%i];
			if(j-i*k>=0)
			{
				rem[j%i]-=posl[j-i*k];
				rem[j%i]%=mod;
			}
		}
		swap(posl,tposl);

		int ftans=((ans*(k+1))%mod-1)%mod;
		if(ftans<0)
			ftans+=mod;
		fans[i-1]=ftans;
	}
	int ind=n/2-1;
	while(ind>=0)
	{
		fans.push_back(fans[ind]);
		ind--;
	}
	// cout<<fans.size()<<endl;
	assert(fans.size()==n);
	for(int i:fans)
		cout<<i<<'\n';
	printclock;
}

//Bismillahir Rahmanir Raheem
#ifdef ONLINE_JUDGE
    #include<bits/stdc++.h>
#endif
#include<iostream>
#include<numeric>
#include<tuple>
#include<iomanip>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<math.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<string>
#include<sstream>
#include<string.h>
#include<deque>
#include<set>
using namespace std;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define clr(cnt, x) memset((cnt), (x), sizeof(cnt))
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int,int> > vii;
typedef pair<int, int> pii;
typedef vector<bool> vbl;
typedef vector<pair<ll,ll> > vll;
typedef pair<ll, ll> pll;
#define PQ priority_queue
#define ff first
#define ss second
#define MP make_pair
#define MT make_tuple
#define mxN (int)2e5 + 2
#define sz(n) (int)(n).size()
#define fasterIO ios::sync_with_stdio(0); cin.tie(0);
#define forc(cn) for(auto &x : (cn))
#define findc(cn, abc) ((cn).find(abc) != (cn).end())

#define PI 2*acos(0)
#define forc(cn) for(auto &x : (cn))
#define MAX 200010
const ll inf = INT_MAX;
const int mod = 1e9 + 7;
struct V {
    ll a, b;
};
bool cmp(const V x, const V y) {
    if(2 * x.a + x.b == 2 * y.a + y.b)
        return x.a < y.a;
    return 2 * x.a + x.b < 2 * y.a + y.b;
}
void solve()
{
    int n;
    cin >> n;
    vector<V> a(n);
    forc(a) cin >> x.a >> x.b;
    sort(all(a), cmp);
    reverse(all(a));
    ll sa = 0, sb = 0, ans = 0;
    forc(a) sa += x.a;
    forc(a) {
        sb += x.a + x.b;
        sa -= x.a;
        ans++;
        if(sb > sa) break;
    }
    cout << ans << endl;

}
int main()
{
    fasterIO
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r+", stdin);
        freopen("output.o", "w+", stdout);
    #endif
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}


#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
using ll=long long;
using ld=long double;

ld judge(string s){
  ll res=0;
  vector<ll> v(9);
  for(ll i=0;i<s.length();i++){
    v[s[i]-48-1]++;
  }
  for(ll i=1;i<=9;i++){
    res+=(i*pow(10,v[i-1]));
  }
          return res;
}

int main(){
  ll N;cin>>N;ll res=0;
  N*=2;
  for(ll i=1;i<=sqrt(N);i++){
    if(N%i==0){
      if(i%2==0){
        if((N/i)%2==1)res++;
      }else{
        if((N/i)%2==0)res++;
      }
    }
  }cout<<res*2<<endl;
}

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

#define all(v) v.begin(), v.end()
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep_up(i, a, b) for (ll i = a; i < b; ++i)
#define rep_down(i, a, b) for (ll i = a; i > b; --i)

#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second

#define vvvvll vector<vector<vector<vector<ll>>>>
#define vvvll vector<vector<vector<ll>>>
#define vvll vector<vector<ll>>
#define vll vector<ll>

#define vvvvdo vector<vector<vector<vector<double>>>>
#define vvvdo vector<vector<vector<double>>>
#define vvdo vector<vector<double>>
#define vdo vector<double>

#define pqll priority_queue<ll>
#define pqllg priority_queue<ll, vector<ll>, greater<ll>>

constexpr ll INF = (1ll << 60);
// constexpr ll mod = 998244353;
// constexpr ll mod = 67280421310721;
constexpr ll mod = 1000000007;
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
void pt_vll(vector<T> &v) {
    ll vs = v.size();
    rep(i, vs) {
        cout << v[i];
        if (i == vs - 1)
            cout << "\n";
        else
            cout << " ";
    }
}
template <typename T>
void pt_vvll(vector<vector<T>> &v) {
    ll vs = v.size();
    rep(i, vs) pt_vll(v[i]);
}
template <typename T>
void pt(T val) {
    cout << val << "\n";
}

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

ll modinv(ll a, ll m) {
    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;
}

void pre_process(vector<vector<ll>> const &a, vector<vector<ll>> &S) {
    ll H = (ll)a.size();
    ll W = (ll)a[0].size();
    S.assign(H + 1, vector<ll>(W + 1));
    for (ll h = 1; h < H + 1; h++) {
        for (ll w = 1; w < W + 1; w++) {
            S[h][w] =
                a[h - 1][w - 1] + S[h][w - 1] + S[h - 1][w] - S[h - 1][w - 1];
        }
    }
}

vector<ll> divisor(ll n, vll &ret) {
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return ret;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N;
    cin >> N;
    vll ret;
    divisor(2 * N, ret);

    ll ans = 0;
    rep(i, ret.size()) {
        ll x = ret[i];
        ll y = 2 * N / x;

        if ((x - y + 1) % 2 == 0 && (x + y - 1) % 2 == 0) ans++;
    }

    pt(ans);

    return 0;
}


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

const int MAX_N = 200;         // n の最大値
vector<vector<long long>> com;  // 前計算の結果を保存
void init() {
    com.assign(MAX_N, vector<long long>(MAX_N));
    com[0][0] = 1;
    for (int i = 1; i < MAX_N; ++i) {
        com[i][0] = 1;
        for (int j = 1; j < MAX_N; j++) {
            com[i][j] = (com[i - 1][j - 1] + com[i - 1][j]);
        }
    }
}
long long nCk(int n, int k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return com[n][k];
}
int main() {
    long long l;
    cin >> l;
    init();
    cout << nCk(l-1, 11) << endl;
}

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

#define lp(i,n) for(int i=0; i<n; i++)
#define cc cout
#define ll long long

// ll fact(ll n)
// {
//     ll res = 1;
//     for (ll i = 2; i <= n; i++)
//         res = res * i;
//     return res;
// }

// ll nCr(ll n, ll r)
// {
//     return fact(n) / (fact(r) * fact(n - r));
// }

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

	int n;
    cin>>n;
    long int ans=1;
    for(int i=1;i<12;i++){
        ans=ans*(n-i);
        ans=ans/i;
    }
    cout<<ans;

}


#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

/* #define MULTI 1 */

void pre()
{
}

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

int main()
{
	pre();
#ifdef MULTI
	int T;
	cin >> T;
	for (int t = 0; t < T; ++t) {
#endif
		solve();
#ifdef MULTI
	}
#endif
	return 0;
}

#include<bits/stdc++.h>
#include<iostream>
using namespace std;
using LL = long long;
using P = pair<int,int>;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); ++i)
//using Graph = vector<vector<int>>;

int main(){
	double A, B;
	cin >> A >> B;
	cout << (1-B/A)*100 << endl;

}


#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 998244353
using Graph=vector<vector<int>>;

vector<int> parent;
int find(int x){
  int y=parent[x];
  while(y!=parent[y]){
    y=find(y);
  }
  return parent[x]=y;
}
void unite(int a,int b){
  int x=find(a);
  int y=find(b);
  if(x!=y){
    parent[x]=y;
  }
}

int main(){
  int N,K;
  cin>>N>>K;
  vector<vector<int>> a(N,vector<int>(N));
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cin>>a[i][j];
    }
  }

  parent.resize(N);
  for(int i=0;i<N;i++){
    parent[i]=i;
  }

  for(int i1=0;i1<N;i1++){
    for(int i2=0;i2<N;i2++){
      bool flag=true;
      for(int j=0;j<N;j++){
        if(a[i1][j]+a[i2][j]>K){
          flag=false;
          break;
        }
      }
      if(flag==true){
        unite(i1,i2);
      }
    }
  }

  vector<ll> sum(N,0);
  for(int i=0;i<N;i++){
    sum[find(i)]++;
  }
  ll ans=1;

  for(int i=0;i<N;i++){
    for(ll j=1;j<=sum[i];j++){
      ans*=j;
      ans%=MOD;
    }
  }

  for(int i=0;i<N;i++){
    parent[i]=i;
    sum[i]=0;
  }

  for(int j1=0;j1<N;j1++){
    for(int j2=0;j2<N;j2++){
      bool flag=true;
      for(int i=0;i<N;i++){
        if(a[i][j1]+a[i][j2]>K){
          flag=false;
          break;
        }
      }
      if(flag){
        unite(j1,j2);
      }
    }
  }

  for(int i=0;i<N;i++){
    sum[find(i)]++;
  }

  for(int i=0;i<N;i++){
    for(ll j=1;j<=sum[i];j++){
      ans*=j;
      ans%=MOD;
    }
  }

  cout<<ans<<endl;
}

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

const int MOD = 998244353;
vector<vector<int>> adj;
vector<bool> visited;

ll fact(ll x) {
    if (x == 0) return 1;
    return x * fact(x-1) % MOD;
}

int dfs(int i) {
    visited[i] = true;
    int cnt = 1;
    for (int j : adj[i]) {
        if (visited[j]) continue;
        cnt += dfs(j);
    }
    return cnt;
}

int main() {
    int n, k;
    cin >> n >> k;
    int a[n][n];
    rep(i, n) rep(j, n) cin >> a[i][j];

    ll ans = 1;
    rep(b, 2) {
        if (b) rep(i, n) for (int j = i+1; j < n; j++)
            swap(a[i][j], a[j][i]);
        adj.assign(n, {});
        visited.assign(n, false);
        rep(i, n) rep(j, n) {
            if (i == j) continue;
            bool flag = true;
            rep(l, n) {
                if (a[l][i] + a[l][j] > k)
                    flag = false;
            }
            if (flag) adj[i].push_back(j);
        }
        rep(i, n) ans = ans * fact(dfs(i)) % MOD;
    }

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


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

vector<string> v{
  "8",
  "16",
  "61",
  "24",
  "42",
  "32",
  "23",
  "48",
  "84",
  "56",
  "65",
  "64",
  "46",
  "72",
  "27",
  "88",
  "96",
  "69"
};

bool Solve(string s)
{
  if (find(v.begin(), v.end(), s) != v.end())
    return true;

  sort(s.begin(), s.end());
  rep(i,13,124)
  {
    string t = to_string(i * 8);
    sort(t.begin(), t.end());
    if (s.find(t) != string::npos)
      return true;
  }

  return false;
}

int main() {
  string s;
  cin >> s;
  if (Solve(s)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

bool check(int n){
	while(n!=0){
		int t = n%10;
		if(t==0){
			return false;
		}
		n = n/10;
	}
	return true;
}

bool check_2(int val, vector<int> arr){
	while(val!=0){
		int t = val%10;
		if(arr[t]>0){
			arr[t]--;
		}
		else{
			return false;
		}
		val = val/10;
	}
	return true;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	vector<int> arr(10,0);
	for(int i=0;i<int(s.size());i++){
		int val = s[i] - '0';
		//cout<<val<<endl;
		arr[val]++;
	}
	if(s.size() == 1){
		if(s[0] == '8')
			cout << "Yes\n";
		else{
			cout << "No\n";
		}
		return 0;
	}
	if(s.size()==2){
		int n1 = (s[0]-'0')*10 + (s[1]-'0');
		int n2 = (s[1]-'0')*10 + (s[0]-'0');
		if(n1 == 16 || n1 == 24 || n1 == 32 || n1 == 56 || n1==48||
			n1 == 64 || n1 == 72 || n1 == 88 || n1 == 96 || n2 == 16 || n2 == 24 || n2 == 32 || n2 == 56 ||
			n2 == 64 || n2 == 72 || n2 == 88 || n2 == 96 ||n2==48){
			cout << "Yes\n";
		}else{
			cout << "No\n";
		}
		return 0;
	}
	//vector<int> v;
	int val = 112;
	while(val<=999){
		if(val%8==0 && check(val)){
			//v.push_back(val);
			if(check_2(val,arr)){
				cout<<"Yes\n";
				return 0;
			}
		}
		val+=8;
	}

	cout<<"No\n";
	return 0;
}


//================code===================//

//#define TLE

#ifdef TLE
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#endif

#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <ctime>

#define ci(t) cin>>t
#define co(t) cout<<t
#define LL long long
#define ld long double
#define fa(i,a,b) for(LL i=(a);i<(LL)(b);++i)
#define fd(i,a,b) for(LL i=(a);i>(LL)(b);--i)
#define setp pair<pair<int,int>,int>
#define setl pair<int,int>
#define micro 0.000001

using namespace std;

LL gcd(LL a, LL b) { return a % b ? gcd(b, a % b) : b; }
LL lcm(LL a, LL b) { return (a * b) / gcd(a, b); }
#ifdef OHSOLUTION
#define ce(t) cerr<<t
#define AT cerr << "\n=================ANS=================\n"
#define AE cerr << "\n=====================================\n"
#else
#define AT
#define AE
#define ce(t)
#define __popcnt __builtin_popcountll
#endif

pair <int, int> vu[9] = { {0,1},{1,0},{-1,0} ,{0,-1},{1,0},{1,0}, {-1,1} , {1,-1},{-1,-1} }; //RDLU EWSN

template<typename T, typename U> void ckmax(T& a, U b) { a = a < b ? b : a; }
template<typename T, typename U> void ckmin(T& a, U b) { a = a > b ? b : a; }
struct gcmp { bool operator()(LL a, LL b) { return a < b; } bool operator()(setl a, setl b) { return a.second < b.second; } };
struct lcmp { bool operator()(LL a, LL b) { return a > b; } bool operator()(setl a, setl b) { return a.second > b.second; } };

const int max_v = 2e5 + 7;
const int INF = 1e9 + 7;
const LL LNF = (LL)5e18 + 7ll;
const LL mod = 1e9 + 7;

string s;
string t;
int n;
int arr[max_v];
int ten[max_v];
int dp[max_v][7];

bool dnq(int idx, int m)
{
	if (idx == -1) return m==0;

	int& ret = dp[idx][m];

	if (~ret) return ret;

	if (t[idx] == 'A')
	{
		ret = 1;
		ret &= dnq(idx - 1, (ten[idx] * arr[idx]+m) % 7);
		ret &= dnq(idx - 1, m);
	}
	else
	{
		ret = 0;
		ret |= dnq(idx - 1, (ten[idx] * arr[idx] + m) % 7);
		ret |= dnq(idx - 1, m);
	}

	return ret;
}

int main()
{
#ifdef OHSOLUTION
	freopen("input.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ci(n >> s >> t);
	reverse(s.begin(), s.end());
	reverse(t.begin(), t.end());
	fa(i, 0, s.size()) arr[i] = s[i] - '0';

	ten[0] = 1;
	fa(i, 1, n) ten[i] = ten[i - 1] * 10 % 7;
	memset(dp, -1, sizeof(dp));
	bool ck = dnq(n - 1,0);
	ck ? co("Takahashi") : co("Aoki");
	return 0;
}

#include<ctime>
#include<cstdio>
#include<cctype>
#define ll long long
using namespace std;
const ll N=2e5+10;
const char s[]="110";
ll read() {
	char c;
	ll x=0,f=1;
	while(!isdigit(c=getchar()))
		f-=2*(c=='-');
	while (isdigit(c)){
		x=x*10+(c-48)*f;
		c=getchar();
	}
	return x;
}
ll n;
char str[N];
ll solve(){
	ll res=1e10;
	if(n==1){
		if(str[0]=='1')
			return res*2;
		return res;
	}
	if(n==2){
		if(str[0]=='1')
			return res;
		if(str[1]=='1')
			return res-1;
		return 0;
	}
	if(str[0]=='0'){
		--res;
		ll t=-1;
		for(ll i=1;i<n;++i){
			++t;
			if(t==3){
				--res;
				t=0;
			}
			if(str[i]^s[t])
				return 0;
		}
		return res;
	}
	if(str[1]=='0'){
		--res;
		ll t=-1;
		for(ll i=2;i<n;++i){
			++t;
			if(t==3){
				--res;
				t=0;
			}
			if(str[i]^s[t])
				return 0;
		}
		return res;
	}
	ll t=-1;
	for(ll i=0;i<n;++i){
		++t;
		if(t==3){
			--res;
			t=0;
		}
		if(str[i]^s[t])
			return 0;
	}
	return res;
}
int main() {
	#ifndef ONLINE_JUDGE
	freopen("B.in","r",stdin);
	freopen("B.out","w",stdout);
	#endif
	clock_t t1=clock();
	//--------
	n=read();
	scanf("%s",str);
	printf("%lld",solve());
	//--------
	clock_t t2=clock();
	fprintf(stderr,"time:%0.3lfs",1.0*(t2-t1)/CLOCKS_PER_SEC);
	return 0;
}