#include<bits/stdc++.h>
using namespace std;
int main()
{
	double a,b,c,d;
	double x,m;
	cin>>a>>b>>c>>d;
	m=d/b;
	x=(c-a)/(1+m)+a;
	printf("%.10lf",x);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define PB push_back
#define MP make_pair
#define LL long long
#define ll long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define VVI vector<vector<int>>
#define PII pair<int,int>
#define VPII vector<PII>
#define LD long double
#define INF 1000000000000
#define MOD 1000000007
#define COMAX 110000 // combnation array max range
#define MAXR 100000 // array max range
#define FI first
#define SE second
#define PQG priority_queue<int,VI,greater<int>> // Ascending. e.g. 1..n
#define PQL priority_queue<int,VI,less<int>> // Descending. e.g. n..1
#define SETG set<int,greater<int>> // Descending. e.g. n..1
#define SETL set<int,less<int>> // Ascending. e.g. 1..n
#define vecprint(v) R(i,v.size())cerr << v[i] << " ";cerr << endl;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T min(vector<T> &v) { return *min_element(v.begin(),v.end()); }
template<class T>T max(vector<T> &v) { return *max_element(v.begin(),v.end()); }
template<class T>T modpow(T a, T b, T m) { a %= m; T r = 1; while (b > 0) { if (b & 1) r = (r * a) % m; a = (a * a) % m; b >>= 1; } return r; }
ll modinv(ll a,ll m=MOD) {ll b = m, u = 1, v = 0;while (b) {ll t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
template<class T>string radixconv(T n, T k){ string s; while(n/k){ s=to_string(n%k)+s; n/=k; } s=to_string(n%k)+s; return s; }
template<class T>vector<T> divs(T n){ T t=1; vector<T> r; while(t*t<=n){ if(!(n%t)){ r.push_back(t); if(t!=(n/t)) r.push_back(n/t); } t++; } return r; } //  sqrt(n)
template<class T>vector<T> commondivs(vector<T> ns){ T mn=min(ns); vector<T> r; for(auto &d:divs(mn)){ for(int i=0;i<(int)ns.size();i++){ if(ns[i]%d) break; if(!((int)ns.size()-1-i)) r.push_back(d); } } return r; }
template<class T>vector<bool> eratosieve(T n){vector<bool> r((n+1>2 ? n+1 : 2),1);r[0]=0;r[1]=0;for(int i=2;i*i<=n;i++){if(r[i]){for(int j=i+i;j<=n;j+=i){r[j]=0;}}}return r;} // nloglogn
template<class T>T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<class T>T lcm(T a, T b) { return a*b/gcd(a,b); }
template<class T>vector<T> primefactor(T n){ vector<T> r; auto c = divs(n); for(auto &i:c){ for(auto &j:c){ if(i!=j && j!=1 && !(i%j)) break; if(j==c.back()) r.push_back(i); } } return r; }
template<class T>vector<pair<T,T>> primefactors(T n){ vector<pair<T,T>> r; for(int i=2;i*i<=n;i++){if(n%i)continue;int e=0;while(!(n%i)){n/=i;e++;}r.push_back(make_pair(i,e));}if(n!=1) r.push_back(make_pair(n,1));return r; }
template<class T>long long binsearch(long long from,long long to,T fn){while(to-from > 1){long long mid = (to+from)/2;if(fn(mid)){from=mid;}else{to=mid;}}return from;}
struct Comb{ll fac[COMAX+1],finv[COMAX+1],inv[COMAX+1];Comb() {init();}void init() {fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,COMAX){fac[i] = ((fac[i - 1]%MOD) * (i%MOD)) % MOD;inv[i] = (((-inv[MOD%i]%MOD+MOD)%MOD) * ((MOD/i) % MOD))%MOD;finv[i] = ((finv[i - 1]%MOD) * (inv[i]%MOD)) % MOD;}}ll com(ll n,ll k){if(n<k)return 0;if(n<0 || k<0)return 0;return (((fac[n] * finv[k])%MOD) * finv[n - k] % MOD) % MOD;}};

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(11);
    cerr << fixed << setprecision(6);
    LD x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    y2=-y2;
    cerr << "y2:" << y2 << endl;
    LD a=(y2-y1)/(x2-x1);
    cerr << "a:" << a << endl;
    LD b=y1-a*x1;
    cerr << "b:" << b << endl;
    LD ans=b/(-a);
    //if(x1<x2){
    //    ans=abs(ans)+x1;
    //}else{
    //    ans=x1-abs(ans);
    //}
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

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

#define SZ(x)                       (int) x.size()
#define F                           first
#define S                           second

const int N = 1e6 + 10, MOD = 1e9 + 7;
ll n, m, T, L[N], R[N], c;

int main() {
    scanf("%lld%lld%lld", &n, &m, &T); c = n;
    for (int i = 1; i <= m; i++) {
        scanf("%lld%lld", &L[i], &R[i]);
    }
    for (int i = 1; i <= m; i++) {
        c = max(0LL, c - (L[i] - R[i - 1]));
        if (c == 0) return !printf("No\n");
        c = min(n, c + R[i] - L[i]);
    }
    if (T - R[m] >= c) printf("No\n");
    else printf("Yes\n");
    return 0;
}

#include <bits/stdc++.h>

#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>
#define srt(v) sort(v.begin(), v.end())
#define srtg(v) sort(v.begin(), v.end(), greater<int> ())
#define FOR(k, n) for(int k=0; k<n; k++)
#define pb push_back
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define printarr(v) for(auto& x : v) cout<<x<<" "; cout<<endl
#define ree cout<<"******************************************"<<endl
#define double long double

using namespace std;

char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };
char alphsl[26] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
const int MOD = 1000000007;
char alphs[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
const double pi = 3.14159265358;

void solve() {

    int n, m, t;
    cin>>n>>m>>t;

    vi a(m), b(m);
    for(int i=0; i<m; i++){
        cin>>a[i]>>b[i];
    }
    int last=0, start=n;
    for(int i=0; i<m; i++){
        n-=a[i]-last;
        if(n<=0){
            cout<<"No"<<endl;
            return;
        }
        n+=b[i]-a[i];
        n=min(start, n);
        last=b[i];
    }
    n-=t-last;
    if(n<=0){
            cout<<"No"<<endl;
            return;
        }
        cout<<"Yes"<<endl;

}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

        //tests
        solve();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
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;}

int main(){
	int a[3];
	REP(i,3) cin >> a[i];

	sort(a, a+3);
	if(a[1]-a[0]== a[2]-a[1] )cout << "Yes\n";
	else cout<<"No\n";

	return 0;
}

#include <bits/stdc++.h>
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void Yes(bool a) { cout << (a?"Yes":"No") << endl; }
void YES(bool a) { cout << (a?"YES":"NO") << endl; }

int main(int argc, char **argv) {
	int a, b, c; cin >> a >> b >> c;
	bool flag = false;
	if (a*2 == b + c) flag = true;
	if (b*2 == a + c) flag = true;
	if (c*2 == a + b) flag = true;
	Yes(flag);
}


//DUEL
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")
#define shandom_ruffle(a, b) shuffle(a, b, rng)
#define vi vector<int>
#define vl vector<ll>
#define popcnt __builtin_popcount
#define popcntll __builtin_popcountll
#define all(a) begin(a),end(a)

using namespace std;
using namespace __gnu_pbds;

using ll=long long;
using ull=unsigned long long;
using ld=long double;
const int MOD=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w,bool fl=false)
{
	cout<<w.size()<<en;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<en;
	if (fl) cout<<flush;
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

void compress(vi&v)
{
	set<int> s;
	for (auto a: v) s.insert(a);
	vi o(all(s));
	for (auto&a: v) a=lower_bound(all(o),a)-o.begin();
}

void compress(vl&v)
{
	set<ll> s;
	for (auto a: v) s.insert(a);
	vl o(all(s));
	for (auto&a: v) a=lower_bound(all(o),a)-o.begin();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a,int base=10)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=base;
		k+=a[i]-'0';
	}
	return k;
}

template<class T>
void eras(vector<T>& a,T b)
{
	a.erase(find(a.begin(),a.end(),b));
}

string its(ll k,int base=10)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%base)+'0');
		k/=base;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

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

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

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
const int N=300010;
int k,n,ch[1000][1000],a[N],sa[N];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829*2)+13893829);
	cin>>n>>k;
	for (int i=0;i<n;++i)
	{
		int x;
		cin>>x;
		for (int j=0,r=1;j<=k;++j,r=mult(r,x)) sa[j]=add(sa[j],r);
	}
	for (int i=0;i<=k;++i)
	{
		ch[i][0]=1;
		for (int j=1;j<=i;++j) ch[i][j]=add(ch[i-1][j],ch[i-1][j-1]);
	}
	for (int i=1;i<=k;++i)
	{
		int su=0;
		for (int j=0;j<=i;++j) su=add(su,mult(ch[i][j],mult(sa[j],sa[i-j])));
		su=sub(su,mult(sa[i],pot(2,i)));
		su=divide(su,2);
		cout<<su<<en;
	}
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
constexpr int inf=1000001000;
constexpr ll INF=2e18;
constexpr ll mod=1000000007;
// ll MOD=998244353;
const ll MOD=998244353;

void Add(int &a, int b) {
  a += b;
  while (a >= MOD) a -= MOD;
  while (a < 0) a += MOD;
}

void Mul(int &a, int b) {
  a = 1LL * a * b % MOD;
}

int Pow(int b, int e) {
  if (e < 0) e += MOD - 1;
  int ret = 1;
  while (e) {
    if (e & 1) ret = 1LL * ret * b % MOD;
    b = 1LL * b * b % MOD;
    e >>= 1;
  }
  return ret;
}

int main() {
    int n,k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    // vector<vector<ll>> b(n,vector<ll>(k+1,1));
    vector<ll> b(n,1);
    vector<ll> e(k+5,0);
    rep(i,k+1) e[i]=Pow(i,MOD-2);
    vector<ll> c(k+1,0);
    rep(i,n){
      rep(j,k+1){
        (c[j]+=b[i])%=MOD;
        b[i]=(b[i]*a[i]%MOD*e[j+1])%MOD;
      }
    }
    // rep(i,n){
    //   rep(j,k+1) (c[j]+=b[i][j])%=MOD;
    // }
    vector<ll> ans(k+1);
    ans[1]=1;
    rep(i,k){
      ans[i+2]=(ans[i+1]*(i+2))%MOD;
    }
    vector<ll> o(k,0);
    rep(i,k){
      rep(j,k+1){
        if (i+1-j<0) break;
        (o[i]+=c[j]*c[i+1-j]%MOD)%=MOD;
      }
    }
    vector<ll> p(k+2,0);
    ll cc;
    rep(i,n){
      cc=a[i]*2;
      rep(j,k) {
        (p[j]+=cc)%=MOD;
        (cc*=a[i]*2)%=MOD;
      }
    }
    rep(i,k) cout << ((ans[i+1]*o[i]%MOD+MOD-p[i])%MOD)*Pow(2,MOD-2)%MOD << endl;
}


