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

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

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

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

	int b,c;
  	cin>>b>>c;
  	if (b!=0 && c==1){
      	cout<<2<<endl;
      	return 0;
    }
  	int A,B,C,D;
  	if (c%2==1){
      	A=-b-c/2;
      	B=-b+c/2;
      	c--;
      	C=b-c/2;
      	D=b+c/2-1;
    }
  	else{
      	A=b-c/2;
      	B=b+c/2-1;
      	c--;
      	C=-b-c/2;
      	D=-b+c/2;
    }
  	//cout<<A<<" "<<B<<" "<<C<<" "<<D<<" "<<endl;
  	cout<<(B-A+1)+(D-C+1)-max(0ll,min(B,D)-max(A,C)+1)<<endl;
	return 0;
}

#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <bits/stdc++.h>
using namespace std;

#define lson 2*i
#define rson 2*i+1
#define LS l,mid,lson
#define RS mid+1,r,rson
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define W(a) while(a)
#define gcd(a,b) __gcd(a,b)
#define ll long long
#define MAX 1000005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EXP 1e-8
#define lowbit(x) (x&-x)
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}

int main () {
    ll n, k; cin >> n >> k;
    while (k--) {
        if (n % 200) {
            n *= 1000; n += 200;
        } else
            n /= 200;
    }
    cout << n << endl;
    return 0;
}


// 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;
//
//
int ncr(int n, int r){
    if(r > n || r < 0)
        return 0;
    if(n < 3){
        int ans = 1;
        for(int i = 1; i <= r; i++)
            ans *= (n - i + 1);
        for(int i = 1; i <= r; i++)
            ans /= (i );
        return ans;
    }

    return ncr(n/3, r/3) * ncr(n%3, r%3); // Lucas's theorem
}
void solve(){
    int n;
    string str;
    cin>>n>>str;
    string test = "BWR";
    int arr[n];
    for(int i = 0; i < n; i++)
        arr[i] = test.find(str[i]);

    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += ncr(n-1, i)*arr[i];
        ans %= 3;
    }
    if(n%2 == 0){
        ans *= -1;
        ans += 3;
    }
    ans %= 3;
    cout<<test[ans];
}
signed main(){
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0;
}

/*
 ALLAH is Almighty....
*/
#include <bits/stdc++.h>
using namespace std;

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

#define pi                                acos( -1.0 )
#define rep( i, a, n )                    for ( ll i = a; i < n; i++ )
#define per( i, a, n )                    for ( ll i = n - 1; i >= a; i-- )
#define ll                                long long
#define all( x )                          ( x ).begin(), ( x ).end()

typedef tree < ll, null_type, less < ll >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

const ll N = 2e5 + 9;
const ll MOD = 1e9 + 7;

ll n, ans, T;
ll A[ 42 ];
vector < ll > part1, part2;

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

      rep( i, 0, n ) {
            cin >> A[ i ];
      }

      ll num = 1 << ( n / 2 );

      while ( num-- ) {
            ll sum = 0;
            rep( i, 0, 22 ) {
                  if ( ( 1 << i ) & num ) {
                        sum += A[ i ];
                  }
            }
            part1.push_back( sum );
      }

      num = 1 << ( n - n / 2 );

      while ( num-- ) {
            ll sum = 0;
            rep( i, 0, 22 ) {
                  if ( ( 1 << i ) & num ) {
                        sum += A[ i + n / 2 ];
                  }
            }
            part2.push_back( sum );
      }

      part1.push_back( 0 );
      part2.push_back( 0 );
      part2.push_back( 1e18 );
      sort( all( part2 ) );

      rep( i, 0, part1.size() ) {
            ll res = part1[ i ];
            if ( res > T ) {
                  continue;
            }
            ll idx = upper_bound( all( part2 ), T - res ) - part2.begin();
            res += part2[ idx - 1 ];
            ans = max( ans, res );
      }

      cout << ans;
}

int main()
{
      ios_base::sync_with_stdio( false );
      cin.tie( NULL );
      cout.tie( NULL );
      cout << setprecision( 12 );

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

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

      return 0;
}


//2*10^9
//9*10^18
// __int128_t
#include<bits/stdc++.h>
using namespace std;

#define ull unsigned long long int
#define ll long long int

const ll M=1e9+7;

//to handle when remainder is -neg we add + M
//but when rem is +pos that time also we add so use %M
//so it will work for both
ll mod(ll n){
    return (n%M + M)%M;
}
ll modAdd(ll a, ll b){
    return mod(mod(a)+mod(b));
}
ll modMul(ll a, ll b){
    return mod(mod(a)*mod(b));
}
ll modMinus(ll a, ll b){
    return mod(mod(a)-mod(b));
}
ll modpow(ll x, ll n)
{
    if (n == 0)
        return 1%M;
    if (n == 1)
        return x%M;
    ll u = modpow(x,n/2);
    u = modMul(u,u);
    if (n%2)
        u = modMul(u,x);
    return u;
}

ll mod1(ll n, ll mod){
    return (n%mod + mod)%mod;
}
ll modMul1(ll a, ll b, ll mod){
    return mod1(mod1(a,mod)*mod1(b,mod),mod);
}
ll modpow1(ll x, ll n, ll mod)
{
    if (n == 0)
        return 1%mod;
    if (n == 1)
        return x%mod;
    ll u = modpow1(x,n/2,mod);
    u = modMul1(u,u,mod);
    if (n%2)
        u = modMul1(u,x,mod);
    return u;
}

ll gcd(ll a,ll b){
    if(b==0)
        return a;
    return gcd(b,a%b);
}
bool isPrime(ll n){
    int end = sqrt(n);
    for(int i=2;i<=end;i++)
        if(n%i==0)
            return false;
    return true;
}

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

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

    while(t--){
        ll n,m;
        cin>>n>>m;

        ll result = modpow1(10,n,m*m);
        cout<<(result/m)%m<<endl;
    }
    return 0;
}

#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

int V,E;
vector<ll> A;

struct Edge{
  int to;
  ll cost;
  Edge(int to, ll cost):to(to),cost(cost){}
};

template<typename T>
bool visit(const T& G,int v,vector<int>& order,vector<int>& color){
  color[v] = 1;
  for(__typeof((G[v]).begin()) e = G[v].begin();e != G[v].end();e++){
      if(color[e->to] == 2)continue;//このvisit以外のvisitで訪れた
      if(color[e->to] == 1)return false;//このvisitで訪れた
      if(!visit(G,e->to,order,color))return false;
    }
  order.push_back(v);
  color[v] = 2;
  return true;
}

template<typename T>
bool topologicalSort(const T& G,vector<int>& order){
  int SizeG = G.size();
  vector<int> color(SizeG);
  for(int u=0;u<SizeG;u++) if(!color[u] && !visit(G,u,order,color)) return false;
  reverse(order.begin(),order.end());
  return true;
}

int main() {
  cin >> V >> E;
  vector<vector<Edge>> G(V);
  A.resize(V);
  rep(i,V) cin >> A[i];
  int s,t;
  rep(i,E) {
    cin >> s >> t;
    --s, --t;
    G[s].pb((Edge){t,0});
  }
  vector<int> order;
  assert( topologicalSort(G,order) );
  reverse(ALL(order));
  if(0) {
    rep(i,(int)order.size()){
      cout << order[i]+1 << endl;
    }
  }

  ll ans = -LLONG_MAX;
  vector<ll> maxi(V,-1);
  rep(i,(int)order.size()) {
    int v = order[i];
    ll tmp_maxi = -1;
    rep(j,(int) G[v].size()) {
      int t = G[v][j].to;
      tmp_maxi = max(tmp_maxi, maxi[t]);
    }
    if( tmp_maxi != -1LL ) {
      ans = max(ans,tmp_maxi - A[v]);
    }
    tmp_maxi = max(tmp_maxi,A[v]);
    maxi[v] = tmp_maxi;
  }
  cout << ans << endl;

  return 0;
}


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

vector<vector<bool>> masu(10,vector<bool>(10));
int h,w;

