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

#define ll long long
#define ri register int
#define rep(io, st, ed) for(int io = st; io <= ed; io ++)
#define drep(io, ed, st) for(int io = ed; io >= st; io --)

#define gc getchar
inline int read() {
	int p = 0, w = 1; char c = gc();
	while(c > '9' || c < '0') { if(c == '-') w = - 1; c = gc(); }
	while(c >= '0' && c <= '9') p = p * 10  + c - '0', c = gc();
	return p * w;
}

const int limn = 8e5 + 5;

int n, far, lst, cnt;
int cap[limn], node[limn], nxt[limn], dep[limn], maxd[limn], son[limn];

void addedge(int u, int v) {
	nxt[++ cnt] = cap[u]; cap[u] = cnt; node[cnt] = v;
}

void dfs(int o, int fa) {
	#define cur node[i]
	maxd[o] = o; son[o] = 0;
	for(int i = cap[o]; i; i = nxt[i]) if(fa != cur) {
		dep[cur] = dep[o] + 1;
		dfs(cur, o);
		if(dep[ maxd[cur] ] > dep[ maxd[o] ])
			maxd[o] = maxd[cur], son[o] = cur;
	}
}

int E[limn];
void dfs2(int o, int fa) {
	E[o] = E[lst] + dep[o] + dep[lst] - 2 * dep[fa]; lst = o;
	for(int i = cap[o]; i; i = nxt[i])
		if(cur != fa && cur != son[o]) dfs2(cur, o);
	if(son[o]) dfs2(son[o], o);
}

int main() {
	n = read();
	rep(i, 2, n) {
		int u = read(), v = read();
		addedge(u, v); addedge(v, u);
	}
	dfs(1, 0); //find the diamter
	int u = maxd[1];
	dep[u] = 1; dfs(u, 0); //reset it!
	dfs2(u, 0);
	rep(i, 1, n) printf("%d ", E[i]); printf("\n");
	return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define endl '\n'
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define done(x) {cout << x << endl;return;}
#define mini(x,y) x=min(x,y)
#define maxi(x,y) x=max(x,y)
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;
uniform_int_distribution<int> rng(0, 1e9);

//DEBUG FUNCTIONS START
#define cerr cout
void __print(int 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...);}
#ifdef LOCAL
#define deb(x...)  _print(x)
#else
#define deb(x...)
#endif
// DEBUG FUNCTIONS END

const int N = 2e5 + 5;

void solve(){

    int n;
    cin >> n;
    int ans = n;
    int x = 1, y = 0;

    while(x <= n){
        int z = y + n / x + (n % x);
        x *= 2;
        y++;
        mini(ans, z);
    }

    cout << ans << endl;

}

