#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define X first
#define Y second
#define nl '\n'
#define AC return 0
#define pb(a) push_back(a)
#define mst(a,b) memset(a, b, sizeof a)
#define rep(i,n) for(int i = 0; (i)<(n); i++)
#define rep1(i,n) for(int i = 1; (i)<=(n); i++)
#define scd(a) scanf("%lld", &a)
#define scdd(a,b) scanf("%lld%lld", &a, &b)
#define scs(s) scanf("%s", s)
//#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const ll INF = (ll)0x3f3f3f3f3f3f3f, MAX = 9e18, MIN = -9e18;
const int N = 1e6+10, M = 2e6+10, mod = 1e9+7, inf = 0x3f3f3f3f;
pll a[N];
vector<ll> ans;

int main()
{
	IOS;
	int _;
	// cin>>_;
	_ = 1;
	while(_--)
	{
		ll n;
		cin>>n;
		rep1(i, n)	cin>>a[i].X>>a[i].Y;
		sort(a+1, a+1+n);
		ll mi1 = MAX, mi2 = MAX, mx1 = MIN, mx2 = MIN, id1 = 0, id2 = 0;
		rep1(i, n)
		{
			if(a[i].Y <= mi1)	mi2 = mi1, mi1 = a[i].Y, id1 = i;
			else if(a[i].Y <= mi2)	mi2 = a[i].Y;

			if(a[i].Y >= mx1)	mx2 = mx1, mx1 = a[i].Y, id2 = i;
			else if(a[i].Y >= mx2)	mx2 = a[i].Y;
		}
		ans.pb(a[n].X-a[1].X);
		ans.pb(a[n].X-a[2].X);
		ans.pb(a[n-1].X-a[1].X);
		// cout<<id1<<' '<<id2<<nl;
		if(id1 + id2 != n + 1 && (id1 != 1 || id1 != n || id2 != 1 || id2 != n))
			ans.pb(mx1-mi1);//, cout<<"ok?"<<nl;
		ans.pb(mx2-mi1);
		ans.pb(mx1-mi2);
		sort(ans.begin(), ans.end(), greater<ll>());
		cout<<ans[1]<<nl;
	}

	AC;
}

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

using namespace std;
//using namespace atcoder;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using ld = long double;
using vld = vector<ld>;
using vb = vector<bool>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

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

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

template <class T> ostream& operator<<(ostream& s, const vector<T>& a) {
    for(auto i : a) s << i << ' ';
    return s;
}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 62;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n;
    cin >> n;
    ll off = 0, ub = INFL, lb = -INFL;
    while(n--) {
        ll a, t;
        cin >> a >> t;
        if(t == 1) {
            off += a;
        }
        else if(t == 2) {
            a -= off;
            chmax(lb, a);
            if(lb > ub) ub = lb;
        }
        else {
            a -= off;
            chmin(ub, a);
            if(lb > ub) lb = ub;
        }
    }
    ll q;
    cin >> q;
    while(q--) {
        ll x;
        cin >> x;
        if(ub == lb) cout << ub+off << endl;
        else if(x < lb) cout << lb+off << endl;
        else if(ub < x) cout << ub+off << endl;
        else cout << x+off << endl;
    }
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int N = S.size();
  bool ok = true;
  for (int i = 0; i < N; i++){
    if (i % 2 == 0){
      if (isupper(S[i])){
        ok = false;
      }
    } else {
      if (islower(S[i])){
        ok = false;
      }
    }
  }
  if (ok){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

// THINGS TO REMEMBER
// ENDL is slow, '\n' is fast
// Clear everything (including graphs) between test cases
// use anti-anti-hash: https://codeforces.com/blog/entry/62393
// pb-ds: https://codeforces.com/blog/entry/11080
// check when to use LLONG_MAX/LLONG_MIN vs INT_MAX or INT_MIN
// You frequently suffer from confirmation bias - you trust your initial solution and miss simple things.
// When you hit a roadblock, remember to rethink the solution ground up, not just try hacky fixes

int main(){

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

    string n;
    cin>>n;

    ll ans=INT_MAX;
    ll sz=n.size();

    for(int i=0;i<(1<<sz)-1;i++){
    	ll c=0;
    	for(int j=0;j<sz;j++){
    		if(((i>>j)&1)==0){
    			c+=n[j]-'0';
    		}
    	}
    	// cerr<<i<<" "<<c<<endl;

    	if(c%3==0){
    		ans=min(ans,(ll)__builtin_popcount(i));
    	}
    }

    if(ans==INT_MAX){
    	cout<<-1<<endl;
    }
    else{
    	cout<<ans<<endl;
    }

}


#include<iostream>

#define MAX_N 300000

using namespace std;

typedef long long ll;

ll N, a[MAX_N], ans[MAX_N];

ll bit[MAX_N + 1];

int sum(int i) {
	int s = 0;
	while (i > 0) {
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(int i, int x) {
	while (i <= N) {
		bit[i] += x;
		i += i & -i;
	}
}

int main() {

	cin >> N;

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

	for (ll i = 0; i < N; i++) {
		ans[0] += i - sum(a[i] + 1);
		add(a[i] + 1, 1);
	}

	for (int i = 0; i < N - 1; i++) {
		ans[i + 1] = ans[i] + N - 2 * a[i] - 1;
	}

	for (int i = 0; i < N; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

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

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

  vector<int>A(N);
  vector<int>B(N);
  int mini=1000000001;
  for(int i=0; i<N; i++){
    B[i]=C[0][i]-C[0][0];
    mini=min(B[i], mini);
  }

  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(B[j]!=C[i][j]-C[i][0]){
        cout << "No" << endl;
        return 0;
      }
    }
  }

  for(int i=0; i<N; i++)B[i]-=mini;

  for(int i=0; i<N; i++){
    A[i]=C[i][0]-B[0];
  }

  cout << "Yes" << endl;
  for(int i=0; i<N; i++){
    if(i!=N-1)cout << A[i] << ' ';
    else cout << A[i] << endl;
  }

 for(int i=0; i<N; i++){
    if(i!=N-1)cout << B[i] << ' ';
   else cout << B[i] << endl;
  }

}


#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long modpow(long long a, long long b){
	long long ans = 1;
	while (b > 0){
		if (b % 2 == 1){
			ans *= a;
			ans %= MOD;
		}
		a *= a;
		a %= MOD;
		b /= 2;
	}
	return ans;
}
long long modinv(long long a){
	return modpow(a, MOD - 2);
}
vector<long long> mf = {1};
vector<long long> mfi = {1};
long long modfact(int n){
	if (mf.size() > n){
		return mf[n];
	} else {
		for (int i = mf.size(); i <= n; i++){
			long long next = mf.back() * i % MOD;
			mf.push_back(next);
			mfi.push_back(modinv(next));
		}
		return mf[n];
	}
}
long long modfactinv(int n){
	if (mfi.size() > n){
		return mfi[n];
	} else {
		return modinv(modfact(n));
	}
}
long long modbinom(int n, int k){
	if (n < 0 || k < 0 || k > n){
		return 0;
	} else {
		return modfact(n) * modfactinv(k) % MOD * modfactinv(n - k) % MOD;
	}
}
int main(){
  int N, M, K;
  cin >> N >> M >> K;
  if (N > M + K){
    cout << 0 << endl;
  } else {
    long long ans = modbinom(N + M, N);
    int a = N - K - 1, b = K + M + 1;
    ans -= modbinom(a + b, a);
    if (ans < 0){
      ans += MOD;
    }
    cout << ans << endl;
  }
}

// Author : Shivraj Ahirwar //

#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define ll long long int
#define nx cout<<"\n";
#define mod 1e9+7

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

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tc = 1;
    // cin>>tc;
    while (tc--){
		ll a,b,c;
		cin>>a>>b>>c;
		if(a*b>=0){
			if(a<0){
				if(c%2==0){
					if(a<b) cout<<">";
					else if(a>b) cout<<"<";
					else cout<<"=";
				}
				else{
					if(a<b) cout<<"<";
					else if(a>b) cout<<">";
					else cout<<"=";
				}
			}
			else{
					if(a<b) cout<<"<";
					else if(a>b) cout<<">";
					else cout<<"=";
			}
		}

		else{
				if(c%2==0){
					if(abs(a)<abs(b)) cout<<"<";
					else if(abs(a)>abs(b)) cout<<">";
					else cout<<"=";
				}
				else{
					if(a<b) cout<<"<";
					else if(a>b) cout<<">";
					else cout<<"=";
				}
		}
		// else{
		// 	if(c%2==0){
		// 			if(abs(a)<abs(b)) cout<<"<";
		// 			else if(abs(a)<abs(b)) cout<<">";
		// 			else cout<<"=";
		// 		}
		// 		else{
		// 			if(a<b) cout<<"<";
		// 			else if(a>b) cout<<">";
		// 			else cout<<"=";
		// 		}
		// }
		nx
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std ;
#define Next( i, x ) for( register int i = head[x]; i; i = e[i].next )
#define rep( i, s, t ) for( register int i = (s); i <= (t); ++ i )
#define drep( i, s, t ) for( register int i = (t); i >= (s); -- i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 5e5 + 5 ;
int n ;
char s[N], t[N] ;
void out() {
	puts("-1") ; exit(0) ;
}
int st[N], top ;
signed main()
{
	n = gi() ;
	scanf("%s", s + 1 ) ;
	scanf("%s", t + 1 ) ;
	int a = 0, b = 0 ;
	rep( i, 1, n ) a += (s[i] == '1') ;
	rep( i, 1, n ) b += (t[i] == '1') ;
	if( a < b ) out() ;
	if( (a % 2) != (b % 2) ) out() ;
	int Ans = 0 ;
	for(re int i = n; i >= 1; -- i) {
		if( s[i] == '1' ) st[++ top] = i ;
		if( t[i] == '1' ) {
			if(top == 0) out() ;
			Ans += (st[top] - i), -- top ;
		}
	}
	for(re int i = 1; i <= top; i += 2) {
		int u = st[i] - st[i + 1] ;
		Ans += u ;
	}
	cout << Ans << endl ;
	return 0 ;
}

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

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

map<ll, ll> memo;
ll x, y;

ll solve(ll y) {
    if (x >= y) return memo[y] = x-y;
    if (memo.count(y)) return memo[y];
    ll res = y-x;
    if (y % 2 == 0) chmin(res, solve(y/2)+ 1);
    else chmin(res, 1 + min(solve(y+1), solve(y-1)));
    return memo[y] = res;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> x >> y;
    cout << solve(y) << endl;
    return 0;
}


//→__int128_tを使う&GNU C++17 (64)で提出する

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//イテレーション
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//x:コンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf
#define INF64 9223372036854775807 //9.223372036854775807×10^{18}:64bit整数のinf
#define MOD 1000000007 //問題による
//略記
#define F first
#define S second
//出力(空白区切りで昇順に)
#define coutALL(x) for(auto i=x.begin();i!=--x.end();i++)cout<<*i<<" ";cout<<*--x.end()<<endl;

//aをbで割る時の繰上げ,繰り下げ
ll myceil(ll a,ll b){return (a+(b-1))/b;}
ll myfloor(ll a,ll b){return a/b;}

long long comb(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}

signed main(){

	ll a,b,k;
	cin >> a >> b >> k;
	ll c;
	ll n=a+b;
	k--;
	for(ll i=0;i<n;i++){
		if(a>0){
			c=comb(a+b-1,b);
			if(k<c){
				cout << "a";
				a--;
			}
			else {
				cout << "b";
				k -= c;
				b--;
			}
		}
		else {
			cout << 'b';
			b--;
		}
	}
	cout << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define rng(v) v.begin(),v.end()
#define rngr(v) v.rbegin(),v.rend()
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using P3 = tuple<int, int, int>;
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vs vector<string>
using vp = vector<P>;
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; }
using CP = complex<double>;
double dot( const CP &z, const CP &w ){ return (z.real()*w.real() + z.imag()*w.imag()); }
double cross( const CP &z, const CP &w ){ return (z.real()*w.imag() - z.imag()*w.real()); }

int n;
string s, x;
vvi memo;
bool dp(int i = 0, int r = 0){
    if(memo[i][r] != -1) return memo[i][r] ;
    if(i == n) return r==0;
    int a = s[i]-'0';
    int b = ((r*10+a)%7), c = ((r*10)%7);
    if(memo[i+1][b] == -1) memo[i+1][b]  = dp(i+1, b);
    if(memo[i+1][c] == -1) memo[i+1][c]  = dp(i+1, c);
    if(x[i] == 'A'){
        return memo[i+1][b] && memo[i+1][c];
        //return (dp(i+1, (r*10+a)%7)) && (dp(i+1, (r*10)%7));
    }else{
        return memo[i+1][b] || memo[i+1][c];
        //return (dp(i+1, (r*10+a)%7)) || (dp(i+1, (r*10)%7));
    }
}
int main()
{
    cin >> n >> s >> x;
    memo.resize(n+1, vi(7, -1));
    if(dp()) cout << "Takahashi" << endl;
    else cout << "Aoki" << endl;
    return 0;
}


#include <cstdio>
#include <cstring>
#define N 110
#define mo 998244353

using namespace std;

int f[N][5010];
int n, w[N];
int sum;
int jc[N];
int ans;

int main(){
//	freopen("funny.in", "r", stdin);
	scanf("%d", &n);
	for (int i=1; i<=n; i++) scanf("%d", &w[i]), sum+=w[i];
	jc[0]=1;
	for (int i=1; i<=n; i++) jc[i]=1ll*jc[i-1]*i%mo;
	if (sum%2==1){
		printf("%d\n", 0);
		return 0;
	}
	int sx=sum/2;
	f[0][0]=1;
	for (int i=1; i<=n; i++){
		for (int j=n; j; j--){
			for (int k=w[i]; k<=sx; k++){
				(f[j][k]+=f[j-1][k-w[i]])%=mo;
			}
		}
	}
	for (int i=1; i<=n; i++){
		(ans+=1ll*jc[i]*jc[n-i]%mo*f[i][sx]%mo)%=mo;
	}
	printf("%d\n", ans);

	return 0;
}

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

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

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

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

#define en "\n"

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

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

struct modint {
    long long x;
    modint(long long x=0):x((x%MOD+MOD)%MOD){}
    long long val(){
        return x;
    }
    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 {
        modint res(*this);
        return res+=a;
    }
    modint operator-(const modint a) const {
        modint res(*this);
        return res-=a;
    }
    modint operator*(const modint a) const {
        modint res(*this);
        return res*=a;
    }
    modint pow(long long t) const {
        if (!t) return 1;
        modint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }

	// must be gcd(x,MOD)==1
    modint inv() const {
		// a^{-1} = 1/a MOD p (拡張Euclidの互除法)
		long long b = MOD, u = 1, v = 0, z = x;
		while(b){
			long long t = z / b;
			z -= t * b; swap(z, b);
			u -= t * v; swap(u, v);
		}
		u %= MOD;
		if (u < 0) u += MOD;
		return modint(u);
	}

    //modint inv() const {
    //    return pow(MOD-2);
    //}

    modint& operator/=(const modint a) {
    	return (*this) *= a.inv();
    }
    modint operator/(const modint a) const {
        modint res(*this);
        return res/=a;
    }
};
using mint = modint;

struct Factorial{

    vector<mint> fact, ifact;

    Factorial(int N): fact(N+1), ifact(N+1) {
        assert(N < MOD);

        fact[0] = 1;
        for(int i=0; i<N; i++) fact[i+1] = fact[i] * (i+1);

        ifact[N] = fact[N].inv();
        for(int i=N; i>0; i--) ifact[i-1] = ifact[i] * i;
    }

    mint C(int n, int k){
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }

    mint P(int n, int k){
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[n-k];
    }

    mint inv(int n){
        assert(n>0);
        return fact[n-1]*ifact[n];
    }
};

mint dp[101][101][10101];

void Main(){
    int N; cin >> N;
    int sum = 0;
    Factorial F(100);
    dp[0][0][0] = 1;
    REP(i,N){
        int w; cin >> w; sum += w;
        REP(j,i+1)REP(k,10000){
            dp[i+1][j+1][k+w] += dp[i][j][k];
            dp[i+1][j][k] += dp[i][j][k];
        }
    }
    if(sum&1){
        cout << 0 << en;
        return;
    }
    sum >>= 1;
    mint ans(0);
    REP(i,N+1){
        ans += dp[N][i][sum] * F.fact[i] * F.fact[N-i];
    }
    cout << ans.x << en;
    return;
}

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


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
const long double pi = 2.0 * asin(1.0);
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};
ll modpow(ll a, ll n, ll mod)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a % mod * (a % mod) % mod;
        n >>= 1;
    }
    return res;
}
int main()
{
    ll n, p;
    cin >> n >> p;
    ll ans = (p - 1) * modpow(p - 2, n - 1, MOD) % MOD;
    cout << ans << endl;
}

