#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <functional>
#include <utility>
#include <tuple>
#include <numeric>
#include <queue>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <regex>
#include <stack>
#include <limits>
#include <climits>

using namespace std;

const int M = 998244353;

int dfs(int i, vector<int>& was, vector<vector<int>>& v) {
	was[i] = 1;
	int res = 1;
	for (int next : v[i]) {
		if (was[next] == 0) {
			res += dfs(next, was, v);
		}
	}
	return res;
}

vector<int> calcfact(int n) {
	vector<int> res(n+1);
	res[0] = 1;
	for (int i = 1; i <= n; ++i) {
		res[i] = (res[i - 1] * (long long)i) % M;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<vector<int>> a(n, vector<int>(n, 0));
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			cin >> a[i][j];

	auto f = calcfact(n);
	vector<vector<int>> v(n);
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			bool ok = true;
			for (int z = 0; z < n; ++z) {
				if (a[i][z] + a[j][z] > k) {
					ok = false;
					break;
				}
			}
			if (ok) {
				v[i].push_back(j);
				v[j].push_back(i);
			}
		}
	}

	int res = 1;

	vector<int> was(n, 0);
	for (int i = 0; i < n; ++i) {
		if (was[i] == 0) {
			int cnt = dfs(i, was, v);
			res = (res * (long long)f[cnt]) % M;
		}
	}

	v.assign(n, vector<int>(n, 0));
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			bool ok = true;
			for (int z = 0; z < n; ++z) {
				if (a[z][i] + a[z][j] > k) {
					ok = false;
					break;
				}
			}
			if (ok) {
				v[i].push_back(j);
				v[j].push_back(i);
			}
		}
	}

	was.assign(n, 0);
	for (int i = 0; i < n; ++i) {
		if (was[i] == 0) {
			int cnt = dfs(i, was, v);
			res = (res * (long long)f[cnt]) % M;
		}
	}

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

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <limits>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
template<class T> inline int  sz(T &a) { return a.size(); }
using ll = long long; using ld = long double;
using pi = pair<int,int>; using pl = pair<ll,ll>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
const int inf = numeric_limits<int>::max();
const ll infll = numeric_limits<ll>::max();
// Modint
// modint<MOD> で宣言
template<ll MOD>
struct modint{
  ll x;
  ll mod = MOD;
  modint(ll x=0):x(x%MOD){}
  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(ll t) const{
    if(!t) return 1;
    modint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }

  //for prime mod
  modint inv() const{
    return pow(MOD-2);
  }
  modint& operator/=(const modint a){
    return (*this) *= a.inv();
  }
  modint operator/(const modint a) const{
    modint res(*this);
    return res/=a;
  }
};
using mint = modint<998244353>;

const int NMAX=1000010; // we can calculate nCk until n is equal to NMAX
mint fact[NMAX],infac[NMAX];
void Make_Fact(){
  fact[0]=fact[1]=1;
  for(int i=2;i<=NMAX-1;++i){
    fact[i]=fact[i-1]*(mint)i;
  }
}
void Make_InvFact(){
  infac[0]=infac[1]=1;
  for(int i=2;i<=NMAX-1;++i){
    infac[i]=infac[i-1]/(mint)i;
  }
}
mint Comb(int n,int k){
  if(n<0||k<0||n-k<0) return 0;
  return fact[n]*infac[k]*infac[n-k];
}

struct UFT{
  vector<int> par;//親
  vector<int> rank;//木の深さ
  vector<int> size;//木の大きさ
  int n;

  UFT(int _n)
  {
    n = _n;
    par.resize(n);
    rank.assign(n,0);
    size.assign(n,1);
    rep(i,n){
      par[i] = i;
    }
  }

  //xの根を返す
  int find(int x)
  {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
  }

  //x,yを併合
  void unite(int x,int y)
  {
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rank[x] < rank[y]){
      par[x] = y;
      size[y] += size[x];
    }
    else{
      par[y] = x;
      size[x] += size[y];
      if(rank[x] == rank[y]) rank[x]++;
    }
  }

  //x,yが同じグループにいるかどうかを返す
  bool same(int x,int y)
  {
    return find(x) == find(y);
  }

  //xの属する木のサイズを探す
  int usize(int x)
  {
    return size[find(x)];
  }
};

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

  Make_Fact();
  UFT uf(2*n);
  rep(i,n) {
    rep(j,n) {
      if(i >= j) continue;
      bool f = true;
      rep(l,n) {
	if(a[i][l] + a[j][l] > k) f =false;
      }
      if(f) uf.unite(i, j);
    }
  }

  rep(i,n) {
    rep(j,n) {
      if(i >= j) continue;
      bool f = true;
      rep(l,n) {
	if(a[l][i] + a[l][j] > k) f =false;
      }
      if(f) uf.unite(i+n, j+n);
    }
  }

  mint res(1);
  rep(i,2*n) {
    if(uf.find(i) == i) {
      res *= fact[uf.usize(i)];
    }
  }

  cout << res.x << "\n";

  return 0;
}


#include <bits/stdc++.h>
#include <string>
#define ll long long
#define ld long double
#define iter vector<ll>::iterator
#define mp make_pair
#define pb push_back
#define all(x)  x.begin(),x.end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define frep(i,a,b) for(ll i=a;i<=b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define deb(x) cout<<x<<endl
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
int t;
ll MOD = 1000000007;
ll INF = 1e18+7;
ll MAXN = 5*1e5+100;
ll fact(ll n){

	if(n==1||n==0){
		return 1;
	}
	else{
		return n*fact(n-1);
	}
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
ll binpow(ll a, ll b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
ll binpow(ll a, ll b, ll m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll ncr(ll n,ll r){
    return fact(n)/(fact(r)*fact(n-r));
}
void solve(){
    string S; cin >> S;
    int ans = 0;
    for(int i=0; i<=9999; i++){
        vector<bool> flag(10);
        int X = i;
        for(int j=0; j<4; j++){
            flag[X%10] = true;
            X /= 10;
        }
        bool flag2 = true;
        for(int j=0; j<10; j++){
            if(S[j]=='o' && !flag[j]) flag2 = false;
            if(S[j]=='x' && flag[j]) flag2 = false;
        }
        ans += flag2;
    }
    cout << ans << endl;
}

int main(){
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    //cin>>t;
    //cout<<t;
    t=1;
    while(t--){
    //cout<<t<<endl;
    solve();
	}
}

#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int c1 = 0, c2 = 0;
        for (int j = i; j < N; ++j) {
            if (S[j] == 'A')
                c1++;
            else if (S[j] == 'T')
                c1--;
            else if (S[j] == 'C')
                c2++;
            else
                c2--;
            if (c1 == 0 && c2 == 0) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
//#include <atcoder/modint>
//#include <atcoder/math>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }

    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}

long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//using mint = modint998244353;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  //using namespace std;

  int n, m;
  cin>>n>>m;
  vector<long long> w(n);
  REP(i, n) cin>>w[i];
  vector<long long> l(m), v(m);
  REP(i, m) cin>>l[i]>>v[i];

  long long min_v = INF;
  REP(i, m) if(v[i] < min_v) min_v = v[i];
  //cout << "min_v = " << min_v << endl;
  long long max_w = -1;
  REP(i, n) max_w = max(max_w, w[i]);
  if(max_w > min_v){
    cout << -1 << endl;
    return 0;
  }

  typedef pair<long long, long long> P;
  auto cmp = [](P p, P q) -> bool {
    return p.second < q.second;
  };
  {
    vector<P> vec;
    REP(i, m) vec.emplace_back(l[i], v[i]);
    sort(ALL(vec), cmp);
    REP(i, m){
      l[i] = vec[i].first;
      v[i] = vec[i].second;
    }
  }
  //REP(i, m) cout << l[i] << " " << v[i] << endl;
  vector<long long> dl(m);
  REP(i, m){
    if(i == 0) dl[i] = l[i];
    else dl[i] = max(l[i], dl[i - 1]);
  }

  sort(ALL(w));
  long long ans = INF;
  do {
    vector<long long> dw(n);
    REP(i, n){
      if(i == 0) dw[i] = w[i];
      else dw[i] = w[i] + dw[i - 1];
    }
    vector<vector<long long>> x(n, vector<long long>(n, 0));
    REP(i, n){
      REP(j, n){
        if(i > j) continue;
        //i <= j
        if(i == j) continue;
        //i < j
        long long cw;
        if(i > 0) cw = dw[j] - dw[i - 1];
        else cw = dw[j];
        int idx = lower_bound(ALL(v), cw) - v.begin();
        if(idx == 0) continue;
        x[i][j] = max(x[i][j], dl[idx - 1]);
      }
    }

    vector<long long> dp(n);
    REP(i, n){
      if(i == 0) continue;
      long long temp = 0;
      for(int j = 0; j <= i; j++){
        temp = max(temp, dp[j] + x[j][i]);
      }
      dp[i] = temp;
    }

    ans = min(ans, dp[n - 1]);
  } while (next_permutation(ALL(w)));

  cout << ans << endl;

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define hi ios_base::sync_with_stdio;cin.tie(NULL);cin.tie(NULL);
typedef long long int ll;
typedef long double ld;
typedef long long unsigned llu;
#define test				int test; cin>>test; while(test--)
#define loop(i,n,k) 		for(int i=n;i<k;i++)
#define rloop(i,n,k) 		for(int i=n;i>=k;i--)
#define INT(a) 				int a;scanf("%d",&a);
#define intin(temp)			scanf("%d",&temp);
#define longin(temp)		scanf("%lld",&temp);
#define LLI(a) 				ll a;scanf("%lld",&a);
#define DOUBLE(a) 			double a;scanf("%f",&a);
#define LD(a) 				long double a;scanf("%lf",&a);
#define pb(i) 				push_back(i);
#define sz(i) 				i.size()
#define mkp(i,j)			make_pair(i,j);
#define ip 					pair<int,int>
#define dp					pair<ll,ll>
#define FOR(i,n)			for(i=0;i<n;i++)
#define range(v)			v.begin(),v.end()
#define bye					return 0;
#define file				freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
//===============================================================================================================
//Author:- Absolute_looser
//Class :- loosers
//===============================================================================================================
template<class c>
c gcd (c a,c b){
	if(b==0)
		return a;
	gcd(b,a%b);
}template<class a>
bool prime(a n){
	for(a i=2;i<=sqrt(n);i++){
		if(n%i==0)
			return 0;
	}
	return 1;
}
bool bigger(pair<int,int>picachu,pair<int,int> qicachu){
	return (picachu.first<qicachu.first);
}void printarr(int arr[],int n){
	for(int i=0;i<n;i++)
		cout<<arr[i]<<' ';
	cout<<endl;
}
int chartoint(char c) {
    if (c >= 'a' && c <= 'z') return c - 'a';
    if (c >= 'A' && c <= 'Z') return c - 'A' + 26;
    return 52;
}
int kadane(int arr[],int n){
	int maximum= arr[0];
	int max_so_far = 0;
	for(int i=0;i<n;i++){
		max_so_far+=arr[i];
		if(max_so_far>maximum)
			maximum = max_so_far;
		if(max_so_far<0)
			max_so_far = 0;
	}
	return maximum;
}
int a[200004];
ll div(ll x,ll n,ll m){
	ll ans =1 ;
	while(n){
		if(n&1){
			ans = ans*x%m;
		}
		x = x*x%m;
		n >>=1;
	}
	return ans;
}
void run(){
	ll n;
	ll m;
	cin >> n;
	cin >> m;
	cout << div(10,n,m*m)/m<< endl;
}
int main(){
	hi;
	#ifndef ONLINE_JUDGE
   	freopen("input.txt", "r", stdin);
  	freopen("error.txt", "w", stderr);
  	freopen("output.txt", "w", stdout);
   	#endif

   	{
      	run();
   	}
  	cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
 	bye;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)//rep(i,回数){処理}
using namespace std;
using ll = long long;
using P = pair<int, int>;
#include <unordered_set>

int main() {

    ll n,count=1, sum=0; cin >> n;
    vector<ll> v(n); rep(i,n) cin >> v[i];
    sort(v.begin(), v.end());
    for (int i=0; i<n-1; i++) {
        if (v[i] == v[i+1]) count++;
        else {
            sum += count*(count-1)/2;
            count = 1;
        }
    }
    sum += count*(count-1)/2;
    ll ans  = n*(n-1)/2;
    cout << ans - sum << endl;

    return 0;
}

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

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

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

template <typename T> bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T> bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

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

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

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

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    ll n; cin >> n;
    vl A(n); cinv(A);
    map<ll, ll> mp;
    for (ll &x : A) mp[x]++;
    ll ans = 0;
    rep(i, n-1)
    {
        ans += n-1-i;
        if (mp[A[i]] > 1)
        {
            mp[A[i]]--;
            ans -= mp[A[i]];
        }
    }
    cout << ans << nl;
}


#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <string>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<int> present(2e5 + 1);
	int min_valid = 0;
	int p;
	for (int i = 0; i < n; ++i) {
		cin >> p;
		present[p] = 1;
		while (present[min_valid]) {
			++min_valid;
		}

		cout << min_valid << "\n";
	}

	return 0;

}

#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
using namespace std;
#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 Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
const double PI=acos(-1);
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
    if(x>y)return x;
    else return y;
}
ll min(ll x,ll y){
    if(x<y)return x;
    else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n;cin >> n;
    vector<int> out;
    set<int> res;
    rep(i,200009)res.insert(i);
    rep(i,n){
        int p;cin >> p;
        res.erase(p);
        out.push_back((*begin(res)));
    }
    rep(i,n)cout << out[i] << endl;
}


