// 2020-12-27 15:59:19
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
// #include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
// #include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
// #include <atcoder/segtree>
// #include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
// using namespace atcoder;

// clang-format on
void answer() {
  int n;
  ll x;
  cin >> n >> x;
  vector<ll> a(n), xs(n);
  rep(i, n) cin >> a[i];
  {
    ll w = x;
    rep(i, n - 1) {
      xs[i] = w % (a[i + 1] / a[i]);
      w /= (a[i + 1] / a[i]);
    }
    xs[n - 1] = w;
  }
  vector<vector<ll> > dp(n + 1, vector<ll>(2, 0));
  dp[0][0] = 1;
  rep(i, n - 1) {
    rep(j, 2) rep(k, 2) dp[i + 1][j] += dp[i][k];
    if (xs[i] == 0) dp[i + 1][1] -= dp[i][0];
    if (xs[i] == a[i + 1] / a[i] - 1) dp[i + 1][0] -= dp[i][1];
  }
  cout << dp[n - 1][0] + dp[n - 1][1] << '\n';
}

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

//IQ134高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007
#define MODB  998244353

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

int main() {
	ll ans = 0;
	ll tmp = 0;
	int n; cin >> n;
	vector<ll> a(n);
    cin >> a;
    map<ll, ll> m;
    m[0]++;
    REP(i, n){
        if(i%2==0)tmp += a[i];
        else tmp -= a[i];
        m[tmp]++;
    }
    for(auto it = m.begin(); it != m.end(); it++){
        ans += (it->second) * (it->second - 1LL) / 2;
    }
	cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll t;
    cin >> t;
    rep(i, t)
    {
        ll n;
        cin >> n;
        vector<ll> a(n);
        map<ll, ll> m;
        rep(i, n)
        {
            cin >> a[i];
            m[a[i]]++;
        }
        if (n % 2 == 0)
        {
            bool b = true;
            for (auto p : m)
            {
                auto v = p.second;
                if (v % 2 != 0)
                {
                    b = false;
                }
            }
            if (b)
            {
                cout << "Second" << endl;
            }
            else
            {
                cout << "First" << endl;
            }
        }
        else
        {
            cout << "Second" << endl;
        }
    }
}

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

// Main
int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), p(n);
    cin >> a >> b >> p;
    rep(i, n) {
        --p[i];
    }

    rep(i, n) {
        if (a[i] <= b[p[i]] && p[i] != i) {
            cout << "-1\n";
            return 0;
        }
    }

    vector<int> idx(n);
    iota(all(idx), 0);
    sort(all(idx), [&](int i, int j) {return a[i] > a[j];});

    vector<int> ansi, ansj;
    for (int i : idx) {
        while (p[i] != i) {
            ansi.push_back(i + 1);
            ansj.push_back(p[i] + 1);
            swap(p[i], p[p[i]]);
        }
    }

    cout << ansi.size() << "\n";
    rep(i, ansi.size()) cout << ansi[i] << " " << ansj[i] << "\n";
}


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

#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
#define f first
#define s second
#define nl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MOD = 1e9+7;
// const int MOD = 998244353;
template<class T> using pqg = priority_queue<T,vector<T>,greater<T>>;

int n, m;
vector<pii> adj[100001];
int val[100001];
bool vis[100001];

void dfs(int x, int v){
  val[x]=v;
  vis[x]=true;
  trav(k, adj[x]){
    if(vis[k.f]) continue;
    dfs(k.f, (k.s==v?(v==n?1:v+1): k.s));
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  cin >> n >> m;
  rep(i, 1, m){
    int u, v, c; cin >> u >> v >> c;
    adj[u].pb({v, c});
    adj[v].pb({u, c});
  }

  rep(i, 1, n){
    if(vis[i]) continue;
    dfs(i, 1);
  }

  rep(i, 1, n) cout << val[i] <<nl;
}

#include<bits/stdc++.h>

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

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

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 110000

vector<vector<int>>g(MAXN);
map<pi, int> costs;
vector<int>r(MAXN);

void dfs(int now=0, int p=-1){
//cout<<now<<' '<<p<<endl;
  if(now==0)r[now]=0;
  for(auto to: g[now]){
    if(to==p || r[to]>=0)continue;

    int c = costs[{now, to}];
    if(r[now]==c)c++;
    r[to] = c;

    dfs(to, now);
  }
}

int main(){
  int n, m;cin>>n>>m;
  g = vector<vector<int>>(n);
  rep(i, m){
    int u,v,c;cin>>u>>v>>c;u--,v--,c--;
    g[u].push_back(v);
    g[v].push_back(u);
    costs[{u, v}] = c;
    costs[{v, u}] = c;
  }

  rep(i, n)r[i]=-1;

  dfs();

  rep(i, n)cout<<r[i]%n+1<<endl;

  return 0;
}


#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
#include<cstring>
using namespace std;
int a[100][100];
const int N=1e6;
int L[N],dp[N];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        a[x][y]=1;
        a[y][x]=1;
    }
    int R=1<<n;
    for(int S=0;S<R;S++){
        int flag=1;
        for(int i=1;i<=n;i++){
            int x1=i-1;
            if(!((S>>x1)&1)) continue;
            for(int j=i+1;j<=n;j++){
                int x2=j-1;
                if(!((S>>x2)&1)) continue;
                if(a[i][j]==0){
                    flag=0;
                    break;
                }
            }
            if(flag==0) break;
        }
        L[S]=flag;
    }
    for(int S=1;S<R;S++){
        dp[S]=n+1;
        for(int T=S;T;T=(T-1)&S){
            if(L[T]) dp[S]=min(dp[S],dp[T^S]+1);
        }
    }
    printf("%d\n",dp[R-1]);
}

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 1e5;

int main() {
    int n, m; cin >> n >> m;
    vint g(n, 0);
    rep(i,n) g[i] |= 1 << i;
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        g[a] |= 1 << b;
        g[b] |= 1 << a;
    }
    vector<bool> connect(1 << n, false);
    connect[0] = true;
    rep(i,1<<n) {
        if (connect[i]) {
            rep(j,n) {
                if ((i & g[j]) == i) connect[i | (1 << j)] = true;
            }
        }
    }
    vint dp(1 << n, inf);
    for (int i = 1; i < 1 << n; i++) {
        if (connect[i]) dp[i] = 1;
        else {
            for (int j = i; j > 0; --j &= i) {
                if (j == i) continue;
                chmin(dp[i], dp[j] + dp[i ^ j]);
            }
        }
    }
    cout << dp.back() << endl;
}


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

int main() {
	int n, m;
	cin >> n >> m;
	set<int> a, b, ans;
	rep(i, n) {
		int v;
		cin >> v;
		a.insert(v);
	}
	rep(i, m) {
		int v;
		cin >> v;
		b.insert(v);
	}
	for (auto v : a) {
		bool which = false;
		for (auto x : b) {
			if (v == x) which = true;
		}
		if (!which) ans.insert(v);
	}
	for (auto v : b) {
		bool which = false;
		for (auto x : a) {
			if (v == x) which = true;
		}
		if (!which) ans.insert(v);
	}
	int count = 0;
	for (auto v : ans) {
		count++;
		cout << v;
		if (count < ans.size()) cout << " ";
	}
	cout << endl;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define fore(i_in,a) for (auto& i_in: a)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fio() cin.tie(nullptr);ios::sync_with_stdio(false);
#define DEBUG_CTN(v) cerr<<#v<<":";for(auto itr=v.begin();itr!=v.end();itr++) cerr<<" "<<*itr; cerr<<endl
template<class T> bool chmax(T &a, const T &b) {if (a<b) { a = b; return true; } return false;}
template<class T> bool chmin(T &a, const T &b) {if (a>b) { a = b; return true; } return false;}
template<class T> void print(const T &t) { cout << t << "\n"; }
const ll INF = 1LL << 62;
const int iINF = 1 << 30;

int n;
string s,t;

int main() {
    fio(); cin>>n>>s>>t;
    vector<set<int>> dp(n+1);
    dp[n].insert(0);
    rrep(i,n){
        int c = s[i]-'0';
        if(t[i]=='T'){
            rep(j,7) {
                int x = (10*j+c)%7;
                int y = (10*j)%7;
                if(dp[i+1].count(x)!=0 or dp[i+1].count(y)!=0) dp[i].insert(j);
            }
        } else {
            rep(j,7) {
                int x = (10*j+c)%7;
                int y = (10*j)%7;
                if(dp[i+1].count(x)!=0 and dp[i+1].count(y)!=0) dp[i].insert(j);
            }
        }
    }
    print(dp[0].count(0)!=0?"Takahashi":"Aoki");
}


// Hail god Yato

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

#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    int n;
    cin>>n;
    vector<ll> vec(n);
    for(int i = 0; i < n; i++)
        cin>>vec[i];
    vec.push_back(0);
    sort(vec.begin(), vec.end());
    ll ans = 1;
    for(int i = 1; i <= n; i++){
        ans *= (vec[i] - vec[i-1] + 1);
        ans %= MOD;
    }
    cout<<ans;
}
signed main(){
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0;
}

#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define sqr(x) ((x) * (x))
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    cin>>n;
    int a;
    set<int> st;

    loop(i,0,n)
    {
        cin>>a;
        st.insert(a);
    }

    LL ans = 1, p = 0;
    for(int x : st)
    {
        ans = (ans * (x - p + 1)) % MOD;
        p = x;
    }

    cout<<ans<<'\n';

    return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} else return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} else return false;}
struct Edge {int to; int w; Edge(int to, int w) : to(to), w(w) {}; };
using Graph = vector<vector<Edge>>;
const int INF = 1<<30;
const ll INFL = 1LL<<60;

int lcs (vector<int> x, vector<int> y) {
  int n = x.size();
  int m = y.size();
  vector<vector<int>> dp(n+1, vector<int>(m+1, INF));
  dp[0][0] = 0;
  rep(i, n+1) {
    rep(j, m+1) {
      if (j > 0) chmin(dp[i][j], dp[i][j-1] + 1);
      if (i > 0) chmin(dp[i][j], dp[i-1][j] + 1);
      if (i > 0 && j > 0) {
        int cost = 0;
        if (x[i-1] != y[j-1]) cost = 1;
        chmin(dp[i][j], dp[i-1][j-1]+cost);
      }
    }
  }
  return dp[n][m];
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  int ans = lcs(a, b);
  cout << ans << endl;
  return 0;
}

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