#include <bits/stdc++.h>

using namespace std;

const int P = 1e9+7;

/*struct mat{
    int a[3][3];
    void start() {
        for (int i = 0; i < 2; ++i) {
            for (int j = 0; j < 2; ++j) {
                a[i][j] = 0;
            }
        }
        for (int i = 0; i < 2; ++i) {
            a[i][i] = 1;
        }
    }
} base;

mat mult(mat a, mat b) {
    mat res;
    res.start();
    for (int k = 0; k < 2; ++k) {
        for (int i = 0; i < 2; ++i) {
            for (int j = 0; j < 2; ++j) {
                res.a[i][j] += (a.a[i][k] * 1ll * b.a[k][j])%P;
                res.a[i][j] %= P;
            }
        }
    }
    return res;
};

mat fpow(mat a, int k) {
    mat res;
    res.start();
    for (;k; k>>=1, a = mult(a, a)) {
        if(k&1) {
            res = mult(res, a);
        }
    }
    return res;
}

int main() {
    long long n, p;
    cin >> n >> p;
    base.a[0][0] = p;
    base.a[0][1] = 0;
    base.a[1][0] = p-1;
    base.a[1][1] = 1;

    mat ans = fpow(base, n-1);

    cout << (3ll*ans.a[1][0])%P << endl;
}*/

int fpow(int a, int k) {
    int res = 1;
    for (;k; k>>=1, a = a * 1ll * a % P) {
        if(k&1) {
            res = res * 1ll * a % P;
        }
    }
    return res;
}

int main() {
    long long n, p;
    cin >> n >> p;
    if(p==2) {
        if(n == 1) cout << 1 << endl;
        else cout << 0 << endl;
    } else {
        int ans = fpow((p-2), n-1);
        cout << ((p-1) * 1ll * ans) % P << endl;
    }
}


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

using namespace std;

template<typename T>
long long modpow(const T n,const T p,const T mod);
template<typename T>
long long modinv(const T n,const T mod);
template<typename T>
bool chmax(T &a,const T &b);
template<typename T>
bool chmin(T &a,const T &b);

long long inf=1000000007;

int main(){
	long long n;
	cin>>n;
	vector<vector<long long>> tosi(n,vector<long long>(3));

	for(long long i=0;i<n;i++) cin>>tosi.at(i).at(0)>>tosi.at(i).at(1)>>tosi.at(i).at(2);
	vector<vector<long long>> dp(n,vector<long long>(modpow((long long)2,n,inf),inf));
	dp.at(0).at(0)=0;

	for(long long i=0;i<(1<<n);i++){
		bitset<18> bits=i;
		for(long long j=0;j<n;j++){
			if(!(i==0 && j==0) && bits.test(j)==false) continue;
			for(long long k=0;k<n;k++){
				if(bits.test(k)) continue;

				long long a=abs(tosi.at(j).at(0)-tosi.at(k).at(0));
				long long b=abs(tosi.at(j).at(1)-tosi.at(k).at(1));
				long long c=max((long long)0,tosi.at(k).at(2)-tosi.at(j).at(2));
				chmin(dp.at(k).at(i+modpow((long long)2,k,inf)),dp.at(j).at(i)+a+b+c);
			}
		}
	}

	cout<<dp.at(0).at(modpow((long long)2,n,inf)-1)<<endl;

	return 0;
}

template<typename T>
long long modpow(const T n,const T p,const T mod){
	if(p==0) return 1;
	if(p%2==0){
		long long a=modpow(n,p/2,mod);
		return a*a%mod;
	}
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}

template<typename T>
long long modinv(const T n,const T mod){
	return modpow(n,mod-2,mod);
}

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

template<typename T>
bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return 1;
	}
	return 0;
}

#include <bits/stdc++.h>
#define F(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define f(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
using namespace std;
bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
 int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}
int a,b,c,d;
int main () {
#ifndef ONLINE_JUDGE
file("e");
#endif
	a=read();
	b=read();
	c=read();
	d=read();
	printf("%d\n",a*d-b*c);
	return 0;
}


#pragma region Region_1

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
using ll = long long;
using P = pair<ll, ll>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VP = vector<P>;
using VS = vector<string>;
using VC = vector<char>;
using VVC = vector<vector<char>>;
#define MOD 1000000007
const int INF = (int)1e9 + 10; // int max > 2*10^9
const long long INFL = (ll)2e18 + 10; // ll max > 9*10^18

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

template <class T> T sum(const vector<T>& v) {
    T res = 0;
    for (size_t i = 0; i < v.size(); ++i) res += v[i];
    return res;
}

/////////////////////////////////////////////////////////
// print like python
// https://qiita.com/Lily0727K/items/06cb1d6da8a436369eed
/////////////////////////////////////////////////////////
void print() { cout << endl; }

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << " ";
    print(forward<Tail>(tail)...);
}

template <class T> void print(vector<T>& vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << " ";
    }
    cout << endl;
}

template <class T> void print(vector<vector<T>>& df) {
    for (auto& vec : df) {
        print(vec);
    }
}