#include<bits/stdc++.h>
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;
using namespace std;
vector<int>v[200005];
vector<int>g[200005];
int dep[200005];
int in[200005], out[200005];
int stamp;
void dfs(int now, int pre) {
    in[now] = ++stamp;
    v[dep[now]].pb(stamp);
    for (auto &i : g[now]) {
        if (i == pre) {
            continue;
        }
        dep[i] = dep[now] + 1;
        dfs(i, now);
    }
    out[now] = stamp;
}
void solve() {
    int n;
    cin >> n;
    for (int i = 2 ; i <= n ; i++) {
        int x;
        cin >> x;
        g[x].pb(i);
    }
    dfs(1, 0);
    int q;
    cin >> q;
    while (q--) {
        int x, y;
        cin >> x >> y;

        cout << upper_bound(v[y].begin(), v[y].end(),out[x]) - lower_bound(v[y].begin(), v[y].end(),in[x]) << '\n';
    }
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}

#include <iostream>
#include <vector>
using namespace std;
const int INF = (1u<<31) - 1;

int main() {
	int n;
	cin >> n;
	long long max_thr = INF, min_thr = -INF;
	long long max_v = INF, min_v = -INF;
	for (int i = 0; i < n; i++) {
		long long a, t;
		cin >> a >> t;
		if (t == 1) {
			max_v += a;
			min_v += a;
		} else if (t == 2) {
			if (a > min_v) {
				min_thr += a - min_v;
				min_v += a - min_v;
				if (max_thr < min_thr) {
					max_thr = min_thr;
					max_v = min_v;
				}
			}
		} else {
			if (a < max_v) {
				max_thr -= max_v - a;
				max_v -= max_v - a;
				if (max_thr < min_thr) {
					min_thr = max_thr;
					min_v = max_v;
				}
			}
		}
	}
	int Q;
	cin >> Q;
	for (int q = 0; q < Q; q++) {
		long long x;
		cin >> x;
		long long ans;
		if (x <= min_thr) {
			ans = min_v;
		} else if (x >= max_thr) {
			ans = max_v;
		} else {
			ans = min_v + (x - min_thr);
		}
		cout << ans << endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define pb push_back
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
int n, m, ans1, k;
vector<pair<int, int> > v, vv;
vector<int> ans;

int solve(int i){
    if(i >= k){
        int ok = 0;
        unordered_map<int, int> mp;
        for(auto k : ans)
            mp[k]++;
        for(int i = 0; i < m; ++i){
            int a = v[i].first, b = v[i].second;
            if(mp[a] and mp[b])
                ++ok;
            ans1 = max(ans1, ok);
        }
        return ok;
    }
    long long int a = vv[i].first, b = vv[i].second, cur = 0;
    ans.push_back(a);
    cur += solve(i + 1);
    ans.pop_back();
    ans.push_back(b);
    cur += solve(i + 1);
    ans.pop_back();
    return cur;
}

int main(){
    fast;
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        v.push_back({a, b});
    }
    cin >> k;
    for(int i = 0; i < k; ++i){
        int a, b;
        cin >> a >> b;
        vv.push_back({a, b});
    }
    solve(0);
    cout << ans1 << '\n';
    return 0;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,a[110],b[110],c[110],x[110],y[110],k,ans;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++) scanf("%d%d",&a[i],&b[i]);
    scanf("%d",&k);
    for(int i=1;i<=k;i++) scanf("%d%d",&x[i],&y[i]);
    for(int i=0;i<=(1<<k)-1;i++)
    {
        int p=i;//printf("\n%d\n",p);
        memset(c,0,sizeof(c));
        for(int j=1;j<=k;j++)
        {
            //printf("%d",p&1);
            if(p&1) c[x[j]]++;
            else c[y[j]]++;
            p>>=1;

        }
        int cnt=0;
        for(int j=1;j<=m;j++) if(c[a[j]]&&c[b[j]]) cnt++;
        ans=max(ans,cnt);
    }
    printf("%d\n",ans);
    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
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

#define BOOM ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.14159265358979323846
#define NEWLINE cout<<"\n";
#define ll long long
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(), v.end()
#define ff first
#define ss second
#define pii pair<int,int>
#define mset(a,b) memset(a, b, sizeof(a))
#define BHAAGO {cout<<"NO\n";continue;}
using namespace std;
#define MAXN 200
#define MOD  1000000007
int posfastscan() {
	register int c;  int number = 0;
	for(c = getchar(); !(c>47 && c<58); c= getchar());
	for (; (c>47 && c<58); c=getchar())  number = (number<<1) + (number<<3) + (c ^ 48);
	return number;
}
int fastscan() {
	bool negative = false;  register int c;  int number = 0;
	for(c = getchar(); !(c>47 && c<58) && c!= '-'; c= getchar());
	if (c=='-')  c = getchar(), negative = true;
	for (; (c>47 && c<58); c=getchar())  number = (number<<1) + (number<<3) + (c ^ 48);
	if (negative) return -number; else return number;
}
void write(int x){
	if(x>9) write(x/10);
	putchar(x%10 + 48);
}
//LARGE POWERS
ll power(long long x, long long y, long long p)
{
	ll res = 1;
	x = x % p;
	if (x == 0) return 0;
	while (y > 0){
		if (y & 1)  res = (res*x) % p;
		y = y>>1;
		x = (x*x) % p;
	}
	return res;
}
//Fermat Inverse
ll fermatinv(int n, int p) { return power(n,p-2,p); }

//Combination nCr
int fact[MAXN], ifact[MAXN];
void Cinit() {
	fact[0] = 1;
	for (int i = 1; i < MAXN; ++i) fact[i] = 1LL * fact[i - 1] * i % MOD;
	ifact[MAXN - 1] = power(fact[MAXN - 1], MOD - 2, MOD);
	for (int i = MAXN - 2; i >= 0; --i) ifact[i] = 1LL * ifact[i + 1] * (i + 1) % MOD;
}
int nCr(int n, int r) {
  if (r < 0 || r > n) return 0;
  return (1LL * fact[n] * ifact[r] % MOD * ifact[n - r] % MOD)%MOD;
}
long long int sumXOR(ll arr[], int n)
{
    long long int sum = 0;
    for (int i = 0; i < 64; i++)
    {
        //  Count of zeros and ones
        ll zc = 0, oc = 0;
        // Individual sum at each bit position
        long long int idsum = 0;
        for (int j = 0; j < n; j++)
        {
            if (arr[j] % 2 == 0)
                zc++;
            else
                oc++;
            arr[j] /= 2;
        }

        // calculating individual bit sum
        idsum = ((oc * zc)%MOD) * (1LL << (i/2)) % MOD * (1LL << (i-i/2)) % MOD;

        // final sum
        sum += idsum;
    }
    return sum%MOD;
}
int main()
{
	// BOOM
	int  _, n, m, k, l=0, r=0, i, j, tt=1, sum=0, c, x,y,z=1;
	bool flag=0;
	string s, ss;
	// Cinit();
	// cin>>tt;
	while(tt--){
		// int q;
		cin>>n;
		// int a[n];
		// for(i=0;i<n;i++)  cin>>a[i];
		std::vector<pair<ll,ll>> adj[n];
		for(i=0;i<n-1;i++) {
			ll x,y,z;
			cin>>x>>y>>z;
			adj[x-1].emplace_back(y-1, z);
			adj[y-1].emplace_back(x-1, z);
		}
		ll a[n]={};
		bool vis[n]={};
		queue<int> q;
		q.push(0);
		while(!q.empty()) {
			int u = q.front(); q.pop();
			vis[u]=1;
			for(auto p : adj[u])
				if(!vis[p.ff])
					a[p.ff] = p.ss ^ a[u],
					q.push(p.ff);
			// cout<<"u = "<<u<<endl;
		}
		// cout<<"Y"<<endl;
		cout<<sumXOR(a, n);
		// if(a[1] + a[1] == a[0] + a[2])
			// cout<<"Yes"<<'\n';
			// for(i=0;i<n;i++) cout<<a[i]<<' '; cout<<'\n';
		// }
		// else
			// cout<<ans+1<<'\n';
			// cout<<"No"<<'\n';
	}
	//cout<<ans;
	/*for(i=0;i<n;i++){
		cin>>;
	}
	*/
	// for(i=0;i<=n;i++){
	// 	cout<<"\nadj["<<i<<"] = ";
	// 	for(j=0;j<adj[i].size();j++)
	// 		cout<<adj[i][j]<<" ";
	// }
	// for(i=0;i<d.size();i++)
	// cout<<d[i]<<" ";NEWLINE
	/*v = n*m;
	Graph G(v);
	char a[v], b[n][m];
	vector<bool> visited(v, false);
	vector<pair<int, unsigned long int>> level(v);
	for(i=0;i<v;i++){
		level[i].first = i; level[i].second = 0;
	}*/

	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#define ll long long
#define MAXN 1000005
#define uns unsigned
#define INF 0x3f3f3f3f
using namespace std;
inline ll read(){
	ll x=0;bool f=1;char s=getchar();
	while((s<'0'||s>'9')&&s>0){if(s=='-')f^=1;s=getchar();}
	while(s>='0'&&s<='9')x=(x<<1)+(x<<3)+s-'0',s=getchar();
	return f?x:-x;
}
ll n,k,s,a,b,sum[MAXN<<2];
inline ll fgg(ll s){
	if(s>(n<<1)||s<2)return 0;
	if(s<=n+1)return s-1;
	else return n-(s-n)+1;
}
inline ll gee(ll s){
	ll rank=0;
	for(int i=1;i<=n&&i<s;i++)rank+=sum[s-i];
	return rank;
}
int main()
{
	n=read(),k=read();
	for(int i=1;i<=(n<<2);i++)sum[i]=sum[i-1]+fgg(i);
	s=2;
	for(int i=22;i>=0;i--)
		if(s+(1ll<<i)<=n*3&&gee(s+(1ll<<i))<k)
			s+=(1ll<<i);
	k-=gee(s),s++;
//	printf("%lld %lld %lld %lld\n",gee(3),gee(4),gee(5),gee(6));
//	printf(" %lld %lld\n",s,k);
	for(a=max(1ll,s-(n<<1));a<=n;){
		if(fgg(s-a)>=k)break;
		else k-=fgg(s-a),a++;
	}
//	printf(" %lld %lld\n",a,k);
	b=max(1ll,s-a-n)+k-1;
	printf("%lld %lld %lld\n",a,b,s-a-b);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define For(i,a,b) for(register int i=a;i<=b;++i)
#define Down(i,a,b) for(register int i=a;i>=b;i--)
#define reg register
namespace yspm{
	inline int read(){
		int res=0,f=1; char k;
		while(!isdigit(k=getchar())) if(k=='-') f=-1;
		while(isdigit(k)) res=res*10+k-'0',k=getchar();
		return res*f;
	}
	char s[1010][1010];
	int n,m,fa[3000];
	set<int> lin,col;
	inline int min(int x,int y){return x<y?x:y;}
	inline int max(int x,int y){return x>y?x:y;}
	inline void swap(int &x,int &y){int t=x; x=y; y=t; return ;}
	inline int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}
	inline void merge(int x,int y){
		x=find(x); y=find(y); if(x==y) return ;
		if(x>y) swap(x,y); fa[y]=x; return ;
	}
	signed main(){
		n=read(); m=read(); For(i,1,n) scanf("%s",s[i]+1);
		for(reg int i=1;i<=n+m;++i) fa[i]=i; fa[1]=fa[n]=fa[n+1]=fa[n+m]=1;
		For(i,1,n){
			int pre=0; For(j,1,m) if(s[i][j]=='#') merge(i,j+n),pre?merge(pre+n,j+n):void(),pre=j;
		}
		For(i,1,m){
			int pre=0; For(j,1,n) if(s[j][i]=='#') merge(j,n+i),pre?merge(pre,j):void(),pre=j;
		}
		for(reg int i=1;i<=n;++i) if(find(i)!=1) lin.insert(find(i));
		for(reg int i=n+1;i<=n+m;++i) if(find(i)!=1) col.insert(find(i));
		printf("%lld\n",min(lin.size(),col.size()));
		return 0;
	}
}
signed main(){return yspm::main();}


#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <bitset>
#include <string>
#include <cstdio>
#include <cmath>
#include <climits>
#include <fstream>
#include <functional>
#include <time.h>
using namespace std;

const long long INF = 1LL << 60;
const long long MOD = 1000000007;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

int main(void)
{
    int n;
    cin >> n;
    vector<int> a(n);
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        ans += max(0, a[i]-10);
    }

    cout << ans << endl;
}

#include <bits/stdc++.h>
#define F first
#define S second
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define bck(i, a, b) if ((i) >= (a) && (i) < (b))
#define trav(x, a) for (auto &x : (a))
#define sz(a) (int)(a).size()
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define dbg(X) std::cerr << "[DBG]("<<__FUNCTION__<<":"<<__LINE__<<") " << #X << ": " << X << std::endl;
using namespace std;
typedef long long ll;
typedef string str;
template<typename T> using vec = vector<T>;
template<typename T> using pq = priority_queue<T, vector<T>, std::greater<T>>;
template<typename T> using mxpq = priority_queue<T>;
typedef pair<int,int> pii;
typedef vec<int> vi;
typedef vec<pii> vii;
typedef vec<vi> vvi;
typedef pair<ll,ll> pll;
typedef vec<ll> vl;
typedef vec<pll> vll;
typedef vec<vl> vvl;
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<typename A, typename B>
istream& operator>>(istream& s, pair<A,B>& p) { return s>>p.first>>p.second; }
template<typename T>
istream& operator>>(istream& s, vec<T>& p) { for (T& t : p) s >> t; return s; }
template<typename T>
ostream& operator<<(ostream& s, const vec<T>& p) { for (const T& t : p) s << t << " "; return s; }

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n; cin >> n;
    ll mn = LLONG_MAX;
    rep(b, 0, 63) {
        ll a = n >> b;
        ll c = n & ((1ll << b) - 1);
        ckmin(mn, a+b+c);
    }
    cout<<mn<<endl;
}


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