#define int long long int
#define double long double
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pqi priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define printdecimal(k) cout<<fixed<<setprecision(k);
#define mem(a,k) memset(a,k,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define mod (int)(1e9+7)
#define inf LLONG_MAX
int exp(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int modinv(int x){return exp(x,mod-2);}
int add(int a,int b){a%=mod,b%=mod;a=((a+b)%mod+mod)%mod;return a;}
int sub(int a,int b){a=((a-b)%mod+mod)%mod;return a;}
int mul(int a,int b){a%=mod,b%=mod;a=((a*b)%mod+mod)%mod;return a;}
#define N 1003

int dp[N][N],a[N],b[N];

int duck_duck_go(int idx1,int idx2,int n,int m)
{
	if(dp[idx1][idx2]!=-1) return dp[idx1][idx2];
	if(idx1==n || idx2==m) return (n-idx1)+(m-idx2);
	int res=inf;
	res=min(res,1+duck_duck_go(idx1+1,idx2,n,m));
	res=min(res,1+duck_duck_go(idx1,idx2+1,n,m));
	res=min(res,2+duck_duck_go(idx1+1,idx2+1,n,m));
	res=min(res,(a[idx1]!=b[idx2])+duck_duck_go(idx1+1,idx2+1,n,m));
	return dp[idx1][idx2]=res;
}

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

	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<m;i++)
		cin>>b[i];
	mem(dp,-1);
	cout<<duck_duck_go(0,0,n,m);
	return 0;
}


#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
namespace atcoder {}
using namespace atcoder;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
#define int long long int
struct dijkstra {
  vector<vector<pair<lli, pair<lli, lli>>>> e;
  int n;
  lli inf = 1e18;
  dijkstra(int n) : n(n) { e.resize(n); }
  void add(int a, int b, lli c, lli k) {
    e[a].push_back(make_pair(b, make_pair(c, k)));
  }
  void biadd(int a, int b, lli c, lli k) {
    add(a, b, c, k);
    add(b, a, c, k);
  }
  vector<lli> get(int s) {
    vector<lli> dist(n, inf);
    dist[s] = 0;
    using p = pair<lli, lli>;
    priority_queue<p, vector<p>, greater<p>> que;
    que.push(make_pair(0, s));
    while (!que.empty()) {
      lli d = que.top().first;
      lli cur = que.top().second;
      que.pop();
      if (dist[cur] < d)
        continue;
      dist[cur] = d;
      for (auto s : e[cur]) {
        lli wei = s.second.first;
        lli k = s.second.second;
        lli to = s.first;
        lli t = dist[cur] + wei + (d % k ? k - dist[cur] % k : 0);
        if (dist[to] > t) {
          dist[to] = t;
          que.push(make_pair(t, to));
        }
      }
    }
    return dist;
  }
};
void solve(long long N, long long M, long long X, long long Y,
           std::vector<long long> A, std::vector<long long> B,
           std::vector<long long> T, std::vector<long long> K) {
  dijkstra dij(N);
  rep(i, M) { dij.biadd(A[i] - 1, B[i] - 1, T[i], K[i]); }
  auto t = dij.get(X - 1)[Y - 1];
  if (t >= 1e16) {
    cout << -1 << endl;
  } else {
    cout << t << endl;
  }
}

signed main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  long long X;
  scanf("%lld", &X);
  long long Y;
  scanf("%lld", &Y);
  std::vector<long long> A(M);
  std::vector<long long> B(M);
  std::vector<long long> T(M);
  std::vector<long long> K(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
    scanf("%lld", &T[i]);
    scanf("%lld", &K[i]);
  }
  solve(N, M, X, Y, std::move(A), std::move(B), std::move(T), std::move(K));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}

#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define ll 				long long
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii               map<ll,ll>
#define pqi             priority_queue<ll>			//max pq
#define pqd             priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define MOD             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define pw(b,p)         pow(b,p) + 0.1
#define f(i,k,n)		for(ll i=k;i<n;i++)
#define fd(i,start,end)	for(ll i=start;i>=end;i--)

ll power(ll a, ll b, ll mod) {ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) {if (b & 1)res = res * a % mod; a = a * a % mod;} return res;}
ll power(ll a, ll b) {ll res = 1; assert(b >= 0); for (; b; b >>= 1) {if (b & 1)res = res * a ; a = a * a;} return res;}
ll min( ll a,  ll b) { return (a < b) ? a : b;}
ll max(ll a, ll b) {return (a > b) ? a : b;}
ll gcd (ll a, ll b) {if (a == 0) return  b; return gcd(b % a, a);}

void bwayne()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
}
// ll n;
// cin >> n;
// vi a(n);
// f(i, 0, n) {
// 	cin >> a[i];
// }

// vector<vi> a(n,vector<vi>(m,0));
// f(i,0,n){
// 	f(j,0,m){
// 		cin>>a[i][j];
// 	}
// }

void solve() {
	ll n;
	cin >> n;
	vi a(n + 1);
	mii m;
	f(i, 1, n + 1) {
		cin >> a[i];
		m[a[i]] = i;
	}
	vi ans;
	set<ll> ansset;
	fd(i, n, 2) {
		ll curr = m[i];
		// cout << curr << endl;
		if (curr < i) {
			while (curr < i) {
				ll one = curr;
				ll two = curr + 1;
				ll el1 = a[one];
				ll el2 = a[two];
				swap(a[one], a[two]);
				m[el2] = one;
				m[el1] = two;
				if (ansset.find(curr) != ansset.end()) {
					cout << -1;
					return;
				}
				ans.pb(curr);
				ansset.insert(curr);
				// cout << "&" << curr << endl;
				// f(i, 1, n + 1) {
				// 	cout << a[i] << " ";
				// }
				// cout << endl;
				curr++;
			}
		}
		else if (curr > i) {
			cout << -1;
			return;
		}
	}
	if (ans.size() != n - 1) {
		cout << -1;
		return;
	}
	f(i, 0, n - 1) {
		cout << ans[i] << endl;
	}

}
int main()
{
	bwayne();// remember
	ll t = 1;
	// cin >> t;

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

	return 0;
}


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

int n;
int a[200001];

int main() {
    cin >> n;
    int prev = 0;
    int oPrev = 0;
    vector<int> ans;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (i > a[i]) {
            if (a[i] < prev) {
                cout << "-1\n";
                return 0;
            }
            int j = i;
            while (j > a[i]) {
                ans.push_back(j - 1);
                j--;
            }
            prev = i;
        } else {
            if (a[i] < oPrev) {
                cout << "-1\n";
                return 0;
            }
            oPrev = a[i];
        }
    }
    if (ans.size() != n - 1) {
        cout << "-1\n";
        return 0;
    }
    for (int s : ans) {
        cout << s << "\n";
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

struct fenwick {
    int n;
    vector<int> bit;

    fenwick(int _n) : bit(_n), n(_n) {}

    void add(int idx, int val) {
        for (; idx <= n; idx += idx & (-idx))
            bit[idx] += val;
    }

    int pref(int idx) {
        int ans = 0;
        for (; idx > 0; idx -= idx & (-idx))
            ans += bit[idx];
        return ans;
    }

    int sum(int a, int b) { return pref(b) - pref(a - 1); }
};

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

    vector<int> v(n), inv(n);
    for (int i = 0; i < n; ++i) cin >> v[i];
    fenwick fw(n + 1);
    int ct = 0;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        inv[i] = fw.sum(v[i], n);
        fw.add(v[i], 1);
        ct += inv[i];
        mp[v[i]] = i;
    }
    if (ct != n - 1) {
        cout << -1;
        return;
    }

    vector<int> ans;
    set<int> now;
    for (int i = 0; i < n; i++) {
        int pos = mp[i + 1];
        if (pos == i)continue;
        for (int j = pos; j >= i + 1; j--) {
            swap(v[j], v[j - 1]), ans.push_back(j);
            if (now.count(j)) {
                cout << -1;
                return;
            }
            now.insert(j);
        }
    }
    for (auto x: ans)cout << x << endl;
}

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

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

    while (t--)
        solve();
    return 0;
}


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

int main() {
  ll R,X,Y;
  cin >> R >> X >> Y;
  long double d = sqrt(X*X+Y*Y);
  ll i = 1;
  while(true){
    if(i*R >= d){
      if(i == 1 && i*R != d) cout << i+1 << endl;
      else cout << i << endl;
      return 0;
    }
    i++;
  }
}

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

void solver1(ll R, ll X, ll Y, ll &ans){

    ll dist_sq = X*X + Y*Y;
    double dist = sqrt(dist_sq);
//    ll move_sq = R*R;

//    ll div = 0, mod = 0;
    double div = 0;
    div = dist/R;
//    mod = dist_sq%R;

    if (floor(div) == div) ans = div;
    else ans = div + 1;

    return;
}

void solver2(ll R, ll X, ll Y, ll &ans){

    ll dist_sq = X*X + Y*Y;
    double dist = sqrt(dist_sq);

    if (dist < R){
        ans = 2;
        return;
    }

    ll cnt = 0;
    while (dist > 0){
        dist -= R;
        cnt++;
    }
    ans = cnt;

    return;
}