#pragma endregion Region_1
/////////////////////////////////////////////////////////
struct mint {
    ll x;  // typedef long long ll;
    int mod;
    mint(ll x = 0, int mod = MOD) : x((x % mod + mod) % mod), mod(mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    // x^t
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;// 桁ずらし
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::cout << std::setprecision(15);
    //////////////////////////////////////////
    ll n ,p;
    cin >> n >> p;

    mint x = p-2;
    x = x.pow(n-1) * (p-1);
    print(x.x);

    return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int,int>;

class FenwickTree {
private:
    int bit_size;
    vector<LL> bit;

public:
    FenwickTree(int siz): bit_size(siz), bit(siz + 1) {}

    void add(int num, LL val) {
        for(int i = num + 1; i <= bit_size; i += i & -i) {
            bit[i] += val;
        }
    }

    LL sum(int end) {
        LL res = 0;
        for(int i = end + 1; i > 0; i -= i & -i) {
            res += bit[i];
        }
        return res;
    }

    LL sum(int begin, int end) {
        return sum(end - 1) - sum(begin - 1);
    }

    void init(LL val) {
        for(int i = 1; i <= bit_size; i++) {
            add(i, val);
        }
    }

    int lower_bound(LL val) {
        if(val <= 0) return 0;
        int i = 0, n = 1;
        while(n * 2 <= bit_size) n *= 2;
        for(int k = n; k > 0; k /= 2) {
            if(i + k <= bit_size && bit[i + k] < val) {
                val -= bit[i + k];
                i += k;
            }
        }
        return i + 1;
    }
};

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i,N) cin >> a[i];
  vector<LL> left(N), right(N), ans(N+1);
  LL res = 0;
  FenwickTree ftl(N), ftr(N);
  rep(i,N){
  	left[i] = 2 * ftl.sum(a[i]) - i;
  	res += i - ftl.sum(a[i]);
  	ftl.add(a[i], 1);
  }
  for(int i = N - 1; i >= 0; i--){
  	right[i] = 2 * ftr.sum(a[i]) - (N - 1 - i);
  	ftr.add(a[i], 1);
  }
  ans[N] = res;
  rep(i,N){
  	ans[N-1-i] = ans[N-i] + left[N-1-i] + right[N-1-i];
  }
  //cout << res << endl;
  rep(i,N) cout << ans[i] << endl;

  return 0;
}


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

int main(){
  int N,M; cin >> N >> M;
  if(M==0){
    cout << 1 << endl;
  }else{
    vector<int> A(M), S(M+1);
    int k=N;
    for(int i=0; i<M; i++) cin >> A[i];
    sort(A.begin(),A.end());
    for(int i=0; i<M; i++){
      if(i==0){
        S[0]=A[0]-1;
        if(S[0]>0) k=min(k,S[0]);
      }else{
        S[i]=A[i]-A[i-1]-1;
        if(S[i]>0) k=min(k,S[i]);
        if(i==M-1){
          S[M]=N-A[M-1];
          if(S[M]>0) k=min(k,S[M]);
        }
      }
    }
    int result=0;
    for(int i=0; i<=M; i++){
      result+=((S[i]+k-1)/k);
    }
    cout << result << endl;
  }
}

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using pl = pair<ll, ll>;
using vl = vector<ll>;
using vp = vector< pair<ll, ll> >;
using vvl = vector<vl>;
using vs = vector<string>;
#define pi 3.14159265359;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (ll)(s); i < (ll)(n); i++)
#define rep3(i, s, n) for (ll i = (ll)(n); i >= (ll)(s); i--)
#define all(v) v.begin(), v.end()
template<class T> void chmax(T& a, T b) {
    if (a < b) a = b;
}
template<class T> void chmin(T& a, T b) {
    if (a > b) a = b;
}

ll binary_search2(ll key, vl vec) {
    ll left = 0, right = vec.size() - 1;
    while (right >= left) {
        ll mid = left + (right - left) / 2;
        if (vec[mid] == key) return mid;
        else if (vec[mid] > key) right = mid - 1;
        else left = mid + 1;
    }
    return left;
}

ll search(ll key, vl vec) {
    rep(i, vec.size()) {
        if (key <= vec[i]) return i;
    }
    return -1;
}

int main() {
    ll n, m, q;
    cin >> n >> m >> q;

    vp vw(n);
    rep(i, n) cin >> vw[i].second >> vw[i].first;
    sort(vw.begin(), vw.end(), greater<pl>());

    vl x(m);
    rep(i, m) cin >> x[i];

    vp lr(q);
    rep(i, q) cin >> lr[i].first >> lr[i].second;

    rep(i, q) {
        vl ex(0);
        rep(j, m) {
            if (j < lr[i].first - 1 || j > lr[i].second - 1) {
                ex.push_back(x[j]);
            }
        }
        sort(all(ex));

        ll len = ex.size();
        vector<bool> used(len, true);
        ll ansi = 0;

        rep(a, n) {
            if (ex.size() == 0) break;

            ll value = vw[a].first;
            ll weight = vw[a].second;

            rep(b, len) {
                if (weight <= ex[b] && used[b]) {
                    ansi += value;
                    used[b] = false;
                    break;
                }
            }
        }

        cout << ansi << endl;
    }
}


#include <bits/stdc++.h>

using namespace std;

#define rep(i,n)for(int i=0;i<(int)(n);++i)
#define fixed(n)fixed<<setprecision(n)
#define ll long long
#define ALL(a)a.begin(),a.end()
#define LLA(a)a.rbegin(),a.rend()

template<class T>void chmin(T& a,T b){
    if(a>b){
        a=b;
    }
}
template<class T>void chmax(T& a,T b){
    if(a<b){
        a=b;
    }
}

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

const long long INF=1LL<<60;
const long long MOD=1000000007;

int main(){
    int N;cin>>N;
    vector<int>A(N);
    rep(i,N){
        cin>>A[i];
    }
    ll MIN=INF;
    for(int bit=0;bit<(1<<(N-1));++bit){
        vector<int>S(N);
        rep(i,N){
            if(N==0)S[i]=0;
            else if(bit&(1<<(i-1))){
                S[i]=1;
            }
        }
        vector<int>OR;
        ll orr=0;
        rep(i,N){
            if(S[i]==1){
                OR.push_back(orr);
                orr=A[i];
            }else{
                orr=orr|A[i];
            }
        }if(orr!=0){
            OR.push_back(orr);
        }
        ll xorr=0;
        rep(i,OR.size()){
            xorr=xorr^OR[i];
        }
        chmin(MIN,xorr);
    }
    cout<<MIN;
}

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

using ll = long long;
using Vi = std::vector<int>;
using Vl = std::vector<ll>;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

constexpr int I_INF = std::numeric_limits<int>::max();
constexpr ll L_INF = std::numeric_limits<ll>::max();

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