//shorthands
#define ll                long long
#define ld                long double
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define mkp               make_pair
#define fastio            ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (ll)((x).size())
#define fr                first
#define sc                second
#define vll               vector <ll>
#define vpll              vector < pair<ll,ll> >
#define vect(a,n)         vll a(n); rep(i,0,n) cin>>a[i];
#define rep(i,a,b)        for(ll i = a; i < b; i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define PI                3.14159265358979323846

//Debug
#define printall(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<"\n";

//Constants
const int mod = (int) 1e9 + 7 ;
const int INF = (int) 1e18 ;

//Input-Output File
void fileio(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif
}

ll modulo_binary_exp(ll a , ll b , ll m) {
    ll res = 1;
    while(b) {
        if(b % 2 == 0) {
            b = b/2;
            a = ((a % m)*(a % m)) % m;
        }
        else
        {
            b--;
            res = ((res % m)*(a % m)) % m;
        }
    }

    return res;
}

void solve() {
    ll a,b,c;
    cin >> a >> b >> c;
    ll p = modulo_binary_exp(b , c , 100);
    p += 100;
    ll q = modulo_binary_exp(a , p , 10);
    cout << q;
}

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


#include <stdio.h>
#include <queue>
#include <set>
#include <iostream>

using namespace std;
typedef long long int llint;

llint n;

priority_queue<llint> que;

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

    set<long> ans;
    for(long d=1;d*d<=n;d++){
        if(n%d==0){
            ans.insert(d);
            ans.insert(n/d);
        }
    }

    for(auto x:ans)cout << x << endl;
}

/* C++ */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = ll(0); i < ll(n); i++)
#define Rep(i, n) for(ll i = ll(1); i < ll(n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.14159265358979323846
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n"
ll fac[MAX], finv[MAX], inv[MAX];

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

bool palindrome(string s){
  bool flag=true;
  rep(i,(ll)s.size()) if(s[i]!=s[s.size()-1-i]) flag=false;
  return flag;
}

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}

ll Sint(ll n) {
  ll ans=0;
  while(n!=0) ans+=n%10,n/=10;
  return ans;
}

ll Svec(vector<ll> v){
  ll n=0;
  rep(i,(ll)v.size()) n+=v[i];
  return n;
}

ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}

ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}