#include <cstdio>
#include <algorithm>

const int N = 2e5 + 5;
typedef long long LL;

int n, m, cntob;
int mxr[N], mxc[N];

int qry[N];

namespace BIT { // 树状数组
	int t[N];
	void add(int x) { while(x <= n) t[x]++, x += (x & -x); }
	int query(int x) { int ret = 0; while(x > 0) ret += t[x], x -= (x & -x); return ret; }
}

int main() {
	std::scanf("%d%d%d", &n, &m, &cntob);
	for(int i = 1; i <= n; i++) mxr[i] = m; // 第 i 行第一步可以到达最右的地方
	for(int i = 1; i <= m; i++) mxc[i] = n; // 第 i 列第一步可以到达最下的地方
	for(int i = 1; i <= cntob; i++) {
		int x, y;
		std::scanf("%d%d", &x, &y);
		mxr[x] = std::min(mxr[x], y - 1);
		mxc[y] = std::min(mxc[y], x - 1);
	}
	for(int i = mxr[1] + 1; i <= m; i++) mxc[i] = 0;
	for(int i = mxc[1] + 1; i <= n; i++) mxr[i] = 0;
	LL ans = 0;
	for(int i = 1; i <= m; i++) ans += mxc[i];
	int cntqry = mxc[1];
	for(int i = 1; i <= cntqry; i++) qry[i] = i;
	std::sort(qry + 1, qry + cntqry + 1, [](int x, int y) { return mxr[x] < mxr[y]; });
	int now = 1;
	for(int i = 1; i <= m; i++) {
		BIT::add(mxc[i] + 1);
		for(; mxr[qry[now]] <= i && now <= cntqry; now++)
			ans += BIT::query(qry[now]);
	}
	std::printf("%lld\n", ans);
	return 0;
} /* self
about TLE (with 14 ACs, 1 WA and 14 TLEs):
	BIT's indexes should add 1 each, because of zeros.
	(0 can't be the index of BIT)
about WA (with 21 ACs and 8 WAs):
	there shouldn't be n (H in the problem) querys
	(line 32 shouldn't be n but mxc[1])
*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a) (a).begin(),(a).end()
const int INIT = 0;//適当に変える max:0 min:2e9 gcd:0 sum:0
struct segmentTree{
private:
    int n;
    vector<int> node;

public:
    segmentTree(vector<int> vec){
        int sz = vec.size();
        n = 1;
        while(n<sz)n *= 2;
        node.resize(2 * n - 1,INIT);

        For(i,0,sz){
            node[i + (n - 1)] = vec[i];
        }
        for(int i=n-2;i>-1;i--){
            node[i] = node[2 * i + 1] + node[2 * i + 2];//演算子は適当に
        }
    }
    void update(int x,int val){
        x += (n - 1);
        node[x] = val;
        while(x){
            x = (x - 1) / 2;
            node[x] = node[2 * x + 1] + node[2 * x + 2];//演算子は適当に
        }
    }
    //区間[a,b) k:今見ているノード

    int get(int a, int b, int k=0, int l=0, int r=-1) {
        // 最初に呼び出されたときの対象区間は [0, n)
        if(r < 0) r = n;

        // 要求区間と対象区間が交わらない
        if(r <= a || b <= l) return INIT;

        // 要求区間が対象区間を完全に被覆
        if(a <= l && r <= b) return node[k];

        // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
        // 左側の子を vl ・ 右側の子を vr としている
        // 新しい対象区間は、現在の対象区間を半分に割ったもの
        int vl = get(a, b, 2 * k + 1, l, (l + r) / 2);
        int vr = get(a, b, 2 * k + 2, (l + r) / 2, r);
        int val = vl + vr;//演算子は適当に
        return val;
    }

};
ll ans = 0;
void Main(){
    using P = pair<int, int>;
    int h, w, m;
    cin >> h >> w >> m;
    vector<int> x(m), y(m);
    For(i,0,m) cin >> x[i] >> y[i];
    vector<P> wall;
    For(i,0,m){
        wall.push_back({x[i], y[i]});
    }
    For(i,1,h+1){
        wall.push_back({i, w+1});
    }
    sort(ALL(wall));
    vector<int> vec(w + 2, 0);
    segmentTree segTree(vec);
    P last = {0, 0};
    int xmax = h + 1;
    int ymax = wall[0].second;
    for(auto p : wall){
        if(p.second == 1) xmax = min(xmax, p.first);
    }

    for(auto p : wall){
        // cout << p.first << " " << p.second << " ";
        if(last.first != p.first){
            // 下右で来る場合の処理
            if(p.first < xmax) ans += p.second - 1;
            else{
                int r = min(ymax, p.second);
                ans += r - 1 - segTree.get(0, r);
                // cout << segTree.get(0, r) << " ";
            }
        }
        else{
            // 右下で来る場合の処理
            int r = min(ymax, p.second);
            if(last.second < r && p.first > 1)ans += r - last.second - 1 - segTree.get(last.second + 1, r);
        }

        segTree.update(p.second, 1);
        last = p;
        // cout << ans << endl;
    }
    cout << ans << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}


#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()
#define BACK(x) x.rbegin(),x.rend()
#define MOD 1000000007
#define INF INT_MAX
#define FLOAT_ANS setprecision(30)
#define TORAD(x) (x*acos(-1)/180.0)
#define TODEG(x) (x*180/acos(-1))
#define elif else if

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

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

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

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

// MAIN PROGRAM -------------

int main(){
	ll n,p;
	cin>>n>>p;
	--p;
	ll ans=modpow(p-1,n-1,MOD);
	cout<<(ans*p)%MOD;
}

/*

*/

#include<algorithm>
#include<iostream>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<utility>
#include<bitset>
#include<cstdio>
#include<string>
#include<time.h>
#include<vector>
#include<cmath>
#include<deque>
#include<queue>
#include<map>
#include<set>
using namespace std;
const int M=1e9+7;
int ksm(int a,int b)
{
	int c=1;
	while(b)
	{
		if(b&1)
			c=1ll*c*a%M;
		a=1ll*a*a%M;
		b>>=1;
	}
	return c;
}
int main()
{
	int n,p,a=1;
	scanf("%d%d",&n,&p);
	printf("%lld",1ll*ksm(p-2,n-1)*(p-1)%M);
}


#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
#define int long long int
#define endl "\n"
#define pb push_back
int sum = 0;
#define arrinp(v) for(auto &i:v) cin>>i,sum+=i;
#define arrout(v) for(auto &i:v) cout<<i<<" ";
#define newline cout<<endl;
#define all(s) (s).begin(),(s).end()
#define dbg(a) cout<<a<<endl;
#define dbg2(a,b) cout<<a<<" "<<b<<endl;
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<int,null_type,less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> new_data_set;
//             // order_of_key(int)  k-th largest element
//             // find_by_order(int) gives us according to the order
//             // insert() to insert in the PBDS
//             // new_data_set ST; calling
int fastModExp(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1){
            res = (res * a);
        }
        a = (a * a);
        b = b >> 1;
    }
    return res;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t(1);
    // cin >> t;
    while (t--) {
        sum = 1;
        int n;
        cin>>n;
        vector<int> v;
        for(int i=0;i<n;i++){
            string s;
            cin>>s;
            if(s[0]=='O'){
                v.pb(i+1);
            }
        }
        for(int i=0;i<v.size();i++){
            sum+=fastModExp(2,v[i]);
        }
        cout<<sum<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define fst first
#define snd second
#define INF 0x7fffffff
#define INFLL 0x7FFFFFFFFFFFFFFF
#define lenA(ar) sizeof(ar)/sizeof(*ar)
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(int i=x;i<y;i++)
#define foreI(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sl "\n";
#define ii pair<ll,ll>
#define mk make_pair

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main(){
   ll n,x;cin>>n>>x;
   fore(i,0,n){
       ll a;cin>>a;
       if(a!=x)cout<<a<<" ";
    }
    cout<<"\n";

}

#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N;
	long long X;
	cin >> N >> X;

	vector<long long> v;
	for (int i = 0; i < N; i++) {
		long long tmp;
		cin >> tmp;
		if (tmp != X) {
			v.push_back(tmp);
		}
	}

	for (long long ans : v) {
		cout << ans << " ";
	}
	cout << endl;

	return 0;
}


// Problem: A - God Sequence
// Contest: AtCoder - AtCoder Regular Contest 117
// URL: https://atcoder.jp/contests/arc117/tasks/arc117_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<ll>
#define vll vector<ll>
#define all(x) (x).begin() , (x).end()

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_ll_distribution<ll>(x, y)(rng)

void dbg(){
	cerr << endl;
}
template<typename Head , typename... Tail>
void dbg(Head h , Tail... t){
	cerr << h << " ";
	dbg(t...);
}

#ifdef EMBI_DEBUG
#define debug(...) cerr << "(" << #__VA_ARGS__  << "): ", dbg(__VA_ARGS__)
#else
#define debug(...)
#endif

const ll max_n = 1e5 + 9;
const ll mod = 1e9 + 7;
const ll inf = 1e9;

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
void solve(){
	ll a , b;
	cin >> a >> b;

	if(a >= b) {
		//positive > negative
		vector<ll> pos , neg;
		ll sum = 0;
		for(ll i = 1 ; i <= a ; i++) {
			pos.pb(i);
			neg.pb(-i);
			sum += i;
		}

		while(neg.size() > b) {
			ll num = neg.back();
			neg.pop_back();
			neg.back() += num;
		}

		for(auto it : pos) {
			cout << it << " ";
		}
		for(auto it : neg) {
			cout << it << " ";
		}
	}
	else {
		vector<ll> pos , neg;
		ll sum = 0;
		for(ll i = 1 ; i <= b ; i++) {
			pos.pb(i);
			neg.pb(-i);
			sum += i;
		}

		while(pos.size() > a) {
			ll num = pos.back();
			pos.pop_back();
			pos.back() += num;
		}

		for(auto it : pos) {
			cout << it << " ";
		}
		for(auto it : neg) {
			cout << it << " ";
		}
	}
}
signed main(){
	ll t = 1;
	// cin >> t;
	for(ll i = 1 ; i <= t ; i++){
		solve();
	}
}