signed main() {

    #ifdef LOCAL
        (void)!freopen("input.txt","r",stdin);
        (void)!freopen("output.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);
    int t = 1;
    //cin >> t;

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

int powm(int a, int b){
    int res = 1;
    while (b) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

int divide(int a, int b) {
    return (a % mod) * powm(b % mod, mod - 2) % mod;
}


#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define puba(a) emplace_back((a))
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N,S[200001],T[200001];
	ll W,P[200001];
	ll imos[200002]={};
	scan(N>>W);
	rep(i,N){
		scan(S[i]>>T[i]>>P[i]);
		imos[S[i]]+=P[i];
		imos[T[i]]-=P[i];
	}
	ll maximos=0;
	rep(i,200002){
		if(i>0) imos[i]+=imos[i-1];
		chmax(maximos,imos[i]);
	}
	if(maximos<=W) prin("Yes");
	else prin("No");
	return 0;
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define li long long
#define pii pair<int, int>
#define vi vector<int>
#define li long long

#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define fore(i, b, e) for (int i = (int)b; i <= (int)e; i++)

int main() {
	int tests;
	scanf("%d", &tests);
	forn(test, tests) {
		int n;
		scanf("%d", &n);
		vi start(n);
		forn(i, n) {
			scanf("%d", &start[i]);
		}
		while(true) {
			vi a = start;
			vi turns;
			while(true) {
				bool sorted = true;
				forn(i, n - 1)  {
					if (a[i] > a[i + 1]) {
						sorted = false;
						break;
					}
				}
				if (sorted) {
					break;
				}
				// forn(i, n) {
				// 	printf("%d ", a[i]);
				// }
				// printf("\n");
				/*if (turns.size() == 2) {
					break;
				}*/
				int turn = turns.size() % 2;
				bool found = false;
				for (int i = turn; i + 1 < n; i += 2) {
					if (a[i] > a[i + 1]) {
						swap(a[i], a[i + 1]);
						turns.pb(i);
						found = true;
						break;
					}
				}
				if (!found) {
					while(true) {
						int pos = rand() % (n - 1);
						if (pos % 2 == turn) {
							swap(a[pos], a[pos + 1]);
							turns.pb(pos);
							break;
						}
					}
				}
			}
			if (turns.size() <= n * n) {
				printf("%d\n", (int)turns.size());
				for (int x: turns) {
					printf("%d ", x + 1);
				}
				printf("\n");
				break;
			}
		}
	}
}


#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 K;
    cin>>K;

    vl AB(K+1);

    rep2(i,K){
        ll now=i;
        while(1){
            if(now>K)break;
            AB[now]++;
            now+=i;
        }
        //AB[K/i]++;
    }
    //printv(AB);
    //reverse(all(AB));
    rep(i,K){

        AB[i+1]+=AB[i];
    }
    //printv(AB);
    ll ans=0;
    rep2(i,K){
        ll now=1;
        ll cnt=1;

        ans+=AB[K/i];
    }

    cout<<ans<<endl;

    //printv(AB);
    return 0;

}

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

const int INF = (1<<30)-1;
const ll LINF = 1e18;

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

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

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

class union_find {
    vector<long long> par, sz, h;
    long long g;    //連結成分数

public:
     union_find(long long n) {
        par.resize(n);
        h.resize(n, 0);
        sz.resize(n,1);
        g = n;
        for (long long i = 0; i < n; i++)
            par[i] = i;
    }

    long long find(long long x) {
        if (par[x] == x)
            return x;
        else
            return par[x] = find(par[x]);
    }

    void unite(long long x, long long y) {
        x = find(x), y = find(y);
        if (x == y)
            return ;

        g--;
        if (h[x] < h[y])
            swap(x, y);

        sz[x] += sz[y];
        sz[y] = sz[x];
        par[y] = x;
        if (h[x] == h[y])
            h[x]++;
    }

    bool same(long long x, long long y) {
        return find(x) == find(y);
    }

    int size(long long x) {
        return sz[x] = sz[find(x)];
    }

    long long groups() {
        return g;
    }
};

int main() {
    int n;  cin >> n;
    vector<ll> a(n), b(n), vals;
    rep(i, n){
        cin >> a[i] >> b[i];
        vals.push_back(a[i]);
        vals.push_back(b[i]);
    }
    sort(vals.begin(), vals.end());
    vals.erase(unique(vals.begin(), vals.end()), vals.end());
    rep(i, n) {
        a[i] = lower_bound(vals.begin(), vals.end(), a[i]) - vals.begin();
        b[i] = lower_bound(vals.begin(), vals.end(), b[i]) - vals.begin();
    }
    union_find uf(vals.size());
    vector<int> cnt(vals.size(), 0);
    rep(i, n) {
        int x = uf.find(a[i]), y = uf.find(b[i]);
        if (x == y) {
            cnt[x]++;
            continue;
        }
        uf.unite(x, y);
        if (x != uf.find(x))
            swap(x, y);

        cnt[x] += 1 + cnt[y];
    }
    vector<bool> flag(vals.size(), false);
    ll ans = 0;
    rep(i, vals.size()) {
        if (flag[uf.find(i)])    continue;
        ans += min(uf.size(i), cnt[uf.find(i)]);
        flag[uf.find(i)] = true;
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define each(e, v) for(auto &e: v)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct io_setup{
    io_setup(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout << fixed << setprecision(15);
    }
} io_setup;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> cnt(N+1, 0);

    rep(i, N){
        int a; cin >> a;
        cnt[a]++;
    }

    ll ans = 0;
    rep(i, K){
        rep(j, N+1){
            if(cnt[j]) cnt[j]--;
            else{
                ans += j;
                break;
            }
        }
    }

    cout << ans << '\n';
}

/***************************************************************
	File name: D.cpp
	Author: ljfcnyali
	Create time: 2021年01月10日 星期日 20时08分49秒
***************************************************************/
#include<bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for ( int i = (a), _end_ = (b); i <= _end_; ++ i )
#define mem(a) memset ( (a), 0, sizeof ( a ) )
#define str(a) strlen ( a )
#define pii pair<int, int>
#define int long long
typedef long long LL;

const int maxn = 1e6 + 10;

int n, C, c[maxn], p[maxn], m, ans;
map<int, int> Map;
struct node
{
    int l, r, w;
} a[maxn];

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

inline void add(int pos, int val) { for ( int i = pos; i <= m; i += lowbit(i) ) c[i] += val; }

inline int get(int pos) { int sum = 0; for ( int i = pos; i > 0; i -= lowbit(i) ) sum += c[i]; return sum; }

signed main()
{
    scanf("%lld%lld", &n, &C);
    REP(i, 1, n)
    {
        scanf("%lld%lld%lld", &a[i].l, &a[i].r, &a[i].w);
        ++ a[i].r; Map[a[i].l] = Map[a[i].r] = true;
    }
    for ( auto it : Map ) { Map[it.first] = ++ m; p[m] = it.first; }
    REP(i, 1, n) { add(Map[a[i].l], a[i].w); add(Map[a[i].r], -a[i].w); }
    REP(i, 1, m - 1)
    {
        int val = min(get(i), C);
        ans += val * (p[i + 1] - p[i]);
    }
    printf("%lld\n", ans);
    return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
#define rprintf(fmt, begin, end) do { const auto end_rp = (end); auto it_rp = (begin); for (bool sp_rp=0; it_rp!=end_rp; ++it_rp) { if (sp_rp) putchar(' '); else sp_rp = true; printf(fmt, *it_rp); } putchar('\n'); } while(0)

template<unsigned MOD_> struct ModInt {
    static constexpr unsigned MOD = MOD_;
    unsigned x;
    void undef() { x = (unsigned)-1; }
    bool isnan() const { return x == (unsigned)-1; }
    inline int geti() const { return (int)x; }
    ModInt() { x = 0; }
    ModInt(int y) { if (y<0 || (int)MOD<=y) y %= (int)MOD; if (y<0) y += MOD; x=y; }
    ModInt(unsigned y) { if (MOD<=y) x = y % MOD; else x = y; }
    ModInt(long long y) { if (y<0 || MOD<=y) y %= MOD; if (y<0) y += MOD; x=y; }
    ModInt(unsigned long long y) { if (MOD<=y) x = y % MOD; else x = y; }
    ModInt &operator+=(const ModInt y) { if ((x += y.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(const ModInt y) { if ((x -= y.x) & (1u<<31)) x += MOD; return *this; }
    ModInt &operator*=(const ModInt y) { x = (unsigned long long)x * y.x % MOD; return *this; }
    ModInt &operator/=(const ModInt y) { x = (unsigned long long)x * y.inv().x % MOD; return *this; }
    ModInt operator-() const { return (x ? MOD-x: 0); }

    ModInt inv() const { return pow(MOD-2); }
    ModInt pow(long long y) const {
	ModInt b = *this, r = 1;
	if (y < 0) { b = b.inv(); y = -y; }
	for (; y; y>>=1) {
	    if (y&1) r *= b;
	    b *= b;
	}
	return r;
    }

    friend ModInt operator+(ModInt x, const ModInt y) { return x += y; }
    friend ModInt operator-(ModInt x, const ModInt y) { return x -= y; }
    friend ModInt operator*(ModInt x, const ModInt y) { return x *= y; }
    friend ModInt operator/(ModInt x, const ModInt y) { return x *= y.inv(); }
    friend bool operator<(const ModInt x, const ModInt y) { return x.x < y.x; }
    friend bool operator==(const ModInt x, const ModInt y) { return x.x == y.x; }
    friend bool operator!=(const ModInt x, const ModInt y) { return x.x != y.x; }
};

constexpr LL MOD = 1000000007;
// constexpr LL MOD = 998244353;
using Mint = ModInt<MOD>;

const int MAX = 3000011;
Mint inv[MAX], fact[MAX], fact_inv[MAX];

bool _auto_init() {
    fact[0] = 1;
    for (int i=1; i<MAX; i++) fact[i] = fact[i-1] * i;
    fact_inv[MAX-1] = fact[MAX-1].inv();
    for (int i=MAX-2; i>=0; i--) fact_inv[i] = fact_inv[i+1] * (i+1);
    inv[0] = 0;
    for (int i=1; i<MAX; i++) inv[i] = fact_inv[i] * fact[i-1];
    return true;
}
const bool _auto_init_done = _auto_init();

Mint nCk(int n, int k) {
    return fact[n] * fact_inv[k] * fact_inv[n-k];
}

int N, M, K;
void MAIN() {
    scanf("%d%d%d", &N, &M, &K);

    Mint ans;
    if (N - M > K) {
	ans = 0;
    } else {
	ans = nCk(N+M, N);
	int X = K+1;
	if (X <= N) {
	    ans -= nCk(N+M, N-X);
	}
    }

    printf("%d\n", ans.geti());
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}

#include <bits/stdc++.h>
#define st first
#define nd second
#define PQ priority_queue

using ll = long long ;
using namespace std;
using pii = pair<int,int>;
const int N = 5e3 + 10;
const int MOD = 998244353;
int dp[N][N], val[N][N], row[N], col[N];
int mul(int x, int y){ return 1LL * x * y % MOD;}
int add(int x, int y){ return (1LL * x + y) % MOD;}
int main(){
	int h, w, k;
	scanf("%d %d %d", &h, &w, &k);
	for(int i = 1; i <= h; i++) row[i] = 1;
	for(int j = 1; j <= w; j++) col[j] = 1;
	for(int i = 1; i <= k; i++){
		char s[3];
		int x, y;
		scanf("%d%d%s", &x, &y, s);
		if(s[0] == 'R') dp[x][y] = 1;
		if(s[0] == 'D') dp[x][y] = 2;
		if(s[0] == 'X') dp[x][y] = 3;
	}
	val[1][1] = 1;
	for(int i = 1; i <= h; i++){
		for(int j = 1;j <= w; j++){
			if(i == 1 & j == 1) continue;
			if(dp[i - 1][j] == 0) val[i][j] = add(val[i][j], mul(row[i], mul(2, val[i - 1][j])));
			else if(dp[i- 1][j] != 1) val[i][j] = add(val[i][j], mul(row[i], val[i - 1][j]));
			if(dp[i][j - 1] == 0) val[i][j] = add(val[i][j],  mul(col[j], mul(2 , val[i][j - 1])));
			else if(dp[i][j - 1] != 2) val[i][j] = add(val[i][j], mul(col[j], val[i][j - 1]));
			if(dp[i][j] == 0) {
				col[j] = mul(col[j], 3);
				row[i] = mul(row[i], 3);
			}
		}

	}
	if(dp[h][w] == 0) val[h][w] = mul(val[h][w], 3);
	printf("%d", val[h][w]);

}


#include<stdio.h>

int main() {

	int N, X,A;

	scanf("%d %d", &N, &X);

	for (int i = 0; i < N; i++) {
		scanf("%d", &A);
		if (A != X) {
			printf("%d ", A);
		}
	}

	return 0;
}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

constexpr i32 mod   = 1e9 + 7;
// constexpr i32 mod   = 998244353;

constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr i32 dx[] = {0, -1, 1, 0, -1, 1, -1, 1};
constexpr i32 dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(i32 x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != (int)v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

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

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

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

void solve() {
  int n = input(), x = input();
  vector< int > ans;
  range(i, 0, n) {
    int a = input();
    if (a == x) continue;
    ans.emplace_back(a);
  }

  cout << ans << endl;
}

signed main() {
  solve();
}


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

int main()
{
    long long N, a[100000], b[100000];
    cin >> N;
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i] >> b[i];
        sum += b[i] * (b[i] + 1) / 2 - a[i] * (a[i] -1) / 2;
    }

    cout << sum;

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  map<int, string> A;
  priority_queue<int> B;
  int t;
  string s;
  for(int i=0;i<n;i++){
    cin >> s >> t;
    A[t] = s;
    B.push(t);
  }
  B.pop();
  cout << A[B.top()] << endl;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    int ans;
    int ansnum;
    for (int i = 2; i <= a.at(n - 1); i++) {
        int count = 0;
        for (int j = 0; j < n; j++) {
            if (a.at(j) % i == 0) {
                count++;
            }
        }
        if (i == 2) {
            ans = count;
            ansnum = 2;
        } else {
            if (ans < count) {
                ans = count;
                ansnum = i;
            }
        }
    }
    cout << ansnum << endl;
    return 0;
}

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using pint = pair<int, int>;
using pll  = pair<ll, ll>;
using vint = vector<int>;
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

int N;
// *********************************************************
int main(){

    cin >> N ;
    map<int,int> mp;

    int an;
    rep(i,N){
        cin >> an;
        int san = sqrt(an);
        for(int i=2; i<=san; i++){
            if(an%i == 0){
                ++mp[i];
                if(an/i != i){
                    ++mp[an/i];
                }
            }
        }
        ++mp[an];

    }

    int max=0;
    int ans=0;
    for(auto i=mp.begin(); i != mp.end(); i++){
        //cout << i->first << " " << i->second<<endl;
        if(max < i->second){
            max = i->second;
            ans = i->first;
        }
    }

    cout << ans << endl;

    return 0;
}


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

typedef long long ll;
using namespace std;
//using namespace atcoder;

#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define _reps(i, s, n) for(ll i = (ll)(s); i < (ll)n; i++)
#define REP(...) _overload(__VA_ARGS__, _reps, _rep,)(__VA_ARGS__)
#define all(v) (v).begin(),(v).end()
#define UNIQUE(v) (v).erase( unique( all(v) ), (v).end() );
#define MOD 1000000007

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

	ll a[n], b[n];
	REP(i, n){
		cin >> a[i];
	}
	REP(i, n){
		cin >> b[i];
	}

	ll c[n];
	ll a_max = a[0];
	c[0] = a[0]*b[0];
	REP(i, 1, n){
		a_max = max(a_max, a[i]);
		c[i] = max(a_max*b[i], c[i-1]);
	}

	REP(i, n){
		cout << c[i] << endl;
	}

	return 0;
}

#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define REP(i,a,b) for (auto i = a; i != b; i++)
#define maxheap priority_queue < ll, std::vector<ll>, std::less<ll> >
#define minheap priority_queue < ll, std::vector<ll>, std::greater<ll> >   // mxheap.push(), mxheap.top(), mxheap.pop()
#define ll long long int
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define pb push_back
#define SQ(a) (a)*(a)

using namespace std;
// using namespace FastIO;
void read(int n,vector<int>& x)
{
    x.clear();
    x.resize(n);
    for(int i = 0;i<n;i++)
    {
        cin>>x[i];
    }

}
void read(int n,int m,vector<vector<int>>& x)
{
    x.clear();
    x.resize(n,vector<int>(m));
    for(int i = 0;i<n;i++)
    {
        for(int j = 0 ;j<m;j++)
            cin>>x[i][j];
    }
}
void read(int n,vector<vector<int>>& x)
{
    x.clear();
    x.resize(n+1);
    for(int i = 0;i<n-1;i++)
    {
         int a,b;
         cin>>a>>b;
         x[a].pb(b);
         x[b].pb(a);
    }
}
void read(int n,vector<vector<int>>& x,int m)
{
    x.clear();
    x.resize(n+1);
    for(int i = 0;i<m;i++)
    {
         int a,b;
         cin>>a>>b;
         x[a].pb(b);
         x[b].pb(a);
    }
}
void read(int n,vector<ll>& x)
{
    x.clear();
    x.resize(n);
    for(int i = 0;i<n;i++)
    {
        cin>>x[i];
    }
}
int main()
{
    std::ios::sync_with_stdio(false);
    int T = 1;
    // freopen("mixmilk.in", "r", stdin);
    // freopen("mixmilk.out", "w", stdout);
    //cin>>T;
    for(int t = 1;t<=T;t++)
    {
        // cout<<"Case #"<<t<<": ";
        int n,m;
        cin>>n;
        vector<ll> a(n);
        vector<ll> b(n);
        read(n,a);
        read(n,b);
        ll maxa = 0;
        ll ans = 0;
        for(int i=0;i<n;i++){
            maxa = max(maxa,a[i]);
            ans = max(ans,maxa * b[i]);
            cout<<ans<<endl;
        }
        // cout<<ans<<endl;

    }

    return 0;
}


#include<bits/stdc++.h>
#define maxn 1000005
#define inf 0x7fffffffffff
#define mod 1000000007
#define mst(a,x) memset(a,x,sizeof(a))
#define up(l,r,i) for(LL i=l;i<=r;i++)
#define down(l,r,i) for(LL i=l;i>=r;i--)
#define in(l,r,a) for(LL i=l;i<=r;i++)cin>>a[i]
#define out(l,r,a) for(LL i=l;i<=r;i++)cout<<a[i]<<" "
#define injz(n,m,a) for(LL i=1;i<=n;i++)for(LL j=1;j<=m;j++)cin>>a[i][j]
#define st(a,n) sort(a+1,a+n+1)
#define sta(v) sort(v.begin(),v.end())
#define endl "\n"
#define hh cout<<endl
#define pb push_back
#define cf cin>>T;while(T--)
#define xh(n) U=n;while(U--)
#define cfout(x) cout<<(x?"YES":"NO")<<endl
#define cs cerr<<"qaq"<<endl
#define dbg(n) cerr<<n<<endl
typedef long long LL;LL T,U;
typedef double db;
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    #ifdef ONLINE_JUDGE
    #else
    //freopen("bwxnQAQin.txt","r",stdin);
    //freopen("bwxnQAQout.txt","w",stdout);
    #endif
    LL n,k,ans=0;
    cin>>n>>k;
    up(1,n,i)
    {
        up(1,k,j)ans+=100*i+j;
    }
    cout<<ans<<endl;
    cerr<<"Time : "<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms";
    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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

	int H, W;
	cin >> H >> W;

	string S[10];
	rep(i, H) cin >> S[i];

	int kotae = 0;
	rep(i, H - 1) rep(j, W - 1) {
		int k = 0;
		if (S[i][j] == '#') k++;
		if (S[i][j + 1] == '#') k++;
		if (S[i + 1][j] == '#') k++;
		if (S[i + 1][j + 1] == '#') k++;

		if (k % 2) kotae++;
	}

	co(kotae);

	Would you please return 0;
}


// FIRST THINK THEN CODE.

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

using namespace std;

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

#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define cld complex<ld>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vld vector<ld>
#define vvld vector<vector<ld>>
#define vpll vector<pll>
#define vcld vector<cld>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define eb emplace_back
#define PI acos(-1)
#define endl "\n"
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define mset(a,val) memset(a,val,sizeof(a));
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
#define FOR(i,a,b)  for(ll i=a;i<=b;i++)
#define FORR(i,a,b)  for(ll i=a;i>=b;i--)
const ll M = 1000000007;
const ll MM = 998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define ordered_set tree<pll, null_type,less<>, rb_tree_tag,tree_order_statistics_node_update>

ll begtime = clock();
#define end_routine() cerr << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

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

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

const ll N = 2e5 + 5;

ll mulmod(ll a, ll b, ll c) {

	ll ans = 0;
	ll y = a % c;
	while (b) {
		if (b & 1) {
			(ans += y) %= c;
		}
		y = y * 2 % c;
		b >>= 1;
	}
	return ans;

}

ll powMbig(ll a, ll b, ll m)
{
	if (a <= 0)return 0;
	a %= m;

	ll ans = 1LL;
	while (b)
	{
		if (b & 1)//ans = ans * a % m;
			ans = mulmod(ans, a, m);
		//a = a * a % m;
		a = mulmod(a, a, m);
		b >>= 1;
	}

	return ans;
}

ll powM(ll a, ll b, ll m)
{
	if (a <= 0)return 0;
	a %= m;

	ll ans = 1LL;
	while (b)
	{
		if (b & 1)ans = ans * a % m;
		//ans = mulmod(ans, a, m);
		a = a * a % m;
		//a = mulmod(a, a, m);
		b >>= 1;
	}

	return ans;
}

ll poww(ll a, ll b)
{

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

	return ans;

}
vpll arr[N];

vector<vvl> cnt(N, vvl(2, vl(62)));
vl foo(60);
void dfs(ll node, ll par) {
	FOR(iter, 0, 59)cnt[node][0][iter] = 1;
	for (auto to : arr[node]) {
		//	vvl lol(2);
		ll child = to.ff;
		if (child == par)continue;
		dfs(child, node);
		ll weight = to.ss;
		for (ll iter = 0; iter < 60; iter++) {
			ll we = 0;
			if (1ll << iter & weight)we = 1;
			(foo[iter] += cnt[node][we][iter] * cnt[child][1][iter]) %= M;
			(foo[iter] += cnt[node][1 ^ we][iter] * cnt[child][0][iter]) %= M;
			(cnt[node][0][iter] += cnt[child][0 ^ we][iter]) %= M;
			(cnt[node][1][iter] += cnt[child][1 ^ we][iter]) %= M;
			// if (cnt[node][0][iter] > M * M)cnt[node][0][iter] %= M;
			// if (cnt[node][1][iter] > M * M)cnt[node][1][iter] %= M;
			// if (foo[iter] > M * M)foo[iter] %= M;
		}
		//	foo += cnt[node][0] * cnt[node][1];
		//	cnt[node]=lol;
	}
	// FOR(iter, 0, 59) {
	// 	if (cnt[node][0][iter] > M * M)cnt[node][0][iter] %= M;
	// 	if (cnt[node][1][iter] > M * M)cnt[node][1][iter] %= M;
	// }
}

void OJ() {

#ifndef ONLINE_JUDGE

	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);

#endif

}

int main() {

	IOS;

	OJ();

	ll n; cin >> n;

	vl u(n), v(n), w(n);

	FOR(i, 0, n - 1) {
		cin >> u[i] >> v[i] >> w[i];
		arr[u[i]].pb({v[i], w[i]});
		arr[v[i]].pb({u[i], w[i]});
	}
	ll ans = 0;

	dfs(1, -1);

	for (ll i = 0; i < 60; i++) {
		ans = (ans + foo[i] * powM(2, i, M)) % M;
	}

	cout << ans;

	return 0;

}

//12252024832524
#include <cstdio>
#include <cstring>
#include <algorithm>
#define TT template<typename T>
using namespace std;

typedef long long LL;
const int MAXN = 200005;
const int MOD = 1e9 + 7;
int n;
LL ans;

LL Read()
{
	LL x = 0,f = 1;char c = getchar();
	while(c > '9' || c < '0'){if(c == '-')f = -1;c = getchar();}
	while(c >= '0' && c <= '9'){x = (x*10) + (c^48);c = getchar();}
	return x * f;
}
TT void Put1(T x)
{
	if(x > 9) Put1(x/10);
	putchar(x%10^48);
}
TT void Put(T x,char c = -1)
{
	if(x < 0) putchar('-'),x = -x;
	Put1(x); if(c >= 0) putchar(c);
}
TT T Max(T x,T y){return x > y ? x : y;}
TT T Min(T x,T y){return x < y ? x : y;}
TT T Abs(T x){return x < 0 ? -x : x;}

int head[MAXN],tot;
struct edge
{
	int v,nxt;
	LL w;
}e[MAXN << 1];
void Add(LL x){ans = (ans + x) % MOD;}
void Add_Edge(int x,int y,LL z)
{
	e[++tot].v = y;
	e[tot].w = z;
	e[tot].nxt = head[x];
	head[x] = tot;
}
void Add_Double_Edge(int x,int y,LL z)
{
	Add_Edge(x,y,z);
	Add_Edge(y,x,z);
}

LL dp[MAXN][2];
void dfs(int x,int fa,int o)
{
	dp[x][0] = 0; dp[x][1] = 0;
	for(int i = head[x]; i ;i = e[i].nxt)
	{
		int v = e[i].v,w = (e[i].w >> o) & 1;
		if(v == fa) continue;
		dfs(v,x,o);
		if(!w)
		{
			Add(dp[x][0] * dp[v][1] % MOD * ((1ll << o) % MOD));
			Add(dp[x][1] * (dp[v][0]+1) % MOD * ((1ll << o) % MOD));
			dp[x][0] += dp[v][0]+1;
			dp[x][1] += dp[v][1];
		}
		else
		{
			Add(dp[x][0] * (dp[v][0]+1) % MOD * ((1ll << o) % MOD));
			Add(dp[x][1] * dp[v][1] % MOD * ((1ll << o) % MOD));
			dp[x][0] += dp[v][1];
			dp[x][1] += dp[v][0]+1;
		}
	}
	Add(dp[x][1] * ((1ll << o) % MOD));
}

int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n = Read();
	for(int i = 1;i < n;++ i)
	{
		int u = Read(),v = Read();
		Add_Double_Edge(u,v,Read());
	}
	for(int i = 0;i <= 60;++ i) dfs(1,0,i);
	Put(ans);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first
#define  s              second
#define  newl           cout<<"\n";
#define  pb             push_back
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#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  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   N     =  1e5+5;
const ll   mod   =  998244353;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

ll n, k, a[55][55];
ll p[55], sz[55], f[55];

void make(ll n){
	for(int i = 1; i <= n; i++){
		p[i] = i;
		sz[i] = 1;
	}
}

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

void merge(ll x, ll y){
	ll a = find(x);
	ll b = find(y);
	if(a != b){
		if(sz[a] >= sz[b]) swap(a,b);
		p[a] = b;
		sz[b] += sz[a];
	}
}

bool can(int x, int y, int f){
	if(f == 1){
		for(int i = 1; i <= n; i++){
			if(a[i][x] + a[i][y] > k) return 0;
		}
	} else {
		for(int i = 1; i <= n; i++){
			if(a[x][i] + a[y][i] > k) return 0;
		}
	}
	return 1;
}

void solve(){
	f[0] = 1;
	for(int i = 1; i < 55; i++) f[i] = f[i - 1] * i % mod;
	cin >> n >> k;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			cin >> a[i][j];
		}
	}
	ll ans = 1;
	make(n);
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(can(i, j, 0)) merge(i, j);
		}
	}
	for(int i = 1; i <= n; i++){
		if(find(i) == i){
			ans = ans * f[sz[i]] % mod;
		}
	}
	make(n);
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(can(i, j, 1)) merge(i, j);
		}
	}
	for(int i = 1; i <= n; i++){
		if(find(i) == i){
			ans = ans * f[sz[i]] % mod;
		}
	}
	deb1(ans)
}