ll Factorial(ll n){
  if(n==0) return 1;
  else return Factorial(n-1)*n;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  rep(i,(ll)s.size()-1){
    if(s[i]==s[i+1]){
      x++;
      if(i==(ll)s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==(ll)s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}

ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

string Toupper(string s){
  string ans="";
  rep(i,s.size()){
    if('a'<=s[i] && s[i]<='z') ans+=(char)s[i]-32;
    else ans+=s[i];
  }
  return ans;
}
string Tolower(string s){
  string ans="";
  rep(i,s.size()){
    if('A'<=s[i] && s[i]<='Z') ans+=(char)s[i]+32;
    else ans+=s[i];
  }
  return ans;
}

void dis(vector<ll> v){ rep(i,v.size()) cout<<v[i]<<endl; }

void dis2(vector<vector<ll>> v){
  rep(i,v.size()){
    rep(j,v[0].size()) cout<<v[i][j]<<' ';
    cout<<endl;
  }
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  /* isPrime[1]=false; */
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*bool cmp(pint a, pint b) { return a.second < b.second; }*/
/* 約数列挙 */
vector<ll> divisor(ll n){
  // O(√n)
  vector<ll> ans;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ans.push_back(i);
      if(i*i!=n) ans.push_back(n/i);
    }
  }
  sort(ALL(ans));
  return ans;
}
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> v=divisor(n);
  rep(i,v.size()) cout<<v[i]<<endl;
}


//#include<math.h>
#include<algorithm>
#include<stdlib.h>
#include<time.h>
#include<stdio.h>
#include<string.h>
#define un unsigned
#define srd srand(time(0))
#define ll long long
#define con continue
#define gtc getchar()
#define ptc putchar
#define dou double
#define eps 0.00000000001
#define opr operator
#define cl(x,a) memset(x,a,sizeof(x))
#define fo0(i,k) for(i=fr[k];i;i=nx[i])
#define fo1(i,l,r) for(i=l;i<=r;i++)
#define fo2(i,l,r) for(i=l;i>=r;i--)
#define fo(i,n) for(i=1;i<=n;i++)
#define ret return
#define x first
#define cint const int
#define y second
#define opi(x) freopen(x,"r",stdin)
#define opo(x) freopen(x,"w",stdout)
#define tpl template<class T>
#define priq priority_queue
#define mp make_pair
#define use using namespace
#define WT while(T--)
#define pb push_back
#define sz size()
use std;
typedef pair<int,int> pii;typedef pair<int,ll> pil;typedef pair<ll,int> pli;typedef pair<ll,ll> pll;
namespace io
{
	void _(int &k){char c;int e=1;k=0;while((c=gtc)>'9'||c<'0')if(c=='-')e=-1;k=c-'0';while((c=gtc)<='9'&&c>='0'){k*=10;k+=c-'0';}k*=e;}
	void _(ll &k){char c;int e=1;k=0;while((c=gtc)>'9'||c<'0')if(c=='-')e=-1;k=c-'0';while((c=gtc)<='9'&&c>='0'){k*=10;k+=c-'0';}k*=e;}
	void _(char &c){while((c=gtc)==' '||c=='\n');}void _(dou &c){scanf("%lf",&c);}void _(char *s){char c;while((c=gtc)!=EOF&&c!=' '&&c!=10)*s++=c;}
	template<class t1,class t2>void _(t1 &a,t2 &b){_(a);_(b);}template<class t1,class t2,class t3>void _(t1 &a,t2 &b,t3 &c){_(a);_(b);_(c);}
	template<class t1,class t2,class t3,class t4>void _(t1 &a,t2 &b,t3 &c,t4 &d){_(a);_(b);_(c);_(d);}
	template<class t1,class t2,class t3,class t4,class t5>void _(t1 &a,t2 &b,t3 &c,t4 &d,t5 &e){_(a);_(b);_(c);_(d);_(e);}
	void _p(dou k){printf("%.6lf",k);}void _p(char *c){for(;*c;ptc(*c++));}void _p(const char *c){for(;*c;ptc(*c++));}void _p(char c){ptc(c);}
	tpl void _p0(T k){if(k>=10)_p0(k/10);ptc(k%10+'0');}tpl void _p(T k){if(k<0){ptc('-');_p0(-k);}else _p0(k);}tpl void __p(T k){_p(k);ptc(' ');}
	tpl void _pn(T k){_p(k);ptc('\n');}template<class t1,class t2>void _p(t1 a,t2 b){__p(a);_pn(b);}
	template<class t1,class t2,class t3>void _p(t1 a,t2 b,t3 c){__p(a);__p(b);_pn(c);}
	template<class t1,class t2,class t3,class t4>void _p(t1 a,t2 b,t3 c,t4 d){__p(a);__p(b);__p(c);_pn(d);}
	tpl void op(T *a,int n){int i;n--;fo(i,n)__p(a[i]);_pn(a[n+1]);}int gi(){int x;_(x);ret x;}ll gll(){ll x;_(x);ret x;}
}
int gcd(int a,int b){ret b?gcd(b,a%b):a;}void fcl(){fclose(stdin);fclose(stdout);}
void fop(const char *s){char c[256],d[256];cl(c,0);cl(d,0);strcpy(c,s);strcpy(d,s);opi(strcat(c,".in"));opo(strcat(d,".out"));}
int eq(dou a,dou b){return a+eps>=b&&b+eps>=a;}tpl void _ma(T &a,T b){if(a<b)a=b;}tpl void _mi(T &a,T b){if(a>b)a=b;}
cint N=1234567,EE=100000000,GG=1000000000,ima=2147483647;
use io;
int n,m,a,b,c,T;
int ksm(int a,int b,int p)
{
	if(!b)
		return 1;
	int t=ksm(a,b/2,p);
	t=t*t%p;
	return b%2?t*a%p:t;
}
int main()
{
	int i,j,a1,a2;
	_(a,b,c);
	_pn(ksm(a%10,ksm(b%4,c,4)+4,10));
}

#include <bits/stdc++.h>
#define rei register int
using namespace std;
int qpow(int x,int p,int mod){
	int res = 1; while(p){
		if(p & 1) res = 1ll*res * x % mod; x = 1ll*x * x % mod; p >>= 1;
	} return res;
} bool vis[11];
int main(){
	int A,B,C; cin >> A >> B >> C;
	int mod = 1,now = 1; vis[1] = 1; while(1){
		now = 1ll*now * A % 10;
		if(vis[now]) break; ++mod; vis[now] = 1;
	} if(A % 2 == 0 || A % 5 == 0) --mod;
	int x = qpow(B,C,mod);
	if(A % 2 != 0 && A % 5 != 0) cout << qpow(A,x,10);
	else cout << qpow(A,(x - 1 + mod) % mod + 1,10) % 10;
	return 0;
}


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

int main() {
	string n;
	cin>>n;
	int d =  n.size()-1;
	int count = 0 , c= 0;
		for(int i = d;i>=0; i-- ){
			if(n[i]=='0')c++;
			else break;
		}
		for(int i = 0;i<c; i++ ){
			n = '0'+n;
		}
		d = d + c ;
		for(int i = 0 ; i <= d/2 ;i++ ){
		if(n[i]!=n[d-i])count=2;
	}
	if(count == 0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

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

#define rep(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
using namespace std;

int main() {
    string s;
    cin >> s;
    if (s == string(s.rbegin(), s.rend())) {
        cout << "Yes" << endl;
    }
    else {
        int n = atoi(s.c_str());
        while (n % 10 == 0) {
            n /= 10;
        }
        string ss = to_string(n);
        if (ss == string(ss.rbegin(), ss.rend())) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}


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

#define N 200100
#define MOD 1000000007 //998244353
#define ll long long
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep2(i, a, b) for(int i = a; i <= b; ++i)
#define rep3(i, a, b) for(int i = a; i >= b; --i)
#define eb emplace_back
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>

vector<pii>e[N];
int a[N];
bool used[N];

void dfs(int k,int pc,int ec) {
	bool v = true;
	used[k] = true;
	if ((a[k] == -1) && (ec != pc))a[k] = ec;
	int sz = e[k].size();
	rep(i, sz) {
		if (!used[e[k][i].first]) {
			if ((a[k] == -1) && (e[k][i].second != pc))a[k] = e[k][i].second;
			dfs(e[k][i].first, a[k], e[k][i].second);
		}
	}
	return;
}

int main() {
	int n, m;
	int x, y, z;
	cin >> n >> m;
	rep(i, m) {
		cin >> x >> y >> z;
		x--;
		y--;
		e[x].pb({ y,z });
		e[y].pb({ x,z });
	}
	rep(i, n) {
		used[i] = false;
		a[i] = -1;
	}
	dfs(0, -1, -1);
	rep2(i, 1, n)used[i] = false;
	rep(i, n) {
		if (a[i] >= 0)used[a[i]] = true;
	}
	rep2(i,1, n) {
		if (!used[i]) {
			x = i;
			break;
		}
	}
	rep(i, n) {
		if (a[i] < 0)a[i] = x;
	}
	rep(i, n)cout << a[i] << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for (int i = 0; i < (int)(n) ; i++)
#define rep2(i,a,b) for (int i = (a); i < (int)(b); i++)
#define repR(i,n) for (int i = (int)(n)-1; i >= 0; i--)
#define ENDL '\n'
#define pb push_back
#define SIZE(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define UNIQUE(a) a.erase(unique(all(a)),a.end());
#define debug(x) cout<<(#x)<<" is : "<<x<<endl;
#define debugc(vec) {cout<<(#vec)<<" is below; ---"<<endl;for(auto c:vec)cout<<c<<" ";cout<<endl<<"----------------"<<endl;}
inline string rev(string s) {string t(s.rbegin(), s.rend()); return t;}
template<class T> inline bool chmin(T &a, T b) { if(a>b) {a=b; return 1;} return 0;}
template<class T> inline bool chmax(T &a, T b) { if(a<b) {a=b; return 1;} return 0;}
const ll INF = (1LL<<30)-1;
const ll INFLL = (1LL<<62)-1;
const ld PI = 3.14159265358979323846L;

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

    int n; cin>>n;
    string s; cin>>s;
    int q; cin>>q;
    int odd=0;
    vector<pair<int,int>> quer;
    while(q--) {
        int t,a,b; cin>>t>>a>>b;
        a--; b--;
        if(t==2) {odd++; continue;}
        if(odd%2==0) {
            quer.push_back({a,b});
        }
        else {
            if(a<=n-1) a+=n;
            else a-=n;
            if(b<=n-1) b+=n;
            else b-=n;
            quer.push_back({a,b});
        }
    }
    for(auto [a,b]:quer) {
        swap(s[a],s[b]);
    }
    if(odd%2==1) {
        string latter=s.substr(n), former=s.substr(0,n);
        s=latter+former;
    }
    cout<<s<<endl;
}


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

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

	int N;
	cin>>N;
	ll cen[4];
	rep(i,4) cen[i]=0;
	vector<ll> A(N),B(N),C(N),D(N);
	rep(i,N){
		cin>>A[i]>>B[i];
		A[i]*=N;
		B[i]*=N;
		cen[0]+=A[i];
		cen[1]+=B[i];
	}
	rep(i,N){
		cin>>C[i]>>D[i];
		C[i]*=N;
		D[i]*=N;
		cen[2]+=C[i];
		cen[3]+=D[i];
	}
	rep(i,4) cen[i]/=N;
	rep(i,N){
		A[i]-=cen[0];
		B[i]-=cen[1];
		C[i]-=cen[2];
		D[i]-=cen[3];
	}
	if(A[0]*A[0]+B[0]*B[0]==0){
		swap(A[0],A[1]);
		swap(B[0],B[1]);
	}
	set<pair<int,int>> s;
	ll L=A[0]*A[0]+B[0]*B[0];
	rep(i,N) s.insert({C[i]*L,D[i]*L});
	bool T=false;
	vector<vector<ll>> q=
	{
		{A[0],B[0]},
		{B[0]*-1,A[0]}
	};
	//rep(i,N) cout<<A[i]<<" "<<B[i]<<" "<<C[i]<<" "<<D[i]<<endl;
	rep(i,N){
		if(L!=C[i]*C[i]+D[i]*D[i]) continue;
		bool U=true;
		vector<vector<ll>> p(2,vector<ll>(2));
		vector<vector<ll>> r=
		{
			{C[i],D[i]*-1},
			{D[i],C[i]}
		};
		rep(a,2) rep(b,2) rep(c,2){
			p[a][b]+=q[a][c]*r[c][b];
		}
		/*rep(i,2){
			rep(j,2) cout<<p[i][j]<<" ";
			cout<<endl;
		}*/
		rep(j,N){
			ll X=0,Y=0;
			X=A[j]*p[0][0]+B[j]*p[0][1];
			Y=A[j]*p[1][0]+B[j]*p[1][1];
			if( !s.count({X,Y}) ){
				U=false;
				break;
			}
		}
		T|=U;
	}
	yneos(T);
}

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

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

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

ll cross(ll x1, ll y1, ll x2, ll y2) {
    return x1*y2 - x2*y1;
}
ll dot(ll x1, ll y1, ll x2, ll y2) {
    return x1*x2 + y1*y2;
}

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

    if(N == 1) {
        puts("Yes");
        return 0;
    }

    set< vector< tuple<ll, ll, ll> > > S;
    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
            if(i == j) continue;
            // ベクトル ij に沿って x 軸を作る感じ
            ll x1 = A[j] - A[i], y1 = B[j] - B[i];
            vector< tuple<ll, ll, ll> > vec;
            for(int k=0; k<N; k++) {
                ll x2 = A[k] - A[i], y2 = B[k] - B[i];
                ll c = cross(x1, y1, x2, y2);
                ll d = dot(x1, y1, x2, y2);
                ll len = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
                vec.emplace_back(c, d, len);
            }
            sort(vec.begin(), vec.end());
            S.emplace(vec);
        }
    }
    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
            if(i == j) continue;
            ll x1 = C[j] - C[i], y1 = D[j] - D[i];
            vector< tuple<ll, ll, ll> > vec;
            for(int k=0; k<N; k++) {
                ll x2 = C[k] - C[i], y2 = D[k] - D[i];
                ll c = cross(x1, y1, x2, y2);
                ll d = dot(x1, y1, x2, y2);
                ll len = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
                vec.emplace_back(c, d, len);
            }
            sort(vec.begin(), vec.end());
            if(S.count(vec)) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}


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