#include<bits/stdc++.h>
using namespace std;
#define lli               long long int
#define ulli              unsigned long long int
#define vi                vector<int>
#define ii                pair<int,int>
#define all(v)            v.begin(),v.end()
#define getunique(v)      {v.erase(unique(v.begin(),v.end()),v.end());}
#define pb                push_back
#define ff                first
#define ss                second
#define endl              "\n"
#define fast_io           ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MS=1000001;
const lli INF=1e9+7;

template<typename T>
 bool comp(T a, T b){
  if(a<b)
    return true;
  return false;
 }
 int n,m;
  int get(int i, int j, vector<string> &v){
    if(i>=n || j>=m)
      return 0;
    if(v[i][j]=='-')
      return -1;
    return 1;
  }
  int dp[3000][3000][3];
 int solve(int i, int j, vector<string> &v, int inx){
  if(i>=n-1 && j>=m-1)
    return 0;
  // if(i>=n || j>=m)
  //   return 0;
  int add=0,a=0,b=0;
 // cout<<mine<<" "<<i+1<<" "<<j+1<<" "<<inx<<endl;
  if(dp[i][j][inx]!=-1)
    return dp[i][j][inx];
  if((inx==0)){
    a=get(i+1,j,v);
    b=get(i,j+1,v);
    if(i==n-1)
      return dp[i][j][inx]=b+solve(i,j+1,v,inx^1);
    else if(j==m-1)
      return dp[i][j][inx]=a+solve(i+1,j,v,inx^1);
   return dp[i][j][inx]=max(a+solve(i+1,j,v,inx^1),b+solve(i,j+1,v,inx^1));
  }
  else{
    a=get(i+1,j,v);
    b=get(i,j+1,v);
     if(i==n-1)
      return dp[i][j][inx]=-b+solve(i,j+1,v,inx^1);
    else if(j==m-1)
      return dp[i][j][inx]=-a+solve(i+1,j,v,inx^1);
    return dp[i][j][inx]=min(-a+solve(i+1,j,v,inx^1),-b+solve(i,j+1,v,inx^1));
  }
 // return add;
 }
int main(){
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
   fast_io;
   cin>>n>>m;
   vector<string> v(n);
   for(int i=0; i<n; i++)
    cin>>v[i];
  memset(dp,-1,sizeof dp);
  int ans=solve(0,0,v,0);
 // cout<<ans<<endl;
   if(ans>0)
    cout<<"Takahashi";
  else if(ans<0)
    cout<<"Aoki";
  else cout<<"Draw";

}


#include<iostream>
using namespace std;
int main()
{
    long long n,ans;
    cin>>n;
    int c[3]={0};
    while(n!=0)
    {
        c[n%10%3]++;
        n/=10;
    }
    int a=(c[1]+c[2]*2)%3;
    int k=c[0]+c[1]+c[2];
    if(a==0)
    {
        ans=0;
    }
    else if(a==1)
    {
        if(c[1])
        {
            if(k==1)
            {
                ans=-1;
            }
            else
            {
                ans=1;
            }
        }
        else
        {
            if(k==2)
            {
                ans=-1;
            }
            else
            {
                ans=2;
            }
        }
    }
    else
    {
        if(c[2])
        {
            if(k==1)
            {
                ans=-1;
            }
            else
            {
                ans=1;
            }
        }
        else
        {
            if(k==2)
            {
                ans=-1;
            }
            else
            {
                ans=2;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

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

typedef long long ll;

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

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

    int ans=100;

    rep(bit,1<<n.size()){
        string s;
        int cnt=0,sum=0;
        rep(i,n.size()){
            if(bit&(1<<i)){
                sum+=n[i]-'0';
                cnt++;
            }
        }

        if(cnt!=0){
            if(sum%3==0){
                int sub=n.size()-cnt;
                ans=min(ans,sub);
            }
        }
    }

    if(ans==100)ans=-1;

    cout<<ans<<endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;
#define LL long long

int main()
{
	LL H;
	cin >> H;
	LL W;
	cin >> W;

	map<string, bool> S;
	for (long long i = 0; i < H; ++i)
	{
		for (long long j = 0; j < W; ++j)
		{
			char s;
			cin >> s;

			string label;
			label += to_string(j);
			label += ",";
			label += to_string(i);

			S[label] = (s == '#');
		}
	}

	LL result = 0;
	for (long long i = 1; i < H-1; ++i)
	{
		for (long long j = 1; j < W-1; ++j)
		{
			string label;
			label += to_string(j);
			label += ",";
			label += to_string(i);
			string above;
			above += to_string(j);
			above += ",";
			above += to_string(i - 1);
			string left;
			left += to_string(j - 1);
			left += ",";
			left += to_string(i);
			string right;
			right += to_string(j + 1);
			right += ",";
			right += to_string(i);
			string down;
			down += to_string(j);
			down += ",";
			down += to_string(i + 1);
			if (S[label])
			{
				if(!S[above] && !S[left])
				{
					result++;
				}
				if (!S[above] && !S[right])
				{
					result++;
				}
				if (!S[down] && !S[left])
				{
					result++;
				}
				if (!S[down] && !S[right])
				{
					result++;
				}
			}
			else
			{
				if (S[above] && S[left])
				{
					result++;
				}
				if (S[above] && S[right])
				{
					result++;
				}
				if (S[down] && S[left])
				{
					result++;
				}
				if (S[down] && S[right])
				{
					result++;
				}
			}
		}
	}

	cout << result << endl;
}

#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<vector<int>> data(N, vector<int>(N));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> data.at(i).at(j);
    }
  }

  int ans = 0;
  vector<int> cities(N);
  for (int i = 0; i < N; i++) {
    cities.at(i) = i;
  }
  do {
    if (cities.at(0) != 0) continue;
    int sum = 0;
    for (int i = 0; i < N; i++) {
      //cout << cities.at(i);
      // 往路
      if (i == N - 1) {
        sum += data.at(cities.at(i)).at(0);
      } else {
        sum += data.at(cities.at(i)).at(cities.at(i + 1));
      }
    }
    //cout << endl;
    if (sum == K) ans++;
  } while (next_permutation(cities.begin(), cities.end()));

  cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<string, int> m;
  int highest = 0;
  for (int i = 0; i < n; ++i) {
  	string s;
    int a;
    cin >> s >> a;
    m[s] = a;
  }
  for (auto x : m) highest = max(highest, x.second);
  int second_highest = 0;
  for (auto x : m) if (x.second != highest) second_highest = max(second_highest, x.second);
  string ans = "";
  for (auto x : m) if (x.second == second_highest) ans = x.first;
  cout << ans << endl;
  return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

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

	LL N;
	cin >> N;

	vector<LL> ret;
	FOR(i, 1, max(2LL, (LL)sqrt(N)) + 1)
	{
		if((N % i) == 0){
			ret.push_back(i);
			ret.push_back(N / i);
		}
	}

	SORT(ret);
	ret.erase(unique(ALL(ret)), ret.end());

	EACH(r, ret){
		cout << r << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0ll)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

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

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

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

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

ll N = 50;
vll a = {-1, 1, 0, 0};
vll b = {0, 0, -1, 1};
vector<char> d = {'U', 'D', 'L', 'R'};
ll si, sj;
vvll tiles(N, vll(N)), points(N, vll(N));
ll tile_count = 0;
ll S = 0;
string ans = "";
vll ans_done;
ll ans_i, ans_j;

void RUN(ll si, ll sj, string st, vll don, ll sc) {
  ll i = si, j = sj;
  vll done = don;
  ll score = sc;
  done[tiles[i][j]] = 1;
  string s = st;
  while (1) {
    vll ikeru;
    rep(k, 4) {
      ll ni = i + a[k];
      ll nj = j + b[k];
      if (ni < 0 or N <= ni or nj < 0 or N <= nj) continue;
      if (done[tiles[ni][nj]] == 1) continue;
      ikeru.pb(k);
    }
    if (ikeru.empty()) break;
    ll r = rand() % ikeru.size();
    ll index = ikeru[r];
    s.pb(d[index]);
    i += a[index];
    j += b[index];
    done[tiles[i][j]] = 1;
    score += points[i][j];
  }
  if (S < score) {
    S = score;
    ans = s;
    ans_done = done;
    ans_i = i;
    ans_j = j;
  }
}

void NOB() {
  ll t_i = ans_i;
  ll t_j = ans_j;
  string t_s = ans;
  vll t_done = ans_done;
  ll t_S = S;
  ll modoru = rand() % t_s.size() + 1 + 20;
  chmin(modoru, (ll)t_s.size());
  rep(r, modoru) {
    char c = t_s[t_s.size() - 1];
    t_s.erase(t_s.end() - 1);
    t_done[tiles[t_i][t_j]] = 0;
    t_S -= points[t_i][t_j];
    if (c == 'U') t_i += 1;
    if (c == 'D') t_i -= 1;
    if (c == 'L') t_j += 1;
    if (c == 'R') t_j -= 1;
  }
  RUN(t_i, t_j, t_s, t_done, t_S);
}

signed main() {
  init();
  cin >> si >> sj >> tiles >> points;
  rep(i, N) chmax(tile_count, MAX(tiles[i]));
  ans_done.resize(tile_count + 1);
  srand(time(NULL));
  rep(n, 1000) RUN(si, sj, "", vll(tile_count + 1), points[si][sj]);
  rep(n, 390000) NOB();
  debug(S);
  ANS;
  return 0;
}

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

struct Tile {
	int tileNum;
	int point;
};

int si, sj;
Tile tile[52][52];
string ans;
string finalans;
bool used[2500];
int di[4] = { -1,0,0,1 };
int dj[4] = { 0,1,-1,0 };
vector<pair<int,int>> moveij;

void move(int ni, int nj, int nowij) {
	if (ni == 51 || nj == 51 || ans.empty()&&(ni!=si&&nj!=sj))
		return;
	moveij.push_back(pair<int, int>(ni, nj));
	tile[50][50].point = -1;
	used[tile[ni][nj].tileNum] = true;
	/*
	if ((tile[ni - 1][nj].used || tile[ni][nj].tileNum == tile[ni - 1][nj].tileNum) ||
		(tile[ni + 1][nj].used || tile[ni][nj].tileNum == tile[ni + 1][nj].tileNum) ||
		(tile[ni][nj - 1].used || tile[ni][nj].tileNum == tile[ni][nj - 1].tileNum) ||
		(tile[ni][nj + 1].used || tile[ni][nj].tileNum == tile[ni][nj + 1].tileNum)) {//どこにもいけない
		return;
	}
	*/
	int nexti = 51, nextj = 51;
	for (int i = 0; i < 4; i++) {
		if (0 <= ni + di[i] && ni + di[i] < 50 && 0 <= nj + dj[i] && nj + dj[i] < 50){
			if (!used[tile[ni + di[i]][nj + dj[i]].tileNum]) {
				if (tile[ni + di[i]][nj + dj[i]].point > tile[nexti][nextj].point) {
					nexti = ni + di[i]; nextj = nj + dj[i];
				}
			}
		}
	}
	if (nexti == 51 && nextj == 51) {
		//string change;
		finalans = (finalans.size() > ans.size()) ? finalans : ans;
		//finalans.erase(0);
		//finalans = change;
		ans.erase((int)ans.size() - 1);
		if (moveij.size() <= 1)return;
		moveij.erase(moveij.end()-1);
		--nowij;
		if (nowij <= 0)
			return;
		int nni = moveij[nowij].first;
		int nnj = moveij[nowij].second;
		moveij.erase(moveij.end() - 1);
		move(nni, nnj, nowij);
	}
	else {
		if (nexti == ni - 1) ans.push_back('U');
		else if (nexti == ni + 1)ans.push_back('D');
		else if (nextj == nj - 1)ans.push_back('L');
		else if (nextj == nj + 1)ans.push_back('R');
		move(nexti, nextj, ++nowij);
	}
}

int main() {
	cin >> si >> sj;
	rep(i, 50) rep(j, 50) cin >> tile[i][j].tileNum;
	rep(i, 50) rep(j, 50) cin >> tile[i][j].point;
	move(si, sj, 0);
	cout << finalans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  	ll i,n,x;
  	cin>>n>>x;
  	ll a[n];
  	for(i=1;i<=n;i++){
    	cin>>a[i];
  	}
  	ll cnt=0;
  	for(i=1;i<=n;i++){
    	if(a[i]!=x){
      		cout<<a[i]<<" ";
      		cnt++;
    	}
  	}
  	if(cnt==0) cout<<" "<<endl;
  	return 0;
}

#include <bits/stdc++.h>
#define  f               first
#define  s               second
#define  sym(s)          s = "#" + s + "#";
#define  all(x)          (x).begin(), (x).end()
#define  alll(x,n)       x+1, x+n+1
#define  newl            cout<<"\n";
#define  foo(i,a,n)      for(ll i = (a); i <= n; i++)
#define  deb1(a)         cout<<a<<"\n";
#define  deb2(a,b)       cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)     cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)   cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  debp(a)         cout<<a.f<<" "<<a.s<<"\n";
#define  debv(a)         for(auto it: a)cout<<it<<" ";newl;
#define  debm(a)         for(auto it: a)cout<<"{"<<it.f<<","<<it.s<<"}, ";newl;
#define  deb1d(a,n)      foo(i,1,n)cout<<a[i]<<" ";newl;
#define  deb2d(a,n,m)    foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}

using namespace std;
using ll              =  long long;
using ld              =  long double;
const ll   MOD        =  1e+9 + 7;
const ll   INF        =  LLONG_MAX;
const int  N          =  (int)2e+5 + 8;

ll n, a[N], x;

void MAIN(int tc) {
    cin >> n >> x;
    for(int i = 1; i <= n; i++){
        int y;
        cin >> y;
        if(y != x)cout << y << " ";
    }
}

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

    int test_cases = 1;
    //cin>>test_cases;
    for (int i = 1; i <= test_cases; i++) {
        MAIN(i);
    }
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define DB double
#define U unsigned
#define P std::pair
#define LL long long
#define LD long double
#define pb emplace_back
#define MP std::make_pair
#define SZ(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 2e5 + 5;
int n,m,mid,ans;
std::vector<int> G[MAXN];
int f[MAXN],g[MAXN];

inline void dfs(int v,int fa=0){
    f[v] = 1e9;g[v] = -1e9;
    for(auto x:G[v]){
        if(x == fa) continue;
        dfs(x,v);
        f[v] = std::min(f[v],f[x]+1);
        g[v] = std::max(g[v],g[x]+1);
    }
    if(f[v] > mid) g[v] = std::max(g[v],0);
    if(f[v]+g[v] <= mid) g[v] = -1e9;
    if(g[v] == mid) ++ans,g[v] = -1e9,f[v] = 0;
}

inline bool chk(int x){
    mid = x;ans = 0;dfs(1);
    if(g[1] != -1e9) ++ans;
    return ans <= m;
}

int main(){
    scanf("%d%d",&n,&m);
    FOR(i,2,n){
        int u,v;scanf("%d%d",&u,&v);
        G[u].pb(v);G[v].pb(u);
    }
    int l = 0,r = n,ans = -1;
    while(l <= r){
        int mid = (l + r) >> 1;
        if(chk(mid)) ans = mid,r = mid-1;
        else l = mid+1;
    }
    printf("%d\n",ans);
    return 0;
}

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

using namespace __gnu_pbds;
using namespace std;

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

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

#define mp make_pair

const int MOD =  998244353;

int mul(int a, int b) {
    return (1LL * a * b) % MOD;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=MOD) s-=MOD;
    return s;
}

int sub(int a, int b) {
    int s = (a+MOD-b);
    if (s>=MOD) s-=MOD;
    return s;
}

int po(int a, ll deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, MOD-2);
}