template <std::ostream& os = std::cout>
class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        auto operator()(const Args&... args) const -> decltype((os << ... << std::declval<Args>()), void()) { print(args...); }
        template <typename T>
        auto pvec(const T& vec, size_t sz) const -> decltype(os << std::declval<decltype(std::declval<T>()[0])>(), void()) {
            for (size_t i = 0; i < sz; i++)
                os << vec[i] << (i == sz - 1 ? term : sep);
        }
        template <typename T>
        auto pmat(const T& mat, size_t h, size_t w) -> decltype(os << std::declval<decltype(std::declval<T>()[0][0])>(), void()) {
            for (size_t i = 0; i < h; i++)
                for (size_t j = 0; j < w; j++)
                    os << mat[i][j] << (j == w - 1 ? term : sep);
        }

    private:
        const char *sep, *term;
        void print() const { os << term; }
        void print_rest() const { os << term; }
        template <class T, class... Tail>
        void print(const T& head, const Tail&... tail) const { os << head, print_rest(tail...); }
        template <class T, class... Tail>
        void print_rest(const T& head, const Tail&... tail) const { os << sep << head, print_rest(tail...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints<> prints;
Prints<std::cerr> prints_err;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    int N;
    cin >> N;
    Vl A(N), B(N), P(N), invP(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (ll i = 0; i < N; i++) {
        cin >> B[i];
    }
    for (ll i = 0; i < N; i++) {
        int p;
        cin >> p;
        --p;
        P[i] = p;
        invP[p] = i;
    }
    Vi ord(N);
    iota(ord.begin(), ord.end(), 0);
    sort(ord.begin(), ord.end(), [&](int l, int r) { return A[l] < A[r]; });
    vector<Pii> ans;
    for (ll i = 0; i < N; i++) {
        int u = ord[i];
        int to = invP[u];
        if (u == to) continue;
        if (A[u] <= B[P[u]] || A[to] <= B[P[to]]) {
            prints()(-1);
            return;
        }
        int t = P[u];
        ans.emplace_back(u, to);
        P[u] = u;
        P[to] = t;
        invP[u] = u;
        invP[t] = to;
    }

    prints()(ans.size());
    for (auto [a, b] : ans) {
        prints()(a + 1, b + 1);
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    std::cin.tie(nullptr), std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    std::ifstream ifs("./in_out/input.txt");
    std::cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    std::ofstream ofs("./in_out/output.txt");
    std::cout.rdbuf(ofs.rdbuf());
#endif
    std::cout << std::setprecision(18) << std::fixed;
    solve();
    std::cout << std::flush;
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf=0x3f,INF=0x3f3f3f3f; const ll LLINF=0x3f3f3f3f3f3f3f3f;
#define sz(x) (int)x.size()
#define af(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x);
#define fil(x, y) fill(af(x), y);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define lc i << 1
#define rc i << 1 | 1
const int mod = 1e9 + 7;
ll fpow(ll a, ll b){ll ret=1;while(b){if(b&1)ret=ret*a%mod;a=a*a%mod,b>>=1;}return ret;}
ll inv(ll x){return x ? fpow(x, mod - 2) : 1;}
void madd(int &a, int b){a+=b;if(a>=mod)a-=mod;}
void msub(int &a, int b){a+=mod-b;if(a>=mod)a-=mod;}
const int MM = 2e5 + 5;

void solve(){
	int n, k;
	cin >> n >> k;
	vector<vector<int>> g(n, vector<int>(n));
	for (auto &v : g) for (auto &x : v) cin >> x;
	vector<int> ord(n);
	for (int i = 0; i < n; i++) ord[i] = i;
	int ans = 0;
	do{
		int sum = 0;
		for (int i = 0; i < n; i++)
			sum += g[ord[i]][ord[(i+1)%n]];
		ans += sum == k && ord[0] == 0;
	} while(next_permutation(af(ord)));
	cout << ans << '\n';
}
int main(){
	cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--) solve();
}

#include<iostream>
#include<cstdio>
#include<cstring>
#define MAXM 25
typedef long long ll;
using namespace std;

ll n,m;
ll cnt[3],ans;
char a[MAXM];

int main(){
	cin>>n>>m;
	ll zz = 0;
	for(int i = 1 ; i <= n ; i++){
		zz = 0;
		scanf("%s" , a + 1);
		for(int j = 1 ; j <= m ; j++)zz += (a[j] == '1');
		zz %= 2;
		if(zz % 2 == 1)ans += cnt[0];
		else ans += cnt[1];
		cnt[zz]++;
	}
	cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{ll n;
cin>>n;
ll ans=0;
ll a[n],b[n];
for(ll i=0;i<n;i++)cin>>a[i];
for(ll j=0;j<n;j++)cin>>b[j];
for(ll i=0;i<n;i++)ans+=a[i]*b[i];
if(ans==0)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;typedef long double ld;typedef vector <int> vi;typedef vector <ll> vll;typedef vector <string> vS;typedef vector <vector <int>> vv;typedef map<int, int> mi;typedef map<string, int> ms;typedef map<char, int> mc;typedef string S;typedef map <ll, ll> ml;typedef map <int, bool> mb;
#define FOR(i,N) for(int i = 0 ; i < N;i++)
#define eFOR(i,a,b) for(int i = a; i <=b;i++)
#define dFOR(i,N) for(int i = N - 1; i>=0;i--)
#define edFOR(i,a,b) for(int i = b ; i >=a;i--)
#define all(x) x.begin(),x.end()
#define SORT(x) sort(all(x))
#define RSORT(x) sort(x.rbegin(),x.rend())
#define mine(x) min_element(all(x))
#define maxe(x) max_element(all(x))
#define pb push_back
#define PI 3.14159265359
#define mod 1000000007
int CASE = 1;
void solve()
{
	int n;
	cin >> n;
	vi a(n), b(n);
	FOR(i, n)
		cin >> a[i];
	FOR(i, n)
		cin >> b[i];
	int cnt = 0;
	FOR(i, n)
		cnt += a[i] * b[i];
	cout << (cnt ? "No" : "Yes");
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int T = 1;
	while (T--)
	{
		solve();
	}
}


// B - Plus Matrix
#include <bits/stdc++.h>
using namespace std;
#define vec vector
using vi = vec<int>;
#define rep(i,e) for(int i=0;i<(e);++i)

int main(){
	int n; cin>>n;
	vec<vi> C(n, vi(n)); rep(i, n) rep(j, n) cin>>C[i][j];
	vi B(n, 1e9), A(n, 0);
	rep(i, n) rep(j, n) B[i] = min(B[i], C[j][i]);
	rep(i, n){
		rep(j, n) A[i] = max(A[i], C[i][j] - B[j]);
		B[i] = C[i][i] - A[i];
	}
	rep(i, n) rep(j, n) if(A[i] + B[j] != C[i][j]){ puts("No"); return 0; }
	puts("Yes");
	rep(i, n) cout<< A[i] <<(i<n-1? " ":"\n");
	rep(i, n) cout<< B[i] <<(i<n-1? " ":"\n");
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll r() {
	ll x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))x=x*10+c-'0',c=getchar();
	return x*f;
}
#define d r()
ll n,tmp,k;
int main(){
	n=d;
	if(n==0){
		cout<<0;
		return 0;
	}
	if(n==2){
		cout<<1;
		return 0;
	}
	ll k=max((ll)0,(ll)sqrt(2*n+2)-100);
	tmp=(1+k)*k/2;
	while(1){
		if(tmp>n+1)break;
		k++;
		tmp+=k;
	}
	k--;
	cout<<n-k+1;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000030;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;
typedef pair<int,P> PP;

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

ll mod(ll val, ll M) {
    val = val % M;
    if(val < 0) {
        val += M;
    }
    return val;
}

template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

long double d[101][101][101];

long double solve(int A,int B,int C) {
    if(d[A][B][C] != -1) {
        return d[A][B][C];
    }
    if(A == 100 || B == 100 || C == 100) return 0;
    long double a = A;
    long double b = B;
    long double c = C;
    return d[A][B][C] = 1 + solve(A + 1,B,C) * (long double)(a / (a + b + c)) + solve(A,B + 1,C) * (long double)(b / (a + b + c)) + solve(A,B,C + 1) * (long double)(c / (a + b + c));
}

int main() {
    int A,B,C;
    cin >> A >> B >> C;
    for(int i = 0;i < 101;i++) {
        for(int j = 0;j < 101;j++) {
            for(int k = 0;k < 101;k++) {
                d[i][j][k] = -1;
            }
        }
    }
    cout << fixed;
    cout << setprecision(8) << solve(A,B,C) << endl;
}

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

void DBG() { cerr << endl; }
template<class Head, class... Tail>
void DBG(Head H, Tail... T) { cerr << ' ' << H; DBG(T...); }
#define dbg(...) cerr << "(" << (#__VA_ARGS__) << "):", DBG(__VA_ARGS__)

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

#define sqr(a) ll(a) * (a)
#define siz(a) int(a.size())
#define ints(a...) int a; read(a)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define trav(i, v) for (const auto i : v)
#define fill(a, b) memset(a, b, sizeof(a))
#define rep(i, b, n) for (auto i = b; i < n; i++)
#define per(i, b, n) for (auto i = b; i >= n; i--)
#define unify(a) sort(all(a)); a.resize(unique(all(a)) - a.begin())

template <class T> using vec = vector<T>;
template <class... Args> inline void read(Args&... args) { ((cin >> args), ...); }
template <class... Args> inline void show(Args... args) { ((cout << args << " "), ...); }
template <class T1, class T2> inline bool ckmin(T1 &a, T2 b) { return a > b ? a = b, 1 : 0; }
template <class T1, class T2> inline bool ckmax(T1 &a, T2 b) { return a < b ? a = b, 1 : 0;  }
template <class T> inline void operator>> (istream& in, vector<T>& v) { rep(i, 0, siz(v)) in >> v[i]; }
template <class T> inline void operator<< (ostream& out, const vector<T>& v) { rep(i, 0, siz(v)) out << v[i] << " \n"[i + 1 == siz(v)]; }

const int MOD = 1e9 + 7;
const int N = 101;
ld dp[N][N][N];

ld f(int a, int b, int c) {
    if (a == 100 || b == 100 || c == 100)
        return 0;
    if (dp[a][b][c] >= 0)
        return dp[a][b][c];

    ld res = 1, sum = a + b + c;
    if (sum == 0)
        return 0;
    if (a < 100)
        res += a * f(a + 1, b, c) / sum;
    if (b < 100)
        res += b * f(a, b + 1, c) / sum;
    if (c < 100)
        res += c * f(a, b, c + 1) / sum;
    return dp[a][b][c] = res;
}

void solve() {
    ints(a, b, c);
    fill(dp, -1);
    cout << f(a, b, c);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
    int _ = 1;
    // cin >> _;
    rep(i, 1, _ + 1) {
        // printf("Case %d: ", i);
        // Solution solve;
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define ti3 tuple<int,int,int>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll mod = 1e9 + 7;
const ll linf = 1LL << 62;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, M;
vector<pii> ms[20];
ll dp[1 << 18][20];
int cnt[1 << 18][20];
vector<int> to[1 << 18];
int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int X, Y, Z;
        cin >> X >> Y >> Z;
        ms[X].push_back({Y, Z});
    }
    for (int i = 0; i < (1 << N); i++) {
        for (int j = 0; j < N; j++) {
            if ((i >> j) & 1) {
                for (int k = j + 1; k <= N; k++) {
                    cnt[i][k]++;
                }
            } else {
                to[i].push_back(j);
            }
        }
    }
    dp[0][0] = 1;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j < (1 << N); j++) {
            bool flag = true;
            for (auto u : ms[i]) {
                if (cnt[j][u.first] > u.second) flag = false;
            }
            if (flag) {
                for (auto u : to[j]) {
                    dp[j | (1 << u)][i + 1] += dp[j][i];
                }
            } else {
                dp[j][i] = 0;
            }
        }
    }
    cout << dp[(1 << N) - 1][N] << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a)
#define dumparr(a,n)
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

pll operator+(pll a,pll b){
  return pll(a.first+b.first,a.second+b.second);
}
pll operator-(pll a,pll b){
  return pll(a.first-b.first,a.second-b.second);
}
pll operator*(ll a,pll b){
  return pll(b.first*a,b.second*a);
}
const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const string ATCODER="atcoder";
int main(){
  cout<<setprecision(1000);
  ll T;
  cin>>T;
  For(times,T){
    string S;
    cin>>S;
    if(ATCODER<S){
      cout<<0<<endl;
      continue;
    }
    set<char> s;
    for (auto &&i : S)
    {
      s.insert(i);
    }
    if(s.size()==1&&*s.begin()=='a'){
      cout<<-1<<endl;
      continue;
    }
    if(S[1]>'a'){
      cout<<1<<endl;
      continue;
    }
    ([&S](){
      REP(S.size()){
        if(S[i]>'a'){
          if(S[i]>'t'){
            cout<<i-1<<endl;
            return;
          }else{
            cout<<i<<endl;
            return;
          }
        }
      }
    })();
  }
  return 0;
}

#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll>
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++)
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 10000000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
    string str;
    cin>>str;
    ll n=str.length();
    ll co=0, c_=0, cx=0;
    forr(i, n)
    {
    	if(str[i]=='o') co++;
    	else if(str[i]=='x') cx++;
    	else c_++;
    }
    if(co>4||cx==10)
    {
    	cout<<0<<endl;
    	return;
    }
    ll ans=0;
    vl fact(20, 1);
    forr1(i, 18) fact[i]=(fact[i-1]*i);
    if(co==4)
    {
    	cout<<fact[4]<<endl;
    	return;
    }
    else if(co==3)
    {
    	cout<<3*fact[4]/2+(fact[4]*c_)<<endl;
    }
    else if(co==2)
    {
    	ans+=(14);
    	ans+=(2*c_*fact[4]/2);
    	if(c_>=2)
    	{
    		ans+=(c_*(c_-1)/2)*fact[4];
    		ans+=(c_*fact[4]/2);
    	}
    	else if(c_==1)
    	{
    		ans+=(c_*fact[4]/2);
    	}
    	cout<<ans<<endl;
    }
    else if(co==1)
    {
    	ans=power(c_+1, 4);
    	ans-=power(c_, 4);
    	cout<<ans<<endl;
    	return;
    }
    else
    {
    	cout<<power(c_, 4)<<endl;
    	return;
    }
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
long long S = 1;
void dfs(int i ,vector<int> arr[] , vector<bool>& v){
    v[i] = true;
    long long a = 3;
    if(arr[i].size()> 2)
        S = 0;
    for(int k = 0; k < arr[i].size() ; k++){
        if(!v[arr[i][k]])
            a--;
    }
    if(a < 0)
        S = 0 ;
    S *= a;
    for(int k = 0; k < arr[i].size() ; k++){
        if(!v[arr[i][k]])
           dfs(arr[i][k],arr,v);
    }
}
int main() {
    int n ,m ,k;
    cin>>n>>m;
    map<int,int> mp;
    for(int i =  0; i < n ; i++){
        cin>>k;
        mp[k]++;
    }
    for(int i = 0; i < m ; i++){
        cin>>k;
        mp[k]++;
    }
    for(auto [x,y] : mp){
        if(y == 1)
        cout<<x<<" ";
    }
}

#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
#define inf INT_MAX
#define linf LLONG_MAX
#define lninf LLONG_MIN
const int mod = 1e9 + 7;
const int N = 1e5 + 4;
typedef long double ld;

int solve()
{
	int n, m, k; scn(n); scn(m); scn(k);

	pair<ld, ld> p = {0.0, 0.0};

	vector<int> mark(n + 1, 0);

	rep(i, 0, k)
	{
		int val; scn(val);

		mark[val]++;
	}

	int cnt = 0;

	rep(i, 1, n)
	{
		if(mark[i])
		cnt++;
		else
		{
			if(cnt >= m)
			{
				pri(-1); return 0;
			}

			cnt = 0;
		}
	}

	if(cnt >= m)
	{
		pri(-1); return 0;
	}

	vector<pair<ld, ld>> v(n + m + 1, {0.0, 0.0});

	for(int i = n - 1; i >= 0; i--)
	{
		p.F -= v[i + m + 1].F; p.S -= v[i + m + 1].S;

		if(mark[i])
		{
			v[i].F = 1.0;
		}
		else
		{
			v[i].F = p.F / (ld)m; v[i].S = p.S / (ld)m;

			v[i].S += 1.0;
		}

		// cout << v[i].F << " " << v[i].S << endl;

		if(i == 0)
		cout << fixed << setprecision(10) << v[i].S / (1.0 - v[i].F);

		p.F += v[i].F; p.S += v[i].S;
	}

	return 0;
}

int main()
{
	int t = 1; //scn(t);

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

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<pll> vpll;

void INX(){}
template<typename Head, typename... Tail>
void INX(Head&& head, Tail&&... tail)
{
    cin >> head;
    INX(forward<Tail>(tail)...);
}
void OUTX(){}
template<typename Head, typename... Tail>
void OUTX(Head&& head, Tail&&... tail)
{
    cout << head << endl;
    OUTX(forward<Tail>(tail)...);
}

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>

int main()
{
    ll N;
    INX(N);

    vpll xy(N);
    for (ll i = 0; i < N; i++)
    {
        INX(xy[i].first, xy[i].second);
    }
    sort(xy.begin(), xy.end());

    ll cnt = 0;
    bool isEnd = false;
    for (ll i = 0; i < N - 1; i++)
    {
        if(xy[i].first == xy[i + 1].first)
        {
            cnt++;
            if(cnt == 2)
            {
                isEnd = true;
                OUTX("Yes");
                break;
            }
        }
        else
        {
            cnt = 0;
        }
    }

    for (ll i = 0; !isEnd && i < N - 2; i++)
    {
        for (ll j = i + 1; !isEnd && j < N - 1; j++)
        {
            if(xy[i].first == xy[j].first)
            {
                continue;
            }

            pll dif = MP(xy[j].first - xy[i].first, xy[j].second - xy[i].second);
            ld a = (ld)dif.second / (ld)dif.first;
            ld b = (ld)xy[i].second - a * (ld)xy[i].first;

            for (ll k = j + 1; !isEnd && k < N; k++)
            {
                ld tmp = (ld)xy[k].second - (a * (ld)xy[k].first + b);
                if(abs(tmp) < 0.000000001)
                {
                    isEnd = true;
                    OUTX("Yes");
                    break;
                }
            }
        }
    }

    if(!isEnd)
    {
        OUTX("No");
    }

    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; }
// #define DEBUG

int main() {
  #ifdef DEBUG
  const time_t START_MILLISEC = time(NULL) * 1000;
  #endif
  int N; cin >> N;
  vector<int> x(N);
  vector<int> y(N);
  rep (i, N) cin >> x[i] >> y[i];

  bool flag = false;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      for (int k = j+1; k < N; k++) {
        int xi = x[i] - x[k], yi = y[i] - y[k];
        int xj = x[j] - x[k], yj = y[j] - y[k];
        if (xi * yj == xj * yi) flag = true;
        // double aij = (y[j] - y[i]) / (double)(x[j] - x[i]);
        // double yk = aij * (x[k] - x[i]) + y[i];
        // if (yk == (double)y[k]) {
          // flag = true;
          // printf("y=%lf(x-%d)+%d\n yk=%lf, y[k]=%d\n", aij, x[i], y[i], yk, y[k]);
        // }
      }
    }
  }

  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  // scanf("%d%d%d%d", &, &, &, &);
  #ifdef DEBUG
  const time_t END_MILLISEC = time(NULL) * 1000;
    cout << e-s << endl;
  #endif
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
// #define LOCAL // 提出時はコメントアウト
#define DEBUG_

typedef long long ll;
const double EPS = 1e-9;
const ll INF = ((1LL<<62)-(1LL<<31));
typedef vector<ll> vecl;
typedef pair<ll, ll> pairl;
template<typename T> using uset = unordered_set<T>;
template<typename T, typename U> using mapv = map<T,vector<U>>;
template<typename T, typename U> using umap = unordered_map<T,U>;

#define ALL(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define sz(x) (ll)x.size()
ll llceil(ll a,ll b) { return (a+b-1)/b; }
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; }
template<class T> vector<vector<T>> genarr(ll n, ll m, T init) { return vector<vector<T>>(n,vector<T>(m,init)); }

///// DEBUG
#define DUMPOUT cerr
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
template<typename T>istream&operator>>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<typename T,typename U>ostream&operator<<(ostream&os,pair<T,U>&pair_var){os<<"("<<pair_var.first<<", "<<pair_var.second<<")";return os;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&vec){os<<"{";for(int i=0;i<vec.size();i++){os<<vec[i]<<(i+1==vec.size()?"":", ");}
os<<"}";return os;}
template<typename T,typename U>ostream&operator<<(ostream&os,map<T,U>&map_var){os<<"{";repi(itr,map_var){os<<*itr;itr++;if(itr!=map_var.end())os<<", ";itr--;}
os<<"}";return os;}
template<typename T>ostream&operator<<(ostream&os,set<T>&set_var){os<<"{";repi(itr,set_var){os<<*itr;itr++;if(itr!=set_var.end())os<<", ";itr--;}
os<<"}";return os;}
void dump_func(){DUMPOUT<<endl;}
template<class Head,class...Tail>void dump_func(Head&&head,Tail&&...tail){DUMPOUT<<head;if(sizeof...(Tail)>0){DUMPOUT<<", ";}
dump_func(std::move(tail)...);}
#ifndef LOCAL
#undef DEBUG_
#endif
#ifdef DEBUG_
#define DEB
#define dump(...)                                                          \
DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
        << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
        << endl                                                            \
        << "    ",                                                         \
    dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif

//////////

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

int solve(ostringstream &cout) {
    #ifdef LOCAL
    ifstream in("../../Atcoder/input.txt");
    cin.rdbuf(in.rdbuf());
    #endif

    ll A,B;
    cin>>A>>B;

    ll N = B - A + 1;
    vecl P = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71};
    while (sz(P) > 0 && N < P.back()) P.pop_back();

    ll U = 1LL<<sz(P);
    auto dp = genarr(N+1,U+1,0LL);

    dp[0][0] = 1;
    ll ans = 0;
    rep(i,N) {
        ll x = i + A;
        ll mask = 0;
        rep(j,sz(P)) {
            if (x % P[j]) continue;
            mask += 1LL<<j;
        }
        rep(S,U) {
            if ((mask & S) == 0) dp[i+1][S | mask] += dp[i][S];
            dp[i+1][S] += dp[i][S];
        }
        if (i == N-1) {
            rep(S,U) ans += dp[i+1][S];
        }
    }

    cout << ans << endl;

    return 0;
}