using ll = long long;
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define POPCOUNT(x) __builtin_popcount(x)
template <typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template <typename T> void chmax(T &a, const T &b) { a = max(a, b); }

const ll INF = 1LL << 60;

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} fastiofastio;

const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

// BEGIN CUT
ll modpow(ll x, ll y, ll m) {
    ll a = 1, p = x;
    while (y > 0) {
        if (y % 2 == 0) {
            p = (p * p) % m;
            y /= 2;
        } else {
            a = (a * p) % m;
            y--;
        }
    }
    return a;
}
// END CUT

int dp[100000][2]; //た or あ

vector<int> G[100000];
int sz[100000];

int dfs(int v) {
    sz[v] = 1;
    for (int to : G[v]) {
        sz[v] += dfs(to);
    }
    return sz[v];
}

void solve(int v) {
    //た のターンだとする
    vector<int> odd, even;
    int ans = 0;
    for (int to : G[v]) {
        solve(to);
        if (sz[to] % 2 == 0)
            even.push_back(dp[to][0] - dp[to][1]);
        else
            odd.push_back(dp[to][0] - dp[to][1]);
        ans += dp[to][1];
    }
    sort(ALL(odd), greater<int>());
    int rest = 0;
    for (int x : even) {
        if (x >= 0)
            ans += x;
        else
            rest += x;
    }
    if (odd.size() % 2 == 0)
        ans += rest;
    for (int i = 0; i < odd.size(); i += 2)
        ans += odd[i];
    dp[v][0] = ans - 1;

    // あ のターン
    odd.clear();
    even.clear();
    ans = rest = 0;
    for (int to : G[v]) {
        if (sz[to] % 2 == 0)
            even.push_back(dp[to][1] - dp[to][0]);
        else
            odd.push_back(dp[to][1] - dp[to][0]);
        ans += dp[to][0];
    }
    sort(ALL(odd));
    for (int x : even) {
        if (x <= 0)
            ans += x;
        else
            rest += x;
    }
    if (odd.size() % 2 == 0)
        ans += rest;
    for (int i = 0; i < odd.size(); i += 2)
        ans += odd[i];
    dp[v][1] = ans + 1;
}

int main() {
    int n;
    cin >> n;
    FOR(i, 1, n) {
        int p;
        cin >> p;
        p--;
        G[p].push_back(i);
    }
    dfs(0);
    solve(0);
    cout << (n + dp[0][1]) / 2 << endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

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

    ll n; cin >> n;
    ll a[n]; zep(i, 0, n)cin >> a[i];
    ll cnt[200]; memset(cnt, 0, sizeof(cnt));

    ll ans = 0;
    zep(i, 0, n){
        ans += cnt[a[i] % 200];
        cnt[a[i] % 200]++;
    }
    print(ans)

    return 0;
}


//全力以赴
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 3e5 + 5;
const ll MOD = 1e9+7;

int parent[N];
const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};

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

ll extGcd(ll a, ll b, ll &x, ll &y) { // solves for x and y where ax+by=gcd(a,b)
    if(b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}

ll modInv(ll a, ll p) { // solve for x=a^-1 where ax + py = 1 % p
    if(gcd(a, p) != 1) return -1; // modInv only exists if a and p are coprime (gcd(a, p) = 1)
    ll x, y;
    extGcd(a, p, x, y);
    x = (x % p + p) % p;
    return x;
}

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

/*
a^b:
if b is even -> a^b = a^(b/2) * a^(b/2)
if b is odd -> a^b  = a * a^(b-1/2) * a^(b-1/2)
*/
ll modPow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * a) % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return res;
}

int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}

void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}

ll nCr(ll n, ll r) {
    ll res = 1;
    for(ll i=1;i<=r;i++) {
        res = res * (n - r + i) / i;
    }
    return res;
}

int ask(int i, int j) {
    cout << "? " << i + 1 << ' ' << j + 1 << endl;
    int v;
    cin >> v;
    return v;
}

int msbPos(int n) {
    if(n == 0) return 0;
    int msbPos = 0;
    n /= 2;
    while(n != 0) {
        n /= 2;
        msbPos++;
    }
    return msbPos;
}

string toOct(int n) {
    string res;
    while(n > 0) {
        res = to_string(n % 8) + res;
        n /= 8;
    }
    return res;
}

vector<int> d(1e6+6);

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

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

// I've done my sentence but committed no crime
#pragma GCC optimize("Ofast")
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define mod (int)(1e9+7)
#define flush fflush(stdout);

void solve() {
    int n,m,x,y; cin>>n>>m>>x>>y;
    string s[n];
    for(auto &it:s)
        cin>>it;

    int ans=0;
    x--;y--;
    for(int i=x-1;i>=0&&s[i][y]!='#';i--){
        ans++;
    }
    for(int i=x+1;i<n&&s[i][y]!='#';i++){
        ans++;
    }
    for(int i=y-1;i>=0&&s[x][i]!='#';i--){
        ans++;
    }
    for(int i=y+1;i<m&&s[x][i]!='#';i++){
        ans++;
    }
    ans++;
    cout<<ans;
}

int32_t main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define Rep(i,j,n) for (ll i=(ll)(j);i<=(ll)(n);++i)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int mod = 998244353;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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 gcd(ll a,ll b){return b?gcd(b,a%b):a;}

/*
ll ti=clock();
cout<<("Execution Time: %.4lf sec", 1.0 * (clock() - ti) / CLOCKS_PER_SEC)<<endl;
*/