mt19937 rnd(time(0));

/*
const int LIM = 3e5 + 5;

vector<int> facs(LIM), invfacs(LIM);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<LIM; i++) facs[i] = mul(facs[i-1], i);
    invfacs[LIM-1] = inv(facs[LIM-1]);
    for (int i = LIM-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    if (n<k) return 0;
    if (n<0 || k<0) return 0;
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/

/*struct DSU
{
    vector<int> sz;
    vector<int> parent;
    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

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

    void union_sets(int a, int b) {
        find_set(a);
        find_set(b);

        a = find_set(a);
        b = find_set(b);

        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        };
    }

    DSU (int n)
    {
        parent.resize(n);
        sz.resize(n);
        for (int i = 0; i<n; i++) make_set(i);
    }
};*/

vector<vector<int>> G;

int n, k;

vector<int> parent;
vector<int> depth;
vector<vector<int>> children;

void dfs(int v, int par = -1)
{
    for (auto it: G[v]) if (it!=par)
    {
        children[v].push_back(it);
        depth[it] = depth[v] + 1;
        parent[it] = v;
        dfs(it, v);
    }
}

set<pair<int, int>> worst;
vector<bool> deleted;
vector<int> deleting;

void del(int v, int dist)
{
    if (!deleted[v])
    {
        worst.erase(mp(depth[v], v)); deleted[v] = true;
    }
    if (dist<=deleting[v]) return;
    deleting[v] = dist;

    if (dist==0) return;

    for (auto it: G[v]) del(it, dist-1);
}

bool check(int d)
{
    worst.clear();
    for (int i = 0; i<n; i++) worst.insert(mp(depth[i], i));
    deleted.clear(); deleted.resize(n);
    deleting.clear(); deleting.resize(n);

    int cnt = 0;
    while (!worst.empty())
    {
        cnt++;
        //cout<<"Iter "<<cnt<<": "<<endl;

        //for (auto it: worst) cout<<it.first<<' '<<it.second<<endl;

        auto it = *prev(worst.end());
        if (it.first<=d)
        {
            return (cnt<=k);
        }

        int deleting = it.second;
        for (int i = 0; i<d; i++) deleting = parent[deleting];
        //cout<<"Deleting: "<<deleting<<endl;
        del(deleting, d);
    }
    if (worst.empty()) return (cnt<=k);
}

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

    cin>>n>>k;

    G.resize(n);
    for (int i = 0; i<n-1; i++)
    {
        int u, v; cin>>u>>v; u--; v--;
        G[u].push_back(v); G[v].push_back(u);
    }

    parent.resize(n); depth.resize(n); children.resize(n);

    parent[0] = -1;
    dfs(0);

    int L = 0; int R = n;
    while (R-L>1)
    {
        int mid = (L+R)/2;
        if (check(mid)) R = mid; else L = mid;
    }

    cout<<R<<endl;

}


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

typedef tree<long long, null_type, less<long long>,
rb_tree_tag, tree_order_statistics_node_update> pbds;
//less_equal for identical elements

#define DEBUG

#ifdef DEBUG
#define debug(...) printf(__VA_ARGS__);
#else
#define debug(...)
#endif
#define fi first
#define se second
#define pb emplace_back
#define sz(x) (int)x.size()
#define mnto(x,y) x=min(x,(__typeof__(x))y)
#define mxto(x,y) x=max(x,(__typeof__(x))y)
#define INF 1023456789
#define LINF 1023456789123456789
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vll;

int primes[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71};
ll a,b,n,arr[80],memo[80][1500000];

ll dp(int x,int msk){
	if(x==n)return 1;
	if(memo[x][msk]!=-1)return memo[x][msk];
	int nmsk=msk;
	for(int i=0;i<20;++i){
		if(arr[x]%primes[i]==0){
			if(msk&(1<<i))return memo[x][msk]=dp(x+1,msk);
			nmsk|=(1<<i);
		}
	}
	return memo[x][msk]=dp(x+1,nmsk)+dp(x+1,msk);
}

int main(){
	scanf("%lld%lld",&a,&b);
	n=b-a+1;
	for(int i=0;i<n;++i){
		arr[i]=i+a;
	}
	memset(memo,-1,sizeof memo);
	printf("%lld\n",dp(0,0));
}


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