int main() {
    ostringstream oss;
    int res = solve(oss);

    cout << oss.str();
    return res;
}

#include <stdio.h>

using namespace std;

long long pr[20] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71};
long long a, b, n, ans = 1;
long long dp[1 << 21];
long long te[73];

void dfs(long long now, long long t) {
  if (t == n) {
    return;
  }
  for (int i = t; i < n; i++) {
    if (!(now & te[i])) {
      dfs(now | te[i], i + 1);
      ans++;
    }
  }
}

int main() {
  long long a, b;
  scanf("%lld%lld", &a, &b);
  n = b - a + 1;
  for (long long i = a; i <= b; i++) {
    for (int j = 0; j < 20; j++) {
      if (i % pr[j] == 0) {
        te[i - a] = te[i - a] | (1 << j);
      }
    }
  }
  dfs(0, 0);
  printf("%lld", ans);
}


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

const int64_t MAX = 10000000000;

int64_t is_valid(string &S, string &T){
  int64_t ret = -1;
  for(int i=0; i<S.size() - T.size()+1; i++){
    bool flag = true;
    for(int j=0; j<T.size(); j++){
      if(S[i+j] != T[j]){
        flag = false;
      }
    }
    if(flag){
      ret = i;
      break;
    }
  }
  return ret;
}

int main(){
  int N;
  cin >> N;
  string T;
  cin >> T;
  if(T == "1"){
    cout << MAX*2 << endl;
    return 0;
  }
  if(T == "11" || T == "0"){
    cout << MAX << endl;
    return 0;
  }

  string A = "110";
  string S = "";
  for(int i=0; i<(N+4)/3; i++){
    S += A;
  }
  //cout << S << endl;

  int64_t x = is_valid(S,T);
  if(x == -1){
    cout << 0 << endl;
  }
  else{
    int64_t ok = 0;
    int64_t ng = MAX+10;
    while(ng - ok > 1){
      int64_t mid = (ok+ng)/2;
      if((mid-1)*3 + N <= MAX*3 - x){
        ok = mid;
      }
      else{
        ng = mid;
      }
    }
    cout << ok << endl;
  }

}

#include "bits/stdc++.h"
#pragma GCC optimize "trapv"

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

#define pb push_back
#define endl "\n"

#define F first
#define S second

#define drink_boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(v) v.begin(),v.end()

#define TEST_CASE int  t;cin>>t;while(t--)
#define debug(...) cout<<#__VA_ARGS__<<" = "; print(__VA_ARGS__);

using namespace std;
const int MOD = 1e9 + 7;

void print()  {    cout<<endl;  }
void printArray()  {    return;  }
void read() { return; }

template<typename T , typename... Args>  void print(T a , Args... arg)    {    cout << a << " " ;    print(arg...);    }

template<typename T , typename... Args> void read(T &a , Args&... arg) {   cin >> a;   read(arg...);   }

template<typename T,typename... Args> void read(vector<T>&v , Args&... arg) {  for(auto &i : v)  cin>>i;  read(arg...);  }

template<typename T,typename... Args> void printArray(vector<T>&v, Args&... arg) {   for(auto i : v)     cout<<i<<" ";   cout<<endl;  printArray(arg...);    }

int power(int a,int b) { int  res=1; while(b) { if(b&1LL) res=res*a; b>>=1LL; a=a*a; } return res; }

int modPower(int a,int b) { int res=1; while(b) { if(b&1L) res=(res%MOD*a%MOD)%MOD; b>>=1; a=(a%MOD*a%MOD)%MOD; } return res; }

int gcdExtended(int a,int b,int *x,int *y){ if(a==0) { *x=0,*y=1; return b; } int x1,y1; int gcd=gcdExtended(b%a,a,&x1,&y1); *x=y1-(b/a)*x1; *y = x1; return gcd; }