int main(){
	GODSPEED;
	int test = 1;
	//cin >> test;
	for(int i = 1; i <= test; i++){
		solve();
	}
}

#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)x.size()
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = b; i >= a; --i)
#define all(x) x.begin(), x.end()

using ll = long long;
using namespace std;

const int N = 1 << 20;

int n, dp[N], sz[N];
vector<int> g[N];

void dfs(int v) {
	sz[v] = 1;
	vector<int> q;
	vector<pair<int, int>> h;
	for (auto u : g[v]) {
		dfs(u);
		sz[v] += sz[u];
		if (sz[u] % 2 == 0) {
			int he = sz[u] - dp[u];
			int im = dp[u];
			if (im >= he) {
				dp[v] += im;
			}
			else {
				dp[v] += min(im, he);
				q.pb(he - im);
			}
		}
		else {
			h.pb({2 * dp[u] - sz[u], dp[u]});
		}
	}
	sort(all(q));
	sort(all(h));
	reverse(all(h));
	rep(i, 0, sz(h) - 1) {
		if (i % 2 == 0) dp[v] += h[i].se;
		if (i % 2 == 1) dp[v] += (h[i].fi - h[i].se) * -1;
	}
	if (sz(h) % 2 == 1)
		for (auto x : q)
			dp[v] += x;
}