string s;
int f[10];
int main() {
	ios::sync_with_stdio(0);
	cin >> s;
	memset(f, 0, sizeof(f));
	for(int i = 0; i < s.size(); i++)
		f[s[i] - '0']++;
	if(s.size() == 2) {
		int d1 = (s[0] - '0') * 10 + (s[1] - '0');
		int d2 = (s[1] - '0') * 10 + (s[0] - '0');
		if(d1 % 8 == 0 || d2 % 8 == 0)
			cout << "Yes" << endl;
		else cout << "No" << endl;
		return 0;
	}
	if(s.size() == 1) {
		if(s == "8")
			cout << "Yes" << endl;
		else cout << "No" << endl;
		return 0;
	}
	for(int i = 112; i < 1000; i += 8) {
		int d1 = i / 100;
		int d2 = i / 10 % 10;
		int d3 = i % 10;
		int t[10];
		for(int i = 0; i <= 9; i++)
			t[i] = f[i];
		if(t[d1] > 0) t[d1]--;
		else continue;
		if(t[d2] > 0) t[d2]--;
		else continue;
		if(t[d3] <= 0) continue;
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
// Compile with "(g++) -std=c++11 -Wall -Wextra -Wconversion -Wshadow -Dcychien"
#ifdef cychien
#define debug(...) do {\
	fprintf(stderr, "%s - %d : (%s) = ", __PRETTY_FUNCTION__, __LINE__, #__VA_ARGS__);\
    _DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x) {cerr << x << '\n';}
template<typename I, typename ...T> void _DO(I&&x,T&&...tail) {cerr << x << ", "; _DO(tail...);}
#define IOS
#else
#define debug(...)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#endif
#define FOR(i, n) for(int i = 0; i < n; i++)
#define FOR1(i, n) for(int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define SZ(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const int NF = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9 + 7;
const ld PI = 3.14159265358979323846264338327950288;

ll mypow(ll a, ll x){
	if (x == 0) return 1;
	if (x == 1) return a;
	ll res = mypow(a, x >> 1);
	res *= res;
	if (x & 1) res *= a;
	return res;
}
set<ll> s;
int main() {
    IOS;
    ll n;
    cin >> n;
    for (ll a = 2; a <= 100000; a++){
    	for (ll b = 2; b <= 40; b++){
    		ld bb = ld(b), aa = ld(a);
    		if (bb * log(aa) <= log((ld)1e18)){
    			ll cc = mypow(a, b);
    			if (cc <= n){
    				s.insert(cc);
				}
			}
		}
	}
	cout << n - SZ(s) << '\n';
    return 0;
}


#include<iostream>
using namespace std;
int main() {
  int year;
  cin >> year;
  int century;
  century = year/100;
  if(year % 100 == 0) {
    cout << century;
  }
  else{
    cout << century + 1;
  }
  return 0;
}


/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#include <vector>
#include <map>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 262144

static_assert(__builtin_popcount(N) == 1);
template <class T>
class Bit{
public:
    T a[N];
    void add(int x,T k)
    {
        while( x < N ) a[x] += k, x += x+1&~x;
    }
    T qry(int x)
    {
        T res = 0;
        while( x >= 0 ) res += a[x], x -= x+1&~x;
        return res;
    }
    int lbd(T k)
    {
        if( a[N-1] < k ) return N;
        int res = -1, x = N>>1;
        while(x)
        {
            if(a[res+x]<k) k-=a[res+=x];
            x>>=1;
        }
        return res+1;
    }
    int ubd(T k)
    {
        if( a[N-1] <= k ) return N;
        int res = -1, x = N>>1;
        while(x)
        {
            if(a[res+x]<=k) k-=a[res+=x];
            x>>=1;
        }
        return res+1;
    }
};

Bit<int> bit;

int a[N], b[N];
std::map<int, std::vector<int>> mp;

int main()
{
    int n;
    scanf("%d", &n);
    for(int i=0;i<n;++i) scanf("%d", &a[i]);
    for(int i=0;i<n;++i) scanf("%d", &b[i]);
    for(int i=n-1;i>=0;--i) mp[b[i]+i].push_back(i);
    lli ans = 0;
    for(int i=0;i<n;++i)
    {
        std::vector<int> &v = mp[a[i]+i];
        if(v.empty()) return puts("-1"), 0;
        int k = v.back();
        v.pop_back();
        ans += i-bit.qry(k);
        bit.add(k,1);
    }
    printf("%lld\n", ans);
    return 0;
}

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<numeric>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0)

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
//using mint = modint998244353;

int dh[] = {-1,0,1,0};
int dw[] = {0,1,0,-1};

template<typename T>
struct BinaryIndexedTree{
	vector<T> bit;
	BinaryIndexedTree(int sz){
		bit.resize(sz+1);
	}
	void add(int k, T x){ //k番目にxを加える
		for(int i = k; i < (int)bit.size(); i |= i+1) bit[i] += x;
	}
	T sum(int k){ //[0,k)の区間の総和を求める
		T res = 0;
		for(int i = k-1; i >= 0; i = (i&(i+1))-1){
			res += bit[i];
		}
		return res;
	}
};

int main(){
    int n; cin >> n;
    vector<Pi> a(n);
    vector<Pi> b(n);
    rep(i,n) cin >> a[i].first,a[i].second = i;
    rep(i,n) cin >> b[i].first,b[i].second = i;
    rep(i,n) a[i].first += i;
    rep(i,n) b[i].first += i;
    vector<Pi> c,d;
    c = a,d = b;
    sort(c.begin(),c.end());
    sort(d.begin(),d.end());
    rep(i,n){
        if(c[i].first != d[i].first){
            cout << -1 << endl;
            return 0;
        }
    }
    vector<int> id(n);
    rep(i,n) id[c[i].second] = d[i].second;
    ll ans = 0;
    BinaryIndexedTree<int> bit(n);
    rep(i,n){
        ans += bit.sum(n)-bit.sum(id[a[i].second]);
        bit.add(id[a[i].second],1);
    }
    cout << ans << endl;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(b-1)),y(up?b:(a-1)){}_RX(int a):_RX(0,a){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef int64_t i64;
typedef uint64_t u64;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

int main() {

	const int A = read_item();
	const int B = read_item();

	int total = A + B;
	int ans = 4;

	if(total >= 15 && B >= 8) {
		ans = 1;
	} else if(total >= 10 && B >= 3) {
		ans = 2;
	} else if(total >= 3) {
		ans = 3;
	}

	printf("%d\n", ans);

	return 0;
}

/* wafdayo~~~ */

#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front

typedef long long ll;
typedef unsigned long long ull;
typedef short int si;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int nMax = 1e6+5;
const ll mod = 1e9+7;

int h,w,mini,sum;

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

	int x;
	cin >> h >>w;
	mini = INT_MAX;
	for (int i=0;i<h;i++) {
		for (int j=0;j<w;j++) {
			cin >> x;
			sum += x;
			mini = min(mini,x);
		}
	}
	cout << sum - mini * h * w << "\n";
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll a,b,c,d,count=1,x,y=0;
    cin>>a>>b>>c>>d;
    if(c*d<=b)cout<<-1<<endl;
    else
    {
        if((a+b)<=(c*d))cout<<1<<endl;
        else
        {
            count=1;
            x=a;
           while(1)
           {
               if(x<=(y*d)) {cout<<count-1<<endl;break;}
               x+=b;
               y+=c;
               count++;
           }
        }
    }
    return 0;
}

#include<cstdio>
#include<algorithm>
using namespace std;
long long a,b,c,d,x,ans;
int main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	x=c*d-b;
	if(x<=0)ans=-1;
	else{
		ans=a/x;
		if(a%x)++ans;
	}
	printf("%lld",ans);
	return 0;
}


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

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

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

int main() {
    ll S, P; cin >> S >> P;

    // N = S - M
    // (S - M) * M = P
    // SM - M^2 = P
    // M^2 - SM + P = 0
    ll ans = 0;
    for(ll M=1; M<=8000000; M++) {
        ll N = S - M;
        if(N <= 0) break;
        if(N*M == P) ans++;
    }
    cout << (ans > 0 ? "Yes" : "No") << endl;
    return 0;
}

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

#ifdef _DEBUG
#include "_DEBUG.hpp"
#endif
#define int long long
const long long inf = 2e18;
const int mod = 1e9 + 7;

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &in : v) is >> in;
  return is;
}

template <class T>
vector<T> make_vec(size_t a) {
  return vector<T>(a);
}

template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template <class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
  t = v;
}

template <class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v) {
  for (auto &e : t) fill(e, v);
}

// nCr mod p (p < 10) O(100 + log(n))
int Lucas(int n, int r, int p) {
  assert(n >= r);
  vector<vector<int>> dp(p, vector<int>(p));  // dp[n][r] = nCr
  for (int i = 0; i < p; i++) {
    dp[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % p;
    }
  }
  int res = 1;
  while (n > 0) {
    res = (res * dp[n % p][r % p]) % p;
    n /= p;
    r /= p;
  }
  return res;
}

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

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int color = (s[i] == 'B' ? 0 : s[i] == 'W' ? 1 : 2);
    ans = (ans + Lucas(n - 1, i, 3) * color) % 3;
  }
  if (n % 2 == 0) ans = (3 - ans) % 3;
  cout << (ans == 0 ? 'B' : ans == 1 ? 'W' : 'R') << endl;

  return 0;
}


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

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

int main() {
    ll N; cin >> N;
    vector<ll> a(N), t(N);
    rep(i,N) cin >> a[i] >> t[i];
    ll l = -inf, r = inf, add = 0;
    ll L = -inf, R = inf;
    bool is_straight = false;
    rep(i,N) {
        if (t[i]==1) {
            if (is_straight) {
                L += a[i];
                R += a[i];
                continue;
            }
            add += a[i];
            if (l!=-inf) L += a[i];
            if (r!=inf) R += a[i];
        } else if (t[i]==2) {
            if (is_straight) {
                chmax(L,a[i]);
                chmax(R,a[i]);
                continue;
            }
            if (a[i]<=L) continue;
            if (R<=a[i]) {
                L = a[i];
                R = a[i];
                is_straight = true;
                continue;
            }
            L = a[i];
            l = L - add;
        } else {
            if (is_straight) {
                chmin(L,a[i]);
                chmin(R,a[i]);
                continue;
            }
            if (R<=a[i]) continue;
            if (a[i]<=L) {
                L = a[i];
                R = a[i];
                is_straight = true;
                continue;
            }
            R = a[i];
            r = R - add;
        }
    }

    ll Q; cin >> Q;
    vector<ll> res(Q);
    rep(q,Q) {
        ll x; cin >> x;
        if (is_straight) {
            res[q] = L;
        } else {
            if (x<=l) res[q] = L;
            else if (x<r) res[q] = x + add;
            else res[q] = R;
        }
    }
    for (ll ans : res) cout << ans << endl;
}

#include <bits/stdc++.h>

using namespace std;

template<typename T>
void debug(vector<T> item) {

	for (auto i : item) {
		cout << i << " ";
	}

	cout << endl;
}