int main(){
  char s;
  int ans=0;
  bool a,b,c,d;
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>s;
      if(s=='#'){
        masu.at(i).at(j)=true;
      }else{
        masu.at(i).at(j)=false;
      }
    }
  }
  for(int i=1;i<h-1;i++){
    for(int j=1;j<w-1;j++){
      if(masu.at(i).at(j)){
      a=masu.at(i-1).at(j-1);
      b=masu.at(i-1).at(j);
      c=masu.at(i-1).at(j+1);
      d=masu.at(i).at(j-1);
      if(!a&&!b&&c&&!d)ans+=2;
      if(a&&b&&!c&&!d)ans+=2;
      if(a&&!b&&!c&&d)ans+=2;
      if(!a&&b&&c&&!d)ans+=2;
      if(!a&&!b&&c&&d)ans-=2;
      if(a&&b&&c&&!d)ans+=4;
      if(a&&b&&!c&&d)ans-=2;
      if(!a&&b&&c&&d)ans+=2;
      if(!a&&!b&&!c&&!d)ans+=4;
     // cout<<"("<<i<<","<<j<<") ans="<<ans<<"abcd"<<a<<b<<c<<d<<endl;
      }
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	int i,j,H,W;cin>>H>>W;
	vector<string>s(H);
	for(i=0;i<H;i++){cin>>s[i];}
	s[0][0]='#';
	s[0][W-1]='#';
	s[H-1][0]='#';
	s[H-1][W-1]='#';
	//地面の連結成分を数える
	vector<int>renR(H);
	vector<int>renC(W);
	queue<int>que;
	int rs=0;
	int Rx=0,Cx=0;
	for(i=0;i<H+W;i++){
		if(i<H){
			if(renR[i]!=0){continue;}
			bool aru=0;
			for(j=0;j<W;j++){
				if(s[i][j]=='#'){aru=1;break;}
			}
			if(!aru){Rx++;continue;}
			rs++;
			renR[i]=rs;
			que.push(i);
		}else{
			if(renC[i-H]!=0){continue;}
			bool aru=0;
			for(j=0;j<H;j++){
				if(s[j][i-H]=='#'){aru=1;break;}
			}
			if(!aru){Cx++;continue;}
			rs++;
			renC[i-H]=rs;
			que.push(i);
		}
		while(que.size()){
			if(que.front()<H){
				int t=que.front();
				que.pop();
				for(j=0;j<W;j++){
					if(renC[j]==0&&s[t][j]=='#'){
						renC[j]=renR[t];
						que.push(j+H);
					}
				}
			}else{
				int t=que.front()-H;
				que.pop();
				for(j=0;j<H;j++){
					if(renR[j]==0&&s[j][t]=='#'){
						renR[j]=renC[t];
						que.push(j);
					}
				}
			}
		}
	}
	//for(i=0;i<H;i++){cerr<<renR[i]<<" ";}
	//for(i=0;i<W;i++){cerr<<renC[i]<<" ";}
	//cerr<<endl;
	cout<<rs-1+min(Rx,Cx)<<endl;
}


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

template <int64_t mod>
class modint {
    int64_t x;

public:
    modint(int64_t x = 0) : x((x % mod + mod) % mod) {}
    modint operator-() const { return modint(-x); }
    modint& operator+=(const modint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    modint& operator-=(const modint& a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    modint& operator*=(const modint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    modint operator+(const modint& a) const {
        return modint(*this) += a;
    }
    modint operator-(const modint& a) const {
        return modint(*this) -= a;
    }
    modint operator*(const modint& a) const {
        return modint(*this) *= a;
    }
    modint pow(int64_t t) const {
        if (not t) return 1;
        modint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime mod
    modint inv() const { return pow(mod - 2); }
    modint& operator/=(const modint& a) {
        return (*this) *= a.inv();
    }
    modint operator/(const modint& a) const {
        return modint(*this) /= a;
    }
    friend ostream& operator<<(ostream& os,
                               const modint& m) {
        os << m.x;
        return os;
    }
};

const int64_t mod = 1e9 + 7;
using mint = modint<mod>;

int main() {
    int64_t n, p;
    cin >> n >> p;
    mint ans = mint(p - 1) * mint(p - 2).pow(n - 1);
    cout << ans << endl;
    return 0;
}

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define REV(i, a, b) for (int i = (b) - 1; i >= (a); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001l
#define MOD 1000000007
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

/**
 * x^a mod MODを求める O(log a)
 * @return x^a mod MOD
 */
int mod_pow(int x, int a) {
    int res = 1;
    while(a > 0){
        if(a & 1) res = res * x % MOD;
        x = x * x % MOD;
        a >>= 1;
    }
    return res;
}

/**
 * xのmod Mでの逆元を求める O(log MOD)
 * mod MODの中でのa / b はa * mod_inv(b)をする
 * @return xの逆元(mod MOD)
 */
int mod_inv(int x){
    return mod_pow(x, MOD - 2);
}

class DNowhereP {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int n, p;
        cin >> n >> p;
        int res = mod_pow(p-2, n-1);
        res *= ((p-1) % MOD);
        res %= MOD;
        cout << res << endl;
	}
};

signed main() {
	DNowhereP solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(){
  int N, M, K;
  cin >> N >> K >> M;
  int sum=0;
  int purpose = M*N;
  for(int i=0; i<N-1; i++){
    int x;
    cin >> x;
    sum+=x;
  }
  if(purpose - sum <=K){
    if(purpose-sum >=0){
      cout << purpose-sum << endl;
    }else
    {
      cout << 0 << endl;
    }

  }
  if(purpose-sum>K)cout << -1 << endl;
  return 0;
}

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

static const auto do_fast_io = [] {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return nullptr;
}();

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    long long req = (a * a) + (b * b);
    if (req < c * c) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

int main() {
    int N; cin >> N;
    vector<ll> A(N), B(N), M(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
        B[i] = A[i];
        if(i > 0) B[i] += B[i-1];
        if(i == 0) M[i] = max(0LL, A[i]);
        else M[i] = max(M[i-1], B[i]);
    }

    ll pos = 0, ma = 0;
    for(int i=0; i<N; i++) {
        chmax(ma, pos+M[i]);
        pos += B[i];
    }
    cout << ma << endl;
    return 0;
}

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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int calc(int i) {
    int sum;
    sum=(3+i-2)*(i+3-1)/2;
    return sum;
}

int main()
{
    int k;
    cin >> k;
    vector<int> dp(200020);
    dp[0]=0;
    dp[1]=1;
    for(int i=2;i<=k;i++) {
        ll tot=1,cnt=0;
        const auto &res = prime_factorize(i);
        for(auto x:res) {
            tot*=calc(x.second);
        }
        //cout << i << " " << tot+cnt << endl;
        dp[i]=dp[i-1]+tot+cnt;
    }
    cout << dp[k] << endl;
    return 0;
}


#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i=1; i < (int)(n); i++)
#define rrep(i, n) for (int i=((int)(n)-1); i>=0; i--)
#define rreps(i, n) for (int i=((int)(n)-1); i>0; i--)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;
using p = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int N, X;
  scanf("%d%d", &N, &X);
  vector<int> a(N);
  rep (i, N) cin >> a[i];
  rep (i, N) {
    if (a[i] == X) continue;
    cout << a[i] << " ";
  }
  cout << endl;
  return 0;
}

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

int main()
{

  //  ll t;
  //  cin>>t;
  //  while (t--)
  //  {
       ll n,x;
       cin>>n>>x;
       ll a[n];
       for (int i = 0; i < n; i++)
       {
         cin>>a[i];
       }
          for (int i = 0; i < n; i++)
       {
         if(a[i]!=x)
         cout<<a[i]<<" ";
       }
       cout<<endl;

   //}

}


#include<iostream>
using namespace std;
int main(){

long long int i,j,k,n;
cin>>n;
long long int a[n],b[n];
long long int ma,mi;
cin>>a[0];
ma=a[0];
for(i=1;i<n;i++){

    cin>>a[i];
    if(a[i]>ma){
        ma=a[i];
    }
}
cin>>b[0];
mi=b[0];
for(i=1;i<n;i++){

    cin>>b[i];
    if(b[i]<mi){
      mi=b[i];
    }
}
if(ma>mi){
    cout<<"0";
}
else{

    cout<<mi-ma+1;
}
}

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

const int N=1100;
int pre[N];

int main()
{
	int n,x=1;
	cin>>n;
	vector<int> a(n+1);
	vector<int> b(n+1);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		pre[a[i]]++;
	}
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
		pre[b[i]+1]--;
	}
	int ans=0;

	for(int i=1;i<1100;i++)
	{
		pre[i] += pre[i-1];
		if(pre[i] == n)	ans++;
	}
	cout<<ans<<endl;

	return 0;
}


//#include <atcoder/all>
//using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(v) v.begin(), v.end()
#define bit(n) (1LL<<(n))
#define FIX(d) fixed << setprecision(d)
using P = pair<int, int>;
using LP = pair<ll, ll>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const ll LINF = (1LL<<60);

unsigned int xor128(){
  static unsigned int x=123456789,y=362436069,z=521288629,w=88675123;
  unsigned int t = (x^(x<<11));
  x=y; y=z; z=w;
  return( w=(w^(w>>19))^(t^(t>>8)) );
}

int n;
int cx[200], cy[200], r[200];
int a[200], b[200], c[200], d[200];
//int ma[200], mb[200], mc[200], md[200];

ll score(){
  double sc = 0.0;
  REP(i,n){
    int area = (c[i]-a[i]) * (d[i]-b[i]);
    double tmp = 1.0 - (double)min(area,r[i]) / max(area,r[i]);
    sc += 1.0 - tmp*tmp;
  }
  sc *= 1e9;
  sc /= n;
  return (ll)round(sc);
}

void init(){
  REP(i,n){
    a[i] = cx[i];
    b[i] = cy[i];
    c[i] = cx[i]+1;
    d[i] = cy[i]+1;
  }
}

void add(int ind, int xy){
  int area = (c[ind]-a[ind]) * (d[ind]-b[ind]);
  bool minus = false, plus = false;
  if(xy&1){
    REP(i,n){
      if(i==ind) continue;
      if(max(a[i],a[ind]-1)<min(c[i],c[ind]) && max(b[i],b[ind])<min(d[i],d[ind])){
        minus = true;
      }
      if(max(a[i],a[ind])<min(c[i],c[ind]+1) && max(b[i],b[ind])<min(d[i],d[ind])){
        plus = true;
      }
    }

    if(abs(area-r[ind])>abs(area+d[ind]-b[ind]-r[ind])){
      if(c[ind]<10000 && !plus && (xy&2)) c[ind]++;
      else if(a[ind]>0 && !minus) a[ind]--;
    }
  }else{
    REP(i,n){
      if(i==ind) continue;
      if(max(a[i],a[ind])<min(c[i],c[ind]) && max(b[i],b[ind]-1)<min(d[i],d[ind])){
        minus = true;
      }
      if(max(a[i],a[ind])<min(c[i],c[ind]) && max(b[i],b[ind])<min(d[i],d[ind]+1)){
        plus = true;
       }
    }

    if(abs(area-r[ind])>abs(area+c[ind]-a[ind]-r[ind])){
      if(d[ind]<10000 && !plus && (xy&2)) d[ind]++;
      else if(b[ind]>0 && !minus) b[ind]--;
    }
  }
}

void les(int ind, int xy){
  if(xy&1){
    if(c[ind]-a[ind]==1) return;
    if(a[ind]==cx[ind]) c[ind]--;
    else if(c[ind]==cx[ind]+1) a[ind]++;
    else if(xy&2) a[ind]++;
    else c[ind]--;
  }else{
    if(d[ind]-b[ind]==1) return;
    if(b[ind]==cy[ind]) d[ind]--;
    else if(d[ind]==cy[ind]+1) b[ind]++;
    else if(xy&2) b[ind]++;
    else d[ind]--;
  }
}

const ll LIMIT = 490 * CLOCKS_PER_SEC / 100;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  REP(i,n) cin >> cx[i] >> cy[i] >> r[i];

  init();
  //ll mx = score();
  //cout << mx << endl;
  ll ti = clock();
  while(true){
    ll now = clock();
    ll sub = now - ti;
    if(sub > LIMIT) break;
    REP(loop, 300){
      //int ind = xor128() % n;
      //int xy = xor128() % 2;
      add(xor128()%n, (xor128()%4)+1);
      if((loop+1)%30==0) les(xor128()%n, (xor128()%4)+1);
    }
    //cout << mx << endl;
  }

  REP(i,n) cout << a[i] << " " << b[i] << " " << c[i] << " " << d[i] << '\n';
  return 0;
}

#include <bits/stdc++.h>

using namespace std;
#define len(a) (int) a.size()
#define long long long

int nxt() {
    int a;
    scanf("%d", &a);
    return a;
}

const int N = 55;
long dp[N][2];
long a[N];
long k[N];
long s;
int can[N];
int n;

int main() {
    n = nxt();
    scanf("%lld", &s);

    for (int i = 0; i < n; ++i) {
        scanf("%lld", &a[i]);
    }

    for (int i = 0; i + 1 < n; ++i) {
        can[i] = a[i + 1] / a[i] - 1;
    }

    for (int i = n - 1; i >= 0; --i) {
        k[i] = s / a[i];
        s %= a[i];
    }

    dp[0][0] = 1;

    for (int i = 0; i + 1 < n; ++i) {
        for (int j = 0; j < 2; ++j) {
            if (dp[i][j] == 0) continue;
            long cur = k[i];
            if (j) {
                cur++;
            }
            if (cur == can[i] + 1) {
                dp[i + 1][1] += dp[i][j];
            } else {
                dp[i + 1][0] += dp[i][j];
                if (cur != 0) {
                    dp[i + 1][1] += dp[i][j];
                }
            }
        }
    }

    printf("%lld", dp[n - 1][0] + dp[n - 1][1]);

    return 0;
}


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

//namespace
using namespace std;

//typedef
//typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<long long> vll;

//define
#define i(X) cin>>X;
#define ol(X) cout<<X<<endl;
#define os(X) cout<<X<<" ";
#define inpv(a,n) vector<ll> a(n); for(ll i=0;i<n;i++){cin>>a[i];}
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define line cout<<"\n";
#define pbp(a,b) push_back(make_pair(a,b));
#define iniv(A,n,p) vector<ll> A(n,p);
#define vst(A) sort(A.begin(),A.end());
#define rvst(A) sort(A.rbegin(),A.rend());
#define forin(i,a,b) for(ll i=a;i<=b;i++)
#define forde(i,a,b) for(ll i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
long long MOD=(long long)(1e9+7);
ll mod=MOD;

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen ("input.txt" , "r" , stdin);
    //     // freopen ("OUTPUT.txt" , "w" , stdout);
    // #endif
    fio;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll k,n,m;
        cin>>k>>n>>m;
        vector<ll> a(k);
        vector<ll> b(k);
        vector<pair<ld,ll> > z(k);
        ll cur=0;
        forin(i,0,k-1)
        {
            cin>>a[i];
            b[i]=(a[i]*m)/n;
            cur+=b[i];
            ld f=(b[i]*n)-(a[i]*m);
            z.pb({f,i});
        }
        vst(z);
        ll i=0;
        while(cur<m)
        {
            //cout<<z[i].second<<" ";
            b[z[i].second]++;
            i++;
            cur++;
        }
        forin(i,0,k-1) cout<<b[i]<<" ";
        cout<<endl;
    }
}

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()