int modInverse(int b,int m) {int x,y; int g=gcdExtended(b,m,&x,&y); if (g != 1) return -1; return (x%m + m) % m; }

int modDivide(int a,int b,int m=MOD) { a=a%m; int inv=modInverse(b,m); if(inv==-1) return -1; else return (inv*a)%m; }

void runCase_()
{
   int n,a,b;
   read(n,a,b);
   int ans = n - a + b;
   print(ans);
}

signed main()
{
    drink_boost;
    // TEST_CASE
    runCase_();
    return 0;
}

/** TEST CASES HERE **/
/*

*/


#include <bits/stdc++.h>
#define endl "\n"
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define rep2(i, s, n) for(int i = (s); i < int(n); i++)
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ipair;
typedef pair<ll, ll> lpair;
template <class T> ostream &operator << (ostream &o, const vector<T> &v) //vectorの中身を見る
{o << "{"; for(int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", ":"") << v[i]; o << "}"; return o;}
void map_p(map<int, int> &d){cout << "map: "; for(auto a : d){cout << "{" << a.first << ":" << a.second << "}, ";} cout << endl;} //mapの中身を見る
void set_p(set<int> &d){cout << "set: "; for(int a : d){cout << a << ", ";} cout << endl;} //setの中身を見る

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

    ll n, cnt = 0;
    cin >> n;
    ll max_ = pow(10, 5) + 3;
    set<ll> kinds;
    rep2(i, 2, max_){
        ll now = i;
        while(true){
            now *= i;
            if(n < now) break;
            if(kinds.find(now) == kinds.end()){ // a^b = c^dのこともある
                cnt++;
                kinds.insert(now);
            }
        }
    }
    cout << n - cnt << endl;
    return 0;
}

#include<cstdio>
#include<iostream>
#include<cmath>
#define ll long long
using namespace std;
int main()
{
	ll n;
	scanf("%lld",&n);
	for(ll i = 1; i<=sqrt(n); i++)
	{
		if(n%i==0)
		cout<<i<<endl;
	}
	for(ll i = sqrt(n); i>=1; i--)
	{
		if(i*i!=n)
		 if(n%i==0)
	    	cout<<n/i<<endl;
	}
 }


#ifdef _LOCAL
#	include <dbg_print.h>
#else
#	define NDEBUG
#	define dprint(...)
#endif

#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#include <assert.h>
using namespace std;
typedef long long ll;

bool connected[32][32] = {0};
int n, m;

int check_hist[1<<18] = {0};

bool check(int nodes)
{
	if(check_hist[nodes])
		return (check_hist[nodes] == 2);

	for(int i=0; i<n; ++i)
	{
		if(nodes & (1<<i))
		{
			for(int j=0; j<i; ++j)
			{
				if(nodes & (1<<j))
				{
					if(!connected[i][j])
					{
						check_hist[nodes] = 1;
						return false;
					}
				}
			}
		}
	}

	check_hist[nodes] = 2;
	return true;
}

int hist[1<<18] = {0};

int solve(int nodes)
{
	assert(nodes);

	if(hist[nodes])
		return hist[nodes];

	if(check(nodes))
		return 1;

	int n1 = __builtin_popcount(nodes);
	int res = 999;

	for(int submask=1; submask<(1<<n1); ++submask)
	{
		int mask = 0;
		for(int i=0,j=0; i<n; ++i) if(nodes & (1<<i))
		{
			if((submask>>j)&1)
				mask |= (1<<i);
			++j;
		}
		if(!check(mask))
			continue;

		int r = 1 + solve(nodes & (~mask));
		res = std::min(res, r);
	}

	return hist[nodes] = res;
}

int solve2(int fullMask, int i0, int currMask)
{
	if(!fullMask)
		return 0;

	if(currMask == 0)
	{
		if(hist[fullMask])
			return hist[fullMask];

		if(check(fullMask))
			return 1;
	}

	int res = 999;
	if(currMask)
		res = 1 + solve2(fullMask & (~currMask), 0, 0);

	for(int i=i0; i<n; ++i) if(fullMask & (1<<i))
	{
		currMask |= (1<<i);

		if(check(currMask))
		{
			int r = solve2(fullMask, i+1, currMask);
			res = std::min(res, r);
		}

		currMask &= ~(1<<i);
	}

	if(currMask == 0)
		hist[fullMask] = res;

	return res;
}

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

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

	int ans = solve2((1<<n)-1, 0, 0);
	cout << ans << "\n";

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;

signed main(){

    int N, M; cin >> N >> M;
    vec A(M), B(M);
    bool f[18][18] = {};
    REP(i, M){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        f[A[i]][B[i]] = true;
        f[B[i]][A[i]] = true;
    }

    v_bool ok(bit(N), false);
    FOR(b, 1, bit(N)){
        bool t = true;
        REP(i, N) REP(j, i) if((b >> i) & (b >> j) & 1){
            if(!f[i][j]) t = false;
        }
        ok[b] = t;
    }

    vec dp(bit(N), INF);
    dp[0] = 0;
    FOR(sup, 1, bit(N)){
        int sub = sup;
        do{
            if(ok[sub]){
                chmin(dp[sup], dp[sup ^ sub] + 1);
            }
            sub = (sub - 1) & sup;
        }while(sub != sup);
    }
    Out(dp[bit(N) - 1]);

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9;

signed main()
{
    int a,b;
    cin>>a>>b;
    a=a*2+100;
    cout<<max(0ll,a-b)<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if (15<=a+b&&8<=b){
        cout<<1;
    }
    else if (10<=a+b&&3<=b){
        cout<<2;
    }
    else if (3<=a+b){
        cout<<3;
    }
    else{
        cout<<4;
    }
}


#include <bits/stdc++.h>

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(40)

const ll MOD = 7;
const ll INF = (ll) 1e15;

char C[2] = {'T', 'A'};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S, X;
    cin >> S >> X;

    ll c = 0;
    vector<bool> U(10, false);
    U[0] = true;
    ll p = 1;
    REP(i, N) {
        ll m = (S[N - 1 - i] - '0') * p % MOD;
        if (X[N - 1 - i] != C[c]) {
            c = (c + 1) % 2;
            REP(j, U.size()) {
                U[j] = !U[j];
            }
        }
        vector<bool> u(10, false);
        REP(j, U.size()) {
            u[j] = u[j] || U[j] || U[(j + m) % 7];
        }
        swap(U, u);
        p = p * 10 % MOD;
#if false
        REP(j, 7) {
            if (U[j])
                cout << "O";
            else
                cout << ".";
        }
        cout << endl;
#endif
    }

    bool aoki = false;
    if (C[c] == 'T') {
        if (!U[0])
            aoki = true;
    }
    else {
        if (U[0])
            aoki = true;
    }

    if (aoki)
        cout << "Aoki" << endl;
    else
        cout << "Takahashi" << endl;
    return 0;
}

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

int n;
int dp[200001][8] ;
string s, x ;

bool fun(int idx, int num) {
	if (idx > n) return (num == 0) ;
	int &ret = dp[idx][num] ;
	if (ret != -1) return ret ;
	int cur = 0 ;
	if (x[idx] == 'A') {
		cur = fun(idx+1, (num * 10)%7) ;
		if (cur == 1) cur = fun(idx+1, (num * 10 + (s[idx] - '0'))%7) ;
	}
	else {
		cur = fun(idx+1, (num * 10)%7) ;
		if (cur == 0) cur = fun(idx+1, (num * 10 + (s[idx] - '0'))%7) ;
	}
	return ret = cur ;
}

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

    cin >> n >> s >> x;
    s = "#" + s ;
    x = "#" + x ;
    memset(dp, -1, sizeof(dp)) ;
    bool ok = fun(1, 0) ;
    string ans = "Aoki" ;
    if (ok) ans = "Takahashi" ;
    cout << ans << endl ;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in) for(ll i=0; i<(ll)in.size(); i++) cin>>in[i]
#define forout(out) for(ll i=0; i<(ll)out.size(); i++) cout<<out[i]<<" "
#define rep(i, n) for(ll i=0; i<(n); i++)
#define rep_up(i, a, n) for (ll i = a; i < n; ++i)
#define rep_down(i, a, n) for (ll i = a; i >= n; --i)
#define P 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; }
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define vvvll vector<vector<vector<ll>>>
#define vvll vector<vector<ll>>
#define vll vector<ll>
#define pqll priority_queue<ll>
#define pqllg priority_queue<ll, vector<ll>, greater<ll>>
constexpr ll INF = (1ll << 60);
constexpr ll mod = 1000000007;

int main() {
    ll N; cin >> N;
    vll A(N+1); rep(i,N) cin >> A[i];
    A[N] = 0;
    sort(all(A));
    ll ans = 1;
    rep(i,N) {
        ans *= (A[i+1]-A[i]+1);
        ans %= mod;
    }
    cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<lint> V1(N), V2(N);
  IREP(i, N) cin >> V1[i];
  REP(i, N) cin >> V2[i];
  multiset<lint> st;
  REP(i, N) {
    if(st.size() > 0 && *st.begin() < min(V1[i], V2[i])) {
      st.erase(st.begin());
      st.insert(V1[i]);
      st.insert(V2[i]);
    } else {
      st.insert(max(V1[i], V2[i]));
    }
  }
  lint ans = 0;
  for(lint x : st) ans += x;
  cout << ans << endl;
}


#include <bits/stdc++.h>

#define _overload(_1, _2, _3, _4, name, ...) name
#define _rep1(Itr, N) _rep3(Itr, 0, N, 1)
#define _rep2(Itr, a, b) _rep3(Itr, a, b, 1)
#define _rep3(Itr, a, b, step) for (i64(Itr) = a; (Itr) < b; (Itr) += step)
#define repeat(...) _overload(__VA_ARGS__, _rep3, _rep2, _rep1)(__VA_ARGS__)
#define rep(...) repeat(__VA_ARGS__)

using namespace std;
using i64 = long long;
using u64 = unsigned long long;

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

    i64 n, m, q;
    cin >> n >> m >> q;
    vector<pair<i64, i64>> item(n);  // first:w, second: v;
    for (auto &vs : item) cin >> vs.first >> vs.second;

    vector<pair<i64, i64>> x(m);  // first:const, second: idx;
    repeat(i, m) {
        cin >> x[i].first;
        x[i].second = i;
    }

    sort(x.begin(), x.end());
    sort(item.begin(), item.end());

    repeat(_, q) {
        i64 l, r;
        cin >> l >> r;
        l--;

        i64 ans = 0;
        int idx = 0;  // item_idx;
        priority_queue<i64> que;
        for (auto c : x) {
            if (l <= c.second && c.second < r) continue;

            while (idx < n && item[idx].first <= c.first) {
                que.push(item[idx].second);
                idx++;
            }

            if (!que.empty()) {
                ans += que.top();
                que.pop();
            }
        }

        cout << ans << endl;
    }

    return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

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

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, M, Q;
ll W[100], V[100];
ll X[100];
std::vector<P> ps;
ll dp[60][60];