int main() {
	int N;

	cin >> N;

	int64_t mn = -(int64_t)1e9;
	int64_t mx = 1e9;

	int64_t sum = 0;
	for (int i = 0; i < N; ++i) {
		int64_t a, b;
		cin >> a >> b;

		if (b == 1) {
			sum += a;
			mn += a;
			mx += a;
		} else if (b == 2) {
			mn = max(a, mn);
			mx = max(a, mx);
		} else {
			mn = min(a, mn);
			mx = min(a, mx);
		}
	}

	int Q;

	cin >> Q;

	for (int i = 0; i < Q; ++i) {
		int64_t q;
		cin >> q;

		q += sum;

		if (mn <= q && q <= mx) {
			cout << q << endl;
		} else if (q < mn) {
			cout << mn << endl;
		} else {
			cout << mx << endl;
		}
	}

	return 0;
}


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

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

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

const string First = "First";
const string Second = "Second";

int main(){
  cout<<setprecision(1000);
  ll T;
  cin>>T;
  For(times,T){
    ll N;
    cin>>N;
    vector<ll> A(N);
    REP(N)cin>>A[i];
    if(N%2){
      cout<<Second<<endl;
    }else{
      map<ll,ll> cnt;
      REP(N){
        cnt[A[i]]+=1;
      }
      bool f = false;
      for (auto &&i : cnt)
      {
        if(i.second%2){
          f=true;
        }
      }
      if(f){
        cout<<First<<endl;
      }else{
        cout<<Second<<endl;
      }
    }
  }
    return 0;
}

#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <string.h>
#include <algorithm>
#include <map>
#define INF 0x3f3f3f3f
#define LL long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int a[200010];
map<int,int>mm;
int main(){
	int t;
	cin>>t;
	while(t--){
		mm.clear();
		int n;
		cin>>n;
		for(int i=1;i<=n;i++){
			cin>>a[i];
			mm[a[i]]++;
		}
		if(n&1)puts("Second");
		else{
			int flg=0;
			for(auto it=mm.begin();it!=mm.end();it++){
				if(it->S&1){
					flg=1;
					break;
				}
			}
			if(flg)puts("First");
			else puts("Second");
		}
	}
	return 0;
}


#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
    #include <atcoder/all>
    using namespace atcoder;
#endif

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<string>;
using vin= vector<int>;
using ll=long long;
using ull=unsigned long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using P=pair<int ,int>;
//const long double pi=acos(-1);
#define ft first
#define sd second
#define fn front
#define pb push_back
#define eb emplace_back
#define it insert
#define si(v) int((v).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sot(x) sort(x.begin(), x.end())
#define rese(x) reverse(x.begin(), x.end())
#define vnn(x,y,s,name) vector<vector<int>> name(x, vector<int>(y,s))
#define mse(x) memset(x, 0, sizeof(x))
#define mii(x,y,z) min(x,min(y,z))
#define maa(x,y,z) max(x,max(y,z))
#define cps CLOCKS_PER_SEC
#define yes cout<<"Yes"<<"\n"
#define no cout<<"No"<<"\n"
#define cset(x) cout<<fixed<<setprecision(x)
//const int INF=1001001001;
//998244353  1000000007

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<long long> ax(n);
    long long as=0;
    rep(i,n){
        ll a,b;
        cin>>a>>b;
        as-=a;
        ax[i]=2*a+b;
    }
    sot(ax);
    rese(ax);
    int cnt=0;
    while(as<=0){
        as+=ax[cnt];
        cnt++;
    }
    cout<<cnt<<endl;
}

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

template<int64 mod>
struct ModInt{
  int64 x;
  constexpr ModInt(int64 y = 0):x((y%mod+mod)%mod){}
  constexpr ModInt& operator+=(const ModInt& a){
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt& operator-=(const ModInt& a){
    if((x -= a.x) < 0)x += mod;
    return *this;
  }
  constexpr ModInt& operator*=(const ModInt& a){
    x = x * a.x % mod;
    return *this;
  }
  constexpr ModInt& operator/=(const ModInt& a){
    *this *= a.inv();
    return *this;
  }
  constexpr ModInt operator-() const {
    return ModInt(-x);
  }
  constexpr ModInt operator+(const ModInt& a) const {
    return ModInt(*this) += a;
  }
  constexpr ModInt operator-(const ModInt& a) const {
    return ModInt(*this) -= a;
  }
  constexpr ModInt operator*(const ModInt& a) const {
    return ModInt(*this) *= a;
  }
  constexpr ModInt operator/(const ModInt& a) const {
    return ModInt(*this) /= a;
  }
  constexpr ModInt operator++(){
    *this += ModInt(1);
    return *this;
  }
  constexpr ModInt operator++(int){
    ModInt old = *this;
    ++*this;
    return old;
  }
  constexpr ModInt operator--(){
    *this -= ModInt(1);
    return *this;
  }
  constexpr ModInt operator--(int){
    ModInt old = *this;
    --*this;
    return old;
  }
  constexpr bool operator==(const ModInt& a) const {
    return x == a.x;
  }
  constexpr bool operator!=(const ModInt& a) const {
    return x != a.x;
  }
  constexpr ModInt pow(int64 r) const {
    if(!r)return 1;
    ModInt res = pow(r>>1);
    res *= res;
    if(r & 1) res *= *this;
    return res;
  }
  constexpr ModInt inv() const {
    return pow(mod-2);
  }
  friend istream& operator>>(istream& is, ModInt& a){
    int64 t;
    is >> t;
    a = ModInt(t);
    return is;
  }
  friend ostream& operator<<(ostream& os, const ModInt& a){
    return os << a.x;
  }
};
using mint = ModInt<MOD>;

mint dp[(int)(2e5)+5][20][2];  // dp[i][j][k] := i番目までにj種類使って(1:Nと一致, 0:Nより真に小さい)ときの通り数

int32 hex2ten(char c){
  if('0' <= c && c <= '9'){
    return c - '0';
  }else{
    return 10 + c - 'A';
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int32 k;
  cin >> s >> k;

  dp[0][0][0] = 1; // 0
  dp[0][1][0] = hex2ten(s[0]) - 1; // 1,...,(s_0-1)
  dp[0][1][1] = 1;  //s_0

  set<int32> st;

  REP(i,s.size()-1){
    st.insert(hex2ten(s[i]));
    dp[i+1][1][0] += dp[i][0][0] * 15;
    dp[i+1][0][0] += dp[i][0][0];
    FOR(j,1,k+1){
      dp[i+1][j+1][0] += dp[i][j][0] * (16 - j);
      dp[i+1][j][0] += dp[i][j][0] * j;

      REP(l,hex2ten(s[i+1])){
        if(st.count(l)){
          dp[i+1][j][0] += dp[i][j][1];
        }else{
          dp[i+1][j+1][0] += dp[i][j][1];
        }
      }
      if(st.count(hex2ten(s[i+1]))){
        dp[i+1][j][1] += dp[i][j][1];
      }else{
        dp[i+1][j+1][1] += dp[i][j][1];
      }
    }
  }
  ANS(dp[s.size()-1][k][0] + dp[s.size()-1][k][1]);
  return 0;
}


#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=1;i<=(n);++i)
#define rep3(i,i0,n) for(ll i=i0;i<(n);++i)
#define rrep(i,n) for(ll i=((n)-1); i>=0; --i)
#define rrep2(i,n) for(ll i=(n); i>0; --i)
#define pb push_back
#define mod 1000000007
#define fi first
#define se second
#define len(x) ((ll)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
using Pi = pair< ll, ll >;
using vl = vector<ll>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<Pi>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

const ll INF = 1LL << 60;
const ld PI = 3.1415926535897932385;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
void printb(ll N,ll d=16){
    rep(i,d){
        cout<<(N/(1<<(d-i-1)))%2;
    }
    cout<<endl;

}
void printv(vector<ll>a){
    rep(i,a.size()){
        if(i==a.size()-1){
            cout<<a[i]<<endl;
        }else{
            cout<<a[i]<<" ";
        }
    }
}
bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;

    }else{
        return a.second < b.second;
    }
}

//const vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1};
//const vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

int main() {
    ll N;
    cin>>N;
    vector<ld> A(N);

    rep(i,N){
        cin>>A[i];
    }
    auto f = [&](ld x){
        ld ret=0;
        rep(i,N){
            ret+=min(A[i],2*x)-A[i]-x;
        }

        return ret/ld(N);
    };

    ll cnt=500;
    ld h=2e9;
    ld l=0;
    while(cnt--){
        ld c1 = (l*2+h)/3.0;
        ld c2 = (h*2+l)/3.0;
        //cout<<c1<<" "<<c2<<" "<<l<<" "<<h<<endl;
        if(f(c1)>f(c2)){
            h=c2;
        }else{
            l=c1;
        }
    }

    cout << fixed << setprecision(15);
    cout<<-f((l+h)/2)<<endl;

    return 0;

}

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

void solve()
{
	int n;
	cin>>n;
	vector<double>v(n);
	double sum=0;
	for(int i=0;i<n;++i)
	{
	    cin>>v[i];
	    sum+=v[i];
	}
	sum/=n;
	sort(v.begin(), v.end());
	vector<double>pre(n);
	pre[0]=v[0];
	for(int i=1;i<n;++i) pre[i]=pre[i-1]+v[i];
	double ans=1000000000000000000;
	for(int i=0;i<n;++i)
	{
	    double x=v[i]/2;
	    double val=x+sum;
	    double w=0;
	    if(i>0) w=pre[i-1];
	    val-=(2*x*(n-i)+w)/n;
	    ans=min(ans,val);
	    //cout<<val<<' '<<i<<'\n';
	}
	cout<<fixed<<setprecision(6)<<ans;

}

int main()
{
	solve();
}


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

const long long MAXVAL = (long long) 1e18 + 1;
const long long MOD = 1000000007ll;
//const long long MOD = 998244353ll;
const int INF = 1000000001;

long long poww(int x, long long pow) {
  if (pow == 0ll ) return 1;
  if (pow == 1ll) return x % MOD;
  long long ans = poww(x, pow >> 1) % MOD;
  ans = (ans * ans) % MOD;
  if ((pow & 1) == 1) {
    ans = (ans * x ) % MOD;
  }
  return ans % MOD;
}

ll gcd(ll x, ll y) {
  if (x == 0) return y;
  while (y) {
    x %= y;
    swap(x, y);
  }
  return x;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int q = 1;
   //cin >> q;
  while (q-- >0) {
    int n;
    cin >> n;
    int k;
    cin >> k;
    int cc[n];
    for (int i = 0; i < n; ++i) cc[i]  = 0;
    for (int i = 0; i < n; ++i) {
      int x;
      cin >> x;
      cc[x]++;
    }
    int ans = 0;
    int j =0 ;
    while (cc[0] && j < k) {
      for (int i = 0 ;i < n; ++i) {
        if (cc[i] == 0) break;
        ++ans;
        --cc[i];
      }
      ++j;
    }
    cout << ans << "\n";

  }
}

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