int main(){

    ll R, X, Y;
    cin >> R >> X >> Y;

    ll ans = 0;
//    solver1(R, X, Y, ans);
//    cerr << ans << endl;
    solver2(R, X, Y, ans);
//    cerr << ans << endl;

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


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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> con(m, {0, 0});
    rep(i, m) cin >> con[i][0] >> con[i][1];
    int k;
    cin >> k;
    vector<vector<int>> k_s(k, {0, 0});
    vector<int> choise(k);
    rep(i, k) cin >> k_s[i][0] >> k_s[i][1];
    int re = pow(2, k);
    int ans = 0;
    rep(i, re)
    {
        rep(j, k)
        {
            if ((i >> j) & 1 == 1)
            {
                choise[j] = k_s[j][1];
            }
            else
            {
                choise[j] = k_s[j][0];
            }
        }
        int match = 0;
        vector<vector<int>> count(m, {0, 0});
        rep(j, k)
        {
            rep(l, m)
            {
                if (choise[j] == con[l][0])
                {
                    count[l][0]++;
                }
                if (choise[j] == con[l][1])
                {
                    count[l][1]++;
                }
            }
        }
        rep(j, m)
        {
            if (count[j][0] > 0 && count[j][1] > 0)
            {
                match++;
            }
        }
        ans = max(ans, match);
    }
    cout << ans << endl;
}

#include <algorithm>
#include <iomanip>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <numeric>
#include <vector>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i, n) _rep2(i, 0, n)
#define _rep2(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using i64 = long long;
template<class T, class U>
bool chmin(T& a, const U& b) { return (b < a) ? (a = b, true) : false; }
template<class T, class U>
bool chmax(T& a, const U& b) { return (b > a) ? (a = b, true) : false; }

template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(vector<T>&v){stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v){if(v.size())o<<join(v);return o;}
template<typename T>string join(vector<vector<T>>&vv){string s="\n";rep(i,vv.size())s+=join(vv[i])+"\n";return s;}
template<typename T>ostream& operator<<(ostream&o,vector<vector<T>>&vv){if(vv.size())o<<join(vv);return o;}
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;

char winnner(char a, char b)
{
    if(a == b) return a;
    if(a == 'R' && b == 'S')
    {
        return 'R';
    }
    if(a == 'S' && b == 'R')
    {
        return 'R';
    }
    if(a == 'P' && b == 'R')
    {
        return 'P';
    }
    if(a == 'R' && b == 'P')
    {
        return 'P';
    }
    if(a == 'S' && b == 'P')
    {
        return 'S';
    }
    if(a == 'P' && b == 'S')
    {
        return 'S';
    }
}

int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    s += s;

    rep(j, k)
    {
        string n_s = "";
        for (int i = 0; i < int(s.size()) - 1; i += 2)
        {
            n_s += winnner(s[i], s[i + 1]);
        }
        s = n_s + n_s;
    }

    cout << s[0] << endl;

    return 0;
}


// Username: WillTheBill
// Time of creation: 2020-11-08 15:24
// Original filename: m.cp.cpp

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

// shortcuts
#define pb push_back
#define fi first
#define se second
#define all(_v) _v.begin(),_v.end()
#define ll long long

// IO
#define multitest signed __T; cin >> __T; while(__T--)
template<typename T>
void _read(T& t);
template<typename T>
void _read(vector<T>&v);
template<typename T1, typename T2>
void _read(pair<T1,T2>&p);
template<typename T>
void _read(T& t){cin >> t;}
template<typename T>
void _read(vector<T>&v){for(unsigned _i=0;_i<v.size();_i++)_read(v[_i]);}
template<typename T1, typename T2>
void _read(pair<T1,T2>&p){_read(p.first);_read(p.second);}
void _masterread(){}
template<typename T,typename... V>
void _masterread(T& t, V&... v){_read(t);_masterread(v...);}
#define re(...)_masterread(__VA_ARGS__)

template<typename T>
void _print(T t);
template<typename T>
void _print(vector<T>&v);
template<typename T1, typename T2>
void _print(pair<T1,T2>&p);
template<typename T>
void _print(T t){cout<<t;}
template<typename T>
void _print(vector<T>&v){for(unsigned _i=0;_i<v.size();_i++)_print(v[_i]),cout<<(_i==v.size()-1?"":" ");}
template<typename T1, typename T2>
void _print(pair<T1,T2>&p){_print(p.first);cout<<" ";_print(p.second);}
void _masterprint(){cout<<endl;}
template<typename T,typename... V>
void _masterprint(T t, V... v){_print(t);if(sizeof...(v))cout<<" ";_masterprint(v...);}
#define pr(...)_masterprint(__VA_ARGS__)

// DEBUG
// colored output???
template <typename T> // start forward declaration
void _debug(T t);
template<typename T1,typename T2>
void _debug(pair<T1,T2> p);
template<typename T>
void _debug(vector<T>v);
template <typename T> // end forward declaration
void _debug(T t){cerr<<t;}
template<typename T1,typename T2>
void _debug(pair<T1,T2> p){cerr<<"{";_debug(p.first);cerr<<", ";_debug(p.second);cerr<<"}";}
template<typename T>
void _debug(vector<T>v){cerr<<"(";for(unsigned _i=0;_i<v.size();_i++)_debug(v[_i]),cerr<<(_i==v.size()-1?"":", ");cerr << ")";}
void _masterdebug(){cerr<<"]\n";}
template<typename T,typename... V>
void _masterdebug(T t,V... v){_debug(t);if(sizeof...(v))cerr<<", ";_masterdebug(v...);}
#ifdef __local__
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"] = [";_masterdebug(__VA_ARGS__)
#else
#define debug(...)
#endif

// TYPES
// #define int long long

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int h,w,n,m; re(h,w,n,m);
	vector<vector<int>> grid (h,vector<int> (w));
	vector<vector<bool>> good (h, vector<bool> (w));
	for(int i = 0; i < n; i++){
		int a,b; re(a,b); a--,b--;
		grid[a][b] = 1;
		good[a][b] = 1;
	}
	for(int i = 0; i < m; i++){
		int c,d; re(c,d);c--,d--;
		grid[c][d] = 2;
	}
	for(int i = 0; i < h; i++){
		int last = grid[i][0];
		for(int j = 1; j < w; j++){
			if(last == 1) good[i][j] = 1;
			if(grid[i][j] != 0) last = grid[i][j];
		}
		last = grid[i][w-1];
		for(int j = w - 2; j >= 0; j--){
			if(last == 1) good[i][j] = 1;
			if(grid[i][j] != 0) last = grid[i][j];
		}
	}
	for(int j = 0; j < w; j++){
		int last = grid[0][j];
		for(int i = 1; i < h; i++){
			if(last == 1) good[i][j] = 1;
			if(grid[i][j] != 0) last = grid[i][j];
		}
		last = grid[h-1][j];
		for(int i = h - 2; i >= 0; i--){
			if(last == 1) good[i][j] = 1;
			if(grid[i][j] != 0) last = grid[i][j];
		}
	}
	int cnt = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cnt += good[i][j] && grid[i][j] != 2;
		}
	}
	pr(cnt);
}

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

int main(){
  int H,W,N,M;
  cin >> H >> W >> N >> M;
  vector<vector<int>> G(H,vector<int>(W,0));
  for(int i=0;i<N;i++){
    int a,b;
    cin >> a >> b;
    a--;b--;
    G[a][b] = 1;
  }
  for(int i=0;i<M;i++){
    int c,d;
    cin >> c >> d;
    c--;d--;
    G[c][d] = -1;
  }

  vector<vector<int>> X(H,vector<int>(0)),Y(W,vector<int>(0));
  vector<vector<bool>> Xl(H,vector<bool>(0)),Yl(W,vector<bool>(0));
  for(int i=0;i<H;i++){
    bool light=0;
    for(int j=0;j<W;j++){
      if(G[i][j]==1) light = 1;
      if(G[i][j]==-1){
        X[i].push_back(j);
        Xl[i].push_back(light);
        light = 0;
      }
    }
    X[i].push_back(W);
    Xl[i].push_back(light);
  }
  for(int i=0;i<W;i++){
    bool light=0;
    for(int j=0;j<H;j++){
      if(G[j][i]==1) light = 1;
      if(G[j][i]==-1){
        Y[i].push_back(j);
        Yl[i].push_back(light);
        light = 0;
      }
    }
    Y[i].push_back(H);
    Yl[i].push_back(light);
  }

  long long ans=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(G[i][j]==-1) continue;
      int a = lower_bound(X[i].begin(),X[i].end(),j) - X[i].begin(),
          b = lower_bound(Y[j].begin(),Y[j].end(),i) - Y[j].begin();
      if(Xl[i][a] || Yl[j][b]) ans++;
    }
  }

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