//ll の最大値　2147483647≒10^9
//long longの最大値　9,223,372,036,854,775,807≒10^18

ll gcd(ll a, ll b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}
ll digit(ll x){
    ll d=0;
    while(x){
        d++;
        x/=10;
    }
    return d;
}

int main(){
    cout<<fixed<<setprecision(20);
    double N;
    cin>>N;
    double x,y,x_,y_;
    cin>>x>>y>>x_>>y_;
    double cx=(x+x_)/2;
    double cy=(y+y_)/2;
    //cout<<cx<<' '<<cy<<endl;
    x-=cx;
    y-=cy;
    double r=sqrt(x*x+y*y);
    //cout<<r<<endl;
    //cout<<x<<' '<<y<<endl;
    double pi=3.141592653589793;
    double d=2*pi/N;
    double cos_=cos(d);
    double sin_=sin(d);
    double cos=x/r;
    double sin=y/r;
    cout<<r*(cos*cos_-sin*sin_)+cx<<' '<<r*(sin*cos_+cos*sin_)+cy<<endl;
}


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

using ll = int64_t;

using vl = vector<ll>;

#define ice(i, a, b) for (int (i) = (a); (i) < (b); ++(i))

const ll INF = 1e18;

ll A, B, C, A2, B2, C2;
vl a(200000), t(200000);

void fix(ll& X, ll& Y, ll& Z, int idx) {
    if (t[idx] == 1) {
        X = a[idx], Y = -INF, Z = INF;
    }
    else if (t[idx] == 2) {
        X = 0, Y = a[idx], Z = INF;
    }
    else if (t[idx] == 3) {
        X = 0, Y = -INF, Z = a[idx];
    }
}

void solve() {
    int n; cin >> n;
    ice(i, 0, n) {
        cin >> a[i] >> t[i];
    }
    fix(A, B, C, 0);
    ice(i, 1, n) {
        fix(A2, B2, C2, i);
        ll X = A2 + A, Y = max(B2, min(A2 + C, A2 + B)), Z = min(C2, max(B2, A2 + C));
        A = X, B = Y, C = Z;
    }
    int q; cin >> q;
    ice(i, 0, q) {
        int x; cin >> x;
        cout << min(C, max(B, x + A)) << '\n';
    }
}

int main() {
    int tc = 1;
    ice(i, 0, tc) {
        solve();
    }
}

#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

long long N, A[1 << 18], T[1 << 18];
long long Q, X[1 << 18];

int main() {
	// Step #1. 入力
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i] >> T[i];
	cin >> Q;
	for (int i = 0; i < Q; i++) cin >> X[i];

	// Step #2. 上限と下限を求める
	long long cl = -(1LL << 60), cr = (1LL << 60), sum = 0;
	for (int i = 0; i < N; i++) {
		if (T[i] == 1) { cl += A[i]; cr += A[i]; sum += A[i]; }
		if (T[i] == 2) { cl = max(cl, A[i]); cr = max(cr, A[i]); }
		if (T[i] == 3) { cl = min(cl, A[i]); cr = min(cr, A[i]); }
	}

	// Step #3. クエリに答える
	for (int i = 0; i < Q; i++) {
		long long val = 0;
		if (cl - sum <= X[i] && X[i] <= cr - sum) {
			val = X[i] + sum;
		}
		else if (X[i] <= cl - sum) {
			val = cl;
		}
		else if (cr - sum <= X[i]) {
			val = cr;
		}
		cout << val << endl;
	}
	return 0;
}


#include <bits/stdc++.h>
// #include <atcoder/modint>
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define INF 2000000000000000000
#define ll long long
#define ld long double
#define pll pair<ll, ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

//==================param==========
ll depth = 10;
//=================================

ll si, sj;
vector<vector<ll>> board(50, vector<ll>(50));
vector<vector<ll>> point(50, vector<ll>(50));
map<ll, bool> already;
vector<char> way_char = {'R', 'D', 'L', 'U'};
vector<vector<ll>> ways = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
stack<ll> max_ans;
stack<ll> ans;
ll max_point = 0;
ll now_point = 0;
clock_t start;

void get_input() {
  cin >> si >> sj;
  for (ll i = 0; i < 50; ++i) {
    for (ll j = 0; j < 50; ++j) {
      cin >> board.at(i).at(j);
    }
  }
  for (ll i = 0; i < 50; ++i) {
    for (ll j = 0; j < 50; ++j) {
      cin >> point.at(i).at(j);
    }
  }
  already[board.at(si).at(sj)] = true;
}

bool can_move(ll way) {
  ll nh = si + ways.at(way).at(0), nw = sj + ways.at(way).at(1);
  if (nh < 0 || nw < 0 || nh >= 50 || nw >= 50) {
    return false;
  }
  if (already[board.at(nh).at(nw)]) {
    return false;
  }
  return true;
}

void make_move(ll way) {
  si += ways.at(way).at(0), sj += ways.at(way).at(1);
  already[board.at(si).at(sj)] = true;
  ans.push(way);
  now_point += point.at(si).at(sj);
  if (now_point > max_point) {
    max_ans = ans;
    max_point = now_point;
  }
}
void rev_move() {
  ll way = ans.top();
  ans.pop();
  now_point -= point.at(si).at(sj);
  already[board.at(si).at(sj)] = false;
  si -= ways.at(way).at(0), sj -= ways.at(way).at(1);
}