int main() {
  std::cin >> N >> M >> Q;

  rep( i, N ) {
    std::cin >> W[i] >> V[i];

    ps.emplace_back(W[i], V[i]);
  }

  std::sort(all(ps));

  rep( i, M )
    std::cin >> X[i];

  rep( q, Q ) {
    ll L, R;
    std::cin >> L >> R;

    std::vector<ll> xs;

    rep( i, M ) {
      if( i >= L-1 && i < R )
        continue;

      xs.emplace_back(X[i]);
    }

    std::sort(all(xs));

    ll m = xs.size();

    rep( i, N+5 ) rep( j, m+5 )
      dp[i][j] = 0;

    rep( i, N ) rep( j, m+1 ) {
      ll k = std::lower_bound( xs.begin()+j, xs.end(), ps[i].first )-xs.begin();

      chmax( dp[i+1][k+1], dp[i][j]+ps[i].second );
      chmax( dp[i+1][j], dp[i][j] );
    }

    ll ans = 0;

    rep( j, m+1 )
      chmax( ans, dp[N][j] );

    std::cout << ans << endl;
  }

  return 0;
}


#include <bits/stdc++.h>
#define M 1000000007
#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define d(x) cout << #x << " " << x << "\n";
#define min(x1, x2) (x1 > x2 ? x2 : x1)
#define max(x1, x2) (x1 < x2 ? x2 : x1)
#define min3(x1, x2, x3) (x3 > min(x1, x2) ? min(x2, x1) : x3)
#define max3(x1, x2, x3) (x3 < max(x1, x2) ? max(x1, x2) : x3)
#define ll long long int
#define ul unsigned long long int
#define p pair<ll, ll>
#define ld long double
#define dv(v)                            \
    cerr << #v << "  ";                  \
    for (int i = 0; i < (v).size(); i++) \
        cerr << v[i] << " ";             \
    cerr << "\n";
#define inf INT_MAX
#define mp(x, y) make_pair(x, y)
using namespace std;

vector<tuple<ul, ul, ul>> v;
ul dp[1 << 18][101];
int n;
int m;

ul fact[19];
void fac(ul n)
{
    fact[0] = 1;
    for (ul i = 1; i <= n; ++i)
    {
        fact[i] = (fact[i - 1] * i);
    }
}

ll rec(ul i, int j)
{
    if (dp[i][j] != -1)
    {
        return dp[i][j];
    }
    bitset<18> b(i);
    if (j == m)
    {
        int tn = 0;
        for (int k = 0; k < n; ++k)
        {
            if (b[k] == 1)
            {
                ++tn;
            }
        }
        return dp[i][j] = fact[n - tn];
    }
    ul x = get<0>(v[j]);
    ul y = get<1>(v[j]);
    ul z = get<2>(v[j]);
    int no = 0;
    int tn = 0;
    for (int k = 0; k < n; ++k)
    {
        if (b[k] == 1)
        {
            ++tn;
        }
        if (b[k] == 1 && k + 1 <= y)
        {
            ++no;
        }
    }
    if (no > z)
    {
        return dp[i][j] = 0;
    }
    else
    {
        if (tn == x)
        {
            return dp[i][j] = rec(i, j + 1);
        }
        else
        {
            dp[i][j] = 0;
            for (ll k = 0; k < n; ++k)
            {
                if (b[k] == 0)
                {
                    dp[i][j] += rec(i + (1 << k), j);
                }
            }
            return dp[i][j];
        }
    }
}

int main()
{
    fio;
    ll t, x, y, z, k;
    cin >> n >> m;
    memset(dp, -1, sizeof(dp));
    fac(18);
    t = m;
    while (t--)
    {
        cin >> x >> y >> z;
        v.push_back(make_tuple(x, y, z));
    }
    sort(v.begin(), v.end());
    cout << rec(0, 0) << "\n";
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b); i-- > (a); )
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int((x).size())
#define lb(x...) lower_bound(x)
#define ub(x...) upper_bound(x)

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

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

const int N = 1 << 18;
int n, a[N], b[N], p[N], inv[N], ord[N];
vector<pair<int, int>> op;

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

    int n; cin >> n;
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    rep(j, 0, n) cin >> p[j], --p[j], inv[p[j]] = j;

    bool impossible = false;
    rep(i, 0, n) if (p[i] != i && a[i] <= b[p[i]]) impossible = true;
    if (impossible) return cout << "-1", 0;

    rep(i, 0, n) ord[i] = i;
    sort(ord, ord + n, [&](int x, int y) { return a[x] < a[y]; });

    rep(k, 0, n) {
        int i = ord[k];
        if (p[i] == i) continue;
        int j = inv[i];
        op.emplace_back(i, j);
        inv[i] = i;
        p[j] = p[i];
        inv[p[j]] = j;
    }
    cout << sz(op) << '\n';
    for (auto [i, j] : op) cout << i + 1 << ' ' << j + 1 << '\n';
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")

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

// size(x), rbegin(x), rend(x) need C++17
#define sz(x) int((x).size())
#define all(x) begin(x), end(x)
#define rall(x) x.rbegin(), x.rend()
#define sor(x) sort(all(x))
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second

#define mset(a,b) memset(a, b, sizeof(a))
#define dbg(x) cout << "[" << #x << "]: " << x << endl;
#define forn(i,n) for(int i=0; i < n;i++)
#define nrof(i,n) for(int i = n-1; i >= 0; i--)
#define fori(i,a,b) for(int i = a; i <= b; i++)
#define irof(i,b,a) for(int i = b; i >= a; i--)
#define each(val, v) for(auto &val : v)

using ll = long long;
using db = long double; //pode ser double

using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<string>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;

const int MAXN = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const db EPS = 1e-9;
const db PI = acos((db)-1);

void solve(){
    int n;
    cin >> n;
    n -= 1;
    cout << n << '\n';
}

int main(){

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

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

    return 0;
}

/*
PRESTA ATENCAO!!!!

NAO FIQUE PRESO EM UMA ABORDAGEM
A SUA INTUICAO PODE ESTAR ERRADA - TENTE OUTRAS COISAS
LIMPOU TUDO PARA O PROXIMO CASO?
caso especial? n == 1

*/

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

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    ll max=0,res=-1;
    for(ll i=0;i<n;i++)     cin>>a[i];
    for(ll i=2;i<1000;i++)
    {
        ll cnt=0;
        for(ll j=0;j<n;j++){
            if(a[j]%i==0)       cnt++;
        }
        if(cnt>max)     max=cnt,res=i;
    }
    cout<<res;
    return 0;
}


/**
*    author: kuins_air
*    created: 28.05.2021 11:21:10
**/

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

string S;
int main() {
    cin >> S;
    int n = (int)S.size();
    rep(i, 1, (int)S.size() + 1) {
        if(S[n-i] == '0') cout << 0;
        if(S[n-i] == '1') cout << 1;
        if(S[n-i] == '6') cout << 9;
        if(S[n-i] == '8') cout << 8;
        if(S[n-i] == '9') cout << 6;
    }
    cout << endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int N=4e5+10;
int T,n;
char s1[N],s2[N],s3[N];
int pos[4][2][N],now[4];
int main(){
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);
		scanf("%s%s%s",s1+1,s2+1,s3+1);
		for(int i=1;i<=n;++i) printf("0");
		for(int i=1;i<=n;++i) printf("1");
		printf("0\n");
	}
	return 0;
}


//#include<i_am_noob_orz>
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define int ll
#define ull unsigned long long
#define pii pair<int,int>
#define X first
#define Y second
#define mod ((ll)1e9+7)
#define pb push_back
#define mp make_pair
#define abs(x) ((x)>0?(x):(-(x)))
#define F(n) Fi(i,n)
#define Fi(i,n) Fl(i,0,n)
#define Fl(i,l,n) for(int i=l;i<n;i++)
#define memres(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
#define sz(a) ((int)a.size())
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define endl '\n'
#define bit_count(x) __builtin_popcountll((x))
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define jimmy_is_kind false
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;

//#define LOCAL
#ifdef LOCAL
#define bug(...) cerr<<"#"<<__LINE__<<' '<<#__VA_ARGS__<<"- ", _do(__VA_ARGS__)
template<typename T> void _do(T && x) {cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T && x, S&&...y) {cerr<<x<<", "; _do(y...);}
#define IOS()
#else
#define IOS() ios_base::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define bug(...)
#endif

int add(int a,int b){return(a+b>=mod?a+b-mod:a+b);}
int sub(int a,int b){return(a<b?a+mod-b:a-b);}
int po(int a,int b){
	if(b==0)return 1;
	if(b==1)return(a%mod);
	int tem=po(a,b/2);
	if(b&1)return(((tem*tem)%mod)*a)%mod;
	else return(tem*tem)%mod;
}
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}

signed main(){
	IOS();
	int n;
	cin>>n;
	int lg=__lg(n)+1;
	F(n){
		int x=(i+1)*2;
		if((x%n)==0)x=n;
		else x=(x%n);
		cout<<x<<" ";
		x=(i+1)*2+1;
		if((x%n)==0)x=n;
		else x=(x%n);
		cout<<x<<endl;
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string(string(s)); }
string to_string(bool b) { return to_string(int(b)); }
string to_string(vector<bool>::reference b) { return to_string(int(b)); }
string to_string(char b) { return "'" + string(1, b) + "'"; }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) {
	string res = "{";
	for (const auto& x : v) res += (res == "{" ? "" : ", ") + to_string(x);
	return res + "}";
}
void debug() { cerr << endl; }
template <typename Head, typename... Tail>
void debug(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug(T...);
}
#define db(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define db(...) 42
#endif
typedef long long ll;
typedef long double ld;
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		printf("%d %d\n", 2 * i % n + 1, (2 * i + 1) % n + 1);
	}
}


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