int main(){
  ll x,y,z;
  cin>>x>>y>>z;
  ll ans=10000000;
  while(1){
    if(y*z>x*ans){
      break;
    }
    ans--;
  }
  print(ans);
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<random>
#include<ctime>
#include<queue>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e6+5;
ll n;
ll up[105];
ll dp[105][105][105];
int vis[105][105][105];
int len;
ll dfs(int pos,int limit,int a,int b){
	if(pos==-1) return 1;
	if(!limit&&vis[pos][a][b]!=-1) return dp[pos][a][b];
	ll ans = 0;
	int li = limit?up[pos]:1;
	for(int i=0;i<=li;i++){
		if(i==0){
			if(a>0) ans+=dfs(pos-1,limit&&(i==li),a-1,b);
		}else {
			if(b>0) ans+=dfs(pos-1,limit&&(i==li),a,b-1);
		}
	}
	if(!limit&&vis[pos][a][b] == -1) dp[pos][a][b] = ans,vis[pos][a][b] = 0;
	return ans;
}
ll f(ll x,int a,int b){
	int pos = 0;memset(up,0,sizeof(up));
	while(x){
		up[pos++] = x&1LL;
		x>>=1LL;
	}
	return dfs(a+b-1,1,a,b);
}
void clc(ll ans){

	string tmp;
	while(ans){
		if(ans&1LL) tmp+='b';
		else tmp+='a';
		ans>>=1;
	}
	while(tmp.size()<(len)) tmp+='a';
	reverse(tmp.begin(),tmp.end());
	cout<<tmp<<"\n";
}
int main() {
	int a,b;
	ll s;
	cin>>a>>b>>s;
	len = a+b;
	ll l = (1LL<<(b))-1;
	ll r = l<<a;
	ll ans = 0;
	memset(vis,-1,sizeof(vis));
	while(l<=r){
		ll mid = l+(r-l)/2;
		ll sum = f(mid,a,b);
		if(sum>=s){
			if(sum==s){
				ans = mid;
			}
			r = mid-1;
		}else{
			l = mid+1;
		}
	}
	clc(ans);
    return 0;
}


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

typedef int ll;
const int N=10,M=1e5+10;

int n,m;
int wei[N],id[N];
ll f[N];
pair<int,int> bri[M]; //(limit,length)

inline int Read(int &r){
	int b=1,c=getchar();r=0;
	while(c<'0' || '9'<c) b=c=='-'? -1:b,c=getchar();
	while('0'<=c && c<='9') r=(r<<1)+(r<<3)+(c^'0'),c=getchar();
	return r*=b;
}
int Query(int tot){
	int le=0,ri=m;
	while(le+1<ri){
		int mi=(le+ri)>>1;
		if(bri[mi].first<tot) le=mi;
		else ri=mi;
	}
	if(bri[ri].first<tot) return bri[ri].second;
	return bri[le].second;
}
int main(){
	Read(n),Read(m);
	int minbri=1e8,maxwei=0;
	for(int i=1;i<=n;i++) maxwei=max(maxwei,Read(wei[i])),id[i]=i;
	for(int i=1;i<=m;i++){
		Read(bri[i].second);
		minbri=min(minbri,Read(bri[i].first));
	}
	if(minbri<maxwei){
		printf("-1\n");
		return 0;
	}
	sort(bri+1,bri+1+m);
	for(int i=2;i<=m;i++)
		bri[i].second=max(bri[i].second,bri[i-1].second);
	ll ans=(ll)1e18;
	do{
		for(int i=1;i<=n;i++) f[i]=0;
		for(int i=1;i<=n;i++){
			int tot=wei[id[i]];
			for(int j=i+1;j<=n;j++){
				tot+=wei[id[j]];
				f[j]=max(f[j],f[i]+Query(tot));
			}
		}
		ans=min(ans,f[n]);
	}while(next_permutation(id+1,id+1+n));
	printf("%d\n",ans);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pl = pair<ll, ll>;
using Vs = vector<string>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗

int main() {
    ll h,w,n,m;
    cin >> h >> w >> n >> m;
    VVl aka(h,Vl(w)),lit(h,Vl(w));
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        x--;y--;
        aka[x][y]+=2;
    }
    rep(i,m){
        ll x,y;
        cin >> x >> y;
        x--;y--;
        aka[x][y]--;
    }
    rep(i,h)rep(j,w){

        if(aka[i][j]>0){
            while(j>0){
                if(aka[i][j-1]==-1)break;
                j--;

            }
            while(j<w){
            if(aka[i][j]==-1){
                //j++;
                break;
            }
            lit[i][j]++;
            j++;
            }

        }
        //cout << j << endl;
    }
    rep(j,w)rep(i,h){
        if(aka[i][j]>0){
            while(i>0){
                if(aka[i-1][j]==-1)break;
                i--;

            }
            while(i<h){
                if(aka[i][j]==-1){
                    //i++;
                    break;
                }
                lit[i][j]++;
                i++;

            }
            //cout << i << endl;
        }
    }
    ll ans=0;
    rep(i,h)rep(j,w){
        if(lit[i][j]>=1&&aka[i][j]>=0) ans++;
        //cout << lit[i][j] << endl;
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

int main()
{
    canhazfast();

    int n, ans = 0;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        ans = gcd(ans, a);
    }
    cout << ans << '\n';

    return 0;
}


#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d;

    cin >> a >> b >> c >> d;

    int ans = a * d - b * c;

    cout << ans;

}

//#include <atcoder/maxflow.hpp>
#include <memory>
#include <iostream>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
#include <complex>
#include <thread>

#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;

using namespace std;
//using namespace atcoder;

//ll modd = (1000LL * 1000LL * 1000LL + 7LL);
ll modd = 998244353;

int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no

    auto start = chrono::steady_clock::now();

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(a); readint(b); readint(c); readint(d);
        cout << a*d-b*c << endl;
    }
//        auto stop = chrono::steady_clock::now();
//        auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start);
//        cout << "Duration: " << duration.count() << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,x,n) for(int i = x; i<=n; i++)
#define FORO(i,n) for(int i = 0; i<n; i++)
#define nl "\n"
#define sp " "
#define MOD 1000000007
#define pb push_back

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b,c;
	cin>>a>>b>>c;
	if(a*a+b*b<c*c) cout<<"Yes";
	else cout<<"No";
	return 0;
}

#ifdef LOCAL
//#define _GLIBCXX_DEBUG
#endif
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<char> Vc;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;
typedef vector<vector<char>> VVc;
typedef vector<vector<vector<ll>>> VVV;
typedef vector<vector<vector<vector<ll>>>> VVVV;

#define endl '\n'
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define rEach(i, mp) for (auto i = mp.rbegin(); i != mp.rend(); ++i)
#ifdef LOCAL
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgset(st) cerr << #st << ":"<<endl; for (auto i = st.begin(); i != st.end(); ++i) { cerr << *i <<" ";}cerr<<endl;
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#else
#define dbg(...)
#define dbgmap(...)
#define dbgset(...)
#define dbgarr(...)
#define dbgdp(...)
#endif
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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 (b<a) { a=b; return true; } return false; }

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

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    s<<endl;
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

// パスカル Pascal nCk
long long com[61][61];

int solve(){
    ll a,b,k;
    cin>>a>>b>>k;
    ll n = a+b;

    string s;

    com[0][0] = 1;
    for (int i = 1; i < 61; ++i) {
        for (int j = 0; j <= i; ++j) {
            com[i][j] += com[i-1][j];
            if (j > 0) com[i][j] += com[i-1][j-1];
        }
    }

    dbg(com[60][30])
    auto dfs = [&](auto &&self, ll a, ll b, ll k)->void {
        if(a<=0 && b<=0) return;
        dbg(mp(mp(a,b),k));
        if( a > 0){
            ll zenhan = com[a+b-1][a-1];
            dbg(zenhan)
            if(k <= zenhan){
                s += 'a';
                a--;
                self(self, a,b,k);
            }else{
                k -= zenhan;
                s += 'b';
                b--;
                self(self, a,b,k);
            }
        }else{
            s += 'b';
            b--;
            self(self, a,b,k);
        }
    };
    dfs(dfs, a, b, k);
    out(s);

    return  0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);
//    ll T;
//    cin>>T;
//    while(T--)
    solve();
}


#include <bits/stdc++.h>
//#include <atcoder/modint>
//#include <atcoder/math>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPP(i, n) for(int i = 1; i <= n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c = a % i_7;
    if(c >= 0) return c;
    return c + i_7;
}
long long po(long a, long b){
    if(b == 0) return 1;

    long long z = po(a , b / 2);
    z = mod(z * z);
    if(b % 2 != 0) z = mod(a * z);
    return z;
}

bool prime_(int n){
    if(n == 1){
        return false;
    }else if(n == 2){
        return true;
    }else{
        for(int i = 2; i <= std::sqrt(n); i++) if(n % i == 0) return false;
        return true;
    }
}

long long gcd_(long long a, long long b){
    if(a < b) std::swap(a,b);
    if(a % b == 0) return b;
    else return gcd_(b, a % b);
}

long long lcm_(long long x, long long y){
    return (x / gcd_(x,y)) * y;
}

using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//using mint = modint998244353;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  //using namespace std;

  int x;
  cin>>x;
  int ans = ((x + 99) / 100) * 100 - x;
  if(ans == 0) ans = 100;
  cout << ans << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*b);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
#define num_l(a,v) POSL(a,v) //v未満の要素数
#define num_eql(a,v) POSU(a,v) //v以下の要素数
#define num_h(a,v) (a.size() - POSU(a,v)) //vより大きい要素数
#define num_eqh(a,v) (a.size() - POSL(a,v)) //v以上の要素数
// static_cast< long long ll >

int N = 30*30;
int L = 30;
// (i,j) i個下 , j個右
int ind(int a,int b){
	return a*L + b;
}

//vector< vector<string> > S(N,vector<string>(N));
vector<vector<long double>> H(L,vector<long double>(L,5000.0));
vector<vector<long double>> V(L,vector<long double>(L,5000.0));

// 上は下より(i,j)のiが小さい　右は左より(i,j)のjが大きい

// 順路正の向きで
const int From_U = 0;//上から来た
const int From_D = 1;//下から来た
const int From_L = 2;//左から来た
const int From_R = 3;//右から来た

// 復元
string make_char = "DURL";
const int dy[] = {-1,1,0,0};
const int dx[] = {0,0,-1,1};

int main(){
	int sy,sx,ty,tx;
	int s,t;
	FOR(k,0,1000){
		cin >> sy >> sx >> ty >> tx;

		int dir_y = 1;
		int dir_x = 1;
		if(sy > ty) dir_y = -1;
		if(sx > tx) dir_x = -1;

		// (i,j) には (i - dir_y , j) or (i , j - dir_x) から行く

		vector< vector<long double> > score(L,vector<long double>(L,INF));
		vector< vector<int> > from(L,vector<int>(L,-1));

		score[sy][sx] = 0;
		for(int y=sy;(y-dir_y)!=ty;y+=dir_y){
			for(int x=sx;(x-dir_x)!=tx;x+=dir_x){
				//cout << y << " " << x << endl;

				if(y==sy && x==sx) continue;
				long double a = INF,b = INF;
				if(y != sy) a = score[y-dir_y][x] + H[min(y-dir_y,y)][x];
				if(x != sx) b = score[y][x-dir_x] + V[y][min(x,x-dir_x)];

				if(a < b){
					from[y][x] = (dir_y == 1 ? From_U : From_D );
					score[y][x] = a;
				}else{
					from[y][x] = (dir_x == 1 ? From_L : From_R );
					score[y][x] = b;
				}

			}
		}
		//return 0;
		//cout << "95" << endl;

		string T;
		int y=ty,x=tx;
		while(y!=sy || x!=sx){
			int a = from[y][x];
			T += make_char[a];
			assert(0 <= a && a <= 3);
			y += dy[a];
			x += dx[a];
			//cout << "from[" << y <<  "][" << x << "] = "  << a << endl;
		}

		//cout << "106" << endl;

		//cout << T << endl;
		REV(T);
		/*{ // チェック
			assert(T.size() == (abs(sy-ty)+abs(sx-tx)));
			int ud=0,lr=0;
			for(auto c:T){
				if(c == 'U' || c == 'D') ud++;
				if(c == 'L' || c == 'R') lr++;
			}
			assert(abs(sy-ty) == ud);
			assert(abs(sx-tx) == lr);
		}*/
		cout << T << endl;
		cout << flush;

		long double score_now,r;
		cin >> score_now;

		r = pow( score_now / score[ty][tx] , 1.0 - 1.0*(abs(sy-ty) + abs(sx-tx)) / 120.0 );

		y=ty,x=tx;
		while(y!=sy || x!=sx){
			int a = from[y][x];
			int by = y + dy[a],bx = x + dx[a];
			if(by != y){
				H[min(by,y)][x] *= r;
			}else{
				V[y][min(bx,x)] *= r;
			}
			y += dy[a];
			x += dx[a];
		}
	}
}

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