#define ll long long
#define ld long double
#define pb push_back
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define ff first
#define ss second
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define REPR(i,n,a) for(ll i=n;i>a;i--)
#define sq(x) (x)*(x)
#define t_c(t) ll t;cin>>t;while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// #define gcd(a,b) __gcd(a,b)
// #define lcm(a,b) (a*(b/gcd(a,b)))

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

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

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

ll neg_mod(ll a, ll b){
    ll r=a%b;
    return r<0 ? r+b : r;
}

// const ll maxN=1000000;
// ll prime[maxN+1];

// void sieve(){
//     prime[0]=prime[1]=1;
//     for(ll i=2;i<=maxN;i++){
//         if(prime[i]==0){
//             for(ll j=i*i;j<=maxN;j+=i){
//                 prime[j]=1;
//             }
//         }
//     }
// }

void solve(){
    ll t,n;
    cin>>t>>n;
    ll dis=100+t;
    vector<ll> v(dis+1,0);
    for(ll i=1;i<=100;i++){
        ll curr=(ll)floor(((ld)t*(ld)i)/(ld)100);
        v[i+curr]=1;
    }
    vector<ll> nv;
    for(ll i=1;i<=dis;i++){
        if(v[i]==0){
            nv.pb(i);
        }
    }
    ll mul=((ll)ceil((ld)n/(ld)t))-1;
    ll mod=n%t;
    if(mod==0){
        mod=t;
    }
    ll ans=(mul*dis)+(nv[mod-1]);
    cout<<ans;
    // for(ll i=0;i<nv.size();i++){
    //     cout<<nv[i]<<" ";
    // }
}

int main(){
    fast_io;
    // init_code();
    // t_c(t){
    //     solve();
    // }
    solve();
    return 0;
}


#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 3e3; int n;
lli a[maxN][5];
map<vector<int>, int> cnt;

vector<int> merge(vector<int> &a1, vector<int> a2)
{
  vector<int> ans(5);
  for (int i = 0; i < 5; i++) ans[i] = max(a1[i], a2[i]);
  return ans;
}
bool bruteForce(map<vector<int>, int>::iterator it = cnt.begin(), int chosen = 0, vector<int> curr = {0, 0, 0, 0, 0})
{
  if (chosen == 3 && *min_element(curr.begin(), curr.end()) == 1)
    return true;
  if (it == cnt.end())
    return false;

  if (bruteForce(next(it), chosen, curr))
    return true;
  for (int j = 1; chosen + j <= 3 && j <= it->second; j++)
  {
    curr = merge(curr, it->first);
    if (bruteForce(next(it), chosen + j, curr))
      return true;
  }
  return false;
}

bool can(lli x)
{
  cnt.clear();
  for (int i = 0; i < n; i++)
  {
    vector<int> b(5);
    for (int j = 0; j < 5; j++)
      b[j] = a[i][j] >= x;
    if (!cnt.count(b)) cnt[b] = 0;
    cnt[b]++;
  }

  return bruteForce();
}

int main()
{
  while (~scanf("%d", &n))
  {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < 5; j++)
        scanf("%lld", &a[i][j]);

    lli lo = 0, hi = 1e9;
    while (lo < hi)
    {
      lli mid = (lo + hi + 1) >> 1LL;
      if (can(mid)) lo = mid;
      else hi = mid - 1;
    }

    printf("%lld\n", lo);
  }
  return 0;
}

#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

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

			// sim dor(const c&) { ris; }
	};
	#ifdef ASJKD
}
	#endif
	#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
	#define read(x) for(auto &i : (x)){cin>>i;}
	#define all(x) begin(x), end(x)
	#define pb push_back
#define maxn 1500
ll mod = 998244353;
int INF = 1e9+1e8+1e7;
ll INF64 = 1e18;

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

struct pl{
	vector<int> h;
	void readd(){
		h.resize(5);
		for(int i=0;i<5;i++){
			cin>>h[i];
		}
	}
	bool amgood(vector<int> &sub, pl &other){
		int mn = INF;
		int mn2 = INF;
		for(int i=0;i<sub.size();i++){
			mn = min(h[sub[i]], mn);
		}
		for(int i=0;i<sub.size();i++){
			mn2 = min(other.h[sub[i]], mn2);
		}
		return mn > mn2;
	}
};
void test_case(int tnum){
	int n;
	cin>>n;
	vector<pl> a(n);
	for(int i=0;i<n;i++){
		a[i].readd();
	}
	vector<int> perm(5);
	for(int i=0;i<5;i++){
		perm[i]=i;
	}
	int ans =0;
	do{
		for(int t1=0;t1<=5;t1++){
			for(int t2=0;t2+t1<=5;t2++){
				vector<vector<int>> sub(3);
				for(int i=0;i<t1;i++){
					sub[0].pb(perm[i]);
				}
				for(int i=t1;i<t1+t2;i++){
					sub[1].pb(perm[i]);
				}
				for(int i=t1+t2;i<5;i++){
					sub[2].pb(perm[i]);
				}
				vector<pl> team;
				set<int> taken;
				for(int i=0;i<3;i++){
					int idx = -1;
					pl cur;
					cur.h.resize(5);
					for(int j=0;j<n;j++){
						if(!taken.count(j) && (idx == -1 or !cur.amgood(sub[i], a[j]))){
							idx = j;
							cur = a[j];
						}
					}
					taken.insert(idx);
					team.pb(a[idx]);
				}
				vector<int> mxs(5);
				for(pl p : team){
					for(int i=0;i<5;i++){
						mxs[i] = max(mxs[i], p.h[i]);
					}
				}
				ans = max(ans, *min_element(all(mxs)));

				// debug() << imie(sub) imie(taken) imie(perm) imie(t1) imie(t2);
				assert(sub[0].size() + sub[1].size() + sub[2].size() == 5);
			}
		}
	} while(next_permutation(all(perm)));
	cout << ans << '\n';
}
int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(false);
	int t=1;
	// cin>>t;
	for(int test=1;test<=t;test++){
		test_case(test);
	}
	return 0;
}


#include <bits/stdc++.h>
#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 chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define even(x) (x % 2 == 0 ? true : false)
#define odd(x) (x % 2 ? true : false)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;
//const int mod = 1000000007;
//vector<vector<int>> dp(m, vector<int>(n));

void	solve()
{
	vector<int>a(3);

	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(all(a));
	if (a[2] - a[1] == a[1] - a[0])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

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

	solve();
}

#include<bits/stdc++.h>
#define ll long long
ll n,m,k;
const ll mod = 998244353;
ll qmul(ll a,ll b){
	ll tmp = 0,s=0;
	while(b){
		s=(s+a)%mod;
		if(b&1) tmp=(tmp+s)%mod;
		b>>=1;
	}
	return tmp;
}
ll qpow(ll a,ll b){
	if(b==0) return 1;
	ll tmp = qpow(a,b/2);
	tmp = (tmp*tmp)%mod;
	if(b&1) tmp=(tmp*a)%mod;
	return tmp;
}
int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	if(n==1){
		printf("%lld",qpow(k,m));
		return 0;
	}
	if(m==1){
		printf("%lld",qpow(k,n));
		return 0;
	}
	ll ans = 0;
	ll last = 0;
	for(int i=1;i<=k;++i){
		ll a = qpow(i,n);
		ll b= qpow(k-i+1,m);
		ans=(ans+((a-last+mod)%mod)*b%mod)%mod;
		last = a;
	}
	printf("%lld",ans);
	return 0;
}


// {{{ Template

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

typedef long long ll;
typedef unsigned long long ull;

typedef std::vector <int> poly;
typedef std::pair <int,int> pii;

#define	fi first
#define se second
#define rez resize
#define pp pop_back
#define pb push_back
#define mkp std::make_pair

#define lep(i,l,r) for(int i=l;i<=r;++i)
#define rep(i,r,l) for(int i=r;i>=l;--i)

#define CLEAR(x) memset((x),0,sizeof((x)))
#define COPY(x,y) memcpy((x),(y),sizeof((x)))

const int inf=1e9+7;
const int mod=1e9+7;

template <class T> inline T read() {
	char ch; bool flag=0; T x=0;
	while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
	while(isdigit(ch)) x=x*10+ch-48,ch=getchar();
	return flag?-x:x;
}
struct {
	inline operator ll() {return read<ll>();}
	inline operator int() {return read<int>();}
	template <class T> inline void operator () (T &x) {x=*this;}
	template <class T,class ...A> inline void operator () (T &x,A &...a)
	{x=*this,this->operator()(a...);}
} IN;

template <class T> inline void chkmax(T &x,T y) {if(x<y) x=y;}
template <class T> inline void chkmin(T &x,T y) {if(x>y) x=y;}

inline int mul(int x,int y) {return 1ll*x*y%mod;}
inline int dec(int x,int y) {x-=y; if(x<0) x+=mod; return x;}
inline int add(int x,int y) {x+=y; if(x>=mod) x-=mod; return x;}
inline void sub(int &x,int y) {x-=y; if(x<0) x+=mod;}
inline void pls(int &x,int y) {x+=y; if(x>=mod) x-=mod;}

inline int modpow(int x,int y,int res=1) {
	for(y = (y+mod-1)%(mod-1);y;y>>=1,x=mul(x,x)) if(y&1) res=mul(res,x);
	return res;
}

// }}}

const int N = 2e5 + 5;
char s1[N], s2[N], s3[N];
int n;

inline void solve () {
	IN (n);
	scanf("%s%s%s\n",s1,s2,s3);
	lep (i,1,n) putchar ('0');
	lep (i,1,n) putchar ('1');
	putchar ('0'), puts ("");
}

int main() {
	int T = int(IN);
	while (T--) solve ();
	return 0;
}