ll cnt = 0;
bool fin = false;
void dfs() {
  if (fin) {
    return;
  }
  cnt += 1;
  if (cnt % 100 == 0) {
    clock_t end = clock();
    ld time = (ld)(end - start) / CLOCKS_PER_SEC * 1000.0;
    if (time > 1.9) {
      fin = true;
      return;
    }
  }
  for (ll i = 0; i < 4; ++i) {
    if (can_move(i)) {
      make_move(i);
      dfs();
      rev_move();
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  start = clock();
  get_input();
  dfs();
  string s_ans = "";
  while (!max_ans.empty()) {
    s_ans += way_char.at(max_ans.top());
    max_ans.pop();
  }
  reverse(rng(s_ans));
  cout << s_ans << "\n";
}

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

const int n=50;
ll a[n][n],b[n][n];

ll dr(char c) {
  if(c=='U') return 0;
  else if(c=='R') return 1;
  else if(c=='D') return 2;
  return 3;
}
priority_queue<PP,vector<PP>,greater<PP> > que[2500];

void Main() {
  srand((unsigned)time(NULL));
  ll sx,sy;
  cin >> sx >> sy;
  rep(i,n)rep(j,n) R a[i][j];
  rep(i,n)rep(j,n) R b[i][j];
  ll e[4]={0,1,2,3};
  string w="URDL";
  que[0].push(PP(0,PS("","")));
  ll M=-1;
  string ans="";
  rep(l,2000) {
    while(!que[l].empty()) {
      PP p=que[l].top();que[l].pop();
      string t=p.S.F,r=p.S.S;
      vector<ll> u(2500,0);
      ll x=sx,y=sy,sum=0;
      u[a[x][y]]=1;
      sum+=b[x][y];
      rep(i,t.size()) {
        ll k=dr(t[i]);
        x+=dx[k],y+=dy[k];
        u[a[x][y]]=1;
        sum+=b[x][y];
      }

      rep(jj,r.size()+1) {
        rep(o,10) {
          string rr=r.substr(0,jj);
          vector<ll> uu=u;
          ll ss=sum,x1=x,y1=y;
          REP(kk,jj,20) {
            random_shuffle(e,e+4);
            ll f=0;
            rep(j,4) {
              ll x2=x1+dx[e[j]],y2=y1+dy[e[j]];
              if(check(n,n,x2,y2)&&!uu[a[x2][y2]]&&a[x1][y1]!=a[x2][y2]) {
                uu[a[x2][y2]]=1;
                x1=x2,y1=y2;
                f=1;
                rr+=w[e[j]];
                ss+=b[x1][x2];
                break;
              }
            }
            if(!f) break;
          }
          if(ss>M) {
            M=ss;
            ans=t+rr;
          }
          if(rr.size()==0) break;
          string tt=t;
          tt+=rr[0];
          rr=rr.substr(1);
          que[l+1].push(PP(ss,PS(tt,rr)));
          while(que[l+1].size()>=10) que[l+1].pop();
        }
        if(jj>=t.size()) break;
        ll k=dr(r[jj]);
        x+=dx[k],y+=dy[k];
        u[a[x][y]]=1;
        sum+=b[x][y];
      }
    }
  }
  pr(ans);
}

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


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(...) DBG2::print(#__VA_ARGS__, __LINE__, __VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<llong> VL;
typedef vector<VL> VVL;

const llong INF = 3e18;

int N, M;
VI H, W;
int nearest_teacher_height(int h, bool trace = false) {
   int idx = lower_bound(W.begin(), W.end(), h) - W.begin();
   if (trace)
      DEBUG(idx);
   if (idx == SZ(W)) {
      --idx;
      assert(idx >= 0);
      if (trace)
         DEBUG(1);
      return W[idx];
   }
   if (idx == 0) {
      if (trace)
         DEBUG(2);
      return W[idx];
   }
   if (trace)
      DEBUG(3, W[idx-1], W[idx]);
   if (abs(W[idx-1] - h) < abs(W[idx] - h))
      return W[idx-1];
   else
      return W[idx];
}

llong memo[2][200002];
llong go(int n, bool t) {
   if (n >= SZ(H))
      return 0;
   llong& res = memo[t][n];
   if (res < 0) {
      bool trace = n == 4 && !t;
      // match n-th student with next student
      res = INF;
      if (n+1 < N) {
         llong cur = go(n+2, t) + llabs(H[n+1] - H[n]);
         if (trace)
            DEBUG("1", cur);
         res = min(res, cur);
      }

      // match n-th student to nearest height of teacher
      if (!t) {
         int w = nearest_teacher_height(H[n]);
         if (trace)
            DEBUG(H[n], w);
         llong cur = go(n+1, true) + llabs(H[n] - w);
         if (trace)
            DEBUG("2", cur);
         res = min(res, cur);
      }
   }
   return res;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false);
   cin.tie(nullptr);

   cin >> N >> M;
   H = VI(N);
   REP(i, N)
      cin >> H[i];

   W = VI(M);
   REP(j, M)
      cin >> W[j];

   sort(H.begin(), H.end());
   sort(W.begin(), W.end());

   DEBUG(H);
   DEBUG(W);

// int t = nearest_teacher_height(7, true);
// DEBUG(t);

   memset(memo, -1, sizeof(memo));
   llong res = go(0, 0);
   cout << res << endl;

   return 0;
}


#pragma GCC optimize("O3")

#include "bits/stdc++.h"

#define sz(x) (int)(x).size()
using namespace std;

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

    int n;
    cin >> n;
    cout << (1<<n)-1 << "\n";
    for(int i=1; i<=(1<<n)-1; i++) {
        for(int j=0; j<(1<<n); j++)
            cout << (__builtin_popcount(i & (j+1)) % 2 ? 'A' : 'B');
        cout << "\n";
    }

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define re register
#define INF 2147483647
using namespace std;

inline int read()
{
	int f=1,x=0;char s=getchar();
	while(s<'0'||s>'9')
	{
		if(s=='-') f=-1;
		s=getchar();
	}
	while(s>='0'&&s<='9')
	{
		x=x*10+s-48;
		s=getchar();
	}
	return f*x;
}

struct node
{
	int op;
	int x,y;
};

bool cmp(node a,node b)
{
	if(a.x!=b.x) return a.x<b.x;
	else return a.op<b.op;
}

const int N=2e5+5;
vector<node> v;
vector<int> v1[N],v2[N];
const int mxv=2e5+5;
int t[mxv+5];

inline int lowbit(int x)
{
	return x&(-x);
}

inline void updata(int x,int v)
{
	for(;x<=mxv;x+=lowbit(x))
		t[x]+=v;
}

inline int ask(int x)
{
	int ans=0;
	for(;x;x-=lowbit(x))
		ans+=t[x];
	return ans;
}

int main()
{
	int n=read(),m=read();
	int k=read();
	for(int i=1;i<=k;i++)
	{
		int x=read(),y=read();
		v1[x].push_back(y-1);
		v2[y].push_back(x-1);
	}
	for(int i=1;i<=n;i++) v1[i].push_back(m);
	for(int i=1;i<=m;i++) v2[i].push_back(n);
	for(int i=1;i<=n;i++) sort(v1[i].begin(),v1[i].end());
	for(int i=1;i<=m;i++) sort(v2[i].begin(),v2[i].end());
	ll ans=v1[1][0]+v2[1][0]-1;
	//cout<<ans<<endl;
	for(int i=2;i<=n;i++)
	{
		if(i>v2[1][0]) break;
		//cout<<v1[i][0]<<endl;
		ans+=v1[i][0]-1;
		//cout<<ans<<endl;
	}
//	cout<<ans<<endl;
	for(int i=2;i<=n;i++) v.push_back((node){1,i,v1[i][0]});
	for(int i=2;i<=m;i++) v.push_back((node){2,v2[i][0],i});
	sort(v.begin(),v.end(),cmp);
	//for(int i=0;i<v.size();i++) printf("%d %d %d\n",v[i].op,v[i].x,v[i].y);
	for(int i=0;i<v.size();i++)
	{//printf("%d %d %d\n",v[i].op,v[i].x,v[i].y);
		if(v[i].op==1)
		{
			if(v[i].x>v2[1][0]) continue;
			//cout<<v[i].y+1<<endl;
			updata(v[i].y+1,1);
		}
		else
		{
			//if(v[i].x==0) continue;
			if(v[i].y>v1[1][0]) continue;
			//cout<<ask(v[i].y)-ask(mxv)<<endl;
			ans+=v[i].x-1+ask(v[i].y)-ask(mxv);
		}
		//cout<<ans<<endl;
	}
	printf("%lld\n",ans);
	return 0;
}

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

template<typename T>
struct SegmentTree{
  using OP = function<T(T,T)>;

  int n, defn;
  vector<T> node;
  T t;
  OP op;

  SegmentTree(int n_, T t, OP op) : t(t),op(op){
    n = 1;
    defn = n_;
    while(n < n_) n<<=1;
    node.assign(2*n,t);
  }

  void init(int n_){
    n = 1;
    defn = n_;
    while(n < n_) n<<=1;
    node.assign(2*n,t);
  }

  void set(int k,T x){
    assert(0 <= k && k < n);
    node[k+n] = x;
  }

  void build(){
    for(int k = n - 1; k > 0; k--){
      node[k] = op(node[2*k],node[2*k+1]);
    }
  }

  void change(int k, T x){
    assert(0 <= k && k < n);
    k += n;
    node[k] = x;
    while(k >>= 1){
      node[k] = op(node[2*k],node[2*k+1]);
    }
  }

  void change(int l, int r, T x){
    for(int k = l; k < r; k++) change(k,x);
  }

  T at(int k){
    assert(0 <= k && k < n);
    return node[k+n];
  }

  void add(int k, T a){
    assert(0 <= k && k < n);
    T x = at(k)+a;
    change(k,x);
  }

  T query(int a, int b){
    assert(0 <= a && b <= n);
    if(a==0 && b==defn) return all_query();
    T L = t, R = t;
    for(a += n, b += n; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = op(L, node[a++]);
      if(b & 1) R = op(node[--b], R);
    }
    return op(L, R);
  }

  T all_query() { return node[1]; }

  template<typename C>
  int max_right(int l, C &check){
    if(l == defn) return defn;
    l += n;
    T tm = t;
    do{
      while(l%2 == 0) l >>= 1;
      if(!check(op(tm, node[l]))){
        while(l < n){
          l *= 2;
          if(check(op(tm, node[l]))){
            tm = op(tm, node[l]);
            l++;
          }
        }
        return l - n;
      }
      tm = op(tm, node[l]);
      l++;
    }while((l&-l) != l);
    return defn;
  }

  template<typename C>
  int max_left(int r, C &check){
    if(r == 0) return 0;
    r += n;
    T tm = t;
    do{
      r--;
      while(r>1 && (r%2)) r >>= 1;
      if(!check(op(node[r], tm))){
        while(r < n){
          r = 2*r + 1;
          if(check(op(node[r], tm))){
            tm = op(node[r], tm);
            r--;
          }
        }
        return r + 1 - n;
      }
      tm = op(node[r], tm);
    }while((r&-r) != r);
    return 0;
  }
};

int main(){
  int H, W, M; cin >> H >> W >> M;
  vector<int> height(W, H), width(H, W);
  vector<vector<int>> ps(H);

  rep(i, M){
    int x, y; cin >> x >> y; x--; y--;
    chmin(height[y], x); chmin(width[x], y);
    ps[x].emplace_back(y);
  }

  ll ans = 0;

  SegmentTree<int> seg(
    W,
    0,
    [](int a, int b) { return a+b; }
  );

  rep(i, W){
    if(i < width[0]) ans += height[i];
    else seg.set(i, 1);
  }
  seg.build();

  rep(i, height[0]){
    for(auto&&y : ps[i]){
      seg.change(y, 1);
    }
    ans += seg.query(0, width[i]);
  }

  cout << ans << endl;
}


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

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   200005
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

int main()
{
    db n;
    cin>>n;
    ll s = 1.0,d = 1;
    ll v = min(11ll,(ll)(n-12));
    for(ll i=n-1,j=1;j<=v;i=i-1.0,j=j+1.0)
    {
        s = s * i / j;
        //s /= db(j);
        //pf("%.20f\n",s);
        //cout<<(ll)s<<" "<<(n-i)<<endl;
    }
    cout<<(ll)s<<endl;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define endl "\n"
#define fill(A,x) memset(A,x,sizeof A);

void solve()
{
  int n;
    cin>>n;
	vi pos(n+5),ar(n+5);
	vi ans;
    for(int i=1;i<=n;i++)
    {
        cin>>ar[i];
        pos[ar[i]]=i;
    }
    if(n==2)
    {
        if(pos[1]==1)cout<<0<<endl;
        else {cout<<1<<endl;cout<<1;}
        cout<<endl;
        return;
    }

    for(int i=n;i>0;i--)
    {
        if(i>n||pos[i]==i)
        continue;
        int c=pos[i];
        if(c%2!=(ans.size())%2)
        {
            while(pos[i]!=i)
            {
                int x=ar[pos[i]+1];
                ar[pos[i]]=x;ar[pos[i]+1]=i;
                ans.pb(pos[i]);
                pos[i]++;pos[x]--;
            }
        }
        else
        {
            if(c%2==0)
            {
                ans.pb(1);
                ans.pb(2);
                ans.pb(1);
                pos[ar[1]]+=2;pos[ar[3]]-=2;
                swap(ar[1],ar[3]);
                i++;
            }
            else
            {
                ans.pb(2);
                ans.pb(1);
                ans.pb(2);
                pos[ar[1]]+=2;pos[ar[3]]-=2;
                swap(ar[1],ar[3]);
                i++;
                i++;
            }
        }
    }

    int x=ans.size();
    cout<<x<<endl;

    for(auto it:ans)cout<<it<<" ";
    cout<<endl;
}

signed main()
{
    boost
    int test=0,t;
    cin >> t ;
    //t=1;
   while(test++ <t){
	//   cout<<"Case #"<<test<<": ";
	   solve();}

}


#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar('-');
  }
  while(s--){
    my_putchar(f[s]+'0');
  }
}
int N;
double L[2000+10];
double R[2000+10];
int intersect(int i, int j){
  if(L[j] <=  L[i]  &&   L[i] <= R[j] ){
    return 1;
  }
  if(L[j] <=  R[i]  &&   R[i] <= R[j] ){
    return 1;
  }
  if(L[i] <=  L[j]  &&   L[j] <= R[i] ){
    return 1;
  }
  if(L[i] <=  R[j]  &&   R[j] <= R[i] ){
    return 1;
  }
  return 0;
}
int main(){
  int i;
  rd(N);
  for(i=(0);i<(N);i++){
    int t;
    int l;
    int r;
    rd(t);
    rd(l);
    rd(r);
    if(t == 1){
      L[i] = l;
      R[i] = r;
    }
    else if( t == 2){
      L[i] = l;
      R[i] = r-0.5;
    }
    else if( t == 3){
      L[i] = l+0.5;
      R[i] = r;
    }
    else if( t == 4){
      L[i] = l+0.5;
      R[i] = r-0.5;
    }
    if(L[i] > R[i]){
      L[i] = R[i] = -1;
    }
  }
  int ans = 0;
  for(i=(0);i<(N);i++){
    int j;
    for(j=(i+1);j<(N);j++){
      ans += intersect(i, j);
    }
  }
  wt_L(ans);
  wt_L('\n');
  return 0;
}
// cLay version 20210405-1

// --- original code ---
// //no-unlocked
// int N;
// double L[2d3+10], R[];
//
// int intersect(int i, int j){
//     if(L[j] <=  L[i] <= R[j] ) return 1;
//     if(L[j] <=  R[i] <= R[j] ) return 1;
//     if(L[i] <=  L[j] <= R[i] ) return 1;
//     if(L[i] <=  R[j] <= R[i] ) return 1;
//     return 0;
// }
// {
//     rd(N);
//     rep(i, N){
//         int t, l, r;
//         rd(t, l, r);
//         if(t == 1){
//             L[i] = l;
//             R[i] = r;
//         }else if( t == 2){
//             L[i] = l;
//             R[i] = r-0.5;
//         }else if( t == 3){
//             L[i] = l+0.5;
//             R[i] = r;
//         }else if( t == 4){
//             L[i] = l+0.5;
//             R[i] = r-0.5;
//         }
//         if(L[i] > R[i]) L[i] = R[i] = -1;
//     }
//     int ans = 0;
//     rep(i, N){
//         rep(j, i+1, N){
//             ans += intersect(i, j);
//         }
//     }
//     wt(ans);
// }

#include <iostream>
#include <vector>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//cout << std::fixed << std::setprecision(15) << res << endl;

int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int N;
  cin >> N;
  struct edge {
    int t;
    int l;
    int r;
    edge(int t, int l, int r) : t(t), l(l), r(r) {}
    edge() : t(0),l(0),r(0) {}
  };
  vector<edge> kukan(N);

  rep(i, N) {
    int t,l,r;
    cin >> t >> l >> r;
    kukan[i] = edge(t,l,r);
  }
  ll res = 0;
  rep (i, N) {
    for (int j = i+1; j < N; j++) {
      edge e1 = kukan[i];
      edge e2 = kukan[j];
      if (e2.l < e1.l) {
        edge tmp = e2;
        e2 = e1;
        e1 = tmp;
      } else if (e2.l == e1.l && ((e1.t == 2 || e1.t == 3) && (e2.t == 1 || e2.t == 2))) {
        edge tmp = e2;
        e2 = e1;
        e1 = tmp;
      }

      if (e2.l < e1.r) {
        res++;
      } else if (e2.l == e1.r) {
        if ((e1.t == 1 || e1.t == 3) && (e2.t == 1 || e2.t == 2)) {
          res++;
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define reps(i,n) for (int i = 1; i <= (n); ++i)
#define rrep(i,n) for (int i = (n) - 1; i >= 0; --i)
#define rreps(i,n) for (int i = (n); i > 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define PB push_back
#define MP make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
using namespace std;
using ll = long long;
using P = pair<ll,int>;
using PP = pair<int,pair<int,int>>;

const int N = 1e5;
const ll INF = 1e18;

int n, m, x, y, a, b, t, k;

vector<PP> g[N];
ll d[N];

int main() {
    cin >> n >> m >> x >> y; --x; --y;
    rep(i, m) {
        cin >> a >> b >> t >> k; --a; --b;
        g[a].PB(MP(b, MP(t, k)));
        g[b].PB(MP(a, MP(t, k)));
    }

    rep(i, n) d[i] = INF;
    d[x] = 0;
    priority_queue<P, vector<P>, greater<P>> q;
    q.push(MP(d[x], x));
    while (q.size()) {
        P p = q.top(); q.pop();
        int pos = p.second;
        if (p.first > d[pos]) continue;
        rep(i, SZ(g[pos])) {
            int to = g[pos][i].first;
            int ti = g[pos][i].second.first;
            int ki = g[pos][i].second.second;
            ll tl = (d[pos] + ki - 1) / ki * ki;
            ll ta = tl + ti;
            if (ta >= d[to]) continue;
            d[to] = ta;
            q.push(MP(d[to], to));
        }
    }
    rep(i, n) {
        // printf("d[%d] = %lld\n", i, d[i]);
    }
    if (d[y] == INF) cout << -1 << endl;
    else cout << d[y] << endl;
    return 0;
}

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

int main(){
    long n;
    cin >> n;
    long c[n][n], k[n] = {}, g[n] = {}, mnx = 0, mny = 0;
    bool b = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++) cin >> c[i][j];
    }
    for(int i = 1; i < n; i++){
        k[i] = c[i][0] - c[0][0];
        mnx = min(mnx, k[i]);
    }
    for(int i = 1; i < n; i++){
        for(int j = 1; j < n; j++){
            if(k[j] != c[j][i] - c[0][i]) b = 0;
        }
    }
    for(int i = 1; i < n; i++){
        g[i] = c[0][i] - c[0][0];
        mny = min(mny, g[i]);
    }
    for(int i = 1; i < n; i++){
        for(int j = 1; j < n; j++){
            if(g[j] != c[i][j] - c[i][0]) b = 0;
        }
    }
    if(b == 0) cout << "No" << endl;
    else{
        for(int i = 0; i < n; i++){
            k[i] -= mnx;
            g[i] -= mny;
        }
        long f = c[0][0] - k[0] - g[0];
        if(f < 0) cout << "No" << endl;
        else{
            cout << "Yes" << endl;
            for(int i = 0; i < n; i++){
                cout << k[i] + f;
                if(i == n - 1) cout << endl;
                else cout << " ";
            }
            for(int i = 0; i < n; i++){
                cout << g[i];
                if(i == n - 1) cout << endl;
                else cout << " ";
            }
        }
    }
}


#include <iostream>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
int main() {
  ll n,p,now,ans=1;
  cin>>n>>p;
  now=p-2;
  n--;
  while(n){
    if(n%2) {
      ans*=now;
      ans%=MOD;
    }
    now*=now;
    now%=MOD;
    n/=2;
  }
  ans*=(p-1);
  ans%=MOD;
  cout<<ans;
}

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("a.out","w",stdout); // console output is better (in most cases)
#else
    // add i/o method of specific testing system
#endif
    int a, b;
    cin >> a >> b;
    vector<int> seq(a + b);
    int sum = 0;
    int mn = min(a, b);
    int mx = max(a, b);
    for(int i = 0; i < mx; i++)
    {
        seq[i] = i + 1;
        sum += seq[i];
    }
    for(int i = mx; i < a + b; i++)
    {
        seq[i] = -1 * (i - a + 1);
        sum += seq[i];
    }
    seq[a + b - 1] -= sum;
    for(int i : seq)
    {
        if(a > b)
        {
            cout << i << " ";
        }
        else
        {
            cout << -i << " ";

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


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using ll=long long;
using ld=long double;
using namespace std;
int main(){
  ll n;cin>>n;ll res=0;
  ll m=n+1;ll ns=0;
  for(ll i=1;;i++){
    ns+=i;
    if(ns>m)break;
    res++;

  }
  cout<<n+1-res<<endl;
}

#include <bits/stdc++.h>
using namespace std;
#define fo(a,b) for(int64_t a=0;a<b;a++)
#define sor(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define ll int64_t
#define mod 1000000007
#define vl vector<int64_t>
int main(){
ll n;
  cin>>n;
  ll ub=n+2;
  ll lb=-1;
  while(ub-lb>1){
  ll mid=(lb+ub)/2;
    if(mid>=2*mod){ub=mid;}
    else{if(mid*(mid-1)<=(2*n)+2){lb=mid;}
    else{ub=mid;}}
  }

 cout<<(n+1)-lb+1<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
#define lin(x) ll x; cin>>x;
#define stin(x) string x; cin>>x;
#define yn(x)  if(x) {  cout<<"Yes"<<endl;   }    else {    cout<<"No"<<endl;   }
#define YN(x)  if(x) {  cout<<"YES"<<endl;   }    else {    cout<<"NO"<<endl;   }
#define co(x) cout<<x<<endl;
using ll=long long;
using ld=long double;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll mod=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template <typename T> inline bool chmax(T &a, T b) {
    return ((a < b) ? (a = b, true) : (false));
}
template <typename T> inline bool chmin(T &a, T b) {
    return ((a > b) ? (a = b, true) : (false));
}
ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

ll fact(ll n) {
ll a=1;
rep(i,n) {
a=a*(n-i);
}
return a;
}

ll pow(ll a, ll b) {
ll x=1;
rep(i,b) {
x=x*a;
}
return x;
}

int main() {
lin(S);
  lin(P);

 ll x=sqrt(P)+3;
  repl(i,1,x) {
    ll y=S-i;
    if((P%i==0) &&(y==P/i)) {
      co("Yes");
      return 0;
    }
  }

  co("No");
}

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
	char ch=getchar();int f=0,x=1;
	while(ch<'0'||ch>'9'){if(ch=='-') x=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();}
	return f*x;
}
char s[5000005],t[55]="0atcoder";
int main()
{
	int T=read();
	while(T--)
	{
		scanf("%s",s+1);
		int n=strlen(s+1);
		bool ok=1;
		for(int i=1;i<=n;i++)
		if(s[i]!='a') ok=0;
		if(ok) puts("-1");
		else
		{
			bool ok=1,no=1;
			for(int i=1;i<=min(n,7);i++)
			if(s[i]>t[i])
			{
				puts("0");ok=0;break;
			}
			else if(s[i]<t[i]) {no=0;break;
			}
			if(ok==0) continue;
			if(no&&strlen(s+1)>7)
			{
				puts("0");
				continue;
			}
			for(int i=1;i<=n;i++)
			{
				if(s[i]!='a')
				{
					int ans=i-1;
					if(s[i]>'t') ans--;
					cout<<ans<<endl;
					break;
				}
			}
		}
	}
}


#include<bits/stdc++.h>
int main(){
  int a,b,c,d;
  scanf("%d%d%d",&a,&b,&c);
  d=a+b+c;
  puts(d==a*3||d==b*3||d==c*3?"Yes":"No");
}

#include<bits/stdc++.h>
using ll= long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define RREP(i,n) for(ll i=1;i<ll(n+1);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define Fir first
#define Sec second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>  // Graph
#define VPII vector<pair<int,int>>
#define VPLL vector<pair<ll, ll>>

#define DDD fixed<<setprecision(17)

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/

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

/*.........................memo0

...........................*/

/*.........................memo1

...........................*/

/*.........................memo2

...........................*/
signed main() {
    __MAGIC__
    int a, b, c;
    cin >> a >> b >> c;
    int m1 = 0, m2 = 0, m3 = 0;
    chmax(m1, a);
    chmax(m1, b);
    chmax(m1, c);
    bool isB = false;
    if(m1 != a) {
        chmax(m2, a);
        isB = true;
    }
    if (m1 != b) {
        chmax(m2, b);
        isB = true;
    }
    if (m1 != c) {
        chmax(m2, c);
        isB = true;
    }
    if (!isB) {
        m2 = m1;
    }
    bool isC = false;
    if(m1 != a && m2 != a) {
        chmax(m3, a);
        isC = true;
    }
    if (m1 != b && m2 != b) {
        chmax(m3, b);
        isC = true;
    }
    if (m1 != c && m2 != c) {
        chmax(m3, c);
        isC = true;
    }
    if (!isC) {
        m3 = m2;
    }
    YesNo(m3-m2 == m2-m1);
    return 0;
}


//Never stop trying
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;
typedef pair<int, int> pi;
#define fi first
#define se second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<str> vs;
typedef vector<ld> vd;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

const int MOD = 1e9 + 7; //998244353
const ll INF = 1e18;
const int MX = 2e5 + 10;
const int nx[4] = {0, 0, 1, -1}, ny[4] = {1, -1, 0, 0}; //right left down up

template<class T> using V = vector<T>;
template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } // divide a by b rounded up
constexpr int log2(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))

#define dbg(x) cerr << " - " << #x << " : " << x << endl;
#define dbgs(x,y) cerr << " - " << #x << " : " << x << " / " << #y << " : " << y << endl;
#define dbgv(v) cerr << " - " << #v << " : " << endl << "[ "; for(auto it : v) cerr << it << ' '; cerr << ']' << endl;

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

int power[4000009];

int32_t main() {
	boost; IO();

	power[0]=1;
	FOR(i,1,4000009) power[i]=(power[i-1]*2)%MOD;

	int N,M; cin>>N>>M;
	char g[N][M];
	int a[N][M],b[N][M],c[N][M],d[N][M];

	int K=0;
	FOR(i,0,N) FOR(j,0,M){
		cin>>g[i][j];
		if(g[i][j]=='.') K++;
	}

	//L
	FOR(i,0,N) FOR(j,0,M){
		if(g[i][j]=='#'){
			a[i][j]=0;
			continue;
		}
		a[i][j]=1;
		if(j) a[i][j]+=a[i][j-1];
	}

	//R
	FOR(i,0,N) ROF(j,0,M){
		if(g[i][j]=='#'){
			b[i][j]=0;
			continue;
		}
		b[i][j]=1;
		if(j+1<M) b[i][j]+=b[i][j+1];
	}

	//U
	FOR(j,0,M) FOR(i,0,N){
		if(g[i][j]=='#'){
			c[i][j]=0;
			continue;
		}
		c[i][j]=1;
		if(i) c[i][j]+=c[i-1][j];
	}
	FOR(j,0,M) ROF(i,0,N){
		if(g[i][j]=='#'){
			d[i][j]=0;
			continue;
		}
		d[i][j]=1;
		if(i+1<N) d[i][j]+=d[i+1][j];
	}

	/*FOR(i,0,N){
		FOR(j,0,M)
			cout << d[i][j] << ' ';
		cout << endl;
	}*/

	int ans=0;
	FOR(i,0,N) FOR(j,0,M)if(g[i][j]=='.'){
		int y=a[i][j]+b[i][j]+c[i][j]+d[i][j]-3;
		//cout << y << endl;
		int x=power[y]-1;
		x%=MOD;
		//cout << x << endl;
		x*=power[K-(y)];
		x%=MOD;
		ans+=x; ans%=MOD;
	}
	cout << ans << endl;

	return 0;
}

/* Careful!!!
	.Array bounds
	.Infinite loops
	.Uninitialized variables / empty containers
	.Order of input

   Some insights:
	.Binary search
	.Graph representation
	.Write brute force code
	.Change your approach
*/

#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
int p2[4000001],y[2000][2000],t[2000][2000];
signed main(){
    int h,w;
    string s[2000];
    cin>>h>>w;
    for(int i=0;i<h;i++)
        cin>>s[i];
    for(int i=0;i<h;i++){
        int tmp=0;
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                for(int k=tmp;k<j;k++)
                    y[i][k]=j-tmp;
                tmp=j+1;
            }
        }
        for(int j=tmp;j<w;j++)
            y[i][j]=w-tmp;
    }
    for(int j=0;j<w;j++){
        int tmp=0;
        for(int i=0;i<h;i++){
            if(s[i][j]=='#'){
                for(int k=tmp;k<i;k++)
                    t[k][j]=i-tmp;
                tmp=i+1;
            }
        }
        for(int i=tmp;i<h;i++)
            t[i][j]=h-tmp;
    }
    p2[0]=1;
    for(int i=1;i<=h*w;i++)
        p2[i]=p2[i-1]*2%mod;
    int cnt=0;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            if(s[i][j]=='.')
                cnt++;
    int ans=0;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            if(s[i][j]=='.')
                (ans+=p2[cnt-y[i][j]-t[i][j]+1]*(p2[y[i][j]+t[i][j]-1]+mod-1))%=mod;
    cout<<ans<<endl;
}


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

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

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

    int cnt1=0,cnt2=0,sum=0;

    rep(i,n.size()){
        int m=n[i]-'0';
        sum+=m;

        if(m%3==1)cnt1++;
        else if(m%3==2)cnt2++;
    }

    int ans=-1;

    if(sum%3==0) ans=0;

    else if(sum%3==1){
        if(cnt1>=1&&n.size()>1)ans=1;
        else if(cnt2>=2&&n.size()>2)ans=2;
    }

    else {
        if(cnt2>=1&&n.size()>1)ans=1;
        else if(cnt1>=2&&n.size()>2)ans=2;
    }

    cout<<ans<<endl;
}

#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<string.h>
#include<math.h>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define F first
#define S second
#define MAX 500005
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define AC ios::sync_with_stdio(0);cin.tie(0);
using namespace std;
signed main(){
    AC;
    int n;
    ll a[200005],pre[200005]={0},maxn=0;
    cin>>n;
    FOR(i,1,n+1){
        cin>>a[i];
        pre[i]=pre[i-1]+a[i];
    }
    ll now=0,ans=0;
    FOR(i,1,n+1){
        ans=max(ans,now+maxn);
        maxn=max(maxn,pre[i]);
        now+=pre[i];
    }
    ans=max(ans,now);
    cout<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
const long long INF = 10000000000000007;
const long long mod = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

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

vector<int> table(2500);
vector<vector<int>> tile(2500);
vector<vector<bool>> seen(50,vector<bool>(50,0));
vector<vector<int>>point(50,vector<int>(50));

int now_x, now_y;
// ll sum = 0;
vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};
vector<int>ans;

void solve(int now_x, int now_y) {
  while (1) {
    int num = table[now_x+now_y*50];
    for (int j = 0; j < tile[num].size(); j++) {
      int k = tile[num][j];
      seen[k/50][k%50] = 1;
    }

    int nx,ny,ma=0,index=-1;
    for (int i = 0; i < 4; i++) {
      nx = now_x + dx[i];
      ny = now_y + dy[i];
      if (nx<0||nx>=50||ny<0||ny>=50) continue;
      if (seen[ny][nx]==1) continue;
      if (chmax(ma, point[ny][nx])) {
        index = i;
      }
    }
    if (index==-1) break;
    now_x = now_x + dx[index];
    now_y = now_y + dy[index];
    ans.push_back(index);
  }
  return;
}

int main()
{
  int si, sj;
  cin >> sj >> si;
  now_x = si;
  now_y = sj;

  for (int i = 0; i < 2500; i++) {
    int num;
    cin >> num;
    table[i] = num;
    tile[num].push_back(i);
  }
  for (int i = 0; i < 2500; i++) {
    int x = i%50;
    int y = i/50;
    cin >> point[y][x];
  }

  solve(now_x, now_y);

  // 出力
  for (int i = 0; i < ans.size(); i++) {
    if (ans[i]==0) cout << 'R';
    else if (ans[i]==1) cout << 'D';
    else if (ans[i]==2) cout << 'L';
    else if (ans[i]==3) cout << 'U';
  }
  cout << endl;
}

#include <iostream>
#include <queue>

using namespace std;

int R, C;
int A[501][501], B[501][501];

int dijkstra() {
    bool used[501][501] = {};
    int minScore[501][501] = {};
    for(int i = 0;i < 501;i++) {
        for(int j = 0;j < 501;j++) {
            minScore[j][i] = 1000000000;
        }
    }

    priority_queue<pair<int, pair<int, int>>> que;
    que.push(make_pair(0, make_pair(0, 0)));

    while(que.size()) {
        pair<int, pair<int, int>> now = que.top();
        que.pop();

        int score = -now.first;
        int x = now.second.first;
        int y = now.second.second;

        if (x == C-1 && y == R-1) {
            return score;
        }

        if (used[x][y]) continue;
        // cout << y + 1 << ", " << x + 1 << " = " << score << endl;
        used[x][y] = true;

        // 1
        int nextScore, toX, toY;
        if (x < C-1) {
            nextScore = score + A[x][y];
            toX = x + 1;
            toY = y;
            if(!used[toX][toY] && minScore[toX][toY] > nextScore) {
                minScore[toX][toY] = nextScore;
                que.push(make_pair(-nextScore, make_pair(toX, toY)));
            }
        }

        // 2
        if (x > 0) {
            nextScore = score + A[x-1][y];
            toX = x - 1;
            toY = y;

            if(!used[toX][toY] && minScore[toX][toY] > nextScore) {
                minScore[toX][toY] = nextScore;
                que.push(make_pair(-nextScore, make_pair(toX, toY)));
            }
        }

        // 3
        if (y < R-1) {
            nextScore = score + B[x][y];
            toX = x;
            toY = y + 1;

            if(!used[toX][toY] && minScore[toX][toY] > nextScore) {
                minScore[toX][toY] = nextScore;
                que.push(make_pair(-nextScore, make_pair(toX, toY)));
            }
        }

        // 4
        for (int i = 1;i <= y;i++) {
            nextScore = score + 1 + i;
            toX = x;
            toY = y - i;

            if(!used[toX][toY] && minScore[toX][toY] > nextScore) {
                minScore[toX][toY] = nextScore;
                que.push(make_pair(-nextScore, make_pair(toX, toY)));
            }
        }
    }

    return 0;
}

int main() {
    cin >> R >> C;
    for(int i = 0;i < R;i++){
        for(int j = 0;j < C-1;j++) {
            cin >> A[j][i];
        }
    }

    for(int i = 0;i < R-1;i++){
        for(int j = 0;j < C;j++) {
            cin >> B[j][i];
        }
    }

    int ans = dijkstra();

    cout << ans << endl;

    return 0;
}


//This Code was made by Chinese_zjc_.
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <time.h>
// #include<windows.h>
#define int long long
#define double long double
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
using namespace std;
int n;
string s;
signed main()
{
    ios::sync_with_stdio(false);
    cin >> n >> s;
    if (n < 3)
    {
        if (s == "1")
        {
            cout << 20000000000 << endl;
        }
        if (s == "0")
        {
            cout << 10000000000 << endl;
        }
        if (s == "11")
        {
            cout << 10000000000 << endl;
        }
        if (s == "01")
        {
            cout << 9999999999 << endl;
        }
        if (s == "10")
        {
            cout << 10000000000 << endl;
        }
        if (s == "00")
        {
            cout << 0 << endl;
        }
        return 0;
    }
    if (s[0] == '0')
    {
        s.insert(s.begin(), '1');
    }
    if (s[1] == '0')
    {
        s.insert(s.begin(), '1');
    }
    if (s[s.length() - 2] == '0')
    {
        s.push_back('1');
    }
    if (s[s.length() - 3] == '0')
    {
        s.push_back('0');
    }
    for (int i = 0; i < s.length(); ++i)
    {
        if (s[i] == '0' + (i % 3 == 2))
        {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << 10000000001 - s.length() / 3 << endl;
    return 0;
}

/*#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
//#define MOD 998244353LL
#define doublecout(a) cout<<setprecision(16)<<a<<endl;
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL;
const ll llMIN=-9223372036854775808LL;

void myprint1D(vi &data)
{
  REP(i,data.size())
    cout<<data[i]<<" ";
  cout<<endl;
}

//配列を[y][x]で表示
void myprint2D_T(vvi &data)
{
  REP(i,data.size())
    myprint1D(data[i]);
}

//配列を[x][y]で表示
void myprint2D(vvi &data)
{
  ll l1=data.size();
  ll l2=data[0].size();
  REP(j,l2){
    REP(i,l1)
      cout<<data[i][j]<<" ";
    cout<<endl;
  }
}

//print(a,b...)って使い方
void print1(ll a){cout<<a<<endl;}
void print2(ll a,ll b){cout<<a<<" "<<b<<endl;}
void print3(ll a,ll b,ll c){cout<<a<<" "<<b<<" "<<c<<endl;}
void print4(ll a,ll b,ll c,ll d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void print5(ll a,ll b,ll c,ll d,ll e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n >> k;
  string s;cin>>s;
  vi a(n),b(n);
  REP(i,n) cin>>a[i];
  cout<<ans<<endl;
  return 0;
}
*/
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
//#define MOD 998244353LL
#define doublecout(a) cout<<setprecision(16)<<a<<endl;
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL;
const ll llMIN=-9223372036854775808LL;

void myprint1D(vi &data)
{
  REP(i,data.size())
    cout<<data[i]<<" ";
  cout<<endl;
}

//配列を[y][x]で表示
void myprint2D_T(vvi &data)
{
  REP(i,data.size())
    myprint1D(data[i]);
}

//配列を[x][y]で表示
void myprint2D(vvi &data)
{
  ll l1=data.size();
  ll l2=data[0].size();
  REP(j,l2){
    REP(i,l1)
      cout<<data[i][j]<<" ";
    cout<<endl;
  }
}

//print(a,b...)って使い方
void print1(ll a){cout<<a<<endl;}
void print2(ll a,ll b){cout<<a<<" "<<b<<endl;}
void print3(ll a,ll b,ll c){cout<<a<<" "<<b<<" "<<c<<endl;}
void print4(ll a,ll b,ll c,ll d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void print5(ll a,ll b,ll c,ll d,ll e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n;
  string s,t;cin>>s;
  if (s=="0"){
    cout<<10000000000LL<<endl;
    return 0;
  }
  if (s=="1"){
    cout<<20000000000LL<<endl;
    return 0;
  }
  if (s=="11"){
    cout<<10000000000LL<<endl;
    return 0;
  }

  if (s=="00"){
    cout<<0<<endl;
    return 0;
  }

  if (s=="10"){
    cout<<10000000000LL<<endl;
    return 0;
  }

  if (s=="01"){
    cout<<(10000000000LL-1LL)<<endl;
    return 0;
  }

  t="110";
  string tt="";
  for(ll i=0;i<n/3+3;i++){
    tt+=t;
  }

  ll nn=(n/3+1)*3;
  ll flag=-1;
  if (s==tt.substr(2,n))flag=2;
  if (s==tt.substr(1,n))flag=1;
  if (s==tt.substr(0,n))flag=0;
  if (flag==-1){
    cout<<0<<endl;
    return 0;
  }

  nn=n+flag;
  cout<<((30000000000LL-nn+3)/3)<<endl;
  return 0;
}


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

int cnt[26];

int main() {
	string s; cin >> s;
	reverse(s.begin(), s.end());
	long long ans = 0;
	vector <int> all;
	for (int i = 0; i < s.size(); i++) {
		int j = i;
		while (j < s.size() && s[i] == s[j]) j++;
		if (j - i >= 2) {
			ans += i - cnt[s[i] - 'a'];
			memset(cnt, 0, sizeof(cnt)), cnt[s[i] - 'a'] = j;
		} else cnt[s[i] - 'a']++;
		i = j - 1;
	}
	cout << ans << endl;
	return 0;
}

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

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

// 計算量 O(√N)
ll prime_cnt(ll N) {
    ll res = 0;
    for (ll i=2; i*i<=N; i++) {
        if (N%i!=0) continue;
        while (N%i==0) {
            N /= i;
            res++;
        }
    }
    if (N!=1) res++;
    return res;
}

int main() {
    ll N; cin >> N;
    for (ll i=1; i<=N; i++) {
        cout << prime_cnt(i) + 1 << " ";
    }
    cout << endl;
}


#include<bits/stdc++.h>
using namespace std;
int f(int x)
{
	int ans=0;
	while(x)
	{
		if(x&1)ans++;
		x>>=1;
	}
	return ans;
}
int ksm(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans*=a;
		a*=a;
		b>>=1;
	}
	return ans;
}
int main()
{
	int n,m;
	cin>>n;
	m=ksm(2,n)-1;
	cout<<m<<"\n";
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=m+1;j++)
		{
			if(f(i&j)&1)cout<<"A";
			else cout<<"B";
		}
		cout<<"\n";
	}
	return 0;
}


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

void solve() {
    map<char, int> ch;
    string s, t, w;
    cin >> s >> t >> w;
    for (char c : s) ch.emplace(c, 0);
    for (char c : t) ch.emplace(c, 0);
    for (char c : w) ch.emplace(c, 0);
    if (ch.size() > 10) {
        cout << "UNSOLVABLE";
        return;
    }
    int p[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    do {
        string a, b, c;
        int i = 0;
        for (auto it = ch.begin(); it != ch.end(); ++it, i++)
            it->second = p[i];
        for (char x : s) a.push_back(ch[x] + '0');
        for (char x : t) b.push_back(ch[x] + '0');
        for (char x : w) c.push_back(ch[x] + '0');
        ll A = stoll(a), B = stoll(b), C = stoll(c);
        if (a[0] != '0' && b[0] != '0' && c[0] != '0' && A + B == C) {
            cout << a << "\n"
                 << b << "\n"
                 << c << "\n";
            return;
        }
    } while (next_permutation(p, p + 10));
    cout << "UNSOLVABLE";
}

int main() {
  solve();

  return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int h, w, x, y;
    cin >> h >> w >> x >> y;

    bool arr[h][w];
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            arr[i][j] = false;
        }
    }

    for (int i = 0; i < h; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++)
        {
            if (s[j] == '.')
                arr[i][j] = true;
        }
    }

    x--;
    y--;

    int finalCount = 0;
    int count = 0;

    for (int i = 0; i < w; i++)
    {
        if (arr[x][i])
            count++;
        else
        {
            if (i > y)
            {
                finalCount+=count;
                break;
            }
            count = 0;
        }

        if (i == w - 1)
            finalCount+=count;
    }

    count = 0;
    for (int i = 0; i < h; i++)
    {
        if (arr[i][y])
            count++;
        else
        {
            if (i > x)
            {
                finalCount+=count;
                break;
            }
            count = 0;
        }

        if (i == h - 1)
            finalCount+=count;
    }

    cout << finalCount - 1 << endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
  	int n;cin>>n;
  	for(int i=1;i<=n;i++){
      	cout<<(i+1)/2<<" "<<(n+i+1)/2<<endl;
    }
}