typedef long long ll;
typedef pair<int,int> 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; }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"
#define COUT16(x) cout << fixed << setprecision(16) << (x) << "\n";

unsigned long Combination(int n,int r)
{
    unsigned long i = 1;
    int k = r > n - r ? n - r : r, count;
    if(k < 0) return 0;
    for(count = 1; count <= k; ++count)
    {
        i *= n - count + 1;
        i /= count;
    }
    return i;
}

int main(){
    //input
    ll a,b,k;
    cin >> a >> b >> k;
    string ans = "";
    ll now = 0;
    while(a!=0||b!=0){
        ll now_a = Combination(a+b-1,a-1);//aを選んだとする
        ll now_b = Combination(a+b-1,b-1);//bを選んだとする
        if(now+now_a>=k){
            ans += 'a';
            --a;
        }
        else{
            ans += 'b';
            now+=now_a;
            --b;
        }
    }
    COUT(ans);
}


#include <bits/stdc++.h>
#define lol long long
#define INF 998244353
using namespace std;
int main(){
    int a,b;
    char c;
    cin>>a>>b;
    for(int i=0;i<a;i++){
        cin>>c;
        if(c=='o') b++;
        else if(b!=0) b--;
    }
    cout<<b<<"\n";
    return(0);
}

#include <bits/stdc++.h>
#define f(a, n) for (int a = 0; a < n; a++)
#define F(a, n) for (int a = 1; a <= n; a++)

using namespace std;

int main(){
	int n, x;
	string s;
	cin>>n>>x>>s;
	f(i, n){
		if (s[i] == 'o'){
			x++;
		}
		else{
			if (x > 0) x--;
		}
	}
	cout<<x<<endl;
}


#include <iostream>
#include <vector>
#include  <numeric>
#include<cstdlib>
#include <map>
#include <set>
#include <algorithm>    // std::random_shuffle
#define INF (1<<30)
#define ll long long
#define MAXX 800*800
using namespace std;

int A[888][888];
int B[888][888];
int cumul[888][888];

bool Can(int N,int K) {
    for(int i=0;i<=N;i++) {
        for(int j=0;j<=N;j++) {
            cumul[i][j]=0;
        }
    }
    for(int i=1;i<=N;i++) {
        for(int j=1;j<=N;j++) {
            cumul[i][j]=cumul[i-1][j]+cumul[i][j-1]-cumul[i-1][j-1]+B[i][j];
            // printf("%d %d :: %d\n",i,j,cumul[i][j]);
        }
    }

    // printf("st=%d\n");
    for(int i=1;i+K-1<=N;i++) {
        for(int j=1;j+K-1<=N;j++) {
                // printf("%d %d ::: %d\n",i,j,cumul[i+K-1][j+K-1]-cumul[i-1][j+K-1]-cumul[i+K-1][j-1]+cumul[i-1][j-1]);
                // cout << K*K-(K*K)/2-1 << endl;

            if (cumul[i+K-1][j+K-1]-cumul[i-1][j+K-1]-cumul[i+K-1][j-1]+cumul[i-1][j-1] >= K*K-(K*K)/2) {
                return true;
            }
        }
    }
    return false;

}

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

    ll low=0;
    ll high=1.1e9;

    while(low < high) {
        ll mid = (low + high)/2;
        //cout << mid << endl;
        for(int i=1;i<=N;i++) {
            for(int j=1;j<=N;j++) {
                B[i][j]=(A[i][j]<mid);
            }
        }
        if (Can(N, K)) {
            high=mid;
        } else {
            low=mid+1;
        }
    }
    cout << low-1 << endl;

}

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

// @@ !! LIM(f:>>)

// ---- inserted function f:>> from util.cc
template <typename T1, typename T2>
istream& operator>> (istream& is, pair<T1,T2>& p) {
  is >> p.first >> p.second;
  return is;
}

template <typename T1, typename T2, typename T3>
istream& operator>> (istream& is, tuple<T1,T2,T3>& t) {
  is >> get<0>(t) >> get<1>(t) >> get<2>(t);
  return is;
}

template <typename T1, typename T2, typename T3, typename T4>
istream& operator>> (istream& is, tuple<T1,T2,T3,T4>& t) {
  is >> get<0>(t) >> get<1>(t) >> get<2>(t) >> get<3>(t);
  return is;
}

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

template <typename T>
vector<T> read_vector_n(istream& is, size_t n) {
  vector<T> ret(n);
  for (size_t i = 0; i < n; i++) {
    is >> ret[i];
  }
  return ret;
}

template <typename T>
vector<T> read_vector(istream& is) {
  size_t n; is >> n;
  return read_vector_n<T>(is, n);
}
// ---- end f:>>

// @@ !! LIM -- end mark --

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

  ll N; cin >> N;
  vector<ll> A(2*N); cin >> A;
  using sta = pair<ll, ll>;
  vector<sta> P;
  for (ll i = 0; i < 2*N; i++) {
    P.emplace_back(A[i], i);
  }
  sort(P.begin(), P.end());
  vector<ll> ord(2*N);
  for (ll i = 0; i < 2*N; i++) {
    auto [a, j] = P[i];
    ord[j] = i;
  }
  string ans = "";
  ll exc = 0;
  bool flag = false;
  for (ll i = 0; i < 2*N; i++) {
    if (exc > 0) {
      ll inc = (flag == (bool)(ord[i] < N));
      if (inc) {
        ans += '(';
        exc++;
      }else {
        ans += ')';
        exc--;
      }
    }else {
      if (ord[i] < N) {
        flag = true;
      }else {
        flag = false;
      }
      ans += '(';
      exc++;
    }
  }
  cout << ans << endl;

  return 0;
}


// #pragma GCC optimize("O3")
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace ::std;
// clang-format off
template<typename T> T nxt() {T res; cin >> res; return res;}
#define tests() for (int _ = nxt<int>(); _ > 0; _--)
#define nxt1(t,n) t (n); cin >> n
#define nxt2(t,n,m) t (n),(m); cin >> n >> m
#define nxt3(t,n,m,k) t (n),(m),(k); cin >> n >> m >> k
#define rep(i, A) for (int i = 0 ; i < A ; i++)
#define ll long long
typedef pair<int,int> pii;typedef pair<ll, ll> pll;typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<ll> vl;typedef vector<vl> vvl;
#define dbg(vari) cerr<<#vari<<" = "<<(vari)<<endl;
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
template<typename T> ostream& operator<<(ostream &s,vector<T> t){for(T ti : t)s<<ti<<" ";return s; }
#define all(x) (x).begin(), (x).end()
#define last(vec) vec[vec.size()-1]
#define has(c,x) ((c).find(x) != (c).end())
// clang-format on

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

    int N = nxt<int>();
    cout << N - 1 << endl;
    return 0;
}


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

#define rep(i, n) for (long long i = 0; i < (n); i++)
#define REP(i, s, n) for (long long i = (s); i <= (n); i++)
#define repr(i, n) for (long long i = (n - 1); i >= 0; i--)
#define REPR(i, s, n) for (long long i = (s); i >= (n); i--)
#define all(v) (v).begin(), (v).end() //biginからendへ
#define rall(v) (v).rbegin(), (v).rend()
#define sumvec(v) accumulate(all(v), 0LL)
#define DOUBLE fixed << setprecision(15)
#define OK cerr << "OK\n"
#define OK1 cerr << "OK1\n"
#define OK2 cerr << "OK2\n"
#define sz(s) (long long)s.size()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
typedef pair<ll, ll> P;
typedef vector<P> vP;

//vectorの末尾参照は .back()を使おう。
//if(chmax(ans, i))

#define INT(...)     \
    int __VA_ARGS__; \
    IN(__VA_ARGS__)
#define LL(...)            \
    long long __VA_ARGS__; \
    IN(__VA_ARGS__)
#define CHR(...)      \
    char __VA_ARGS__; \
    IN(__VA_ARGS__)
#define DBL(...)        \
    double __VA_ARGS__; \
    IN(__VA_ARGS__)
#define STR(...)        \
    string __VA_ARGS__; \
    IN(__VA_ARGS__)
#define LD(...)              \
    long double __VA_ARGS__; \
    IN(__VA_ARGS__)

void scan(int &a)
{
    cin >> a;
}
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(string &a) { cin >> a; }
void scan(long double &a) { cin >> a; }

void IN() {}
template <class Head, class... Tail>
void IN(Head &head, Tail &...tail)
{
    scan(head);
    IN(tail...);
}

//INT(a,b)とか使う

void YES(bool b) { cout << ((b) ? "YES\n" : "NO\n"); }
void Yes(bool b) { cout << ((b) ? "Yes\n" : "No\n"); }
void yes(bool b) { cout << ((b) ? "yes\n" : "no\n"); }
void Yay(bool b) { cout << ((b) ? "Yay!\n" : ":(\n"); }
void posible(bool b) { cout << ((b) ? "posible\n" : "imposible\n"); }
void Posible(bool b) { cout << ((b) ? "Posible\n" : "Imposible\n"); }
void POsIBLE(bool b) { cout << ((b) ? "POsIBLE\n" : "IMPOsIBLE\n"); }