int main(){
    int n;
    cin >> n;
    vector<pair<int, int>> p(n);
    for(auto& [x, y] : p) cin >> x >> y;
    for(int i = n; i--; ) for(int j = i; j--; ) for(int k = j; k--; ){
        auto [x1, y1] = p[i];
        auto [x2, y2] = p[j];
        auto [x3, y3] = p[k];
        x1 -= x3;
        x2 -= x3;
        y1 -= y3;
        y2 -= y3;
        if(x1 * y2 == x2 * y1){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
}


#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> v[100000];

pair<int, pair<int, int>> dfs(int x) {
    int p1 = 0, p2 = 0, sa = 0, sb = 0, f = 0, i;
    vector<pair<int, pair<int, int>>> w;

    p1++;
    f = 1 - f;

    for (i = 0; i < v[x].size(); i++) {
        pair<int, pair<int, int>> p = dfs(v[x][i]);
        int x = p.second.first;
        int y = p.second.second;

        if (p.first == 0) {
            if (x <= y) {
                p1 += x;
                p2 += y;
            } else {
                sa += x;
                sb += y;
            }
        } else {
            w.push_back(make_pair(x - y, make_pair(x, y)));
        }
    }

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

    for (i = 0; i < w.size(); i++) {
        int x = w[i].second.first;
        int y = w[i].second.second;

        if (f == 1) {
            p1 += x;
            p2 += y;
        } else {
            p1 += y;
            p2 += x;
        }

        f = 1 - f;
    }

    if (f == 1) {
        p1 += sa;
        p2 += sb;
    } else {
        p1 += sb;
        p2 += sa;
    }

    return make_pair(f, make_pair(p1, p2));
}

int main() {
    int n, i;

    scanf("%d", &n);

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

        scanf("%d", &p);

        v[p - 1].push_back(i);
    }

    printf("%d\n", dfs(0).second.first);

    return 0;
}

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

// DEBUG BEGIN
#ifdef LOCAL
template<class L, class R> ostream &operator<<(ostream &out, const pair<L, R> &p){
	return out << "(" << p.first << ", " << p.second << ")";
}
template<class Tuple, size_t N> struct TuplePrinter{
	static ostream &print(ostream &out, const Tuple &t){ return TuplePrinter<Tuple, N-1>::print(out, t) << ", " << get<N-1>(t); }
};
template<class Tuple> struct TuplePrinter<Tuple, 1>{
	static ostream &print(ostream &out, const Tuple& t){ return out << get<0>(t); }
};
template<class... Args> ostream &print_tuple(ostream &out, const tuple<Args...> &t){
	return TuplePrinter<decltype(t), sizeof...(Args)>::print(out << "(", t) << ")";
}
template<class ...Args> ostream &operator<<(ostream &out, const tuple<Args...> &t){
	return print_tuple(out, t);
}
template<class T> ostream &operator<<(class enable_if<!is_same<T, string>::value, ostream>::type &out, const T &arr){
	out << "{"; for(auto x: arr) out << x << ", ";
	return out << (arr.empty() ? "" : "\b\b") << "}";
}
template<size_t S> ostream &operator<<(ostream &out, const bitset<S> &b){
	for(auto i = 0; i < S; ++ i) out << b[i];
	return out;
}
void debug_out(){ cerr << "\b\b " << endl; }
template<class Head, class... Tail>
void debug_out(Head H, Tail... T){ cerr << H << ", ", debug_out(T...); }
void debug2_out(){ cerr << "\n"; }
template<class Head, class... Tail>
void debug2_out(Head H, Tail... T){ cerr << "\n"; for(auto x: H) cerr << x << "\n"; debug2_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#define debug2(...) cerr << "[" << #__VA_ARGS__ << "]", debug2_out(__VA_ARGS__)
#else
#define debug(...) 42
#define debug2(...) 42
#endif
// DEBUG END

int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	int n;
	cin >> n;
	vector<vector<int>> adj(n);
	for(auto u = 1; u < n; ++ u){
		int p;
		cin >> p, -- p;
		adj[p].push_back(u);
	}
	vector<int> sz(n, 1);
	function<void(int)> dfs_sz = [&](int u){
		for(auto v: adj[u]){
			dfs_sz(v);
			sz[u] += sz[v];
		}
	};
	dfs_sz(0);
	vector<int> dp(n, 1);
	function<void(int)> dfs = [&](int u){
		int sum = 0;
		array<vector<array<int, 2>>, 2> t;
		for(auto v: adj[u]){
			dfs(v);
			t[sz[v] & 1].push_back({dp[v], sz[v] - dp[v]});
			sum += dp[v];
		}
		if(t[1].empty()){
			dp[u] += sum;
		}
		else{
			if((int)t[1].size() & 1){
				for(auto [x, y]: t[0]){
					dp[u] += min(x, y);
				}
			}
			else{
				for(auto [x, y]: t[0]){
					dp[u] += x;
				}
			}
			sort(t[1].begin(), t[1].end(), [&](auto x, auto y){ return x[0] - x[1] < y[0] - y[1]; });
			for(auto i = 0; i < (int)t[1].size(); ++ i){
				dp[u] += t[1][i][i & 1];
			}
		}
	};
	dfs(0);
	debug(dp);
	cout << dp[0] << "\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                   Coded by Aeren                                   //
//                                                                                //
////////////////////////////////////////////////////////////////////////////////////////


#include <iostream>
using namespace std;

#define N 805
#define MAX_A 1000000000
#define rep(i, n) for(int i = 0; i < n; ++i)

int main() {
	int n, k, lim;
	int a[N][N];
	int s[N][N];
	rep(i, N) {
		s[i][0] = 0;
		s[0][i] = 0;
	}
	int ng = -1;
	int ok = MAX_A;
	int mid;
	bool ext;
	cin >> n >> k;
	lim = ((k * k) / 2) + 1;
	rep(i, n) {
		rep(j, n) {
			cin >> a[i][j];
		}
	}

	while ((ng + 1) < ok) {
		mid = (ng + ok) / 2;
		rep(i, n) {
			rep(j, n) {
				s[i + 1][j + 1] = s[i + 1][j] + s[i][j + 1] - s[i][j];
				if (a[i][j] > mid)
					s[i + 1][j + 1]++;
			}
		}
		ext = false;
		rep(i, n - k + 1) {
			rep(j, n - k + 1) {
				if ((s[i + k][j + k] + s[i][j] - s[i][j + k] - s[i + k][j]) < lim)
					ext = true;
			}
		}
		if (ext)
			ok = mid;
		else
			ng = mid;

	}
	cout << ok << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> pin;

const int N = 805;
const int M = 7e5 + 5;
const int Maxn = 1e9;
const ll P = 998244353LL;
const int inf = 1e9 + 5;

int n, k, pos, a[N][N], sum[N][N], ans = inf;

template <typename T>
inline void read(T &X) {
    char ch = 0; T op = 1;
    for (X = 0; ch > '9' || ch < '0'; ch = getchar())
        if (ch == '-') op = -1;
    for (; ch >= '0' && ch <= '9'; ch = getchar())
        X = (X * 10) + ch - '0';
    X *= op;
}

inline int getSum(int x1, int y1, int x2, int y2) {
    return sum[x2][y2] - sum[x2][y1 - 1] - sum[x1 - 1][y2] + sum[x1 - 1][y1 - 1];
}

inline bool chk(int mid) {
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++) {
            sum[i][j] = 0;
            if (a[i][j] <= mid) sum[i][j] = 1;
        }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            sum[i][j] += sum[i][j - 1];
    for (int j = 1; j <= n; j++)
        for (int i = 1; i <= n; i++)
            sum[i][j] += sum[i - 1][j];
    for (int i = 1; i <= n - k + 1; i++)
        for (int j = 1; j <= n - k + 1; j++)
            if (getSum(i, j, i + k - 1, j + k - 1) >= pos)
                return 1;
    return 0;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("sample.in", "r", stdin);
    clock_t st_clock = clock();
#endif

    read(n), read(k);
    int m = 0;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            read(a[i][j]);
    pos = k * k - (k * k / 2);
    int l = 0, r = inf, mid, res;
    for (; l <= r; ) {
        mid = (l + r) / 2;
        if (chk(mid)) res = mid, r = mid - 1;
        else l = mid + 1;
    }
    printf("%d\n", res);

#ifndef ONLINE_JUDGE
    clock_t ed_clock = clock();
    printf("time = %f ms\n", (double)(ed_clock - st_clock) / CLOCKS_PER_SEC * 1000);
#endif
    return 0;
}


// youngjinp20
// 2021 06

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

#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; }
#define byr(x) [](const auto& a, const auto& b) { return a.x > b.x; }
#define smax(a, b) ((a) < (b) ? ((a)=(b), true) : false)
#define smin(a, b) ((a) > (b) ? ((a)=(b), true) : false)
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;

typedef long long ll;

int main() {
	int N;
	cin >> N;
	int i=0;
	int ct=0;
	for (; N > ct; ct += ++i);
	cout << i;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<pll> vpll;
typedef vector<bool> vbl;
typedef vector<vector<bool>> vvbl;

void INX(){}
template<typename Head, typename... Tail>
void INX(Head&& head, Tail&&... tail)
{
    cin >> head;
    INX(forward<Tail>(tail)...);
}
void OUTX(){}
template<typename Head, typename... Tail>
void OUTX(Head&& head, Tail&&... tail)
{
    cout << head << endl;
    OUTX(forward<Tail>(tail)...);
}
void OUTX2(){cout << endl;}
template<typename Head, typename... Tail>
void OUTX2(Head&& head, Tail&&... tail)
{
    cout << head << ' ';
    OUTX2(forward<Tail>(tail)...);
}

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>
#define __LONG_LONG_MIN__ (-__LONG_LONG_MAX__ - 1)

//#define MOD 1000000007 // 10^9 + 7
//setprecision(10)

ll InputDecimalAsLL2(ll base)
{
    string s;
    INX(s);
    int pos = s.find('.');

    ll result1 = stoll(s.substr(0, pos));
    for(ll i = 0; i < base; i++) result1 *= 10;

    ll result2;
    if(pos < 0) result2 = 0;
    else {
        s = s.substr(pos + 1, s.size() - pos);
        ll ssize = (ll)s.size();
        s.resize(base + 1);
        for(ll i = ssize; i < base; i++) s[i] = '0';
        s[base] = '\0';
        result2 = (pos < 0) ? 0 : stoll(s);
    }

    return result1 + result2;
}

#define MUL 10000
ll MyCeil(ll x)
{
    if(x <= 0)
        return MUL * (x / MUL);
    else
        return MUL * ((x - 1) / MUL + 1);
}

ll MyFloor(ll x)
{
    if(x >= 0)
        return MUL * (x / MUL);
    else
        return MUL * ((x + 1) / MUL - 1);
}

int main()
{
    ll X, Y, R;
    X = InputDecimalAsLL2(4);
    Y = InputDecimalAsLL2(4);
    R = InputDecimalAsLL2(4);

    ll r2 = R * R;
    ll result = 0;
    for(ll nowx = MyCeil(X - R), endx = MyFloor(X + R); nowx <= endx; nowx += MUL)
    {
        ll tmp0 = nowx - X;
        tmp0 *= tmp0;
        ld tmp = sqrt((ld)(r2 - tmp0));
        ll uppery = MyFloor(Y + (ll)tmp) / MUL;
        ll lowery = MyCeil(Y - (ll)tmp) / MUL;
        if(uppery >= lowery)
        {
            result += uppery - lowery + 1;
        }
    }
    OUTX(result);

    return 0;
}


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

int main() {
	int n,t,t1,t2;
	string s,s1,s2;

	cin >> n;
	t1=0;
	t2=-1;
	s1="a";
	s2="b";
	rep(i,n){
		cin >> s >> t;
		if(t>t1){
			t2=t1;
			s2=s1;
			t1=t;
			s1=s;
		}else if(t>t2){
			t2=t;
			s2=s;
		}
	}
	cout << s2 << endl;
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  string S;
  cin >> S;
  deque<char> T;
  int side = 0;
  for (char ch : S) {
    if (ch == 'R') {
      side = 1 - side;
    } else {
      if (side == 0) {
        T.push_back(ch);
      } else {
        T.push_front(ch);
      }
    }
  }
  if (side == 1) {
    side = 0;
    reverse(ALL(T));
  }
  string ans;
  REP(i, T.size()) {
    if (!ans.empty() && ans.back() == T[i]) {
      ans.pop_back();
    } else {
      ans.push_back(T[i]);
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}