#include <cstdio>
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		printf("%d %d\n",(i<<1)%n+1,(i<<1|1)%n+1);
	}
	return 0;
}


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

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

*/
#define pii pair<int,int>
#define fi first
#define pb push_back
#define si second
#define int   long long
#define mod   998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define double long double
#define all(o) o.begin(),o.end()

/*
#define T pair<int, int>
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
*/

using namespace std;

int power(int x, int y)
{
    int res = 1LL;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1; // y = y/2
        x = (x*x) % mod;
    }
    return res%mod;
}
int inv(int  n)
{
    return power(n,mod-2)%mod;
}
int isprime(int n){
    if(n<2)return 0;
    int i;
    for(i=2;i*i<=n;i++)
        if(n%i==0)
            return 0;
    return 1;
}
void files(){
    // For getting input from input.txt file
    freopen("lca.in", "r", stdin);
    // Printing the Output to output.txt file
    freopen("lca.out", "w", stdout);

}

int egcd(int a,int b,int &x ,int & y){
    if(b==0){
        x=1;y=0;
        return a;
    }
    int x1,y1;
    int g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-(a/b)*y1;
    return g;
}
const int N=2e6;
//https://codeforces.com/blog/entry/22747
// https://codeforces.com/blog/entry/89609

int n,c[505][505],a[505],b[505];
void solve(){

    cin>>n;
    int i,j,k;
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            cin>>c[i][j];

    for(i=1;i<=n;i++){
        int ok=1;

        for(j=1;j<=n;j++)
        {   b[j]=c[i][j];
            a[j]=c[j][1]-b[1];
            if(a[j]<0)
            ok=0;
        }
        if(ok==0)continue;
        for(j=1;j<=n;j++)
            for(k=1;k<=n;k++)
                if(c[j][k]!=a[j]+b[k] )
                    ok=0;
        if(ok)
        {
            cout<<"Yes\n";
            for(j=1;j<=n;j++)
                cout<<a[j]<<" ";
            cout<<"\n";

            for(j=1;j<=n;j++)
                cout<<b[j]<<" ";
            cout<<"\n";
            return;
        }
    }

    cout<<"No\n";

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

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

void Main() {
  ll n;
  R n;
  ll c[n][n];
  rep(i,n)rep(j,n) R c[i][j];
  set<vector<ll> > s1,s2;
  rep(i,n) {
    vector<ll> a,b;
    rep(j,n-1) {
      a.pb(c[i][j+1]-c[i][j]);
      b.pb(c[j+1][i]-c[j][i]);
    }
    s1.in(a);
    s2.in(b);
  }
  if(s1.size()>1||s2.size()>1) {
    pr("No");
    return;
  }
  vector<ll> v=*s1.begin();
  ll M=0,x=0;
  rep(i,v.size()) {
    x+=v[i];
    M=min(M,x);
  }
  vector<ll> b;
  x=-M;
  b.pb(x);
  rep(i,v.size()) {
    x+=v[i];
    b.pb(x);
  }
  vector<ll> a;
  rep(i,n) a.pb(c[i][0]-b[0]);
  pr("Yes");
  PR(a,n);
  PR(b,n);
}

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


#include <cstring>
#include <iostream>
using namespace std;
using ll = long long;

const int MAXN = 102;
const int MAXC = 122505;

ll k, mod, table[MAXN][MAXC], ret[MAXN];
int n, now;

void calc() {
    memset(table, 0, sizeof(table));
    table[0][0] = 1;

    for (int i = 1; i <= n; ++i) {
        int c = (k * (i + 1) * i) >> 1;
        c = min(c, MAXC - 1);
        for (int j = 0; j <= c; ++j) {
            for (int v = 0; v <= k; ++v) {
                int tmp = j + v * i;
                if (tmp > c) break;
                table[i][tmp] += table[i-1][j];
                if (table[i][tmp] >= mod) table[i][tmp] -= mod;
            }
        }
    }
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    while (cin >> n >> k >> mod) {
        calc();
        for (now = 1; now * 2 <= n + 1; now++) {
            ll ans = 0;
            int l = now - 1, r = n - now;

            ans += k * table[l][0] * table[r][0];
            ans %= mod;

            for (int j = 1; j < MAXC; ++j) {
                ans += (k + 1LL) * ((table[l][j] * table[r][j]) % mod);
                ans %= mod;
            }

            ret[now] = ans;
            ret[n - now + 1] = ans;
        }

        for (now = 1; now <= n; ++now) cout << ret[now] << '\n';
    }
    return 0;
}

/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=101,M=125001;
#define ci const int &

int n,m,MOD;
int f[N][M];

inline int Add(ci a,ci b){return a+b>=MOD? a+b-MOD:a+b;}
inline int Sub(ci a,ci b){return a-b<0? a-b+MOD:a-b;}
inline int Mul(ci a,ci b){return int(1ll*a*b%MOD);}
int main(){
	scanf("%d%d%d",&n,&m,&MOD);
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		int bonj=min(M-1,(i+1)*i/2*m);
		for(int j=0;j<=bonj;j++)
			for(int k=0;k*i<=j && k<=m;k++)
				f[i][j]=Add(f[i][j],f[i-1][j-k*i]);
	}
	for(int x=1;x<=n;x++){
		int tot=0;
		for(int j=1;j<M;j++)
			tot=Add(tot,Mul(f[x-1][j],f[n-x][j]));
		tot=Add(Mul(tot,m+1),m);
		printf("%d\n",tot);
	}
	return 0;
}


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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N;
    cin >> N;
    string S, X;
    cin >> S >> X;
    vector<int> pow_10(N);
    int tmp = 1;
    for (int i=N-1;i>=0;i--) {
        pow_10[i] = tmp;
        tmp = tmp*10%7;
    }

    // 0: takahashi
    // 1: aoki
    vector<int> vec(7, 1);
    vec[0] = 0;
    for (int i=N-1;i>=0;i--) {
        int num = S[i]-'0';
        vector<int> vec_next(7, -1);
        if (X[i] == 'T') {
            for (int j=0;j<7;j++) {
                if (vec[j] == 0) {
                    vec_next[j] = 0;
                    vec_next[(j-num*pow_10[i]%7+7)%7] = 0;
                }
            }
            for (int j=0;j<7;j++) {
                if (vec_next[j] == -1) vec_next[j] = 1;
            }
        } else { // X[i] == 'A
            for (int j=0;j<7;j++) {
                if (vec[j] == 1) {
                    vec_next[j] = 1;
                    vec_next[(j-num*pow_10[i]%7+7)%7] = 1;
                }
            }
            for (int j=0;j<7;j++) {
                if (vec_next[j] == -1) vec_next[j] = 0;
            }

        }
        vec = vec_next;
    }
    if (vec[0] == 0) cout << "Takahashi" << "\n";
    else cout << "Aoki" << "\n";

    return 0;
}