#include <bits/stdc++.h>
using namespace std;
double r, x, y;
int main()
{
	cin >> r >> x >> y;
	double d = hypot(x, y);
	cout << (d < r ? 2 : ceil(d / r)) << endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for(LL i=0;i<(n);i++)

int main()
{
   LL r, x, y;
   LL output = 0;
   long double distance;

   cin >> r >> x >> y;

   distance = sqrt(x*x + y*y);

   if(r <= distance){
    output = distance/r;
    long double temp = distance/r;

    //cout << "temp:" << temp << endl;
    //cout << "dis:" << distance << endl;

    if(output != temp)
        output++;
   }
   else{
       output = 2;
   }

    cout << output << endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long dp[31][31] = {};
long long acolyte(int a, int b)
{
  long long cost = 0;
  if(dp[a][b])
  {return dp[a][b];}
  if(a + b <= 1)
  {return 1;}
  if(a)
  {cost += acolyte(a - 1, b);}
  if(b)
  {cost += acolyte(a, b - 1);}
  dp[a][b] = cost;
  return cost;
}
void solution()
{
  long long a, b, k;
  cin >> a >> b >> k;
  int sum = a + b;
  string output = "";
  while((b && a >= 0) || (a && b >= 0))
  {
    long long cost = 0;
    if(a)
    {
      long long cost = 0;
      if((cost = acolyte(a - 1, b)) < k)
      {output += 'b'; b--; k -= cost;}
      else
      {output += 'a'; a--;}
    }
    else
    {output += 'b'; b--;}
  }
  cout << output << endl;
  return;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int count, counter = 0;
  count = 1;
  while(counter++ < count)
  {solution();}
  return 0;
}

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

#ifdef LOCAL
#include "debug.h"
#endif

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define rep(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repi(i, a, b) for (int i = (int)a; i >= (int)b; i--)
#define pb push_back
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define umin(a, x) a = min(a, x)
#define umax(a, x) a = max(a, x)

ll nxt() {
	ll x; cin >> x; return x;
}

void setIO(string s) {
	#ifndef LOCAL
	ios_base::sync_with_stdio(0); cin.tie(0);
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
	#endif
}

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

	const int maxt = 2e5 + 5;
	vll a(maxt);

	rep(i, 0, n) {
		ll s, t, p; cin >> s >> t >> p;
		a[s] += p; a[t] -= p;
	}

	rep(i, 1, n) a[i] = a[i - 1] + a[i];
	cout << ((*max_element(all(a)) > w) ? "No" : "Yes") << endl;
}

int32_t main(){
	// setIO("trapped");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cout << fixed << setprecision(10);

	int T = 1;
	// cin >> T;

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


// #include <bits/stdc++.h>
// string s;
// getline(cin, s);
// g++ -std=c++11 -O2 -Wall test.cpp -o test
// printf("%.9f\n", x); PRECISION

#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;

#define F first
#define S second

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

const int MAX_LENGTH = (2 * 1e5 + 1);
int n, c;
long long x;
long long dp[MAX_LENGTH][2];

void solve() {
    set<int> set_ids;
    unordered_map<int, long long> max_pos;
    unordered_map<int, long long> min_pos;
    int MMIN = 0, MMAX = 1;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x >> c;
        set_ids.insert(c);
        if (max_pos.find(c) == max_pos.end()) {
            max_pos[c] = x;
            min_pos[c] = x;
        } else {
            max_pos[c] = max(max_pos[c], x);
            min_pos[c] = min(min_pos[c], x);
        }
    }
    vector<int> ids(set_ids.begin(), set_ids.end());
    n = ids.size();
    dp[n - 1][MMIN] = abs(min_pos[ids[n - 1]] - max_pos[ids[n - 1]]) +
                      abs(max_pos[ids[n - 1]]);
    dp[n - 1][MMAX] = abs(min_pos[ids[n - 1]] - max_pos[ids[n - 1]]) +
                      abs(min_pos[ids[n - 1]]);

    for (int i = n - 2; i >= 0; i--) {
        int cur = ids[i];
        int next = ids[i + 1];
        long long d = abs(min_pos[cur] - max_pos[cur]);
        dp[i][MMIN] =
            d + min(dp[i + 1][MMAX] + abs(max_pos[next] - max_pos[cur]),
                    dp[i + 1][MMIN] + abs(min_pos[next] - max_pos[cur]));
        dp[i][MMAX] =
            d + min(dp[i + 1][MMAX] + abs(max_pos[next] - min_pos[cur]),
                    dp[i + 1][MMIN] + abs(min_pos[next] - min_pos[cur]));
    }
    cout << min(abs(min_pos[ids[0]]) + dp[0][MMIN],
                abs(max_pos[ids[0]]) + dp[0][MMAX]);
}

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

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

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

#define int long long
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>

const int N = 105;
int n;
pair<double,double> a[N];
pii dsu[N];

int find(int x)
{
    if(dsu[x].F == x) return x;
    return dsu[x].F = find(dsu[x].F);
}

void merge(int x,int y)
{
    int p = find(x);
    int q = find(y);

    if(p == q) return;

    if(dsu[p].S > dsu[q].S) swap(p,q);

    dsu[q].S+=dsu[p].S;
    dsu[p].F = dsu[q].F;
}

//n is upper
//n+1 is lower

double dis(pair<double,double> x,pair<double,double> y)
{
   return sqrt( ((x.F - y.F)*(x.F - y.F)) + ((x.S - y.S)*(x.S - y.S)) );
}

bool check(double r)
{
    f(i,n+2) dsu[i] = {i,1};

    f(i,n) f(j,n)
        if(dis(a[i],a[j]) <= r + r) merge(i,j);

    f(i,n) if(100 - a[i].S <= r + r) merge(i,n);
    f(i,n) if(a[i].S + 100 <= r + r) merge(i,n+1);

    return find(n) != find(n+1);
}

signed main()
{
    fast;

   cin >> n;

   f(i,n) cin >> a[i].F >> a[i].S;

   double l = 0.00000;
   double r = 100.000000;

   f(i,100)
   {
       double mid = (l+r)/2;

       if(check(mid)) l = mid;
       else r = mid;
   }

   cout << fixed << setprecision(4) << l;
}


// E - Rush Hour 2
#include "bits/stdc++.h"
using namespace std;

#ifndef DEBUG

#define fundri 108
#define debug(...) 1729
#define endl '\n'

#endif

#define int int64_t

typedef pair<int, int> pii;
typedef vector<int> vi;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l = 0, int r = INT_MAX) {return uniform_int_distribution<int>(l, r)(rng);}

bool in_range(int x, int l, int r) {return l <= x && x <= r;}
template<typename H, typename ...T>void inp(H &head) {cin >> head;}
template<typename H, typename ...T>void inp(H &head, T &...tail) {cin >> head;inp(tail...);}
template<typename T>inline istream &operator >>(istream &in, vector<T> &a) {for(T &x : a)in >> x; return in;}
template<typename T, typename U>inline istream &operator >>(istream &in, pair<T, U> &a) {in >> a.first >> a.second; return in;}

// Multi-Dimension Vector
// Usage: vec<n, data-type> dp(dimention-1, dimention-2, ..., dimention-n, default = data-type())
template<int D, typename T> struct vec : public vector<vec<D - 1, T>> {
    static_assert(D >= 1, "Vector dimensions must be greater than zero !!");
    template<typename... Args>
    vec(int n = 0, Args... args) : vector<vec<D - 1, T>>(n, vec<D - 1, T>(args...)){}
};

template<typename T> struct vec<1, T> : public vector<T> {vec(int n = 0, T val = T()) : vector<T>(n, val){}};

const int inf = 1e15;
const bool testcases = false;

const bool ready = []() -> bool {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

#ifdef DHRUV_GHEEWALA
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    return true;
}();

void solve(int tc);
int32_t main(int32_t argc, char **argv) {
    int TC = 1;
    if(testcases) cin >> TC;

    // Pre-Processing goes here...
    for(int tc = 1; tc <= TC; ++tc) {
        solve(tc);
        fundri;
    }
    exit(0);
}

typedef vector<vector<vector<int>>> graph;
graph adj;
void add_edge(graph &a, int u, int v, int c, int d, bool dir = 0)
{
    a[u].push_back({v, c, d});
    if(!dir) a[v].push_back({u, c, d});
}

void clearAll(int n)
{
    adj.clear();
    adj.resize(n + 1);
}

void solve(int tc) {
    int n, m;
    cin >> n >> m;

    clearAll(n);
    int u, v, c, d;
    for(int i = 0; i < m; i++) {
        cin >> u >> v >> c >> d;
        u--, v--;
        add_edge(adj, u, v, c, d);
    }

    auto calc = [&](int c, int d, int t) {
        return c + d / (t + 1) + t;
    };

    auto get = [&](int c, int d, int t) {
        return calc(c, d, max(t, int(sqrt(d))));
        int l = t, r = inf, ans = calc(c, d, t);
        int m = l;
        while(m < r) {
            if(ans >= calc(c, d, m)) {
                ans = calc(c, d, m);
                m++;
            } else {
                m = r + 1;
            }
        }
        return ans;
    };

    priority_queue<pii, vector<pii>, greater<pii>> pq;
    vector<int> dist(n, inf);
    pq.push({0, 0});

    while(!pq.empty()) {
        const auto fir = pq.top();
        pq.pop();

        debug(fir);
        int t = fir.first;
        int u = fir.second;

        if(dist[u] <= t) continue;
        dist[u] = t;

        for(const auto &vec: adj[u]) {
            int v = vec[0];
            int c = vec[1];
            int d = vec[2];
            int cost = get(c, d, t);
            debug(u, v, c, d, cost);

            if(cost < dist[v])
                pq.push({cost, v});
        }
    }
    cout << (dist[n - 1] == inf ? -1 : dist[n - 1]) << endl;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pl = pair<ll, ll>;
using Vs = vector<string>;
//const ll mod = 1000000007;
const ll inf = 1000000000000000000;//10の18乗
#define yn {puts("Yes");}else{puts("No");}
#define dame { puts("-1"); return 0;}
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll n,m;
    cin >> n >> m;
    vector<vector<mint>> dp(50,vector<mint>(10000));
    vector<mint> v(500005);
    v[0]=1;
    v[1]=1;
    dp[0][0]=1;
    rrep(i,1,10005){
        v[i+1]=v[i].x*(i+1);
    }
    //cout << 0 << endl;
    rrep(i,1,21){
        ll x=modpow(2,i-1,mod);
        rep(j,m+1){
            if(dp[i-1][j].x==0) continue;
            for(ll k=0;j+x*k<=m;k+=2){
                //if(dp[i-1][j]==0)
                if(k>n) break;
                mint plus=v[n].x;
                plus/=v[k].x;
                plus/=v[n-k].x;
                dp[i][j+x*k]+=dp[i-1][j].x*plus.x;
            }
        }
        //cout << 0 << endl;
    }
    /*rep(i,20){rep(j,m+1){
        cout << dp[i][j].x << " ";
    }cout << endl;}*/
    cout << dp[20][m].x << endl;
}


#include <iostream>
#include <string>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <set>
#include <map>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200010
#define LIMIT2 500010
#define LIMIT3 1000010
#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef long double ld;
typedef const void cv;
typedef pair<ll,ll> P;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define ALL(a) (a).begin(),(a).end()
#define ALL2(a, n) (a),(a)+(n)
template<class T,class C> T max(T a,C b){ return std::max(a, (T)b); }
template<class T,class C> T min(T a,C b){ return std::min(a, (T)b); }
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a/gcd(a,b))*b;}
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){

}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  string s="110",t;

  cin >> n;
  cin >> t;
  m = modpow(10,10,0);
  k = 0;
  if(t=="1"){//コーナーケース
    cout << 2*m << endl;
    return 0;
  }
  for(i=0;i<n;i++){
    if(i+2<=n){
      if(t.substr(i,2)=="00"){//ダメ
        cout << 0 << endl;
        return 0;
      }
    }
    if(i+3<=n){
      if(t.substr(i,3)=="111"){//ダメ2
        cout << 0 << endl;
        return 0;
      }
      if(t.substr(i,3)=="010"){//ダメ3
        cout << 0 << endl;
        return 0;
      }
    }
  }
  for(i=0;i<n;i++){
    if(t[i]=='0') k++;
  }
  if(t[n-1] == '1') k++;
  result = m-k+1;

  cout << result << endl;
  return 0;
}

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