int main() {
	scanf("%d", &n);
	rep(i, 2, n) {
		int p;
		scanf("%d", &p);
		g[p].pb(i);
	}
	dfs(1);
	printf("%d\n", n - dp[1]);
	return 0;
}


//W4P3R
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define pb push_back
#define re register int
#define fr first
#define sd second
#define pa pair<int,int>
#define FOR(i,a,b) for(re i=a;i<=b;i++)
#define REP(i,a,b) for(re i=a;i>=b;i--)
#define MEM(a) memset(a,0,sizeof(a))
#define N 200010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
inline int lowbit(int x){return x&(-x);}
int n,a[N],x;
int main()
{
	//ios::sync_with_stdio(false);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),x=read();
	FOR(i,1,n)a[i]=read();
	FOR(i,1,n)if(a[i]!=x)cout<<a[i]<<' ';cout<<'\n';
	return 0;
}
//gl

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

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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

// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  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;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N, K; cin >> N >> K;
  vector<vector<ll>> t(N, vector<ll>(N));
  rep(i, N) rep(j, N) cin >> t[i][j];

  ll ans = 0;
  vector<int> v(N);
  iota(v.begin(), v.end(), 0);

  do {
    ll ttl = 0;
    if(v[0] != 0) break;
    rep(i, N) {
      ttl += t[v[i]][v[(i+1)%N]];
    }
    if(ttl == K) ans++;

  } while( next_permutation(v.begin(), v.end()) );

  cout << ans << endl;

}

int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


#include<bits/stdc++.h>
using namespace std;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
using ll =long long;

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<pair<int,char>>> e(n);
    bool v[1000][1000]={};
    for(int i{},a,b;i<(m);++i){
        char c;
        cin>>a>>b>>c;--a,--b;
        v[a][b]=v[b][a]=true;
        e[a].emplace_back(b,c);
        e[b].emplace_back(a,c);
    }
    using ti = tuple<int,int,int>;
   queue<ti> pq;
    vector<vector<bool>> cc(n,vector<bool>(n,false));
    pq.emplace(0,0,n-1);
    int ans{INT_MAX};

    while(!pq.empty()){
    ll c,i,I;
    tie(c,i,I)=pq.front();pq.pop();
        if(ans<=2*c) break;
        if(i==I){
            chmin(ans, 2*c);
            break;
        }
        if(v[i][I]){
            chmin(ans,2*c+1);
            continue;
        }
        if(cc[i][I]) continue;

        cc[i][I]=true;

        for(auto[j,cj]:e[i]) for(auto[J,cJ]:e[I]) if(cj==cJ){

            pq.emplace(c+1, j, J);
        }
    }
    cout<<(ans==INT_MAX?-1:ans)<<'\n';
}

// Problem: F - Rook on Grid
// Contest: AtCoder - Panasonic Programming Contest (AtCoder Beginner Contest 186)
// URL: https://atcoder.jp/contests/abc186/tasks/abc186_f
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

const int N = 2e5+7;
int r[N],c[N],tr[N];
vector<int> link[N];
int n,m,k;
inline int lowbit(int x)
{
	return x & -x;
}

int query(int x)
{
	int res = 0;
	for(int i = x;i;i -= lowbit(i))
		res += tr[i];
	return res;
}

void modify(int x,int v)
{
	for(int i = x;i <= m;i += lowbit(i))
		tr[i] += v;
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	forn(i,1,n)	r[i] = m + 1;
	forn(i,1,m)	c[i] = n + 1;
	while(k--)
	{
		int x,y;scanf("%d%d",&x,&y);
		c[y] = min(c[y],x);
		r[x] = min(r[x],y);
	}

	ll res = 0;
	forn(i,1,m)
	{
		if(c[i] == 1)	break;
		res += c[i] - 1;
	}

	forn(i,1,m)	link[c[i]].push_back(i);
	forn(i,1,n)
	{
		if(r[i] == 1)	break;
		res += query(r[i] - 1);
		// cout << query(r[i] - 1) << endl;
		if(i == 1)
		{
			// cout << r[1] << " " << query(7) << endl;
			forn(j,r[1],m)
			{
				modify(j,1);
			}
		}
		else	for(auto j : link[i])	if(j < r[1])	modify(j,1);
	}
	printf("%lld",res);
    return 0;
}


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

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define UQ(x) (x).resize(distance((x).begin(),unique(x.begin(),x.end())))

using namespace std;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rnd64(chrono::high_resolution_clock::now().time_since_epoch().count());

ll power(ll a,ll m,ll mod){
	ll ans = 1;
	while(m){
		if(m%2) ans *= a, ans %= (mod);
		a = (a*a) % mod;
		m >>= 1;
	}
	return ans;
}

struct custom_hash {  // Credits: https://codeforces.com/blog/entry/62393
 	static uint64_t splitmix64(uint64_t x) {
    	// http://xorshift.di.unimi.it/splitmix64.c
    	x += 0x9e3779b97f4a7c15;
    	x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    	x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    	return x ^ (x >> 31);
  	}

  	size_t operator()(uint64_t x) const {
    	static const uint64_t FIXED_RANDOM =
        	chrono::steady_clock::now().time_since_epoch().count();
    	return splitmix64(x + FIXED_RANDOM);
  	}
  	size_t operator()(pair<int64_t, int64_t> Y) const {
    	static const uint64_t FIXED_RANDOM =
        	chrono::steady_clock::now().time_since_epoch().count();
    	return splitmix64(Y.first * 31 + Y.second + FIXED_RANDOM);
  	}
};

const long long inf = 1e18;
const long long M = 1000000007;

void solve(){
	ll i,j,_;
	ll n, m;
	ll mx = LLONG_MAX;
	cin >> n >> m;
	ll w[n];
	rep(i,0,n) cin >> w[i];
	sort(w,w+n);
	if(n > 1) swap(w[0], w[n - 2]);
	ll tmp[n];
	i = 0;
	ll l = 0, r = n - 1;
	// while(i < n) {
	// 	if(i%2) tmp[i] = w[r], r--;
	// 	else tmp[i] = w[l],l++;
	// 	i++;
	// }
	// rep(i,0,n) w[i] = tmp[i];
	ll l1[m],r1[m];
	_ = 10000;
	rep(i,0,m) cin >> l1[i] >> r1[i];
	do {
	ll dp[n][n];
	rep(i,0,n)rep(j,0,n) dp[i][j] = 0;

ll bl = 0,t;
	rep(t,0,m) {
		l = l1[t], r = r1[t];
		rep(i,0,n) {
			ll now = w[i];
			// cout << now << ' ' << r << endl;
			if(now > r) {
				cout << -1 << endl;
				return;
				// bl = 1;
			}
			rep(j,i + 1,n) {
				now += w[j];
				if(now > r) {
					dp[i][j] = max(dp[i][j], l);
					break;
				}
			}
		}
		if(bl) break;
	}
	if(bl) continue;
	// rep(i,0,n) {
	// 	rep(j,0,n) {
	// 		cout << dp[i][j] << ' ';
	// 	}
	// 	cout << endl;
	// }
	ll k;
	rep(i,1,n) {
		rep(j,0,n) {
			r = j + i;
			if(r >= n) break;
			rep(k,j,r+1) {
				dp[j][r] = max(dp[j][r], dp[j][k] + dp[k][r]);
			}
		}
	}
	mx = min(mx, dp[0][n-1]);
	// if(mx == 3802) cout << _ << endl;
// 	cout << dp[0][n-1] << endl;
//     if(dp[0][n-1] == 3802){
//         for(auto i : w) cout << i << ' ';
// 	cout << endl;
    // }

	}while ( std::next_permutation(w + 1,w + n - 1));
	// cout << _ << endl;
	if(mx == LLONG_MAX) mx = -1;
	cout << mx << endl;
}