#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(),_obj.end()
#define F first
#define S second
#define pll pair<ll, ll>
#define vll vector<ll>
ll n,m,a,b,c,k,temp,x,y,INF=1e18;
const int MAXN=1e5+11,mod=1e9+7;
ll max(ll a,ll b) {return ((a>b)?a:b);}
ll min(ll a,ll b) {return ((a>b)?b:a);}
vll read(int n) {vll v(n);for (int i = 0; i < v.size(); i++)cin>>v[i];return v;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int tree[500000],t[500000+1],ne[500000+1];
void bfst()
{
    for(int i=n-1;i>0;--i)
    tree[i]=tree[i<<1]+tree[i<<1|1];
}
int qfst(int l,int r)
{
    int res=0;
    for(l+=n,r+=n;l<r;l>>=1,r>>=1)
    {
        if(l&1) res+=tree[l++];
        if(r&1) res+=tree[--r];
    }
    return res;
}
void modify(int p, int value)
{
for (tree[p += n] = value; p > 1; p >>= 1)
tree[p >> 1] = tree[p]+tree[p ^ 1];
}
vll v[500000+2];
void sol(void)
{
cin>>n>>m>>k;
for(int i=1;i<=m;i++) t[i]=n+1;
for(int i=1;i<=n;i++) ne[i]=m+1;
vector<pll> vp;
while(k--)
{
  cin>>a>>b;
  t[b]=min(t[b],a);
  ne[a]=min(ne[a],b);
  vp.pb({a,b});
}
for(int i=2;i<=n;i++)
v[ne[i]].pb(i);
ll ans=1;
for(int j=2;j<=ne[1]-1;j++)
{
    ans+=t[j];
    ans--;
}
for(int i=2;i<=t[1]-1;i++)
{
    ans+=ne[i];
    ans--;
}
for(int i=0;i<n;i++) tree[i+n]=1;
bfst();
for(auto x:v[1])
modify(x-1,0);
for(int j=2;j<=ne[1]-1;j++)
{
    ans-=qfst(1,min(t[j],t[1])-1);
    for(auto x:v[j])
    modify(x-1,0);
}
cout<<ans;
return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int test=1;
    //cin>>test;
    while(test--) sol();
}


#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    int a, b;
    cin >> a >> b;
    if (min(a, b) + 3 > max({a, b}))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main() {
	int x,y;
	cin>>x>>y;
	fabs(x-y)<=2?cout<<"Yes":cout<<"No";
}


#include<stdio.h>
#include<stdlib.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
static int IN(void)
{
  int x=0,f=1,c;while(c=getchar(),c<48||c>57){if(c==45)f=-f;}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f*x;
}
static void OUT(long x){if(x<0){putchar('-'),x=-x;}if(x>=10){OUT(x/10);}putchar(x-x/10*10+48);}
static int Asc(const void *p1,const void *p2){rep(i,2){return ((int*)p1)[i]-((int*)p2)[i];}}
int main(void)
{
  int N=IN(),A[200000][2],B[200000][2],C[200000],bit[200000]={};long count=0l,sum=0l;
  rep(i,N){A[i][0]=IN()+i;A[i][1]=i;}qsort(A,N,sizeof(int*),Asc);
  rep(i,N){B[i][0]=IN()+i;B[i][1]=i;}qsort(B,N,sizeof(int*),Asc);
  rep(i,N){if(A[i][0]!=B[i][0]){return !puts("-1");}C[A[i][1]]=B[i][1];}
  rep(i,N)
  {
    sum=0l;for(int j=C[N-1-i]-1;j>=0;j=(j&(j+1))-1){sum+=bit[j];}count+=sum;
    for(int j=C[N-1-i];j<N;j|=j+1){bit[j]++;}
  }
  OUT(count);
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int N=5e5+500;
int n,a[N],b[N],tmpa[N],tmpb[N],cur[N],p[N],s[N];
vector<int>pos[N];
int query(int x){int ans=0;for(;x;x-=x&-x)ans+=s[x];return ans;}
void ins(int x){for(;x<=n;x+=x&-x)s[x]++;}
int main()
{
	long long ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i),a[i]+=i,tmpa[i]=a[i];
	for(int i=1;i<=n;i++)scanf("%d",b+i),b[i]+=i,tmpb[i]=b[i];
	sort(tmpa+1,tmpa+n+1),sort(tmpb+1,tmpb+n+1);
	for(int i=1;i<=n;i++)if(tmpa[i]!=tmpb[i]){puts("-1");return 0;}
	for(int i=1;i<=n;i++)a[i]=lower_bound(tmpa+1,tmpa+n+1,a[i])-tmpa;
	for(int i=1;i<=n;i++)b[i]=lower_bound(tmpb+1,tmpb+n+1,b[i])-tmpb;
	for(int i=1;i<=n;i++)pos[b[i]].push_back(i);
	for(int i=1;i<=n;i++)p[i]=pos[a[i]][cur[a[i]]],cur[a[i]]++;
	for(int i=n;i>=1;i--)ans+=query(p[i]),ins(p[i]);
	cout<<ans<<endl;
}


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

//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define lll __int128
#define tp top()
#define fr front()
#define vi vector<int>
#define sz size()
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define mem(a,  b) memset(a,  (b),  sizeof(a))
#define clr(a) memset(a,  0,  sizeof(a))
#define sqr(x) ( (x) * (x) )
#define all(v) v.begin(),  v.end()

typedef pair<int, int> pii;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;

void optIO(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

string s1,s2,s3,ss1,ss2,ss3;
int n;

void solve(){
	cin>>n;

	cin>>s1>>s2>>s3;
	string s;
	rep(i,0,n) s+='0';
	rep(i,0,n) s+='1';
	s += '0';
	cout<<s<<"\n";
}

int main()
{
	optIO();
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);
	int t=1;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <tuple>
using namespace std;

void yes(){ cout << "yes" << endl; }
void Yes(){ cout << "Yes" << endl; }
void YES(){ cout << "YES" << endl; }
void no(){ cout << "no" << endl; }
void No(){ cout << "No" << endl; }
void NO(){ cout << "NO" << endl; }
void print(string str){ cout << str << endl;}
#define rep(i, n)for(int i=0; i<n; i++)
#define ll long long

ll inf = 1000000007;
ll INF = 1000000000000000007;

int main(){
  ll T;
  cin >> T;

  rep(i, T){
    ll N;
    cin >> N;
    string S[3];
    rep(j, 3){
      cin >> S[j];
    }
    ll end = 2*N-1;
    // 末尾が全て同じ
    if(S[0][end] == S[1][end] && S[1][end] == S[2][end]){
      if(S[0][end] == '0'){
	rep(j, N){
	  cout << "1";
	}
	rep(j, N){
	  cout << "0";
	}
	cout << "1" << endl;
      }
      else{
	rep(j, N){
          cout << "0";
        }
        rep(j, N){
          cout << "1";
        }
        cout <<	"0" << endl;
      }
    }
    // 末尾が全て同じでない
    else{
      rep(j, N){
	cout << "0";
      }
      rep(j, N){
	cout << "1";
      }
      cout << "0" << endl;
    }

  }

  return 0;
}


#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
namespace atcoder {}
using namespace atcoder;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
#define int long long int

void solve(std::string S) {
  rep(i, S.size()) {
    if (!(S[i] >= 'a' && S[i] <= 'z' && i % 2 == 0) &&
        !(S[i] >= 'A' && S[i] <= 'Z' && i % 2 == 1)) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}

signed main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}

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

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

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

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

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1001001001;
const long long LINF = 1001002003004005006;
const double PI = acos(-1);
int d4r[] = {1, 0, -1, 0};
int d4c[] = {0, 1, 0, -1};
int d8r[] = {1, 1, 0, -1, -1, -1, 0, 1};
int d8c[] = {0, 1, 1, 1, 0, -1, -1, -1};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin >> s;
    bool flag = true;
    for(int i = 0;i < s.size();++i) {
        if(i % 2 == 0 && 'A' <= s[i] && s[i] <= 'Z') {
            flag = false;
        }
        else if(i % 2 == 1 && 'a' <= s[i] && s[i] <= 'z') {
            flag = false;
        }
    }
    if(flag == true) {
        cout << "Yes" << '\n';
    }
    else {
        cout << "No" << '\n';
    }
    return 0;
}


//Adarsh
//IIIT Gwalior
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,n) for(int i=1;i<=(int)n;i++)
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MAX_N = 1e5 + 1;
const int MOD = 1e9 + 7;
#define pb push_back
#define vi vector<int>
#define initial(a, x) memset(a, x, sizeof(a))
void solve() {
   ll n,x;
   string s;
   cin>>n>>x>>s;
   rep(i,n){
       if(s[i]=='o') x++;
       else{
           if(x>0) x--;
       }
   }
   cout<<x;
}
int main() {
    FAST_IO
   // int tc;
   // cin >> tc;
    //for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    //}
}

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

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


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         cout<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define endl            "\n"
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

void __print(int32_t x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

void fastIO()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int power(int a,int b,int md)
{
    int ans=1;

    while(b)
    {
        if(b&1) ans*=a;

        ans%=md;
        a*=a;
        a%=md;
        b>>=1;
    }

    return ans;
}

int find(map<int,int> &mp,int x)
{
    //debug("T",x);
    if(!mp.count(x)) return x;
    if(mp[x]==x) return x;
    return mp[x]=find(mp,mp[x]);
}

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

    map<int,int> mp;

    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        //debug(mp);
        //debug(i);
        if(!mp.count(x)&&!mp.count(y)) mp[min(x,y)]=max(x,y);
        else if(!mp.count(x)) mp[x]=find(mp,y);
        else if(!mp.count(y)) mp[y]=find(mp,x);
        else
        {
           // debug("J",mp);
            int px=find(mp,x),py=find(mp,y);

            if(!mp.count(px))
            {
                mp[px]=py;
            }
            else if(!mp.count(py))
            {
                mp[py]=px;
            }

        }
       // debug(mp);
    }
    mp.erase(0);
    cout<<mp.size();
}

int32_t main()
{
    fastIO();
    //w(t)
    {
        solve();
        cout<<endl;
    }
    return 0;
}

/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Reversible Cards
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 200000;
const int MAX_M = 400000;

/* typedef */

typedef vector<int> vi;

/* global variables */

vi nbrs[MAX_M];
bool used[MAX_M];
int ps[MAX_M], cis[MAX_M];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  int m = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    nbrs[a].push_back(b);
    nbrs[b].push_back(a);
    m = max(m, max(a, b));
  }
  m++;
  //printf("m=%d\n", m);

  int sum = 0;
  for (int st = 0; st < m; st++)
    if (! used[st]) {
      used[st] = true;
      ps[st] = -1;
      int gn = 1, en = 0;

      for (int u = st; u >= 0;) {
	vi &nbru = nbrs[u];
	if (cis[u] < nbru.size() && nbru[cis[u]] == ps[u]) cis[u]++;
	if (cis[u] < nbru.size()) {
	  int v = nbru[cis[u]++];
	  en++;
	  if (! used[v]) {
	    used[v] = true;
	    ps[v] = u;
	    gn++;
	    u = v;
	  }
	}
	else {
	  u = ps[u];
	}
      }
      //printf("gn=%d,en=%d\n", gn, en);
      sum += min(en, gn);
    }

  printf("%d\n", sum);
  return 0;
}