//#pragma GCC optimize(2)
#include<bits/stdc++.h>

#define IOS ios::sync_with_stdio(false);cin.tie(nullptr)
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define lc(x) ((x)<<1)
#define rc(x) (((x)<<1)|1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;

const ll LINF=1e18;
const ll MOD=1e9+7;
const int INF=0x3f3f3f3f;
const int MAXM=500050;
const int MAXN=200050;

int dp[MAXN][7],n;
char s[MAXN],t[MAXN];
int dfs(int dep,int rem){
	if(dep>n){
		if(rem)return dp[dep][rem]=2;
		else return dp[dep][rem]=1;
	}

	if(dp[dep][rem])return dp[dep][rem];

	int now=s[dep]-'0';

	int idx1=(rem*10+now)%7,idx2=(rem*10)%7;

	dfs(dep+1,idx1);dfs(dep+1,idx2);

	if(t[dep]=='T'){
		if(dp[dep+1][idx1]==1||dp[dep+1][idx2]==1){
			return dp[dep][rem]=1;
		}else return dp[dep][rem]=2;
	}else if(t[dep]=='A'){
		if(dp[dep+1][idx1]==1&&dp[dep+1][idx2]==1){
			return dp[dep][rem]=1;
		}else return dp[dep][rem]=2;
	}
}
void mainwork(int T){
	scanf("%d",&n);
	scanf("%s",s+1);
	//reverse(s+1,s+n+1);
	scanf("%s",t+1);
	//reverse(t+1,t+n+1);
	dfs(1,0);
	if(dp[1][0]==1)puts("Takahashi");
	else puts("Aoki");
}
signed main(){
	//IOS;
	#ifndef ONLINE_JUDGE
	//freopen("./in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	#endif
	int t=1;
	//scanf("%d",&t);
	//prework();
	for(int i=1;i<=t;i++){
		mainwork(i);
	}
}