int main()
{
	ios::sync_with_stdio(0);
 	cin.tie(0);
	ll T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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

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

bool check(vector<string> &s, map<char,int> &cnv, set<char> &head){

  REP(i,3)if(cnv[s[i][0]] == 0)return false;

  ll s1=0;
  ll s2=0;
  ll s3=0;
  for(auto c: s[0]){
    s1 *= 10;
    s1 += cnv[c];
  }
  for(auto c: s[1]){
    s2 *= 10;
    s2 += cnv[c];
  }
  for(auto c: s[2]){
    s3 *= 10;
    s3 += cnv[c];
  }

  if(s1+s2==s3){
    cout << s1 << " " << s2 << " " << s3 << endl;
    return true;
  }

  return false;
}

int main(){
  vector<string> s(3);
  REP(i,3)cin >> s[i];

  set<char> head;
  head.insert(s[0][0]);
  head.insert(s[1][0]);
  head.insert(s[2][0]);

  map<char,int> mp;
  REP(i,3){
    for(auto c: s[i])mp[c]++;
  }

  if(mp.size() > 10){
    cout << "UNSOLVABLE" << endl;
    return 0;
  }

  vi p(10);
  REP(i,10)p[i]=i;

  do{
    int i=0;
    map<char,int> cnv;
    for(auto v: mp){
      cnv[v.first] = p[i++];
    }
    if(check(s,cnv,head))return 0;

  }while(next_permutation(ALL(p)));

  cout << "UNSOLVABLE" << endl;
}


#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   Y            imag()
#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<long double>
#define     PI                       acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-15);
using namespace std;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const ll N=2000+9,mod=998244353,sh=1000000,inf=100000;
int a[N],b[N];
int main(){
    GO();

    int T=1;
    //cin>>T;
    while(T--){
        ll n,m,t;
        cin>>n>>m>>t;
        for(int i=0;i<m;i++) cin>>a[i]>>b[i];
        ll pre=n;
        ll pre_t=0,bal=0;
        for(int i=0;i<m;i++){
            int l,r;
            l=a[i];
            r=b[i];
            ll add= r-l;
            //cout<<pre<<" "<<l<<" "<<pre_t<<"\n";
            if(pre-(l-pre_t)<=0){
                cout<<"No\n";
                return 0;
            }
            bal= min(n,pre-(l-pre_t)+add);
            pre=bal;
            pre_t=r;
        }

        if(pre-(t-pre_t)<=0){
            cout<<"No\n";
            return 0;
        }

        cout<<"Yes\n";

    }

}

#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <list>
#include <math.h>
#include <vector>
#include <algorithm>
#include<iomanip>
#include <unordered_map>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;
#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 MOD 1e9+7

int main() {
  int A, B, C;

  cin >> A >> B >> C;

  if( A >= 0 && B >= 0) {
    if(A > B) {cout << ">"; return 0;}
    if(A < B) {cout << "<"; return 0;}
    if(A == B) {cout << "="; return 0;}
  }
  if( A >= 0 && B < 0) {
    if(C%2==0) {
      if(A > abs(B)) {cout << ">"; return 0;}
      if(A < abs(B)) {cout << "<"; return 0;}
      if(A == abs(B)) {cout << "="; return 0;}
    }
    else {
      cout << ">"; return 0;
    }
  }
  if( A < 0 && B >= 0) {
    if(C%2==0) {
      if(abs(A) > abs(B)) {cout << ">"; return 0;}
      if(abs(A) < abs(B)) {cout << "<"; return 0;}
      if(abs(A) == abs(B)) {cout << "="; return 0;}
    }
    else {
      cout << "<"; return 0;
    }
  }
  if( A < 0 && B < 0) {
    if(C%2==0) {
      if(abs(A) > abs(B)) {cout << ">"; return 0;}
      if(abs(A) < abs(B)) {cout << "<"; return 0;}
      if(abs(A) == abs(B)) {cout << "="; return 0;}
    }
    else {
      if(abs(A) > abs(B)) {cout << "<"; return 0;}
      if(abs(A) < abs(B)) {cout << ">"; return 0;}
      if(abs(A) == abs(B)) {cout << "="; return 0;}
    }
  }

  //for float, double precision
  cout << std::fixed << setprecision(15);
  return 0;
}


// C++ program to check if three
// points are collinear or not
// using area of triangle.
#include <bits/stdc++.h>
#include <math.h>
#include <stdlib.h>

using namespace std;
// function to check if point
// collinear or not

// Driver Code
int main()
{
	string s;cin>>s;
	int a[10]={0},p,x1,x2,x3,k=0,k1=1;
	for (int i=0;i<s.length();i++) a[s[i]-'0']++;
	if (s.length()==1) {
           if (s[0]=='8') k=1;
	}
	if (s.length()==2) {
        for (int i=10;i<=99;i++) {
		if (i%8==0) {
			int b[10]={0};
			p=i;
			x1=p%10;p=p/10;
			x2=p%10;
			b[x1]++;b[x2]++;
			if (x1==0||x2==0) continue;
			//b[x1]++;b[x2]++;b[x3]++;
			else {
				k1=1;
				for (int j=1;j<10;j++) {
					if (b[j]!=a[j]) {k1=0;break;}
				}
			}
				if (k1==1) {k=1;break;}

		}
	}
	}
	if (s.length()>=3) {
	for (int i=100;i<=999;i++) {
		if (i%8==0) {
			int b[10]={0};
			p=i;
			x1=p%10;p=p/10;
			x2=p%10;p=p/10;
			x3=p%10;
			b[x1]++;b[x2]++;b[x3]++;
			if (x1==0||x2==0||x3==0) continue;
			//b[x1]++;b[x2]++;b[x3]++;
			else {
				k1=1;
				for (int j=1;j<10;j++) {
					if (b[j]>a[j]) {k1=0;break;}
				}
			}
				if (k1==1) {k=1;break;}
		}
	}
	}
	if (k==1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

// This code is contributed
// by Akanksha Rai(Abby_akku)

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<string> s(n);
  REP(i, n) { cin >> s[i]; }
  vector<map<string, bool>> mps(2);
  REP(i, n) {
    if (s[i][0] == '!') {
      ll len = SZ(s[i]);
      string sub = s[i].substr(1, len - 1);
      mps[0][sub] = true;
    } else {
      mps[1][s[i]] = true;
    }
  }

  for (auto p : mps[0]) {
    string t = p.first;
    if (mps[1][t]) {
      cout << t << endl;
      return 0;
    }
  }
  cout << "satisfiable" << endl;
}


#include <bits/stdc++.h>

using namespace std;

long long rec(long long cur, long long tar) {
  static unordered_map<long long, long long> dp;
  if (dp.count(cur)) return dp[cur];
  if (cur <= tar) return dp[cur] = tar - cur;

  if (cur & 1) {
    return dp[cur] = min({cur - tar, rec(cur >> 1, tar) + 2, rec((cur + 1) >> 1, tar) + 2});
  } else {
    return dp[cur] = min(cur - tar, rec(cur >> 1, tar) + 1);
  }
}

int main() {
  long long X, Y;
  cin >> X >> Y;

  cout << rec(Y, X) << endl;

  return 0;
}

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

typedef long long ll;

int main() {
    ll X, Y;
    cin >> X >> Y;
    if (X >= Y) {
        cout << X - Y << "\n";
        return 0;
    }
    map<ll, int> mp;
    queue<ll> q;
    q.push(Y);
    mp[Y] = 0;
    ll ans = 1e18;
    while(!q.empty()) {
        ll p = q.front();
        q.pop();
        ans = min(ans, mp[p] + abs(X - p));
        if (p % 2) {
            if (mp.find(p + 1) == mp.end()) {
                q.push(p + 1);
                mp[p + 1] = mp[p] + 1;
            }
            if (mp.find(p - 1) == mp.end()) {
                q.push(p - 1);
                mp[p - 1] = mp[p] + 1;
            }
        } else {
            if (mp.find(p / 2) == mp.end()) {
                q.push(p / 2);
                mp[p / 2] = mp[p] + 1;
            }
        }
    }
    cout << ans << "\n";
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define is_in(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (int)(x).size()
#define rng(a) a.begin(),a.end()
#define rngr(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
const int inf = 1<<30;
const double pi = acos(-1);
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vs vector<string>
#define vp vector<P>
#define vvp vector<vp>
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll dp[105][105][105];// i ko mademite j ko erabu amariga k tonaru min(x-sum)
int main()
{
    int n;
    ll x;
    cin >> n >> x;
    vll a(n);
    rep(i, n) cin >> a[i];
    ll ans = INF;
    rep2(k, 1, n+1){
        rep(i, n+1)rep(j, k+1)rep(u, k) dp[i][j][u] = INF;
        dp[0][0][x%k] = x;
        rep(i, n)rep(j, k+1)rep(u, k){
            if(dp[i][j][u] == INF) continue;
            chmin(dp[i+1][j][u], dp[i][j][u]);
            if(j < n){
                ll r =((u-a[i])%k + k) %k;
                chmin(dp[i+1][j+1][r], dp[i][j][u]-a[i]);
            }
        }
        if(dp[n][k][0] != INF) chmin(ans, dp[n][k][0]/k) ;
    }
    cout << ans << endl;

    return 0;
}

#pragma GCC target ("avx2")
//#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll uset<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll umap<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
using namespace __gnu_pbds;
using namespace std;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
template<class T, class H>using umap=unordered_map<T,H,custom_hash>;
template<class T>using uset=unordered_set<T,custom_hash>;
const ll mod = 1000000007;
int main()
{
    clock_t clk = clock();
    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
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll a,b;
        cin>>a>>b;
        ll ans=1;
        for(ll i=200000;i>=1;i--)
        {
            ll val=(a/i)*i;
            if(val!=a)
                val+=i;
            if(val<=b&&(val+i)<=b)
            {
                ans=i;
                break;
            }
        }
        cout<<ans;
    }
    // cerr << '\n'<<"Time (in s): " << double(clock() - clk) * 1.0 / CLOCKS_PER_SEC << '\n';
    return 0;
}


#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 998244353;

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

int power(int n, int k){
	int res = 1;

	while(k){
		if(k&1) res *= n;

		k >>= 1;
		n *= n;

		n %= MOD;
		res %= MOD;
	}

	return res;
}

signed main(){
	cout<<fixed<<setprecision(10);

	int N, M;
	int ans = 0;
	vector<vector<int>> table;

	cin>>N>>M;

	table.resize(M+1, vector<int>(N+1));

	for(int i = 0; i < table.size(); i++){
		table[i][0] = 1;

		for(int j = 1; j < table[i].size(); j++){
			table[i][j] = table[i][j-1] * i % MOD;
		}
	}

	for(int h = 1; h <= M; h++){
		for(int j = 1; j < N-1; j++){
			int sum = 0;

			// sum = (power(M - h + 1, j) - power(M - h, j) + MOD) % MOD;
			sum = (table[M - h + 1][j] - table[M - h][j] + MOD) % MOD;
			sum = sum * (h - 1) % MOD;
			sum = (sum * table[M][N - j - 2]) % MOD;
			sum = sum * ((h - 1) * (N - j - 1) % MOD + M * 2) % MOD;

			ans = (ans + sum) % MOD;
		}

		if(N-1 > 0){
			int sum1 = 0, sum2 = 0;

			sum1 = (power(M - h + 1, N-1) - power(M - h, N-1) + MOD) % MOD;
			sum1 = (sum1 * (h - 1) % MOD) % MOD;
			sum1 = (MOD + sum1 * 2) % MOD;

			ans = (ans + sum1 + sum2) % MOD;
		}

		{
			int sum1 = 0, sum2 = 0;

			sum1 = (power(M - h + 1, N) - power(M - h, N) + MOD) % MOD;

			ans = (ans + sum1 + sum2) % MOD;
		}
	}

	cout<<ans<<endl;

	return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 998244353
#define infi 1010000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}

int main(){

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

    int N;
    cin >> N;

    ll ans = 1;

    vi f(N);
    in(N,f);
    rep(i,N) f[i]--;

    vi ff(N,0);

    int s = 0;
    rep(i,N){
        if(ff[i] == 1) continue;
        s = i;
        set<int> vis;
        int t = 0;

        while (ff[s] == 0) {
            ff[s] = 1;
            vis.insert(s);
            s = f[s];
            if(vis.count(s)){
                t = 1;
                break;
            }
        }

        if(t == 1) ans *= 2, ans %= mod;
        s = f[i];

    }

    cout << (ans+mod-1)%mod << endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll ans = -1;
  rep(i,n){
    ll res = 0;
    ll mini = a[i];
    for (int j = i; j < n; j++) {
      chmin(mini, a[j]);
      chmax(ans, mini * (j - i + 1));
    }
  }
  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define int long long
#define pi pair<int,int>
#define f first
#define s second
const int nax=3005,inf=1e18;
const ld eps=1e-14;
void find(ld x,ld r,int& low,int & high)
{
    low=ceil(x-r);
    high=floor(x+r);
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int low=0,high=0,res=0,top=0,bottom=0;
    ld a,b,r,p;
    cin>>a>>b>>r;
    r+=eps;
    find(a,r,low,high);
    //cout<<low<<' '<<high<<'\n';
    for(int i=low;i<=high;i++)
    {
        p=sqrt(pow(r,2)-pow((a-(ld)i),2));
        find(b,p,bottom,top);
        //cout<<top<<' '<<bottom<<'\n';
        res+=top-bottom+1;
    }
    cout<<res;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    double x0, y0, xn, yn;
    cin >> x0 >> y0 >> xn >> yn;
    double cx, cy;
    cx = (x0+xn)/2.0;
    cy = (y0+yn)/2.0;
    double vx, vy;
    vx = x0 - cx;
    vy = y0 - cy;
    double nx, ny;
    nx = cos(2*M_PI/n) * vx - sin(2*M_PI/n) * vy;
    ny = sin(2*M_PI/n) * vx + cos(2*M_PI/n) * vy;
    printf("%.6lf %.6lf\n", nx+cx, ny+cy);
    return 0;
}

#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>

#define ll long long
#define test(t) ll int t; cin>>t; while(t--)
#define F(i,L,R) for(ll int i=L;i<R;i++)
#define F2(i,L,R) for(ll int i=L;i>=R;i--)
#define get1(a) ll int a; cin>>a;
#define get2(a,b) ll int a,b; cin>>a>>b;
#define get3(a,b,c) ll int a,b,c; cin>>a>>b>>c;
#define getstr(s) string s; cin>>s;
#define getvec(v) get1(n); vector<ll int> v(n,-1); F(i,0,n){ cin>>v[i]; }
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pp pair< pair<int,int>, pair<int,int> >
#define MAX 1000000001
#define printer(cnt)  if(cnt==true){cout<<"YES\n";} else{cout<<"NO\n";}

using namespace std;

int main()
{

ios_base::sync_with_stdio(0);

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

 get1(n);

 get2(a,b);

 get2(c,d);

 double cx=(double)(a+c)/2.0 ;

 double cy=(double)(b+d)/2.0 ;

 double PI = acos(-1);

 double theta=360/(double)n; //radians

 double cost=cos(theta*PI/180),sint=sin(theta*PI/180);

 double ans_x=(a-cx)*cost-(b-cy)*sint+cx;
 double ans_y=(a-cx)*sint+(b-cy)*cost+cy;

 cout<<ans_x<<" "<<ans_y;

  return 0;

}


#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,s,d;
    long long x,y;
    cin >> n >> s >> d;
    for(int i=0;i<n;i++){
        cin >> x>> y;
        if(x<s&&y>d){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

}

#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[3];
  for(int i=0;i<3;i++){
    cin>>a[i];
  }
  sort(a,a+3);
  if(a[1]-a[0]==a[2]-a[1])
    cout<<"Yes";

  else
    cout<<"No";

  return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define mod 1000000007
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll ,ll> pii;
int ans=1e9;
string s;
void go(int cur,vector<bool> is,int n)
{
    if(cur==n)
    {
        string got="";
        int p=0;
        forn(i,s.size())
        {
            if(is[i])
            {
                got+=s[i];
            }
            else
            {
                p++;
            }
        }
        if(got.size()==0)return;
        ll x=stoll(got);
        if(x%3==0)
        {
            ans=min(ans,p);
        }
        return;
    }
    is[cur]=false;
    go(cur+1,is,n);
    is[cur]=true;
    go(cur+1,is,n);
}
void solve()
{
    //string s;
    cin>>s;
    vector<bool> is(s.size(),1);
    go(0,is,s.size());
    if(ans==1e9)ans=-1;
    cout<<ans<<endl;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
	solve();
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
char num[20];
int n,cnt[5],sum;
int main(){
	scanf("%s",num);
	n=strlen(num);
	for(int i=0;i<n;++i)
		++cnt[(num[i]-'0')%3];
	sum=(cnt[1]+cnt[2]*2)%3;
	if(sum==0){
		printf("0\n");
		return 0;
	}
	if(sum==1){
		if(cnt[1]){
			if(n<=1)
				printf("-1\n");
			else
				printf("1\n");
		}
		else if(cnt[2]>=2){
			if(n<=2)
				printf("-1\n");
			else
				printf("2\n");
		}
	}
	else{
		if(cnt[2]){
			if(n<=1)
				printf("-1\n");
			else
				printf("1\n");
		}
		else if(cnt[1]>=2){
			if(n<=2)
				printf("-1\n");
			else
				printf("2\n");
		}
	}
}


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

#define rep2(i,k,n) for(i64 i=(i64)(k);i<(i64)(n);i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) begin(x),end(x)
#ifdef ENV_LOCAL
#define dump if (1) cerr
#else
#define dump if (0) cerr
#endif

using namespace std;
using namespace std::string_literals;

using i32 = int32_t;
using i64 = int64_t;
using f64 = double;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 n,m,k;
  cin>>n>>m>>k;
  vi64 a(k);
  rep(i,k) cin>>a[i];
  vector<f64> c0(n+1);
  vector<f64> c1(n+1);
  rep(i,k) c1[a[i]] = 1.0;
  f64 s0 = 0;
  f64 s1 = 0;
  rep(ri,n) {
    i64 i = n - 1 - ri;
    s0 += c0[i+1];
    s1 += c1[i+1];
    if (ri >= m) {
      s0 -= c0[i+m+1];
      s1 -= c1[i+m+1];
    }
    if (c1[i] == 1.0) continue;
    else {
      c0[i] = s0 / m + 1.0;
      c1[i] = s1 / m;
    }
  }
  if (abs(1.0 - c1[0]) < 1e-8) {
    cout<<-1<<endl;
  } else {
    cout<<fixed<<setprecision(10)<<c0[0] / (1.0 - c1[0])<<endl;
  }
  return 0;
}

#include <bits/stdc++.h>

// 1. dp
typedef long double ld;
#define int long long

#define gcd            __gcd
#define endl           "\n"
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define pb             push_back
#define all(x)         x.begin(), x.end()
#define f              first
#define s              second
#define lb             lower_bound
#define ub             upper_bound
#define ins            insert
#define sz(x)          (int)(x).size()
#define mk             make_pair
#define deci(x, y)     fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define PI             3.141592653589793238
using namespace std;
ld dp[101][101][101];
void solve() {
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=100;i>=0;i--)
    {
        for(int j=100;j>=0;j--)
        {
            for(int k=100;k>=0;k--)
            {
                if(i==0 && j==0 && k==0)
                    continue;
                if(i==100 || j==100 || k==100)
                {
                    dp[i][j][k]=0;
                    continue;
                }
                dp[i][j][k]=(i*(dp[i+1][j][k]+1)+j*(dp[i][j+1][k]+1)+k*(dp[i][j][k+1]+1))/((ld)(i+j+k));
            }
        }
    }
    cout<<deci(dp[a][b][c],9)<<endl;
}

int32_t main() {
    nitin;

    solve();
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
    x += y;
    if( x >= m )
        x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
    x -= y;
    if( x < 0 )
        x += m;
}

ll c2( ll n )
{
    ll ans = n*(n-1);
    ans /= 2;
    ans = mod( ans );
    return ans;
}

void solve()
{
    ll n,a,b;
    cin>>n>>a>>b;

    if( a > b )
        swap(a,b);

    ll p = n-a-b, q = n-b, r = n-a;

    if( p < 0 )
    {
        cout<<0,nl;
        return;
    }

    ll ans = 0;
    add( ans, mod( mod( (r+1)*(q+1) ) * mod( 2*(p+1)*(p+2) ) ));
    sub( ans, mod( mod( 4 * c2(p+2) ) * c2(p+2) ) );

    cout<<ans,nl;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    fastio();

    test()
    {
        solve();
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

#include <bits/stdc++.h>
#define INT_MINs -2000000000
#define INT_MAXs 1000000001
#define MID int mid=(l+r)/2
#define REP1(i,x,y) for(int i=x;i<y;i++)
#define REP2(i,x,y) for(int i=x;i<=y;i++)
#define ls (2*k)
#define rs (2*k+1)
#define lson l,mid,2*k
#define rson mid+1,r,2*k+1
#define lc u << 1
#define rc u << 1 | 1
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define IOS ios::sync_with_stdio(0);cin.tie(NULL);
#define pb(a) push_back(a)
#define pi acos(-1)
#define pii pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod=1e9+7;
const int dx[8] = { 0,-1,0,1,-1,-1,1,1}, dy[8] = { 1,0,-1,0,-1,1,-1,1};
ll qk(ll x,ll y){
    ll ans=1;
    while(y){
        if(y&1) ans=ans*x%mod;
        y>>=1;
        x=x*x%mod;
    }
    return ans;
}
void solve(){
    ll n,m,k;
    cin>>n>>m>>k;
    if(n>k+m){
        cout<<0<<endl;
        return;
    }
    ll num=1,num2=1;
    for(ll i=n+m,j=1;i>=n+1;j++,i--){
        num=num*i%mod;
        num2=num2*qk(j,mod-2)%mod;
    }
    num=num*num2%mod;
    ll num3=0,num4=0;
    if(m+k+1<=m+n){
        num3=1,num4=1;
    for(ll i=n+m,j=1;i>=m+k+2;j++,i--){
        num3=num3*i%mod;
        num4=num4*qk(j,mod-2)%mod;
    }
    num3=num3*num4%mod;
    }

    cout<<((num-num3)%mod+mod)%mod<<endl;
}
int main(){
    IOS;
    solve();
    return 0;
}


/*
{
######################
#       Author       #
#        Gary        #
#        2020        #
######################
*/
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
//inline int read(){
//    int x=0;
//    char ch=getchar();
//    while(ch<'0'||ch>'9'){
//        ch=getchar();
//    }
//    while(ch>='0'&&ch<='9'){
//        x=(x<<1)+(x<<3)+(ch^48);
//        ch=getchar();
//    }
//    return x;
//}
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
int n;
string s[101];
bitset<101> reach[101];
int main(){
	cin>>n;
	rb(i,1,n)
		cin>>s[i];
	rb(i,1,n)
		rep(j,n)
			if(s[i][j]=='1')
				reach[j+1].set(i);
	rb(i,1,n)
		reach[i].set(i);
	rb(k,1,n)
		rb(i,1,n)
			rb(j,1,n)
				if(reach[i][j]){
					reach[i]|=reach[j];
				}
	double rest=0.0;
	rb(i,1,n)
		rest+=1.0*n/(reach[i].count());
	printf("%.10f\n",rest/n);
	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;
#define int long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vi vector <int>
#define ff first
#define ss second
#define vp vector <pair<int,int>>
#define vpp vector <pair<int,pair<int,int>>>
#define seti set<int>
#define setbit(x) __builtin_popcountll(x)
#define sov(v) accumulate(all(v),0)
#define fs(it,a) for(auto it=a.begin();it!=a.end();it++)
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pqmax priority_queue <int,vector <int>>
#define pqmin priority_queue <int,vector <int>,greater<int>>
#define dq deque <int>
#define umi unordered_map<int,int>
#define ums unordered_map<string,int>
#define sp(x,y) fixed << setprecision(y) << x
#define out(r,x) cout<<"Case #"<<r<<": "<<x<<ee;
#define all(x) x.begin(),x.end()
#define f(x,y,z) for(x=y;x<z;x++)
#define si size()
#define countdigit(x) floor(log10(x) +1)
#define M 1000000007
#define Z 998244353
#define fill(arr,x) memset(arr,x,sizeof(arr))
//Use (k%M+m)%m always where k is any no
#define PI 3.1415926535
#define lcm(a,b)  a*b/(__gcd(a,b))
 typedef tree<int, null_type, less<int>, rb_tree_tag,
 tree_order_statistics_node_update> pdbs;
// // null for set,mapped_type for map;
// //less for assending greater for descending
//ceil(a/b)=(a+b-1)/b
// v.si-1 can never be negative
#define ghadi() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();
#define ee "\n"
#define re return

//Author Rahul Sannigrahi

vector<int> take(int n)
{
    int i,j;
    vi v;
    f(i,0,n)
    {
        cin>>j;
        v.pb(j);
    }
    return v;
}

int power(int x,int y)
{
    int res=1;

    while(y>0)
    {
       if(y&1)
       res=((res%M)*(x%M))%M;

       y=y>>1;
       x=((x%M)*(x%M))%M;
    }
    re res;
}

bool sortinrev(const pair<int,int> &a,  //desc of vp
               const pair<int,int> &b)
{
       return (a.first > b.first);
}

void show(vector<int>v)
{
    int i;
    for(i=0;i<v.si;i++)
    {
     cout<<v[i]<<" ";
    }
    cout<<ee;
}

int gk=1;
int ks=0;

int decode()
{
int i,j,k,l,n,m;
cin>>n>>k;
vi v;

f(i,0,n)
{
    cin>>l;
    v.pb(l);
}

// // show(v);
 vi pref(n+1,0);
 pref[1]=v[0]-1;
 f(i,2,n+1)
pref[i]=pref[i-1]+v[i-1]-v[i-2]-1;

// show(pref);/
f(j,0,k)
{
    cin>>m;

    if(m>pref[n])
    cout<<v[n-1]+m-pref[n]<<endl;
    else
    {
     int index;
    //  lower_bound(all(pref),m)-pref.begin();

    int r;
    l=0;r=n;
    while(l<=r)
    {
        int mid=(l+r)/2;
        if(pref[mid]-m>=0)
        {
            index=mid;
            r=mid-1;
        }
        else
        l=mid+1;

    }
     if(index==1)
     cout<<m<<ee;
     else
     if(pref[index]==m)
     cout<<v[index-1]-1<<ee;
     else
     {
         cout<<v[index-2]+m-pref[index-1]<<ee;
     }
    }
}
   re 0;
}

int32_t main()
{
    IOS
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    //  freopen("output.txt","w",stdout);
    // #endif

    int t=1;
    //   cin>>t;
    while(t--)
    {
      if (ks)
        {
            cout << "Case #" << gk << ": ";
         gk++;
        }
    decode();
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define M (int)(1e9 + 7)

const int len = 1e8 + 8;
//int ar[len];
bool comp(array<int, 3> a, array<int, 3> b)
{
    if (a[0] == b[0])
    {
        return a[1] < b[1];
    }
    else
        return a[0] < b[0];
}

int solve()
{

    int n;
    cin >> n;

    vector<pair<double,double>> values;
    for(int i=0;i<n;i++){
        double t,l,r;
        cin >> t >> l >> r;

        if(t == 1)
        {
            values.push_back({l,r});
        }
        else if(t==2)
        {
            values.push_back({l,r-0.1});
        }
        else if(t==3)
        {
            values.push_back({l+0.1,r});
        }
        else {
            values.push_back({l+0.1,r-0.1});
        }
    }
    int count = 0;

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

    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(values[i].second>= values[j].first)
            {
                count++;
            }
        }
    }
    return count;

}

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

    // int t;
    // cin >> t;
    // while (t--)
    // {
    //      cout << solve() << "\n";
    //     //solve();
    // }
    cout <<  solve() <<"\n";
}

// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

enum{N=2004};

struct sth{
	int t,l,r;
	bool operator < (const sth&e){ return l<e.l; }
} d[N];

int main(){
	int n = ci();
	int ans = 0;
	rep(i,1,n) d[i] = {ci(),ci(),ci()};
	sort(d+1,d+n+1);
	rep(i,1,n){
		rep(j,1,i-1){
			bool ok = 0;
			if( d[j].r > d[i].l ) ok = 1;
			if( d[j].r == d[i].l && (d[j].t&1) && (d[i].t<=2) ) ok = 1;
			ans += ok;
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll=long long;
using ld=long double;
using pll=pair<ll, ll>;
//using mint = modint1000000007;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo 2e18
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
//priority_queue<ll, vector<ll>, greater<ll>> Q;
/*
3000*3000*5*3
2人とったら、おのずと1人きまる
1000*1000*100まで
2人とった場合は出せる。
2ブタン？10以上をもつとか
でbool
*/
ll A[3010][5];

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

  ll N;
  cin >> N;
  rep(i, N) rep(j, 5) cin >> A[i][j];
  ll high=1e9;
  ll low=1;
  ll mid=(high+low)/2;
  while(high > low+1){
    set<ll> S;
    rep(i, N){
      ll tmp=0;
      rep(j, 5){
        if (A[i][j]>=mid){
          tmp+=1<<j;
        }
      }
      if (tmp) S.insert(tmp);
    }
    vector<ll> Q;
    for(auto s: S)
      Q.push_back(s);
    bool fin=false;
    ll tsz=Q.size();
    if(tsz>3){
      rep(i, tsz){
        for(ll j=i+1; j<tsz; j++){
          for(ll k=j+1; k<tsz; k++){
            ll t=Q[i]|Q[j]|Q[k];
            if (t == ((1<<5)-1)){
              fin = true;
              low = mid;
            }
            if(fin) break;
          }
          if(fin) break;
        }
        if(fin) break;
      }
    }
    else{
      ll t=0;
      for(auto q: Q){
        t|=q;
      }
      if (t == ((1<<5)-1)){
        fin = true;
        low = mid;
      }
    }
    if(!fin) high=mid;
    mid = (high+low)/2;
  }

	bool fin=false;
    set<ll> S;
    rep(i, N){
      ll tmp=0;
      rep(j, 5){
        if (A[i][j]>=high){
          tmp+=1<<j;
        }
      }
      if (tmp) S.insert(tmp);
    }
    vector<ll> Q;
    for(auto s: S)
      Q.push_back(s);
    ll tsz=Q.size();
    if(tsz>3){
      rep(i, tsz){
        for(ll j=i+1; j<tsz; j++){
          for(ll k=j+1; k<tsz; k++){
            ll t=Q[i]|Q[j]|Q[k];
            if (t == ((1<<5)-1)){
              fin = true;
            }
            if(fin) break;
          }
          if(fin) break;
        }
        if(fin) break;
      }
    }
    else{
      ll t=0;
      for(auto q: Q){
        t|=q;
      }
      if (t == ((1<<5)-1)) fin=true;
    }
    if(!fin) high--;
    cout << high << endl;
}

/*
5
3 2 2 2 2
2 3 2 2 2
2 2 3 2 2
2 2 2 3 2
2 2 2 2 3
*/

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

const int N = 3000 + 9;

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

int cnt[1 << 5];

vector<int> vc[N];

bool check(int x, int n) {
    memset(cnt, 0, sizeof(cnt));
    for (int i = 1; i <= n; ++i) {
        b[i] = 0;
        for (int j = 0; j < 5; ++j) {
            if (a[i][j] >= x) {
                b[i] |= 1 << j;
            }
        }
        ++cnt[b[i]];
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            --cnt[b[i]];
            --cnt[b[j]];
            int x = ~(b[i] | b[j]) & 31;
            if (!x) return true;
            for (int y : vc[x]) if (cnt[y]) return true;
            ++cnt[b[i]];
            ++cnt[b[j]];
        }
    }
    return false;
}

int main() {
    for (int i = 0; i < (1 << 5); ++i) {
        for (int j = 0; j < (1 << 5); ++j) {
            if ((i & j) == i) vc[i].push_back(j);
        }
    }
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < 5; ++j) {
            scanf("%d", &a[i][j]);
        }
    }
    int L = 1, R = 1000000000;
    while (L < R) {
        int M = ((L + R) >> 1) + 1;
        if (check(M, n)) L = M;
        else R = M - 1;
    }
    printf("%d\n", L);
    return 0;
}


#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 1; i <= n; i++)
#define rep2(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<
#define AA(i) cout<<i<<endl;
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
    int i,j,N; cin >> N;
    vector<bool> A(N+1,true);
    string S;
    rep(i,N){
      S = std::to_string(i);

      rep2(j,S.size()){
        if(S[j] == '7'){
          A[i] = false;
          break;
        }
      }

      if(A[i]==false){
        continue;
      }

      stringstream K;
      K << std::oct << i;
      S = K.str();

      rep2(j,S.size()){
        if(S[j] == '7'){
          A[i] = false;
          break;
        }
      }
    }

    int ans = 0;

    rep(i,N){
      if(A[i]) ans++;
    }
    AA(ans);
    return 0;
}

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

typedef long long int ll;
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#ifdef LOCAL
    #include "trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}

bool isVal(ll n, ll base){
    while(n>0){
        ll rem = n%base;
        if(rem==7) return false;
        n = n/base;
    }
    return true;
}

void solve(){
    ll n; cin>>n;
    ll ans = 0;
    for(ll i = 1; i<=n; i++)
        ans += isVal(i, 10)&&isVal(i, 8);
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        freopen("err.txt", "w", stderr);
    #endif
    int t=1;
    // cin>>t;
    while(t--)
        solve();
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define OJ \
    freopen("swap.in", "r", stdin); \
    freopen("swap.out", "w", stdout);
void no(){
    cout<<"No";
    exit(0);
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);
ll n;
ll k=11;
cin>>n;
//n+11Cn but this will include 0 solution also
 ll n1=n-1;
 if(n1==k) {
     cout<<1;
     return 0;
 }
        ll r=k;
        ll res=1;
        if(n1-k<k){
            r=n1-k;
        }
        for(int i=1;i<=r;i++){
            res=res*(n-i)/i;
        }
        cout<<res<<"\n";
}

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

int main() {
  int x;
  cin >> x;
  if(x >= 0) cout << x << endl;
  else cout << 0 << endl;
  return 0;
}


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

long long cur[101][10001], pre[101][10001];
long long MOD = 998244353;
int main() {
    int N; cin >> N;
    vector<int> W(N);
    for(int i = 0; i < N; i++) {
        cin >> W[i];
    }
    pre[0][0] = 1LL;

    int sum = 0;
    for(int i = 0; i < N; i++)
        sum += W[i];
    for(int i = 1; i <= N; i++) {
        for(int make = 0; make <= sum; make++) {
            for(int use = 0; use <= N; use++) {
                cur[use][make] = pre[use][make];
                if(W[i - 1] <= make && use > 0)
                    cur[use][make] += pre[use - 1][make - W[i - 1]];
                if(cur[use][make] > MOD) cur[use][make] -= MOD;
            }
        }
        for(int make = 0; make <= sum; make++)
            for(int use = 0; use <= N; use++)
                pre[use][make] = cur[use][make];
    }
    vector<long long> f(N + 1);
    f[0] = 1LL;
    for(int i = 1; i <= N; i++)
        f[i] = f[i - 1] * 1LL * i % MOD;
    long long ans = 0LL;
    if(sum % 2) {
        cout << 0 << "\n";
        return 0;
    }
    for(int use = 0; use <= N; use++) {
        ans += f[use] * 1LL * f[N - use] % MOD * pre[use][sum / 2] % MOD;
        ans %=  MOD;
    }
    if(ans < 0) ans += MOD;
    cout << ans;
}

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

typedef long long s64;
const int N=100+5,D=998244353;
int dp[N*N][N];
s64 fact[N];

int main(){
#ifdef kcz
	freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
#endif
	int n;
	cin>>n;
	int sum=0;
	bool d=0;
	dp[0][0]=1;
	for(int i=1;i<=n;++i){
		d^=1;
		int w;
		cin>>w;
		sum+=w;
		for(int j=sum;j>=w;--j)
		for(int k=1;k<=i;++k)(dp[j][k]+=dp[j-w][k-1])%=D;
	}
	if(sum%2){
		puts("0");
		exit(0);
	}
	fact[0]=1;
	for(int i=1;i<=n;++i)fact[i]=fact[i-1]*i%D;
	s64 ans=0;
	for(int k=0;k<=n;++k){
		(ans+=dp[sum/2][k]*fact[k]%D*fact[n-k])%=D;
	}
	cout<<ans<<endl;
}


#include <bits/stdc++.h>

template <typename T>
T next() {
    T temp; std::cin >> temp;
    return temp;
}

template <>
int next() {
    int temp; scanf("%d", &temp);
    return temp;
}
template <>
long long next() {
    long long temp; scanf("%lld", &temp);
    return temp;
}
template <>
double next() {
    double temp; scanf("%lf", &temp);
    return temp;
}
template <>
float next() {
    float temp; scanf("%f", &temp);
    return temp;
}

template <typename T1, typename T2>
std::pair<T1, T2> next() {
    std::pair<T1, T2> temp;
    temp.first = next<T1>();
    temp.second = next<T2>();
    return temp;
}

template <typename T>
std::vector<T> next(int n) {
    std::vector<T> temp(n);
    for(int i = 0; i < n; i++)
        temp[i] = next<T>();
    return temp;
}

template <typename T1, typename T2>
std::vector<std::pair<T1, T2>> next(int n) {
    std::vector<std::pair<T1, T2>> temp(n);
    for(int i = 0; i < n; i++)
        temp[i] = next<T1, T2>();
    return temp;
}

template <typename T>
void print(const T &x, char endc = '\n') {
    std::cout << x << endc;
    return;
}
void print(const int &x, char endc = '\n') {
    printf("%d%c", x, endc);
    return;
}
void print(const long long &x, char endc = '\n') {
    printf("%lld%c", x, endc);
    return;
}
void print(const size_t &x, char endc = '\n') {
    printf("%zu%c", x, endc);
    return;
}
void print(const float &x, char endc = '\n') {
    printf("%f%c", x, endc);
    return;
}
void print(const double &x, char endc = '\n') {
    printf("%lf%c", x, endc);
    return;
}

template<typename T1, typename T2>
void print(const std::pair<T1, T2> &p, char sepc = ' ', char endc = '\n') {
    print(p.first, sepc);
    print(p.second, endc);
    return;
}

template<typename T>
void print(const std::vector<T> &v, char sepc = ' ', char endc = '\n') {
    for(const T &e : v) print(e, sepc);
    printf("%c", endc);
    return;
}

using namespace std;

void eachTC() {
    int N = next<int>();
    string s = next<string>();
    int res = 0;
    if(s[0] != s[N-1])
        res = 1;
    else {
        res = -1;
        for(int i = 0; i < N-1; i++) {
            if(s[i] != s[0] && s[i+1] != s[0]) {
                res = 2;
                break;
            }
        }
    }
    print(res);
}

int main() {
    constexpr bool multipleTC = false;
    int T = multipleTC ? next<int>() : 1;
    while(T--) eachTC();

    return 0;
}

#include<iostream>
using namespace std;
int main()
{
	char a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c)
	{
		cout<<"Won";
	}
	else
	cout<<"Lost";

}


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

int main() {
    long long n, t, take;
    cin >> t >> n;
    take = (100 + t - 1) / t;
    for (long long i = n * (take - 1); i <= n * (take + 1); i++) {
        if ((i * t) / 100 == n) {
            cout << i + n - 1 << "\n";
            break;
        }
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch TaxIncludedPrice | diff TaxIncludedPrice.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address TaxIncludedPrice.cpp && ./a.out

/*

 5/9/2021

 22:56-

 */

LL N;
int T;

void solve() {
  LL good=0, bad=1e15;
  while(abs(good-bad)>1) {
    LL m=(good+bad)/2;
    LL x=m*(100+T)/100;
    (((x-m)<=N-1)?good:bad)=m;
  }

  LL x1=good*(100+T)/100;
  LL x2=(good+1)*(100+T)/100;
  assert(x2==x1+2);
  assert(x1-good==N-1);
  cout<<x1+1<<endl;
}

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

  cin>>T>>N;
  solve();

  return 0;
}