#define fi first
#define se second
#define rng(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); --i)
#define per(i, b) gnr(i, 0, b)
#define all(obj) begin(obj), end(obj)
#define allr(obj) rbegin(obj), rend(obj)
#define cinv(a) rep(i, (int)a.size()) cin >> a[i]
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<Pi> vp;
typedef vector<vp> vvp;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;

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; }
template <typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, 1, 0, -1};
const int MOD =	1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const long double eps = 1e-10;
const char nl = '\n';

ll power(ll a, ll b) { return b ? power(a * a % MOD, b / 2) * (b % 2 ? a : 1) % MOD : 1; }

ll nCk(int n, int k)
{
	ll x = 1, y = 1;
	for (int i = 1; i <= k; ++i)
	{
		x = x * (n - i + 1) % MOD;
		y = y * i % MOD;
	}
	return x * power(y, MOD - 2) % MOD;
}

struct UF
{
	vi d;
	UF(int n) : d(n, -1) {}
	int root(int x)
	{
		if (d[x] < 0)
			return x;
		return d[x] = root(d[x]);
	}
	bool unite(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (d[x] > d[y]) swap(x, y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return -d[root(x)]; }
};

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout<<fixed<<setprecision(20);
	int n; cin >> n;
	vi x(n), y(n);
	rep(i, n) cin >> x[i] >> y[i];

	int x_min1 = INF, x_min2 = INF, y_min1 = INF, y_min2 = INF;
	int x_max1 = 0, x_max2 = 0, y_max1 = 0, y_max2 = 0;
	int index_x_max1, index_x_min1, index_y_max1, index_y_min1;

	auto two_max = [&](int &max1, int &max2, int &index, vi &vec) -> void
	{
		rep(i, n)
		{
			if (max1 < vec[i])
			{
				max2 = max1;
				max1 = vec[i];
				index = i;
			}
			else if (max2 < vec[i])
			{
				max2 = vec[i];
			}
		}
	};
	two_max(x_max1, x_max2, index_x_max1, x);
	two_max(y_max1, y_max2, index_y_max1, y);

	auto two_min = [&](int &min1, int &min2, int &index, vi &vec) -> void
	{
		rep(i, n)
		{
			if (min1 > vec[i])
			{
				min2 = min1;
				min1 = vec[i];
				index = i;
			}
			else if (min2 > vec[i])
			{
				min2 = vec[i];
			}
		}
	};
	two_min(x_min1, x_min2, index_x_min1, x);
	two_min(y_min1, y_min2, index_y_min1, y);

	if (index_x_max1 == index_y_max1 && index_x_min1 == index_y_min1)
		cout << max(max(x_max1 - x_min2, x_max2 - x_min1), max(y_max1 - y_min2, y_max2 - y_min1)) << nl;
	else
	{
		vi ans;
		ans.pb(x_max1 - x_min1);
		ans.pb(y_max1 - y_min1);
		ans.pb(x_max1 - x_min2);
		ans.pb(y_max1 - y_min2);
		ans.pb(x_max2 - x_min1);
		ans.pb(y_max2 - y_min1);
		sort(allr(ans));
		cout << ans[1] << nl;
	}
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int C[N][N];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> C[i][j];
        }
    }
    int A[N], B[N];
    A[0] = B[0] = 0;
    int min_a = 0;
    for (int i = 1; i < N; i++) {
        int ok = C[0][i] - C[0][0];
        for (int j = 0; j < N; j++) {
            if (C[j][i] - C[j][0] != ok) {
                cout << "No\n";
                return 0;
            }
        }
        A[i] = ok;
        min_a = min(min_a, ok);
    }
    int min_b = 0;
    for (int i = 1; i < N; i++) {
        int ok = C[i][0] - C[0][0];
        for (int j = 0; j < N; j++) {
            if (C[i][j] - C[0][j] != ok) {
                cout << "No\n";
                return 0;
            }
        }
        B[i] = ok;
        min_b = min(min_b, ok);
    }
    for (int i = 0; i < N; i++) A[i] -= min_a;
    for (int i = 0; i < N; i++) B[i] -= min_b;
    int diff = C[0][0] - A[0] - B[0];
    if (diff < 0) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    for (int i = 0; i < N; i++) {
        if (i) cout << " ";
        cout << B[i] + diff;
    }
    cout << "\n";
    for (int i = 0; i < N; i++) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << "\n";
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define llrep(i,n) for(ll i=0; i<(ll)n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define PI (double)3.14159265358979323846;
#define fi first
#define se second
#define kiriage(x,y) (((x)+(y)-1)/(y))
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vp;

int main(){
	int n; cin>>n;
	int c[n][n];
	rep(i,n) rep(j,n) cin>>c[i][j];
	vi M(n);
	rep(i,n){
		int mn = INF;
		rep(j,n){
			mn = min(c[j][i], mn);
		}
		M[i] = mn;
	}
	vi ans(n);
	rep(i,n){
		int dif = c[i][0] - M[0];
		rep(j,n){
			if (dif != c[i][j] - M[j]){
				cout << "No" << endl;
				return 0;
			}
		}
		ans[i] = dif;
	}
	cout << "Yes" << endl;
	rep(i,n) cout << ans[i] << " ";
	cout << endl;
	rep(i,n) cout << M[i] << " ";
}


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

int n;
mt19937 mt;
const int TRIES = 750;
const int SHUFFLES = 0;

bool check(string s, vector<vector<char>>& a, int i, int j) {
    bool isOk = true;
    for (int k = 0; k < s.size() && isOk; ++k) {
        if (s[k] != a[i][(j + k) % n]) {
            isOk = false;
        }
    }
    if (isOk) {
        return true;
    }
    for (int k = 0; k < s.size() && isOk; ++k) {
        if (s[k] != a[(i + k) % n][j]) {
            isOk = false;
        }
    }
    return isOk;
}

int calc(vector<string>& v, vector<vector<char>>& a) {
    int cnt = 0;
    for (string& s : v) {
        bool found = false;
        for (int i = 0; i < n && !found; ++i) {
            for (int j = 0; j < n && !found; ++j) {
                if (check(s, a, i, j)) {
                    found = true;
                }
            }
        }
        cnt += found;
    }
    return cnt;
}

pair<int, vector<vector<char>>> gen(vector<string>& v) {
    shuffle(v.begin(), v.end(), mt);
    vector<vector<char>> a(n, vector<char>(n));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            a[i][j] = char(mt() % 8 + int('A'));
        }
    }
    int i = 0, j = 0;
    for (auto s : v) {
        if (j + s.size() >= n) {
            j = 0;
            ++i;
        }
        if (i >= n) {
            break;
        }
        for (int k = 0; k < s.size(); ++k, ++j) {
            a[i][j] = s[k];
        }
    }
    pair<int, vector<vector<char>>> res = {calc(v, a), a};
    for (int i = 0; i < SHUFFLES; ++i) {
        auto curr = res;
        shuffle(curr.second.begin(), curr.second.end(), mt);
        curr.first = calc(v, curr.second);
        if (curr.first > res.first) {
            res = curr;
        }
    }
    return res;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    mt.seed(time(nullptr));
    int m;
    cin >> n >> m;
    vector<string> v(m);
    for (auto& i : v) {
        cin >> i;
    }
    pair<int, vector<vector<char>>> res = gen(v);
    for (int i = 0; i < TRIES; ++i) {
        auto curr = gen(v);
        if (curr.first > res.first) {
            res = curr;
        }
    }
    for (auto& i : res.second) {
        for (auto& j : i) {
            cout << j;
        }
        cout << '\n';
    }
	return 0;
}

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

template<class T>
using V = vector<T>;

using ll = long long;

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for(int i=m; i<n; i++)

vector<int> par;

void init(int n){
    for(int i=0; i<n; i++) par.at(i) = i;
}

int root(int x){
    if(par.at(x) == x){
        return x;
    }else{
        return par.at(x) = root(par[x]);
    }
}

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

void unite(int x, int y){
    x = root(x);
    y = root(y);
    if(x == y) return;
    par.at(x) = y;
}