/*
	_(┐「ε:)_
*/
#include <bits/stdc++.h>
using namespace std;
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define spc(x, y) setprecision(y) << fixed << x
#define slc(x, w, c) setw(w) << setfill(c) << x
#define file "TEST"
typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef double db;
#define _OD "DEBUG>> "
#define deb_v(x) cerr << _OD << (#x) << ": " << x << '\n'
#define deb_vec(x) cerr << _OD << (#x) << ": "; for (auto i : x) cerr << i << ' '; cerr << '\n'
#define deb_arr(x, l, r) cerr << _OD << (#x) << ": "; for (int i = l; i <= r; ++i) cerr << x[i] << ' '; cerr << '\n'
#define _deb_vec(x) cerr << _OD << (#x) << ": "; for (int i = x.size() - 1; i >= 0; --i) cerr << x[i] << ' '; cerr << '\n'
#define _deb_arr(x, r, l) cerr << _OD << (#x) << ": "; for (int i = r; i >= l; --i) cerr << x[i] << ' '; cerr << '\n'
#define START_TIMER clock_t _, __; _ = clock()
#define END_TIMER __ = clock(); db ___ = db(__ - _) / (db)CLOCKS_PER_SEC; cerr << "\nTime executed: " << spc(___, 5) << " sec\n"
mt19937_64 rd(time(0));
template<typename T> T gcd(T a, T b) { return (b == 0)? a : gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T max(T a, T b, T c) { return max(a, max(b, c)); }
template<typename T> T max(T a, T b, T c, T d) { return max(a, max(b, c, d)); }
ll mulmod(ll a, ll b, ll n) {
	if (b == 0)
		return 0;
	ll tmp = mulmod(a, b >> 1, n);
	if (b & 1)
		return (tmp * 2 % n + a) % n;
	return tmp * 2 % n;
}
template<typename T>
T i_rand(T l, T r) {
	assert(l <= r);
	return uniform_int_distribution<T>(l, r)(rd);
}
template<typename T>
T r_rand(T l, T r) {
	return uniform_real_distribution<T>(l, r)(rd);
}
template<typename T>
void sfe(T a[], int l, int r) {
	shuffle(a + l, a + 1 + r, rd);
}
template<typename T>
void sfe(vector<T> a) {
	shuffle(a.begin(), a.end(), rd);
}
int n;
db l[2001], r[2001], t[2001];
signed main() {
	START_TIMER; ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	// freopen(file".INP", "r", stdin);
	// freopen(file".OUT", "w", stdout);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> t[i] >> l[i] >> r[i];
		if (t[i] == 1)
			continue;
		if (t[i] == 2)
			r[i] -= 0.5;
		if (t[i] == 3)
			l[i] += 0.5;
		if (t[i] == 4) {
			r[i] -= 0.5;
			l[i] += 0.5;
		}
	}
	int rs = 0;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j < i; ++j)
			if (max(l[i], l[j]) <= min(r[i], r[j]))
				++rs;
	cout << rs;
	END_TIMER; return 0;
}
/*
	proof & correctness
	run some pretest
	int32 overflow
	array size
	reinit after tests
	write a tester
	read code line after line again (without reading the template)
	submit
*/

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define forn(i,n) for(int i = 0; i < n; i++)
#define pb push_back
#define sz(x) ((int)(x).size())
#define dbg(x) cerr << #x << "->" << x << "\n";
#define prnt(x) cerr<<"{ ";for(auto i:x)cerr<<i<<" ";cerr<<"}\n";