//出力の形式に合わせて関数をキャスとする

const int inf = 1001001001;
const long long INF = ((1LL << 62) - (1LL << 31));
const long double pi = acos(-1.0);

int main(){

    vector<pair<double,double>> v;
    LL(n);
    rep(i,n){
        LL(t);
        DBL(l,r);
        if(t == 2) r -= 0.1;
        if(t == 3) l += 0.1;
        if(t == 4){
            r -= 0.1;
            l += 0.1;
        }
        v.push_back(make_pair(l,r));
    }
    ll ans = 0;
    rep(i,n){
        REP(j,i + 1,n - 1){
            if(v[i].first == v[j].first || v[i].first == v[j].second || v[i].second == v[j].first || v[i].second == v[j].second) ans++;
            else if((v[j].first < v[i].first && v[j].second > v[i].first) || (v[i].first < v[j].first && v[i].second > v[j].first)) ans++;
        }
    }

    cout << ans;

}

// Template begins
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <queue>
#include <string.h>
#include <string>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define fo(i,a,b) for(i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define sort0(v) sort(all(v))
#define lbb(a,b,arr,x) lower_bound(arr+a,arr+b+1,x)-arr
#define ubb(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-arr
#define freq(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-lower_bound(arr+a,arr+b+1,x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define printp(x) cout << x.ff << " " << x.ss << endl

const ll mod=998244353;
#define inf 9999999999999
#define MAXN   100001

// stores smallest prime factor for every number

ll inv(ll i){if(i==1) return 1;return (mod-((mod/i)*inv(mod%i))%mod)%mod;}

ll gcd(ll a,ll b){if(a==0) return b;return gcd(b,b%a);}
inline void fastio(){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
// Template ends
const int MN = 2e5+7;
ll dp[1 << 21];
ll fun(ll mask, ll n, vector <pii> v[]) {
    int i=__builtin_popcount(mask);
    if (i== n) {
        return 1;
    }
    if (dp[mask] != -1) {
        return dp[mask];
    }
    ll temp = 0;
    ll cnt = 0;
    for (auto j: v[i]) {
        cnt = 0;
        for (ll k = 1; k <= j.ff; k++) {
            if (mask & (1LL << k)) {
                ++cnt;
            }
        }
        if (cnt > j.ss) {
            temp = -1e18;
        }
    }
    for (ll j = 0; j < n; j++) {
        if (mask & (1LL << j)) {
            continue;
        }
        temp+=fun( mask | (1LL << j), n, v);
    }
    temp = max(temp, 0LL);
    return dp[mask] = temp;
}
void solve(){
    ll n,m; cin>>n>>m;
    ll ans;
    if (!m) {
        ans = 1;
        for (ll i = 1; i <= n; i++) {
            ans *= i;
        }
        cout<<ans<<endl;
        return;
    }
    vector <pii> v[20];
    for (ll i = 0; i < m; i++) {
        int x,y,z; cin>>x>>y>>z;
        v[x].pb(mp(y,z));
    }
    memset(dp, -1, sizeof(dp));
    ans = fun( 0, n, v);
    cout<<ans<<endl;
}
int main(){
    fastio();
    //write code
    solve();
    return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, T;
int a[40];
vector<int> pre;
vector<int> suf;

void dfs(int cor, int end, int tsum, vector<int> &vec) {
	if (cor == end) {
		vec.push_back(tsum);
		return;
	}
	dfs(cor + 1, end, tsum, vec);
	dfs(cor + 1, end, tsum + a[cor], vec);
}

signed main() {
	int i, j;

	cin >> n >> T;
	rep(i, n) cin >> a[i];
	if (n == 1) {
		if (a[0] <= T) {
			cout << a[0] << endl;
		}
		else {
			cout << 0 << endl;
		}
		return 0;
	}
	dfs(0, n / 2, 0, pre);
	dfs(n / 2, n, 0, suf);
	sort(pre.begin(), pre.end());
	sort(suf.begin(), suf.end());

	int ans = 0;
	j = 0;
	for (i = (int)pre.size() - 1; i >= 0; i--) {
		if (pre[i] > T) continue;
		for (; j < (int)suf.size(); j++) {
			if (pre[i] + suf[j] > T) break;
		}
		if (j == 0) ans = max(ans, pre[i]);
		else ans = max(ans, pre[i] + suf[j - 1]);
	}
	cout << ans << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod = 1e9+7;
const int maxn = 40;
const int inf = 1e9;
int a[maxn];
int main(){__
	int n;
	cin >> n;
	lli t;
	cin >> t;
	for(int i=0; i < n; i++) cin >> a[i];
	int mit = n/2;
	vector<lli> izq,der;
	int uno = n/2;
	int dos = n - uno;
	for(int msk=0; msk < (1 << uno); msk++){
		lli suma = 0ll;
		for(int j=0; j < uno; j++){
			if(msk & (1 << j)){
				suma+=a[j];
			}
		}
		izq.pb(suma);
	}

	for(int msk=0; msk < (1 << dos); msk++){
		lli suma = 0ll;
		for(int j=0; j < dos; j++){
			if(msk & (1 << j)){
				suma+=a[j+uno];
			}
		}
		der.pb(suma);
	}

	sort(all(izq));
	sort(all(der));

	lli maxi = 0ll;
	for(lli x : izq){
		if(x > t) continue;
		maxi = max(maxi,x);
		int pos = upper_bound(all(der),t - x) - der.begin();
		if(pos == 0) continue;
		pos--;
		assert(der[pos] + x <= t);
		maxi = max(maxi,der[pos] + x);
	}

	for(lli x : der){
		if(x > t) continue;
		maxi = max(maxi,x);
		int pos = upper_bound(all(izq),t - x) - izq.begin();
		if(pos == 0) continue;
		pos--;
		assert(izq[pos] + x <= t);
		maxi = max(maxi,izq[pos] + x);
	}

	cout << maxi << endl;
	return 0;
}


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

namespace hy {
typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define PB push_back
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define MOD (int)(1e9 + 7)
#define EPS (1e-8)
#define INF (int)(1e9)
#define PI 3.14159265358979323846
#define VALID(x, y, m, n) (x >= 0 && x < m && y >= 0 && y < n)
#define LOW_BIT(x) ((x) & (-(x)))
#define fast_iostream ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

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

const vector<PII> dir {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
} using namespace hy;

#ifdef DEBUG
template <class T> ostream& operator << (ostream& os, vector<T>& vec) { for (auto x : vec) os << x << ' '; return os; }
template <class T> ostream& operator << (ostream& os, vector<vector<T> >& vec)
{ for (auto& v : vec) { for (auto x : v) os << x << ' '; os << endl; } os << endl; return os; }
template <class T> ostream& operator << (ostream& os, deque<T>& dq) { for (auto x : dq) os << x << ' '; return os; }
template <class T> ostream& operator << (ostream& os, pair<T, T>& p)
{ os << p.first << ' ' << p.second; os << endl; return os; }
  #if __cplusplus >= 201103L
template <class K, class V> ostream& operator << (ostream& os, unordered_map<K, V>& mp)
{ for (auto x : mp) os << x.first << " : " << x.second << endl; return os; }
  #endif
void print() { cout << endl; }
template<typename T, typename... Ts>
void print(T arg, Ts... args) { cout << " " << arg; print(args...); }
#else
void print() {}
#endif

// <-----------------------------------------------------------> //

/**
 * TODO:
 * Remember to reset global variable in every test cases!
 * Check INT overflow!
 *
 * STAY ORGANIZED.
 */

int main() {
  fast_iostream;

  int n; cin >> n;
  double x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
  double d = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  double theta = PI / 2.0 - PI / n;
  theta *= -1;
  double len = cos(theta) * d;
  PDD p = {(x2 - x1) / d, (y2 - y1) / d};
  PDD q = {cos(theta) * p.first - sin(theta) * p.second, sin(theta) * p.first + cos(theta) * p.second};
  cout << fixed << setprecision(6) << x1 + q.first * len << ' ' << y1 + q.second * len << endl;

  return 0;

}

//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,avx512f")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#include <memory>
#include <random>
#include <functional>
#include <complex>
#include <immintrin.h>
#ifdef DEBUG
#include "./Lib/debug_VC.hpp"
#include "./Lib/Timer.hpp"
#include "./Lib/sample.hpp"
#else
#define dump(...)
#endif

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
template<class T>
inline auto sort(T& t) { std::sort(ALL(t)); }
template<class T>
inline auto rsort(T& t) { std::sort((t).rbegin(), (t).rend()); }
template<class T>
inline auto unique(T& t) { (t).erase(unique((t).begin(), (t).end()), (t).end()); }
template<class T, class S>
inline auto chmax(T& t, const S& s) { if (s > t) { t = s; return true; } return false; }
template<class T, class S>
inline auto chmin(T& t, const S& s) { if (s < t) { t = s; return true; } return false; }
inline auto BR() { std::cout << "\n"; }

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std {
template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } };
}

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

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

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

signed main() {
    ll n;
    cin >> n;
    VL a(n), b(n);
    cin >> a >> b;
    multiset<ll, std::greater<ll>> odd, even;
    REP(i, n) {
        ((i & 1) ? odd : even).emplace(b[i] - a[i]);
    }

    ll ans = 0;
    REPC(x, a) { ans += x; }
    dump(ans, odd, even);
    while (!odd.empty() && *odd.begin() + *even.begin() > 0) {
        ans += *odd.begin() + *even.begin();
        odd.erase(odd.begin());
        even.erase(even.begin());
    }
    cout << ans << endl;
}


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

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

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

    vector<int> points(n - 1);
    rep(i, n) cin >> points[i];

    int cur_sum = 0;
    for (auto point : points) cur_sum += point;

    // check
    for (int i = 0; i <= k; i++) {
        int now = (cur_sum + i) / n;
        if (now >= m) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

// Problem: B - Sign of Friendship
// Contest: AtCoder - ZONe Energy Programming Contest
// URL: https://atcoder.jp/contests/zone2021/tasks/zone2021_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms

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

int main() {
	int n, D, H;
	cin >> n >> D >> H;
	double ans = 0;
	while (n--) {
		int d, h;
		cin >> d >> h;
		ans = max(ans, H - (double)(H - h) / (D - d) * D);
	}
	printf("%.15lf\n", ans);
	return 0;
}