int main(){
    int N, M; cin >> N >> M;
    V<int> a(N), b(N), c(M), d(M);
    rep(i, N) cin >> a.at(i);
    rep(i, N) cin >> b.at(i);
    rep(i, M){
        cin >> c.at(i) >> d.at(i);
        c.at(i)--; d.at(i)--;
    }

    par.resize(N);
    init(N);
    rep(i, M) unite(c.at(i), d.at(i));

    V<ll> suma(N), sumb(N);
    rep(i, N){
        int r = root(i);
        suma.at(r) += a.at(i);
        sumb.at(r) += b.at(i);
    }
    bool flg = true;
    rep(i, N){
        if(suma.at(i) != sumb.at(i)) flg = false;
    }
    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define DREP(i,s,n) for(int i = (s); i < (n); i++)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 998244353;
const double pi = acos(-1);
ll gcd(ll a, ll b) {if(b == 0) return a; else return gcd(b,a%b);}
ll lcm(ll a, ll b) {return a*b/gcd(a,b);}

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<MOD>;

int main() {
    int N,M; cin >> N >> M;
    int K; cin >> K;
    if(N == 1) {
        cout << modpow((mint)K,(ll)M) << endl;
    } else if(M == 1) {
        cout << modpow((mint)K,(ll)N) << endl;
    } else {
        mint ans = 0;
        for(int x = 1; x <= K; x++) {
            ans += (modpow((mint)x,(ll)N)-modpow((mint)(x-1),(ll)N)) * modpow((mint)(K-x+1),(ll)M);
        }
        cout << ans << endl;
    }
    return 0;
}

#include<bits/stdc++.h>
#define int long long
#define ri register signed
#define rd(x) x=read()
#define endl '\n'
using namespace std;
const int N=2e6+5;
const int M=1e6+5;
const int maxn=5e6+5;
const int mod=998244353;
const int inf=0x3f3f3f3f;
inline int read(){int x=0,f=1;char ch=getchar();while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}
inline int ksm(int x,int y=mod-2,int z=mod){int ret=1;while (y){if (y&1) ret=(ret*x)%z;x=(x*x)%z;y>>=1;}return ret;}
int inv[N],fac[N],ifc[N];
void gmax(int &x,int y){x=max(x,y);}
void Init(int n)
{
    inv[1]=1;for (ri i=2;i<=n;i++)inv[i]=inv[mod%i]*(mod-mod/i)%mod;
    fac[0]=1;for (ri i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
    ifc[0]=1;for (ri i=1;i<=n;i++) ifc[i]=ifc[i-1]*inv[i]%mod;
}
int C(int n,int m){if (n>mod) return 0;if (m>n || m<0)return 0;return fac[n]*ifc[m]%mod*ifc[n-m]%mod;}
int c(int n,int m){if (n<mod) return C(n,m);return C(n%mod,m%mod)*c(n/mod,m/mod)%mod;}

int n,m,k,ans;
int a[N],s[N];
signed main()
{
    rd(n);rd(m);rd(k);
    if (n==1)
    {
        cout<<ksm(k,m)<<endl;return 0;
    }
    if (m==1)
    {
        cout<<ksm(k,n)<<endl;return 0;
    }
    Init(2*(n+m));
    for (int i=1;i<=k;i++)
    {
        a[i]=ksm(i,n)-s[i-1];
        a[i]%=mod;
        s[i]=s[i-1]+a[i];
        s[i]%=mod;
        ans+=a[i]*ksm(k-i+1,m)%mod;
        ans%=mod;
    }
    cout<<(ans+mod)%mod<<endl;
}


#include <iostream>

using namespace std;

int main()
{
   int N,M;
   cin>>N>>M;
   cout<<N/M;
}

#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lop ios; ll t; cin>>t; while(t--)
#define pb push_back
#define vi vector<ll>
#define vivi vector<vector<ll>>
#define vipa vector<pair<ll,ll>>
#define F first
#define S second
#define M 1000000007
#define kl "\n"
#define _p(v) for(auto i:v)cout<<i<<" ";
#define all(v) v.begin(),v.end()
#define rll(v) v.rbegin(),v.rend()
typedef long long ll;
ll lcm(ll x, ll y){ll k=x*y; k/=(__gcd(x,y)); return k;}
//ll power(ll x,ll y){ ll r= 1;x = x % M;if(x==0) return 0; while(y>0) {if(y&1) r=(r*x)%M; y=y>>1; x=(x*x)%M;} return r;}

void solve()
{
    ll n,m,k,i,j;
    cin>>n>>m;
    k=n/m;
    cout<<k;
}

int main()
{
    ios
    // ll t;
    // cin>>t;
    // while(t--)
    solve();
	return 0;
}


/*ver 7*/
#include <bits/stdc++.h>
using namespace std;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
using pll = pair<ll,ll>;
using mll = map<ll,ll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
#define each(x,v) for(auto& x : v)
#define reps(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
const ll INF = 1LL << 60;
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<=b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){}
template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
template <typename T> void in1(T &s) {rep(i,s.size()){in(s[i]);}}
template <typename T> void in2(T &s,T &t) {rep(i,s.size()){in(s[i],t[i]);}}
template <typename T> void in3(T &s,T &t,T &u) {rep(i,s.size()){in(s[i],t[i],u[i]);}}
template <typename T> void in4(T &s,T &t,T &u,T &v) {rep(i,s.size()){in(s[i],t[i],u[i],v[i]);}}
template <typename T> void in5(T &s,T &t,T &u,T &v,T &w) {rep(i,s.size()){in(s[i],t[i],u[i],v[i],w[i]);}}
void out(){cout << endl;}
template <typename T,class... U> void out(const T &t,const U &...u){cout << t; if(sizeof...(u)) cout << " "; out(u...);}
void die(){cout << endl;exit(0);}
template <typename T,class... U> void die(const T &t,const U &...u){cout << t; if(sizeof...(u)) cout << " "; die(u...);}
template <typename T> void outv(T s) {rep(i,s.size()){if(i!=0)cout<<" ";cout<<s[i];}cout<<endl;}
template <typename T> void out1(T s) {rep(i,s.size()){out(s[i]);}}
template <typename T> void out2(T s,T t) {rep(i,s.size()){out(s[i],t[i]);}}
template <typename T> void out3(T s,T t,T u) {rep(i,s.size()){out(s[i],t[i],u[i]);}}
template <typename T> void out4(T s,T t,T u,T v) {rep(i,s.size()){out(s[i],t[i],u[i],v[i]);}}
template <typename T> void out5(T s,T t,T u,T v,T w) {rep(i,s.size()){out(s[i],t[i],u[i],v[i],w[i]);}}
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
template <typename T> T allSum(vector<T> a){T ans=T();each(it,a)ans+=it;return ans;}
ll ceilDiv(ll a,ll b) {return (a+b-1)/b;}
ld dist(pair<ld,ld> a, pair<ld,ld> b){return sqrt(abs(a.fi-b.fi)*abs(a.fi-b.fi)+abs(a.se-b.se)*abs(a.se-b.se));} // ２点間の距離
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
#define YES(n) ((n) ? "YES" : "NO"  )
#define Yes(n) ((n) ? "Yes" : "No"  )
#define yes(n) ((n) ? "yes" : "no"  )

int main(){
	init();
	inl(a,b,c);
	V<ll> d{a,b,c};
	map<V<ll>,ld> memo;
	memo[d]=1;
	deque<V<ll>> q;
	ld ans=0;
	q.push_back(d);
	while(q.size()!=0){
		V<ll> now=q.front();
		q.pop_front();
		if(now[0]==100 ||now[1]==100 ||now[2]==100){
			ans+=(now[0]+now[1]+now[2]-d[0]-d[1]-d[2])*memo[now];
			continue;
		}
		ll sum=now[0]+now[1]+now[2];
		rep(i,3){
			if(now[i]!=0){
				V<ll> next=now;
				next[i]++;
				if(memo.count(next)==0){
					q.push_back(next);
					memo[next]=0;
				}
				memo[next]+=memo[now]*now[i]/sum;
			}
		}
	}
	out(ans);
	return 0;
}

#include <iostream>
#include <iomanip>

double dp[101][101][101];

double dfs(int a, int b, int c){
   if(dp[a][b][c]) return dp[a][b][c];
   if(a==100 || b==100 || c==100) return 0;

   double ret = (dfs(a+1, b, c) + 1) * a / (a+b+c);
   ret += (dfs(a, b+1, c) + 1) * b / (a+b+c);
   ret += (dfs(a, b, c+1) + 1) * c / (a+b+c);
   dp[a][b][c] = ret;

   return ret;
}

int main(){
   int A, B, C;
   std::cin >> A >> B >> C;

   std::cout << std::fixed << std::setprecision(10) <<  dfs(A, B, C) << std::endl;

   return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ar array

int n, k;
int arr[60][60];
int vis[60];
ll ans = 1;
int sz[60], dsu[60];
ll fact[60];
ll mod = 998244353;

int parent(int node){
    if(dsu[node] == node) return node;
    return dsu[node] = parent(dsu[node]);
}

void connect(int a, int b){
    a = parent(a), b = parent(b);
    if(a == b) return;
    dsu[a] = b, sz[b] += sz[a];
}

void comprow(int row){
    for(int i = 1; i <= n; i++){
        if(i == row) continue;
        bool f = 1;
        for(int j = 1; j <= n; j++){
            if(arr[row][j] + arr[i][j] > k) f = 0;
        }
        if(f) connect(row, i);
    }
}

void compcol(int col){
    for(int i = 1; i <= n; i++){
        if(i == col) continue;
        bool f = 1;
        for(int j = 1; j <= n; j++){
            if(arr[j][col] + arr[j][i] > k) f = 0;
        }
        if(f) connect(col, i);
    }
}

void factorial(){
    fact[0] = 1;
    for(int i = 1; i <= 50; i++) fact[i] = fact[i-1]*i, fact[i] %= mod;
}

void solve(){
    cin>>n>>k;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cin>>arr[i][j];
        }
    }
    for(int i = 1; i <= n; i++){
        vis[i] = false, dsu[i] = i, sz[i] = 1;
    }
    for(int i = 1; i <= n; i++){
        comprow(i);
    }
    factorial();
    for(int i = 1; i <= n; i++){
        if(vis[ parent(i) ]) continue;
        vis[ parent(i) ] = true;
        ans *= fact[sz[ parent(i) ]], ans %= mod;
    }
    for(int i = 1; i <= n; i++){
        vis[i] = false, dsu[i] = i, sz[i] = 1;
    }
    for(int i = 1; i <= n; i++){
        compcol(i);
    }
    for(int i = 1; i <= n; i++){
        if(vis[ parent(i) ]) continue;
        vis[ parent(i) ] = true;
        ans *= fact[sz[ parent(i) ]], ans %= mod;
    }
    cout << ans << endl;
}

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

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,x,n) for(int i = x; i<=n; i++)
#define FORO(i,n) for(int i = 0; i<n; i++)
#define nl "\n"
#define sp " "
#define MOD 1000000007
#define INF 1000000000000000000
#define pb push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vpi vector<pair<int, int> >
#define vpl vector<pair<ll, ll> >
#define pi pair<int, int>
#define pl pair<ll, ll>
#define ff first
#define ss second

ll n, K, a[51][51], parent[51], sizes[51];

ll mod = 998244353;

ll fact(ll a){
	ll ans = 1;
	FOR(i,2,a){
		ans*=i;
		ans%=mod;
	}
	return ans;
}

void make_set(int v){
    parent[v] = v;
    sizes[v] = 1;
}