void solve() {
	int N; cin >> N;
	vector<pair<long double, long double>> v;
	long double d = 1e-9;
	forn(_, N) {
		int t;
		long double l, r;
		cin >> t >> l >> r;
		if (t == 1) v.pb({l, r});
		if (t == 2) v.pb({l, r - d});
		if (t == 3) v.pb({l + d, r});
		if (t == 4) v.pb({l + d, r - d});
	}
	int ans = 0 ;
	forn(i, N) {
		for (int j = i + 1; j < N; j++) {
			if (max(v[i].first, v[j].first) <= min(v[i].second, v[j].second)) {
				ans++;
			}
		}
	}
	cout << ans;
}

int32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int t = 1;
	// cin >> t;
	forn(i, t)
	solve();
}


#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
constexpr ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
template<class T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
constexpr int dy[4]={-1,0,1,0};
constexpr int dx[4]={0,-1,0,1};

int N, M;
int A[100*100], B[100*100];
int C[100];

vector<pair<int,int>> e[101];
vector<int> v[101];
int ans[100*100];

bool vis[100];
queue<int> que;
bool fin[100];
bool dfs(int n, int p, int b){
    if(vis[n]){
        if(n == p) return true;
        else return false;
    }
    vis[n] = true;
    rep(i, e[n].size()){
        if(C[n] != C[e[n][i].first]) continue;
        if(e[n][i].first == b) continue;
        bool ret = dfs(e[n][i].first, p, n);
        if(ret){
            fin[n] = true;
            ans[e[n][i].second] = n;
            que.push(n);
            return true;
        }
    }
    vis[n] = false;
    return false;
}
bool dfs2(int n, int p, int b){
    if(fin[n]) return true;
    if(vis[n]) return false;
    vis[n] = true;
    rep(i, e[n].size()){
        if(C[n] != C[e[n][i].first]) continue;
        if(e[n][i].first == b) continue;
        bool ret = dfs2(e[n][i].first, p, n);
        if(ret){
            fin[n] = true;
            ans[e[n][i].second] = n;
            que.push(n);
            return true;
        }
    }
    vis[n] = false;
    return false;
}

signed main(){
    cin >> N >> M;
    rep(i, M){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        e[A[i]].pb({B[i],i});
        e[B[i]].pb({A[i],i});
    }
    rep(i, N){
        cin >> C[i];
        v[C[i]].pb(i);
    }

    rep(i, 101){
        rep(j, v[i].size()){
            if(!fin[v[i][j]]){
                bool ret = dfs(v[i][j], v[i][j], -1);
            }
            while(que.size()){
                rep(k, e[que.front()].size()){
                    if(C[que.front()] != C[e[que.front()][k].first]) continue;
                    if(fin[e[que.front()][k].first]) continue;
                    dfs2(e[que.front()][k].first, que.front(), que.front());
                    ans[e[que.front()][k].second] = que.front();
                }
                que.pop();
            }
        }
    }

    rep(i, M){
        if(C[A[i]] > C[B[i]]) cout << "->" << endl;
        else if(C[A[i]] < C[B[i]]) cout << "<-" << endl;
        else{
            if(ans[i] == A[i]) cout << "->" << endl;
            else cout << "<-" << endl;
        }
    }
}

#include <iostream>
using namespace std;
//#define int long long
const int maxm=1e3+5;
int g[maxm][maxm];
int mark[maxm];
int a[maxm];
int b[maxm];
int c[maxm];
int ans[maxm];
int n,m;
void dfs(int x){
    mark[x]=1;
    for(int i=1;i<=n;i++){
        if(g[x][i]){
            g[i][x]=0;
            if(!mark[i]){
                dfs(i);
            }
        }
    }
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=1;i<=n;i++){
        cin>>c[i];
    }
    for(int i=1;i<=m;i++){
        if(c[a[i]]>c[b[i]]){
            ans[i]=1;
        }else if(c[a[i]]<c[b[i]]){
            ans[i]=0;
        }else{
            g[a[i]][b[i]]=g[b[i]][a[i]]=1;
        }
    }
    for(int i=1;i<=n;i++){
        if(!mark[i]){
            dfs(i);
        }
    }
    for(int i=1;i<=m;i++){
        if(g[a[i]][b[i]])ans[i]=1;
        else if(g[b[i]][a[i]])ans[i]=0;
    }
    for(int i=1;i<=m;i++){
        if(ans[i]==1)cout<<"->"<<endl;
        else cout<<"<-"<<endl;
    }
    return 0;
}