int find_set(int v){
    if(v==parent[v]) return v;
    return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b){
    a = find_set(a);
    b = find_set(b);
    if(a!=b){
        if(sizes[a]<sizes[b]) swap(a, b);
        parent[b] = a;
        sizes[a]+=sizes[b];
    }
}

int main(){
//	ios_base::sync_with_stdio(false);
//	cin.tie(NULL);
	cin>>n>>K;
	FORO(i,n){
		FORO(j,n) cin>>a[i][j];
	}
	FORO(i,n) make_set(i);
	FORO(i,n){
		FORO(j,n){
			bool fl = 1;
			FORO(k,n){
				if(a[k][i]+a[k][j]>K){
					fl = 0;
					break;
				}
			}
			if(fl) union_sets(i,j);
		}
	}
	ll ans = 1;
	FORO(i,n){
		if(parent[i]==i) ans = ans*fact(sizes[i])%mod;
	}
	FORO(i,n) make_set(i);
	FORO(i,n){
		FORO(j,n){
			bool fl = 1;
			FORO(k,n){
				if(a[i][k]+a[j][k]>K){
					fl = 0;
					break;
				}
			}
			if(fl) union_sets(i,j);
		}
	}
	FORO(i,n){
		if(parent[i]==i) ans = ans*fact(sizes[i])%mod;
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int n = s.size();
    int i = 0, j = n-1;
    while(s[i] == '0')
        i++;
    while(s[j] == '0')
        j--;
    while(i < j){
        if(s[i] != s[j]){
            cout << "No";
            exit(0);
        }
        i++, j--;
    }
    cout << "Yes";
    return 0;
}

/*************************************************************************
  > File Name: solve.cpp
  > Author: liupo
  > Mail: lanzongwei@gmail.com
  > Created Time: 2021-02-28 21:37:24
 ************************************************************************/

#define GOODOJ
#define SYNC 0

#ifdef GOODOJ
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#include <chrono>
#include <random>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#else
#include <iostream>
#include <cstdio>
#include <cmath>
#include <set>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <deque>
#include <vector>
#include <limits>
#include <cassert>
#include <sstream>
#include <iterator>
#include <functional>
#endif
using namespace std;

#define endl '\n'
#define fep(i,b,e) for(int i=(b);i<(e);++i)
#define rep(i,x) for(int i=0;i<(x);++i)
#define rap(i,x) for(auto& i : (x))
#define seg(t) (t).begin(), (t).end()
#define ep emplace_back
#define mkp make_pair
#define qxx(i,x) for(int i = head[x]; ~i; i = node[i].nex)
#define F first
#define S second
#define lowbit(x) ((-(x))&(x))
#define RE register
#define getchar() getchar_unlocked()
#ifdef DEBUG
void err(istream_iterator<string>){}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << ' ';
	err(++it, args...);
}
#define debug(args...) {string _s=#args;replace(seg(_s),',',' ');\
	cerr<<"DEBUG:";istringstream it(_s);\
	err(istream_iterator<string>(it), args);cerr<<endl;}
#else
#define debug(...)
#endif

template<typename T> inline bool cmax(T& a,const T& b) {return a<b?a=b,1:0;}
template<typename T> inline bool cmin(T& a,const T& b) {return a>b?a=b,1:0;}

#ifdef GOODOJ
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
typedef __gnu_pbds::priority_queue<int> pq;
#endif
typedef std::string str;
typedef long long ll;
typedef double db;
typedef pair<int, int> pa;

const double P = acos(-1.0), eps = 1e-9;
struct point { db x ,y;};
inline int sign(db a) {return a < -eps ? -1 : a > eps;}
#define dot(p1,p2,p3) ((p2.x-p1.x)*(p3.x-p1.x)+(p2.y-p1.y)*(p3.y-p1.y))
#define cross(p1,p2,p3) ((p2.x-p1.x)*(p3.y-p1.y)-(p3.x-p1.x)*(p2.y-p1.y))
#define crossOp(p1,p2,p3) sign(cross(p1,p2,p3))

constexpr int Ma = 1e6, inf = 0x3f3f3f3f, mod = 1e9 + 7;

void solve() {
	str s; cin >> s;
	while (!s.empty() and s.back() == '0') s.pop_back();
	for (int i = 0; i < s.length() / 2; i++) if (s[i] != s[s.length() - 1 - i]) {
		cout << "No" << endl;
		return ;
	}
	cout << "Yes" << endl;
}

signed main() {
#if SYNC==0
	ios::sync_with_stdio(false);
	cin.tie(0);
#endif
	int T = 1;
	while (T--) solve();

	return 0;
}


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

#define ll long long
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

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

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

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

const int N = 100005;
const int M = N / 4;

const ll INF = 1LL << 60;

int A[N], B[N], perm[N];
ll cost[2][N];
int main(){
	int n; cin >> n;
	ll ans = 0;
	for(int i = 1; i <= n; i++) cin >> A[i], ans += A[i];
	for(int i = 1; i <= n; i++) cin >> B[i], perm[i] = i;
	sort(perm + 1, perm + n + 1, [&](int i, int j){return B[i] - A[i] > B[j] - A[j];});
	vector<int> num(2, 0);
	for(int i = 1; i <= n; i++){
		int ind = perm[i];
		int j = ind % 2;
		num[j]++;
		cost[j][num[j]] = cost[j][num[j] - 1] + B[ind] - A[ind];
	}
	ll val = ans;
	for(int i = 1; i <= n / 2; i++){
		ans = max(ans, val + cost[0][i] + cost[1][i]);
	}
	cout << ans << endl;
}

#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define eps (double)(1e-9)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n)cin >> a[i];
    rep(i, n)cin >> b[i];
    vector<int> even, odd;
    rep(i, n){
        if(i % 2 == 0)even.push_back(b[i]-a[i]);
        else odd.push_back(b[i]-a[i]);
    }
    sort(rall(even)); sort(rall(odd));
    ll ans = accumulate(all(a), 0LL);
    rep(i, n/2)ans += max(0, even[i]+odd[i]);
    cout << ans << endl;
}


#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  int m = 5;
  vector<vector<int>> men((n), vector<int>(m));
  rep(i, n) rep(j, m) cin >> men[i][j];
  int l = 0, r = 1001001001;  // 100 100 100 1をすると10^9というのがわかりやすい
  while (l + 1 < r) {
    int c = (l + r) / 2;
    vector<int> s;
    rep(i, n) {
      int x = 0;
      rep(j, m) {
        if (men[i][j] >= c) x |= 1 << j;  // jbit目にbitを立てに行く
      }
      s.push_back(x);
    }
    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()), s.end());
    bool ok = false;
    rep(i, s.size()) rep(j, i + 1) rep(k, j + 1) {  // k<=j<=i
      if ((s[i] | s[j] | s[k]) == (1 << m) - 1)
        ok = true;  //(1<<m)-1でmbitの1...1が作れる
    }
    if (ok)
      l = c;
    else
      r = c;
  }
  cout << l << endl;
  return 0;
}

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
    //int a, b; cin >> a >> b;
    //cout << (a + b) / 2 << " " << (a - b) / 2 << endl;

    /*//cin >> n >> s;
    int n = 5000; string s(n, 'T');
    ll ans = 0;
    for (int i = 2; i <= n; i += 2) {
        for (int j = 0; j < n - i + 1; ++j) {
            int a, t, g, c;
            a = t = g = c = 0;
            rep(k, i) {
                a += s[j + k];
                //if (s[j + k] == 'A') a++;
                //if (s[j + k] == 'T') t++;
                //if (s[j + k] == 'G') g++;
                //if (s[j + k] == 'C') c++;
            }
            if (a == t && g == c) ans++;
        }
    }
    cout << ans << endl;
    */

    int n; string s;
    cin >> n >> s;
    ll ans = 0;
    vector<ll> sum(n + 1);
    sum[0] = 0;
    rep(i, n) {
        int num = 0;
        if (s[i] == 'A') num = 1;
        if (s[i] == 'T') num = -1;
        if (s[i] == 'G') num = 10000;
        if (s[i] == 'C') num = -10000;
        sum[i + 1] = sum[i] + num;
    }
    rep(i, n + 1) {
        for (int j = i + 1; j < n + 1; ++j) {
            if (sum[j] - sum[i] == 0) {
                //cout << i << "(" << sum[i] << "), " << j << "(" << sum[j] << ")" << endl;
                ans++;
            }
        }
    }
    cout << ans << endl;

    //vector<int> pos;
    //for (int i = 0; i < n - 1; ++i) {
    //    bool ok = false;
    //    if (s[i] == 'A' && s[i + 1] == 'T') ok = true;
    //    if (s[i] == 'T' && s[i + 1] == 'A') ok = true;
    //    if (s[i] == 'C' && s[i + 1] == 'G') ok = true;
    //    if (s[i] == 'G' && s[i + 1] == 'C') ok = true;
    //    if (ok) pos.push_back(i);
    //}
    //ans = pos.size();
    //int sz = pos.size();
    //rep(i, sz) {
    //    for (int j = i + 1; j < sz; ++j) {
    //        if (2 < pos[j] - pos[j - 1]) break;
    //        ans++;
    //    }
    //}
    //cout << ans << endl;
    return 0;
}


#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>

constexpr int N = 100005;

int n;
std::vector<long long> a[3];
std::string s;

int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(nullptr);
    std::cin >> n;
    for (int i = 1; i <= n << 1; ++i) {
        long long x;
        std::cin >> x >> s;
        if (s[0] == 'R') a[0].push_back(x);
        else if (s[0] == 'G') a[1].push_back(x);
        else a[2].push_back(x);
    }
    int x = -1, y = -1;
    for (int i = 0; i < 3; ++i) {
        if (a[i].size() & 1) {
            if (x != -1) y = i;
            else x = i;
        }
        std::sort(a[i].begin(), a[i].end());
    }
    if (x == -1) return std::cout << "0\n", 0;
    auto f = [](int x, int y) -> long long {
        long long ans = 1e18;
        for (long long i : a[x]) {
            long long t = std::lower_bound(a[y].begin(), a[y].end(), i) - a[y].begin();
            if (t != a[y].size()) ans = std::min(ans, std::abs(a[y][t] - i));
            if (t) ans = std::min(ans, std::abs(i - a[y][t - 1]));
        }
        return ans;
    };
    int z = 3 - x - y;
    long long ans = f(x, y);
    long long t1 = f(x, z), t2 = f(y, z);
    if (t1 < 1e18) ans = std::min(ans, t1 + t2);
    std::cout << ans << '\n';
    return 0;
}

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

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

ll A[200000], tmp[200001];
void pakuri_sort(int N, ll A[]) {
	const int b = 9;
	rep(k, 6) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

const int CM = 1 << 17, CL = 20;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
const ll pre[9] = { 1,10,100,1000,10000,100000,1000000,10000000,100000000 };
inline ll getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		ll tmp2 = *(ll*)ci;
		if ((tmp2 & ma0) == ma0) {
			ci += 9;
			return 1000000000000000;
		}
		int dig = 68 - __builtin_ctzll((tmp2 & ma0) ^ ma0);
		if (dig == 64) {
			ci++;
			return tmp;
		}
		tmp2 = tmp2 << dig & ma1;
		tmp2 = tmp2 * 10 + (tmp2 >> 8) & ma2;
		tmp2 = tmp2 * 100 + (tmp2 >> 16) & ma3;
		tmp2 = tmp2 * 10000 + (tmp2 >> 32) & ma4;
		ci += (72 - dig >> 3);
		tmp = tmp * pre[64 - dig >> 3] + tmp2;
	}
	return tmp;
}

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

	int N = getint();

	int K[3] = {};
	rep(i, N << 1) {
		ll a = getint();
		char c = *ci++;
		ci++;
		ll C = (ll(c) >> 4 | ll(c) << 1) & 3;
		K[C]++;
		A[i] = a | C << 50;
	}
	pakuri_sort(N * 2, A);
	if (K[0] % 2 == 0 && K[1] % 2 == 0 && K[2] % 2 == 0) {
		co(0);
		return 0;
	}

	auto P = A;
	auto Q = A + K[0];
	auto R = A + K[0] + K[1];
	const ll ma = (1ll << 50) - 1;
	for(int i = N * 2 - 1; i >= K[0]; i--) A[i] &= ma;
	ll sai[3] = {};
	ll saiq = 1e18, sair = 1e18;
	int q = 0, r = 0;
	rep(p, K[0]) {
		if (q < K[1]) if (saiq > abs(Q[q] - P[p])) saiq = abs(Q[q] - P[p]);
		while (q < K[1] - 1 && Q[q] < P[p]) {
			q++;
			if (saiq > abs(Q[q] - P[p])) saiq = abs(Q[q] - P[p]);
		}
		if (r < K[2]) if (sair > abs(R[r] - P[p])) sair = abs(R[r] - P[p]);
		while (r < K[2] - 1 && R[r] < P[p]) {
			r++;
			if (sair > abs(R[r] - P[p])) sair = abs(R[r] - P[p]);
		}
	}
	sai[2] = saiq;
	sai[1] = sair;
	sair = 1e18;
	r = 0;
	q = 0;
	while (q < K[1]) {
		if (r < K[2]) if (sair > abs(R[r] - Q[q])) sair = abs(R[r] - Q[q]);
		while (r < K[2] - 1 && R[r] < Q[q]) {
			r++;
			if (sair > abs(R[r] - Q[q])) sair = abs(R[r] - Q[q]);
		}
		q++;
	}
	sai[0] = sair;
	ll kotae = 1e18;
	if (K[0] % 2 == 0) kotae = min(sai[0], sai[1] + sai[2]);
	else if (K[1] % 2 == 0) kotae = min(sai[1], sai[2] + sai[0]);
	else kotae = min(sai[2], sai[0] + sai[1]);
	co(kotae);

	Would you please return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T1, class T2> inline bool chmax(T1 &a, const T2 &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T1, class T2> inline bool chmin(T1 &a, const T2 &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
struct UnionFind {
private:
    vector<int> par;
    vector<int> count;
    vector<int> rank;
public:
    UnionFind(int N) {
        count.assign(N, 1);
        rank.assign(N, 0);
        par.assign(N, 0);
        rep(i, N) par[i] = i;
    }

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

    void unite(int x, int y) {
        x = root(x), y = root(y);
        if (x == y) return;
        if (rank[x] < rank[y])
            swap(x, y);
        else if (rank[x] == rank[y])
            rank[y]++;
        par[y] = x;
        count[x] += count[y];
        return;
    }

    int size(int x) {
        return count[root(x)];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }
};
using UF = struct UnionFind;

int main() {
    ll N;
    cin >> N;
    vc<string> S(N);
    rep(i, N) cin >> S[i];

    vvc<int> child(N), parent(N);
    rep(i, N){
        vl srch(N);
        srch[i] = true, child[i].eb(i);
        queue<ll> q;
        q.emplace(i);
        while(!q.empty()){
            ll now = q.front();
            q.pop();
            rep(j, N){
                if (srch[j] or S[now][j] == '0') continue;
                srch[j] = true;
                child[i].eb(j);
                q.emplace(j);
            }
        }
        srch = vl(N), q.emplace(i), parent[i].eb(i), srch[i] = true;
        while(!q.empty()){
            ll now = q.front();
            q.pop();
            rep(j, N){
                if (srch[j] or S[j][now] == '0') continue;
                srch[j] = true;
                parent[i].eb(j);
                q.emplace(j);
            }
        }
    }

    ld ans = 0;
    rep(i, N) ans += 1.0L / parent[i].size();

    cout << ans << endl;
}

#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=998244353;
#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";}

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

	int N;
	cin>>N;
	vector<ll> kai(N+1,1);
	int weigt[N];
	int sum=0;
	rep(i,N) cin>>weigt[i],sum+=weigt[i];
	for(int i = 2;i <= N;i++)kai[i]=(kai[i-1]*(i))%Q;
	if(sum%2==1){
		cout<<"0\n";
		return 0;
	}
	ll dp[N+1][sum+1];
  memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(int i =0;i < N;i++){
		for(int j=sum/2;j>=weigt[i];j--){
			for(int k=N-1;k>=0;k--) dp[k+1][j]=(dp[k+1][j]+dp[k][j-weigt[i]])%Q;
		}
	}
	ll ans=0;
	for(int i = 0;i < N;i++){
		ans=(ans+(dp[i][sum/2]*((kai[i]*kai[N-i])%Q))%Q)%Q;
	}
	cout<<(ans)%Q<<endl;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 1000000007
#define ad(a,b) a=(a+b)%mod;
#define X 5010
ll po(ll x,ll y){
	ll res=1;
	for(;y;y>>=1){
		if(y&1)res=res*x%mod;
		x=x*x%mod;
	}
	return res;
}
ll fac[X],ivf[X];
void init(){
	fac[0]=1;
	for(ll i=1;i<X;i++)fac[i]=fac[i-1]*i%mod;
	for(ll i=0;i<X;i++)ivf[i]=po(fac[i],mod-2);
}
ll C(ll n,ll k){
	return fac[n]*ivf[n-k]%mod*ivf[k]%mod;
}

int solve(){
	string s;
	cin>>s;
	string ss=s;
	sort(ss.begin(),ss.end());
	reverse(ss.begin(),ss.end());
	string atc="atcoder";
	if(atc>=ss){
		return -1;
	}
	int ans=1e9;
	for(int i=0;i<=atc.size();i++){
		int cnt=0;
		ss=s;
		for(int j=0;j<i;j++){
			for(int k=j;k<ss.size();k++){
				if(ss[k]==atc[j]){
					cnt+=k-j;
					swap(ss[k],ss[j]);
					break;
				}
			}
		}
		if(i<atc.size()){
			for(int k=i;k<ss.size();k++){
				if(ss[k]>atc[i]){
					cnt+=k-i;
					swap(ss[k],ss[i]);
					break;
				}
			}
		}
		if(atc<ss){
			chmin(ans,cnt);
			//cerr<<i<<":"<<cnt<<endl;
		}
	}
	return ans;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	ll t;
	cin>>t;
	while(t--)cout<<solve()<<"\n";
}

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

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

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

  int t;cin >> t;
  while(t--){
    string s;cin >> s;
    string w = "atcoder";
    if(w < s)cout << 0;
    else{
      int ans = INT_MAX;
      for(int i = 0;i < (int)s.length() - 1;i++){
        for(int j = i + 1;j < (int)s.length();j++){
          swap(s[i], s[j]);
          if(w < s)ans = min(ans, abs(i - j));
          swap(s[i], s[j]);
        }
      }
      if(ans == INT_MAX)cout << -1;
      else cout << ans;
    }
    cout << endl;
  }
}


#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	if(m==0){
		for(int i=1;i<=n;i++) printf("%d %d\n",2*i-1,2*i);
		return 0;
	}
	if(m<0){
		printf("-1\n");
		return 0;
	}
	if(m>=n-1){
		printf("-1\n");
		return 0;
	}
	m++;
	printf("1 %d\n",2*(m+1));
	for(int i=1;i<=m;i++) printf("%d %d\n",2*i,2*i+1);
	for(int i=m+2;i<=n;i++) printf("%d %d\n",2*i-1,2*i);
	return 0;
}

    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 1ll * mod * mod;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// rng
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m;
vector<ii> ans;

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);

    cin >> n >> m;

    if( n == 1 && m == 0 ){
        cout << 1 << ' ' << 2 << '\n';
        return 0;
    }

    if( m >= 0 ){
        if( m + 1 > n - 1 ){ cout << -1 << '\n'; return 0; }
        ans.pb({1,2*(m+1)+1});
        int curr = 2;
        for(int i=1; i<=m; i++){
            ans.pb({curr,curr+1});
            curr += 2;
        }
        ans.pb({curr,curr+2});
        curr += 3;
        for(int i=m+1+1+1; i<=n; i++){
            ans.pb({curr,curr+1});
            curr += 2;
        }
    }
    else{
        cout << -1 << '\n';
        return 0;
    }

    for( auto i : ans )
        cout << i.f << ' ' << i.s << '\n';

    return 0;
}