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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << "Line " << __LINE__ << ": " <<  #x << " = " << (x) << "\n";
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;

template<typename T> using V = vector<T>;
template<typename T> using P = pair<T, T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

template <class T> void UNIQUE(vector<T> &x) {sort(ALL(x));x.erase(unique(ALL(x)), x.end());}
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; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<"\n";}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<"\n";};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

int main(){

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

    cout << N - A + B << endl;

    return 0;
}

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#define f(i,a,b) for(ll  i = a; i < (ll) b ; i++ )
#define af(i,a,b) for(ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll  i = a; i < (ll) b ; i+= k )
#define arep(i,a,b,k) for(ll i = a; i >= (ll) b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define sz(a) (ll) a.size()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller   ios::sync_with_stdio(false);cin.tie(0)

// policy-based

using namespace std;

typedef long long ll; // ll or ll
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

const ll MAX = 3e5 + 20;
const ll mod = 1e9 + 7;
const ll inf = 2e9;

ll a[MAX],b[MAX];
int main(){
	fastio;
	ll n,x,y;

	cin >> n;
	f(i,0,n){
		cin >> a[i] >> b[i];

	}
	ll ans = inf;
	f(i,0,n){
		f(j,0,n){
			if(i == j) continue;
			ans = min(ans,max(a[i], b[j]) );
		}
		ans = min(ans,a[i] + b[i]);
	}
	cout << ans << endl;
	return 0;
}


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

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const ll mod = 1e9+7;
ll mul(ll a,ll b){return ((a%mod)*(b%mod))%mod;}
ll sum(ll a,ll b){return ((a%mod)+(b%mod))%mod;}
ll sub(ll a,ll b){return ((a%mod)-(b%mod))%mod;}
ll power(ll a,ll b){
	ll res = 1;
	while(b){
		if(b&1)res = mul(res,a);
		b >>= 1;
		a = mul(a,a);
	}
	return res;
}

const int maxn = 1000+10;
ll fib[maxn];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	fib[2] = fib[3] = 1;
	forn(i,4,maxn)fib[i] = sum(fib[i-1],fib[i-2]);
	int N; cin >> N;
	char aa,ab,ba,bb; cin >> aa >> ab >> ba >> bb;
	if(N <= 3){
		cout << 1 << '\n';
		return 0;
	}
	ll res = 0;
	if(ab == 'A'){
		if(aa == 'A'){
			res = 1;
		}else{
			if(ba == 'B'){
				res = power(2,N-3);
			}else{
				res = fib[N];
			}
		}
	}else{
		if(bb == 'B'){
			res = 1;
		}else{
			if(ba == 'A'){
				res = power(2,N-3);
			}else{
				res = fib[N];
			}
		}
	}
	if(res < 0)res += mod;
	cout << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/

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

int main() {
  int N, X;
  cin >> N >> X;
  vector<vector<int>> Alc(N, vector<int>(2));
  rep(i, N) cin >> Alc[i][0] >> Alc[i][1];

  bool flag = false;
  int ml = 0;
  int ans;
  rep(i, N) {
    ml += Alc[i][0]*Alc[i][1];
    cerr << i+1 << " " << ml << endl;
    if (ml > X*100) {
      ans = i+1;
      flag = true;
      break;
    }
  }
  if (flag) {
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
}


#pragma region head
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using vv = vector<vector<T>>;
#define _roverload(_a1, _a2, _a3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(...) _roverload(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); --i)
#define rrep(...) _roverload(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bit(n) (1LL << (n))
template <class T>
inline bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void print() { cout << '\n'; }
template <class T>
void print(const vector<T> &v) {
    bool f = false;
    for (const auto &e : v) {
        if (f) cout << ' ';
        cout << e;
        f = true;
    }
    cout << '\n';
}
template <class... T>
void print(const T &...args) {
    bool f = false;
    for (const auto &e : {args...}) {
        if (f) cout << ' ';
        cout << e;
        f = true;
    }
    cout << '\n';
}
const int INF = 1002003004;
const ll LINF = 1002003004005006007ll;
struct preprocess {
    preprocess() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} ____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    vi ls1 = {a % 10};
    ll now = a % 10;
    while (true) {
        now *= a;
        now %= 10;
        if (ls1[0] != now) {
            ls1.emplace_back(now);
        } else {
            break;
        }
    }
    int len = ls1.size();
    vi ls2 = {b % len};
    ll now2 = b % len;
    bool flag = false;
    int cnt = 1;
    while (true) {
        cnt++;
        now2 *= b;
        now2 %= len;
        if (now2 == 0) {
            flag = true;
            break;
        } else if (ls2[0] != now2) {
            ls2.emplace_back(now2);
        } else {
            break;
        }
    }
    int s2 = ls2[(c - 1 + ls2.size()) % ls2.size()];
    if (flag && cnt<=c) s2 = 0;
    int s1 = ls1[(s2 - 1 + ls1.size()) % ls1.size()];
    print(s1);
}

#include<bits/stdc++.h>
using namespace std;
int main () { int N ;cin>>N;
               string s ;int y;cin>>y>>s; int i;

                              for(i=0;i< s.length();i++){
                                   if(y!=0){if(s[i]=='o') {y=y+1;}
                                    else if (s[i]=='x'){y=y-1;}}
                                else if(y==0){if(s[i]=='o') {y=y+1;}
                                              else if (s[i]=='x'){y=y;}}}

                               cout<<y;
                                return 0; }


#include<bits/stdc++.h>
using namespace std;
int k,fact[5];
long long sol;

int main()
{
    scanf("%d",&k);
    fact[1]=1;
    fact[2]=3;
    fact[3]=6;
    for(int i=1;(i*i*i)<=k;i++)
    {
        for(int j=i;(j*j)<=k/i;j++) {
            int lim = (k / i) / j;
            for (int z = j; z <= lim; z++) {
                set<int> S;
               // printf("%d %d %d\n", i, j, z);
                S.insert(i);
                S.insert(j);
                S.insert(z);

                sol += fact[(int) S.size()];

            }
        }
    }

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

#include <iostream>
using namespace std;

int main()
{
  int m,a=1,b=1,c=1,k=0;
  cin >> m;
  for(int a=1;a<=m;a++){
    for(int b=1;a*b<=m;b++){
      for(int c=1;a*b*c<=m;c++)
        k++;
    }
  }
  cout << k;
}


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

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <int, int> ii;

const int mod = 1e9 + 7;
const ll INF = 1e18;
const double EPSILON = 0.001;
const int N = 1e6+5;
ll inverse(ll a, ll b){
    ll inv = -1;
    ll q, r, r1 = a, r2 = b, t, t1 = 0, t2 = 1;

    while (r2 > 0){
        q = r1 / r2;
        r = r1 - q * r2;
        r1 = r2;
        r2 = r;

        t = t1 - q * t2;
        t1 = t2;
        t2 = t;
    }

    if (r1 == 1)
        inv = t1;

    if (inv < 0)
        inv = inv + a;

    return inv;
}
ll mmc(ll a, ll b){
    return (1ll * a * b )/ (1ll * __gcd(a,b));
}
//https://cp-algorithms.com/algebra/linear_congruence_equation.html
int main(){
    fastio;
    int t;
    cin >> t;
    while(t--){
        ll n,s,a;
        cin >> n >> s >> a;
        ll d = (ll)__gcd(a,n);
        ll b = -s + n;

        ll a1 = a/d;
        ll b1 = b/d;
        ll n1 = n/d;

        ll x = (b1 * inverse(n1, a1)) % n1;

        if(((s+x*a)%n) != 0)
            cout << -1 << '\n';

        else cout << x << '\n';
    }
    return 0;
}

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

int main()
{
	int n;
	long long ans = 0;
	cin >> n;
	vector<int> t(n);
	vector<double> l(n);
	vector<double> r(n);
	for (int i = 0; i < n; i++)
	{
		cin >> t.at(i) >> l.at(i) >> r.at(i);
	}
	for (int i = 0; i < n; i++)
	{
		switch (t.at(i))
		{
		case 1:
			break;
		case 2:
			r.at(i) -= 0.5;
			break;
		case 3:
			l.at(i) += 0.5;
			break;
		case 4:
			r.at(i) -= 0.5;
			l.at(i) += 0.5;
			break;
		}
	}
	for (int i = 0; i < n - 1; i++)
	{
		if (r.at(i) < l.at(i))
		{
			continue;
		}
		for (int j = i + 1; j < n; j++)
		{
			if (r.at(j) < l.at(i) || l.at(j) > r.at(i) || r.at(j) < l.at(j))
			{
				//cout << i << ' ' << j << endl;
				continue;
			}
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define lll long long
#define mp make_pair
#define pb push_back
ll inf = 1000000000000000000;
#define deci(n) fixed << setprecision(n)
#define vll vector<ll>
#define vpll vector<pair<ll, ll>>
#define umll unordered_map<ll, ll>
#define mll map<ll, ll>
//#define f first
//#define s second
#define mt make_tuple
#define g(i, name) get<i>(name)

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 = std::chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct hash_pair
{
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2> &p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};

ll p = 1e9 + 7;

//*****************CODE STARTS **************************************
//#define f first
ll mingap(vector <ll> & r, ll x, vector <ll> & g, ll y){
    if(x==0 || y==0)return inf;
    ll minrg=inf;
    ll j=0;
        for(ll i=0; i<x; i++){
            while(j!=y-1 && g[j+1]<=r[i])j++;
            minrg = min(minrg, abs(r[i]-g[j]));
            if(g[j]<=r[i] && j!=y-1)j++;
            minrg = min(minrg, abs(r[i]-g[j]));
        }
        return minrg;
}

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

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

    ll n; cin >> n; n*=2;
    vector <ll> r, g, b;

    for(ll i=0; i<n; i++){
        ll x; cin >> x; char c; cin >> c;
        if(c=='R')r.pb(x);
        else if(c=='G')g.pb(x);
        else b.pb(x);
    }

    sort(r.begin(), r.end());
    sort(g.begin(), g.end());
    sort(b.begin(), b.end());

    if(r.size()%2==0 && g.size()%2==0)cout << 0;
    else if(r.size()%2==0){
        ll minrg=inf, mingb=inf, minbr=inf;
        ll x =r.size(), y=g.size(), z=b.size();

        minrg = mingap(r, x, g, y);
        mingb = mingap(g, y, b, z);
        minbr = mingap(b, z, r, x);
        //cout << minrg << " " << mingb << " " << minbr <<"\n";
        cout << min(mingb, minrg+minbr);
    }
    else{
        if(g.size()%2==0)swap(r, g);
        else swap(r, b);

        ll minrg=inf, mingb=inf, minbr=inf;
        ll x =r.size(), y=g.size(), z=b.size();

        minrg = mingap(r, x, g, y);
        mingb = mingap(g, y, b, z);
        minbr = mingap(b, z, r, x);
        //cout << minrg << " " << mingb << " " << minbr <<"\n";
        cout << min(mingb, minrg+minbr);
    }
}

#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
vector<ll> a[3];

bool comp(vector<ll> &x, vector<ll> &y){
    return ((int)x.size()&1)<((int)y.size()&1);
}

int main(){
    int n;
    scanf("%d", &n);
    for (int i=0;i<n*2;i++){
        char col;
        ll val;
        scanf("%lld %c", &val, &col);
        if (col=='R') a[0].push_back(val);
        if (col=='G') a[1].push_back(val);
        if (col=='B') a[2].push_back(val);
    }
    for (int i=0;i<3;i++) sort(a[i].begin(), a[i].end());
    sort(a, a+3, comp);
    if (!(a[2].size()&1)){
        printf("0\n"); return 0;
    }
    ll ans1=1e18, ans2=1e18;
    for (auto &x:a[1]){
        auto iter = lower_bound(a[2].begin(), a[2].end(), x);
        if (iter!=a[2].end()) ans1 = min(ans1, (*iter)-x);
        if (iter!=a[2].begin()) ans1 = min(ans1, x-(*(--iter)));
    }
    if (a[0].empty()){
        printf("%lld\n", ans1); return 0;
    }

    vector<pair<ll, ll>> tmp(a[0].size(), {1e18, 1e18});

    for (int i=0;i<(int)a[0].size();i++){
        auto x = a[0][i];
        auto iter = lower_bound(a[1].begin(), a[1].end(), x);
        if (iter!=a[1].end()) tmp[i].first = (*iter)-x;
        if (iter!=a[1].begin()) tmp[i].first = min(tmp[i].first, x-(*(--iter)));
    }

    for (int i=0;i<(int)a[0].size();i++){
        auto x = a[0][i];
        auto iter = lower_bound(a[2].begin(), a[2].end(), x);
        if (iter!=a[2].end()) tmp[i].second = (*iter)-x;
        if (iter!=a[2].begin()) tmp[i].second = min(tmp[i].second, x-(*(--iter)));
    }

    int idx = 0, idx2 = 0;
    for (int i=0;i<(int)a[0].size();i++){
        if (ans2>min(tmp[i].first, tmp[i].second)){
            ans2 = min(tmp[i].first, tmp[i].second), idx = i;
            if (tmp[i].first<tmp[i].second) idx2 = 1;
            else idx2 = 2;
        }
    }
    ll tmp2 = 1e18;
    for (int i=0;i<(int)a[0].size();i++) if (i!=idx){
        if (idx2==1) tmp2 = min(tmp2, tmp[i].second);
        if (idx2==2) tmp2 = min(tmp2, tmp[i].first);
    }
    ans2 += tmp2;
    ll ans3;
    if (idx2==1) ans3 = tmp[idx].second;
    else ans3 = tmp[idx].first;
    tmp2 = 1e18;
    for (int i=0;i<(int)a[0].size();i++) if (i!=idx){
        if (idx2==2) tmp2 = min(tmp2, tmp[i].second);
        if (idx2==1) tmp2 = min(tmp2, tmp[i].first);
    }
    ans3 += tmp2;
    printf("%lld\n", min(ans1, min(ans2, ans3)));
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
  int a{},b{},c{};
  cin>>a>>b>>c;
  if (a > b){
    cout<<"Takahashi"<<endl;
  }
  if (a < b){
    cout<<"Aoki"<<endl;
  }
  if (a == b){
    if (c == 0){
      cout<<"Aoki"<<endl;
    }else{
      cout<<"Takahashi"<<endl;
    }
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define WIDTH 30
#define HEIGHT 30
#define Que 1000

#define rep(i, n) for(int i=0;i<(n);i++)
int main() {
  vector<int> Si(1000), Sj(1000), Ti(1000), Tj(1000);
   auto t1 = chrono::high_resolution_clock::now();
  rep(j, Que) {
     auto t2 = chrono::high_resolution_clock::now();
    cin >> Si[j] >> Sj[j] >> Ti[j] >> Tj[j];
    int UD = Ti[j] - Si[j];
    int LR = Tj[j] - Sj[j];
    if(UD>0) { rep(i, UD) cout << "D";}
    else if(UD<0) { rep(i, -UD) cout << "U"; }
    if(LR>0) { rep(i, LR) cout << "R"; }
    else if(LR<0) { rep(i, -LR) cout << "L"; }
    if (chrono::duration_cast<chrono::milliseconds>(t2-t1).count()>200)
      break;
    cout << "\n" << flush;
    int Bk;
    cin >> Bk;
  }
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define          pb                push_back
#define          eb                emplace_back
#define          endl              '\n'
#define          all(x)            x.begin(), x.end()
#define          sz(x)             int(x.size())
#define          pii               pair<int, int>
#define          pll               pair<ll, ll>
#define          ff                first
#define          ss                second

const ll INF = LLONG_MAX;
const int MOD = 1e9+7;
const int MX = 2e5+7;
const double PI = 3.1415926535897932384626;

template<class T> void dbg(T val) {
    cout << val << endl;
}

template<class T> void dbgs(T val) {
    cout << val << " ";
}

void solve() {
    ll N; cin >> N;
    ll x = 0;
    ll sum = 0;
    for (ll i = 1;;++i) {
        if (sum >= N) break;
        sum += i;
        x++;
    }
    dbg(x);
}

void fastIO(string name = "") {
    cin.tie(0)->sync_with_stdio(0);
    if (sz(name)) {
        freopen((name + ".in").c_str(), "r", stdin);
        freopen((name + ".out").c_str(), "w", stdout);
    }
}

int main() {
    fastIO("");

    int tc = 1; //cin >> tc;
    while (tc--) solve();
    return 0;
}

#include <iostream>
#include <cfenv>
#include <cmath>
using namespace std;

int main(){
    int N;
    int x;
    cin >> N;
    for(int i =0; i < N + 1; i++){
        x += i;
        if(x >= N ){
            cout << i << endl;
            break;
        }
    }
}


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

using namespace std;

#define ll long long
#define LL unsigned long long
#define vec(x) vector<x>
#define emb(x)  emplace_back(x)
#define fall(x) x.begin(),x.end()
#define rfall(x) x.rbegin(),x.rend()
#define fo(a,b) for(int i=a; i < b; i++)
#define fset(x) setprecision(x) << fixed
#define fast ios::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);

/*
 *---------------------------------------------
 * --------------------------------------------
 * --------------------------------------------
 *
العمل الجاد يتفوق على الموهبة الكسولة

 * 勤勉は怠惰な才能に勝る
 *
 * 努力打敗懶惰的人才
 *
  * कड़ी मेहनत आलसी प्रतिभा को हरा देती है
  *
 * тяжелая работа превосходит ленивый талант
 *
 * 勤勉は怠惰な才能に勝る
 *
 * 努力打敗懶惰的人才
 *
 * malfacila laboro superas maldiligentan talenton
 *
 * el trabajo duro supera al talento perezoso
 *
 * η σκληρή δουλειά κερδίζει τεμπέλης ταλέντο
 *
 * il duro lavoro batte il talento pigro
 *
 * munca grea bate talentul leneș
 *
 * kazi ngumu hupiga talanta ya uvivu
 *
 * piger ingenii labore verberat
 *
 * làm việc chăm chỉ đánh bại tài năng lười biếng
 *
 * trabalho duro vence talento preguiçoso
 *
 * працавітасць перамагае лянівы талент
 *
 * le travail acharné bat le talent paresseux
 *
 * --------------------------------------------------
 * --------------------------------------------------
 * --------------------------------------------------
*/

int main(){

	fast

    ll X,Y;

    ll newX,newY;

    cin>>newX>>newY;

    X=0,Y=0;

    X=(newX+newY)/2;
    Y=X-newY;

    cout << X << " "<<Y<<endl;

	return 0;
	}

#include <stdio.h>

#include <algorithm>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long llong;

void ABrick(std::istream& in, std::ostream& out) {
  int n, w;
  in >> n >> w;
  out << n / w << "\n";
}

int main(int argc, char** argv) { ABrick(cin, cout); return 0; }


#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define SIZE 55

ll A[SIZE],maxi[SIZE];
ll dp[SIZE][2];

int main(){

	ll N,price;
	scanf("%lld %lld",&N,&price);

	for(ll i = 1; i <= N; i++){

		scanf("%lld",&A[i]);
	}

	maxi[N] = HUGE_NUM;
	for(ll i = N-1; i >= 1; i--){

		maxi[i] = A[i+1]/A[i]-1; //その硬貨を払える最大枚数
	}

	stack<ll> S;

	ll tmp = price;

	for(ll i = N; i >= 1; i--){

		if(A[i] <= tmp){

			ll work = tmp/A[i];
			S.push(work);
			tmp %= A[i];

		}else{

			S.push(0);
		}
	}

	for(int digit = 0; digit <= N; digit++){
		for(int is_up = 0; is_up <= 1; is_up++){

			dp[digit][is_up] = 0;
		}
	}

	dp[0][0] = 1; //dp[桁][繰り上がりの有無] := 場合の数

	for(ll digit = 1; digit <= N; digit++){

		ll x = S.top();
		S.pop();

		for(ll pre_up = 0; pre_up <= 1; pre_up++){
			if(dp[digit-1][pre_up] == 0)continue;

			/*おつりと支払いが両方0*/
			if((pre_up == 0 && x == 0) || (pre_up == 1 && x+pre_up == maxi[digit]+1)){

				if(pre_up == 0 && x == 0){

					dp[digit][0] += dp[digit-1][pre_up];

				}else{

					dp[digit][1] += dp[digit-1][pre_up];
				}
			}

			/*おつりが0で支払いが非0*/
			if((pre_up+x > 0 && pre_up+x != maxi[digit]+1)){

				dp[digit][0] += dp[digit-1][pre_up];
			}

			/*おつりが非0で支払いが0→必ず繰り上がり*/
			if(pre_up+x > 0 && pre_up+x <= maxi[digit]){

				dp[digit][1] += dp[digit-1][pre_up];
			}
		}
	}

	printf("%lld\n",dp[N][0]);

	return 0;
}

// Problem: Blocks on Grid
// Date:

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

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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int n,m;
	int a[101][101];
	cin >> n >> m;
	int minn=101;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j){
			cin >> a[i][j];
			if (a[i][j] < minn)
				minn=a[i][j];
		}
	int res=0;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			if(a[i][j] > minn)
				res+=a[i][j] - minn;
	cout << res;
	return 0;
}


//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#define int long long
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define a first
#define b second
#define fi first
#define sc second
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
#define si(x) int(x.size())

#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

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

template<class t> using vc=vector<t>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.fi<<","<<p.sc<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int n, m, a[105], b[105], k, c[16], d[16];
void solve(){
	cin >> n >> m;
	rep(i, m) cin >> a[i] >> b[i];
	cin >> k;
	rep(i, k) cin >> c[i] >> d[i];

	int ans = 0;
	rep(mask, (1<<k)){
		bool ex[105] = {};
		rep(i, k){
			if(((mask>>i)&1)) ex[c[i]] = 1;
			else ex[d[i]] = 1;
		}
		int tmp = 0;
		rep(i, m){
			tmp += ex[a[i]] && ex[b[i]];
		}
		chmax(ans, tmp);
	}
	cout << ans << endl;
}
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	int t; t = 1; //cin >> t;
	while(t--) solve();
}

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

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 N;
int to[400001], ne[400001], he[200001];
int Q[200001], vis[200001], p, q;
ll are[200001];

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

	cin >> N;
	rep1(i, N * 2 - 2) {
		int a, b;
		cin >> a >> b;
		to[i] = b;
		ne[i] = he[a];
		he[a] = i++;
		to[i] = a;
		ne[i] = he[b];
		he[b] = i;
	}

	Q[q++] = 1;
	while (p < q) {
		int u = Q[p++];
		vis[u] = -1;
		for (int i = he[u]; i; i = ne[i]) {
			if (vis[to[i]] == 0) {
				Q[q++] = to[i];
			}
		}
	}
	int tmp = Q[N - 1];
	p = 0;
	q = 0;
	Q[q++] = tmp;
	vis[tmp] = 0;
	while (p < q) {
		int u = Q[p++];
		for (int i = he[u]; i; i = ne[i]) {
			if (vis[to[i]] < 0) {
				vis[to[i]] = u;
				Q[q++] = to[i];
			}
		}
	}
	ll m = (1ll << 20) - 1, m0 = ~m, m1 = 1ll << 20;
	for (int i = N - 1; i >= 0; i--) {
		int u = Q[i];
		ll kari = (are[u] & m0) + m1 + u;
		if (are[vis[u]] < kari) are[vis[u]] = kari;
	}

	int k = 0;
	q = 0;
	Q[q++] = tmp;
	while (q) {
		k++;
		int u = Q[q - 1];
		if (u < 0) q--;
		else {
			vis[u] = -k;
			Q[q - 1] = -u;
			int nanika = are[u] & m;
			if(nanika) Q[q++] = nanika;
			for (int i = he[u]; i; i = ne[i]) {
				int v = to[i];
				if (vis[v] >= 0 && v != nanika) {
					Q[q++] = v;
				}
			}
		}
	}

	rep1(i, N) cosp(-vis[i]);

	Would you please return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
#define LLINF (1LL<<60)
template<class T,class C> T max(T a,C b){ return std::max(a, (T)b); }
template<class T,class C> T min(T a,C b){ return std::min(a, (T)b); }
//TSPここから
struct TSP{//n<=17
  int n;
  vector<vector<ll> > dist;
  vector<vector<ll> > dp;
  TSP() : n(17){
    init();
  }
  TSP(int n_){
    n = n_;
    init();
  }
  void init(){//全体初期化
    ll i;
    dist.resize(n);
    for(i=0;i<dist.size();i++){
      dist[i].assign(n,LLINF);
    }
    dp_init();
  }
  void dp_init(){//dpのみ初期化
    ll i;
    dp.resize(1<<n);
    for(i=0;i<dp.size();i++){
      dp[i].assign(n,LLINF);
    }
  }
  void create_edge(ll s,ll t,ll d){//有向辺生成
    //s!=t,0<=s,t<n,d>=1
    dist[s][t] = min(dist[s][t],d);
  }
  void create_edge_each(ll a,ll b,ll d){//無向辺生成
    create_edge(a,b,d);
    create_edge(b,a,d);
  }
  void delete_edge(ll s,ll t){//辺の削除
    dist[s][t] = LLINF;
  }
  ll find_shortest_path(ll s){//最短距離(巡回)取得 O(N^2 2^N)
    //0<=s<n,-1=notfound
    ll i,j,k;
    dp_init();
    dp[0][s] = 0;
    for(i=0;i<(1<<n);i++){
      for(j=0;j<n;j++){
        for(k=0;k<n;k++){
          dp[i|1<<k][k] = min(dp[i|1<<k][k], dp[i][j]+dist[j][k]);
        }
      }
    }
    ll res = dp[(1<<n)-1][s];
    return (res>=LLINF ? -1 : res);
  }
  ll find_shortest_path_2(){//最短距離(パス,始点任意)取得 O(N^2 2^N)
    //0<=s<n,-1=notfound
    ll i,j,k;
    dp_init();
    for(ll s=0;s<n;s++) dp[1<<s][s] = 0;

    for(i=0;i<(1<<n);i++){
      for(j=0;j<n;j++){
        for(k=0;k<n;k++){
          dp[i|1<<k][k] = min(dp[i|1<<k][k], dp[i][j]+dist[j][k]);
        }
      }
    }
    ll res = dp[(1<<n)-1][0];
    for(i=1;i<n;i++){
      res = min(res, dp[(1<<n)-1][i]);
    }
    return (res>=LLINF ? -1 : res);
  }
  ll find_shortest_path_2(ll s){//最短距離(パス,始点固定)取得 O(N^2 2^N)
    //0<=s<n,-1=notfound
    ll i,j,k;
    dp_init();
    dp[1<<s][s] = 0;
    for(i=0;i<(1<<n);i++){
      for(j=0;j<n;j++){
        for(k=0;k<n;k++){
          dp[i|1<<k][k] = min(dp[i|1<<k][k], dp[i][j]+dist[j][k]);
        }
      }
    }
    ll res = dp[(1<<n)-1][0];
    for(i=1;i<n;i++){
      res = min(res, dp[(1<<n)-1][i]);
    }
    return (res>=LLINF ? -1 : res);
  }
};
//TSPここまで
vector<ll> edgeA[100010];
ll edgeB[20][20]={};
ll getEdge(ll s,ll t){
  return edgeB[s][t];
}
ll dist[100010]={};
int main(){
  ll i,j,n,m,a,b,k,c[20];
  queue<ll> que;
  cin >> n >> m;
  for(i=0;i<m;i++){
    //a=i+1;b=i+2;
    cin >> a >> b;
    a--;b--;
    edgeA[a].push_back(b);
    edgeA[b].push_back(a);
  }
  cin >> k;
  for(i=0;i<k;i++){
    //if(i==k-1) c[i]=n;
    //else c[i]=i+1;
    cin >> c[i];
    c[i]--;
  }
  for(i=0;i<k;i++){
    ll tmp = c[i];
    que.push(tmp);
    for(j=0;j<n;j++){
      dist[j]=LLINF;
    }
    dist[tmp]=0;
    while(!que.empty()){
      auto p = que.front();
      que.pop();
      //cout << p << endl;
      for(auto q :edgeA[p]){
        if(dist[q]==LLINF){
          dist[q] = dist[p]+1;
          que.push(q);
        }
      }
    }
    for(j=0;j<k;j++){
      ll tmp2 = c[j];
      if(i==j) continue;
      edgeB[i][j] = dist[tmp2];
    }
  }
  TSP tsp(k);
  for(i=0;i<k;i++){
    for(j=0;j<k;j++){
      if(i==j) continue;
      tsp.create_edge(i,j,getEdge(i,j));
    }
  }
  ll res = tsp.find_shortest_path_2();
  cout << (res==-1 ? -1 : res+1) << endl;
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> adj_list(n);
    vector<vector<bool>> adj_matrix(n, vector<bool>(n, 0));
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u;
        --v;
        adj_list[u].push_back(v);
        adj_list[v].push_back(u);
        adj_matrix[u][v] = true;
        adj_matrix[v][u] = true;
    }
    vector<bool> is_complete(1 << n, false);
    is_complete[0] = true;
    for (int mask = 1; mask < (1 << n); ++mask) {
        int i = 0;
        while (!(mask & (1 << i))) {
            ++i;
        }
        if (!is_complete[mask ^ (1 << i)]) {
            continue;
        }
        is_complete[mask] = true;
        for (int j = i + 1; j < n; ++j) {
            if ((mask & (1 << j)) && !adj_matrix[i][j]) {
                is_complete[mask] = false;
            }
        }
    }
    vector<int> components(1 << n, 2 * n + 1);
    components[0] = 0;
    for (int mask = 1; mask < (1 << n); ++mask) {
        if (is_complete[mask]) {
            components[mask] = 1;
            continue;
        }
        int i = 0;
        while (!((1 << i) & mask)) {
            ++i;
        }
        int smaller_mask = mask ^ (1 << i);
        for (int lower_mask = smaller_mask; lower_mask != 0; lower_mask = (lower_mask - 1) & smaller_mask) {
            if (is_complete[mask ^ lower_mask]) {
                components[mask] = min(components[mask], 1 + components[lower_mask]);
            }
        }
    }
    cout << components[(1 << n) - 1] << "\n";
}

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


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

void fail(){
	cout << -1 << '\n';
	exit(0);
}

int main(){
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	int n, l;
	cin >> n >> l;

	long long ans = 0;
	vector<int> a(n+2), b(n+2);
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> b[i];
	a[0] = b[0] = 0;
	a[n+1] = b[n+1] = l+1;
	for(int i = 1; i <= n+1; i++){
		a[i] -= i; b[i] -= i;
	}
	l -= n;
	for(int i = 1; i + 1 <= n; i++){
		if(a[i] < b[i] && b[i+1] < a[i+1]){
			fail();
		}
	}
	for(int j = 0; j < 2; j++){
		int cur = n-1;
		for(int i = n; i >= 1; i--){
			if(a[i] > b[i]){
				if(b[i] == b[i-1]){
					ans++;
				} else {
					while(cur >= 0 && a[cur] > b[i]){
						cur--;
					}
					if(cur < 0 || a[cur] != b[i]) fail();
					ans += i - cur;
				}
			}
		}
		reverse(a.begin(), a.end());
		reverse(b.begin(), b.end());
		for(int& x : a) x = l - x;
		for(int& x : b) x = l - x;
	}
	cout << ans << '\n';
}

//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug

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

int n,l;
int arr[100005];
int brr[100005];

map<int,int> mx;
map<int,int> mn;

void rage(){
	cout<<"-1"<<endl;
	exit(0);
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);

	cin>>n>>l;
	rep(x,0,n) cin>>arr[x];
	rep(x,0,n) cin>>brr[x];

	rep(x,0,n) if (!mx.count(arr[x]-x)) mx[arr[x]-x]=x;
	if (!mx.count(l-n+1)) mx[l-n+1]=n;

	rep(x,n,0) if (!mn.count(arr[x]-x)) mn[arr[x]-x]=x;
	if (!mn.count(1)) mn[1]=-1;

	//for (auto &it:mn) cout<<it.fi<<"_"<<it.se<<" "; cout<<endl;
	//for (auto &it:mx) cout<<it.fi<<"_"<<it.se<<" "; cout<<endl;

	ll ans=0;

	rep(x,0,n){
		if (arr[x]==brr[x]) continue;
		if (arr[x]>brr[x]){ //move stuff left
			if (x!=0 && brr[x-1]==brr[x]-1) ans++;
			else{
				//cout<<"mn: "<<brr[x]-x<<" "<<x<<endl;
				if (!mn.count(brr[x]-x)) rage();
				ans+=x-mn[brr[x]-x];
			}
		}
		else{
			if (x!=n-1 && brr[x]+1==brr[x+1]) ans++;
			else{
				//cout<<"mx: "<<brr[x]-x<<" "<<x<<endl;
				if (!mx.count(brr[x]-x)) rage();
				ans+=mx[brr[x]-x]-x;
			}
		}
	}

	cout<<ans<<endl;
}


#include <bits/stdc++.h>
#include <cmath>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,in,fn) for(int i=in;i<=fn;i++)
#define debug(x) cerr << #x << ": " << x << endl

int main(){
  int a;
  cin >> a;
  int b = 100 - a % 100;
  cout << b << endl;
}

// puts(ans ? "Yes" : "No");  // 1 or 0
// if (ans == 1) cout << "Yes" << endl;
// else cout << "No" << endl;

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define siz(a) int((a).size())
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define pi 3.14159265
const ll mod = 1000 * 1000 * 1000 + 7;
const ll mod1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
using namespace std;

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

    while (y > 0)
    {

        if (y & 1)
            res = (long long)(res*x);

        y = y>>1;

        x = (long long)(x*x);

        //cout<<x<<'\n';
    }
    return res;
}

// Stolen Templates
template <typename T>
T MIN(T first) { return first; }

template <typename T, typename... Args>
T MIN(T first, Args... args) { return min(first, MIN(args...)); }

template <typename T>
T MAX(T first) { return first; }

template <typename T, typename... Args>

T MAX(T first, Args... args) { return max(first, MAX(args...)); }
// Stolen Templates end here

int main()
{

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

fastio();

   ll n;
   cin>>n;

   ll q =n/100;
   cout<<(q+1)*100-n;

return 0;
}

// check all product based operations for integer overflow
// careful of renamed variables especially in loops


#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long double lb = 0;
	long double rb = 2e9 + 9;
	long double p = 1.0 / (long double) n;
	auto f = [&](long double x) {
		long double E = 0.0;
		for (int i = 0; i < n; i++) {
			long double v = x + a[i] - min((long double) a[i], 2.0 * x);
			E += p * v;
		}
		return E;
	};
	for (int i = 0; i < 300; i++) {
		long double g = lb + (rb - lb) / 3.0;
		long double h = lb + 2.0 * (rb - lb) / 3.0;
		if (f(g) < f(h)) {
			rb = h;
		} else {
			lb = g;
		}
	}
	cout << setprecision(8) << fixed << f(lb) << '\n';
	return 0;
}
// B

#pragma GCC optimize ("Ofast")
#pragma GCC optimization ("unroll-loops, no-stack-protector")
#pragma GCC target ("avx")
#pragma GCC target ("avx2")
#pragma GCC target ("fma")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#pragma 03
using namespace std;
using namespace __gnu_pbds;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
	ll n; cin >> n;
	string s1, s2, s3; cin >> s1 >> s2 >> s3;
	string ans; ans.resize(2 * n + 1);
	ans[0] = '1';
	for (ll i = 1; i <= n; i++) ans[i] = '0';
	for (ll i = n + 1; i <= 2 * n; i++) ans[i] = '1';
	cout << ans << "\n";
}
int main(){
	fastio;
	ll t; cin >> t;
	while (t--) solve();
}


#include <bits/stdc++.h>

using namespace std;

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

const int inf = 1e9;
const ll inf64 = 1e18;

int main() {

#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif

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

    int n;
    cin >> n;
    vector<int> a(n + 1), b(n + 1), p(n + 1), f(n + 1), pp;

    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++)
        cin >> b[i];
    for (int i = 1; i <= n; i++)
        cin >> p[i];

    pp = p;

    set<pii> q;

    for (int i = 1; i <= n; i++)
        f[p[i]] = i;

    for (int i = 1; i <= n; i++) {
        if (i == p[i])
            continue;
        q.insert({b[i], i});
        if (a[i] <= b[p[i]]) {
            cout << "-1\n";
            return 0;
        }
    }

    vector<pii> res;

    while (!q.empty()) {
        int i = (--q.end())->second;
        q.erase(--q.end());
        if (p[i] == i)
            continue;
        int j = f[i], k = p[i];
        res.emplace_back(i, j);

        p[i] = i;
        f[i] = i;

        p[j] = k;
        f[k] = j;
    }

    p = pp;

    cout << (int) res.size() << "\n";
    for (auto [i, j] : res) {
        assert(a[i] > b[p[i]]);
        assert(a[j] > b[p[j]]);
        cout << i << " " << j << "\n";
        swap(p[i], p[j]);
    }

    for (int i = 1; i <= n; i++)
        assert(p[i] == i);

    return 0;
}

#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define V vector
#define P pair<int,int>
#define F first
#define S second
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; }
using ll = long long;
using ld = long double;
using namespace std;
const int INF =1001001001;
const int MAX = 2e6+1;
int main() {
    int a,b;cin>>a>>b;
    int w;cin>>w;
    w*=1000;
    int ans1=0,ans2=INF;
    rep(i,1,1e+7){
        double x = (double)w/i;
        if(a<=x&&x<=b){
            chmax(ans1,i);
            chmin(ans2,i);
        }
    }
    if(ans2==INF){
        cout<<"UNSATISFIABLE"<<endl;
        return 0;
    }
    cout<<ans2<<" "<<ans1<<endl;
}


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

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

int main() {
  ll n;
  cin >> n;
  ll x = 1000;
  ll ans = 0;
  while(n-x+1 >= 1) {
    ans += n-x+1;
    x*=1000;
  }

  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
#define ar array
clock_t time_req = clock()*1.0/CLOCKS_PER_SEC;

bool slope(pair<int,int> a , pair<int,int> b , pair<int,int> c){
    return (b.second-a.second)*(c.first-b.first) == (c.second-b.second)*(b.first-a.first);
}

#define int ll
void test_case() {
   int n;
   cin >> n;
   if(n <= 999){
    cout<<"0\n";
    return;
   }
   // int ans2 = 0;
   // for(int i = 999 ; i <= n ; i++){
   //  if(i > 999 && i < 1000000)
   //    ans2++;
   //  if(i >= 1000000 && i < 1000000000)
   //    ans2+=2;
   // }
   // cout<<ans2<<"\n";
   if(n >= 999 && n < 1000000){
    cout<<n-999<<"\n";
    return;
   }
   if(n >= 1000000 && n < 1000000000){
    int ans = (n-999999)*2 + (999999-999);
    cout<<ans<<"\n";
    return;
   }
   if(n >= 1000000000 && n < 1000000000000){
    int ans = (n-999999999)*3+(999999999-999999)*2+(999999-999);
    cout<<ans<<"\n";
    return;
   }
   if(n >= 1000000000000 && n < 1000000000000000){
    int ans = (n-999999999999)*4+(999999999999-999999999)*3+(999999999-999999)*2+(999999-999);
    cout<<ans<<"\n";
    return;
   }
   else{
    // int ans = (n-999999999999)*4+(999999999999-999999999)*3+(999999999-999999)*2+(999999-999);
    cout<<3998998998999005<<"\n";
   }

}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed<<setprecision(10);
    int T = 1;
    // cin >> T;
    while(T--){
        test_case();
    }
}

// dont take stress
// remember the i , j index in double loop
// typing slow but dont make mistake while thinking and typing

//(x,y) , (x1,y1) , (x2,y2)
// (y1-y)/(x1-x) == (y2-y1)/(x2-x1)
// (y1-y)*(x2-x1) == ()s


#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#define ll long long
#define rep(i, a, b) for (int i = a; i <= (int)b; i ++)
#define per(i, a, b) for (int i = (int)a; i >= b; i --)
template < typename T > void read(T & x) {
    x = 0; int flag = 1; char c = getchar();
    for(; !isdigit(c); c = getchar()) if(c == '-') flag = -1;
    for(; isdigit(c); c = getchar()) x = x * 10 + c - '0';
    x *= flag;
}
using namespace std;
const int maxn = 5010, mod = 998244353;
int n, m, k, a[maxn][maxn], f[maxn][maxn][3], b[maxn][maxn], c[maxn][maxn], power[maxn];
void upd(int & x, int y) { x += y; if(x >= mod) x -= mod; }
int main()
{
	memset(a, -1, sizeof(a));
	scanf("%d %d %d", &n, &m, &k);
	rep(i, 1, k) {
		int x, y; char ch;
		scanf("%d %d", &x, &y); cin >> ch;
		if(ch == 'X') a[x][y] = 0;
		else if(ch == 'R') a[x][y] = 1;
		else a[x][y] = 2;
	}
	rep(i, 1, n) rep(j, 1, m)
		b[i][j] = b[i - 1][j] + (a[i][j] == -1 ? 1 : 0),
		c[i][j] = c[i][j - 1] + (a[i][j] == -1 ? 1 : 0);
	if(a[1][1] == -1) f[1][1][0] = f[1][1][1] = f[1][1][2] = 1;
	else f[1][1][a[1][1]] = 1;
	power[0] = 1;
	rep(i, 1, max(n, m)) power[i] = 1ll * power[i - 1] * 3 % mod;
	rep(i, 1, n) rep(j, 1, m) {
		int tmp1 = power[b[i - 1][j + 1]], tmp2 = power[c[i + 1][j - 1]];
		//rep(k, 0, 2) f[i][j][k] = 1ll * f[i][j][k] * tmp % mod;
		if(a[i][j] != -1) {
			if(a[i][j] == 1) {
				rep(k, 0, 2) upd(f[i][j + 1][k], 1ll * tmp1 * f[i][j][1] % mod);
			}
			else if(a[i][j] == 2) {
				rep(k, 0, 2) upd(f[i + 1][j][k], 1ll * tmp2 * f[i][j][2] % mod);
			}
			else {
				rep(k, 0, 2) upd(f[i + 1][j][k], 1ll * tmp2 * f[i][j][0] % mod), upd(f[i][j + 1][k], 1ll * tmp1 * f[i][j][0]%mod);
			}
			continue;
		}
		rep(k, 0, 2) {
			upd(f[i + 1][j][k], 1ll * tmp2 * f[i][j][0]% mod), upd(f[i][j + 1][k], 1ll * tmp1 * f[i][j][0]%mod);
			upd(f[i][j + 1][k], 1ll * tmp1 * f[i][j][1]%mod);
			upd(f[i + 1][j][k], 1ll * tmp2 * f[i][j][2]%mod);
		}
	}
	if(a[n][m] == -1) upd(f[n][m][0], f[n][m][1]), upd(f[n][m][0], f[n][m][2]), printf("%d\n", f[n][m][0]);
	else printf("%d\n", f[n][m][a[n][m]]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using ll = long long;
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl

const int mod = 1e9 + 7;

void solve()
{
    int n;
    cin >> n;
    vector<pair<int, int>> x, y;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        x.push_back({a, i});
        y.push_back({b, i});
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    vector<pair<int, pair<int, int>>> ans;
    ans.push_back({abs(x[0].first - x[n - 1].first), {min(x[0].second, x[n - 1].second), max(x[0].second, x[n - 1].second)}});
    ans.push_back({abs(x[0].first - x[n - 2].first), {min(x[0].second, x[n - 2].second), max(x[0].second, x[n - 2].second)}});
    ans.push_back({abs(x[1].first - x[n - 1].first), {min(x[1].second, x[n - 1].second), max(x[1].second, x[n - 1].second)}});
    ans.push_back({abs(y[0].first - y[n - 1].first), {min(y[0].second, y[n - 1].second), max(y[0].second, y[n - 1].second)}});
    ans.push_back({abs(y[0].first - y[n - 2].first), {min(y[0].second, y[n - 2].second), max(y[0].second, y[n - 2].second)}});
    ans.push_back({abs(y[1].first - y[n - 1].first), {min(y[1].second, y[n - 1].second), max(y[1].second, y[n - 1].second)}});
    sort(ans.begin(), ans.end());
    for (int i = 4; i >= 0; i--)
    {
        if (ans[5].second != ans[i].second)
        {
            cout << ans[i].first << endl;
            return;
        }
    }
}

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

#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <iostream>
#include <fstream>
#include <chrono>

using namespace std;

const int DIV = 998244353;

void solve(int test, std::istream &in) {
    int n, m, k;
    in >> n >> m;
    vector<char> dish(n, 0);
    vector<int> a(m), b(m);
    for (int i = 0; i < m; i++) {
        in >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    in >> k;
    vector<int> c(k), d(k);
    for (int i = 0; i < k; i++) {
        in >> c[i] >> d[i];
        c[i]--;
        d[i]--;
    }
    int answer = 0;
    int maxMask = 1 << k;
    for (int mask = 0; mask < maxMask; mask++) {
        int tmp = mask;
        for (int i = 0; i < k; i++) {
            int x = (tmp & 1) ? c[i] : d[i];
            dish[x]++;
            tmp >>= 1;
        }

        int cur = 0;
        for (int i = 0; i < m; i++) {
            if (dish[a[i]] > 0 && dish[b[i]] > 0)
                cur++;
        }
        if (cur > answer)
            answer = cur;

        tmp = mask;
        for (int i = 0; i < k; i++) {
            int x = (tmp & 1) ? c[i] : d[i];
            dish[x]--;
            tmp >>= 1;
        }
    }
    printf("%d\n", answer);
}

int main(int argc, char *argv[]) {
#ifdef VLAD_LOCAL
    ifstream in("in.txt");
    auto start = std::chrono::steady_clock::now();
#else
    istream &in = cin;
#endif
    solve(0, in);
#ifdef VLAD_LOCAL
    auto end = std::chrono::steady_clock::now();
    double seconds = (double)std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() / 1000;
    printf("%.3lf seconds\n", seconds);
#endif
	return 0;
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) (int)(a.size())
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
int main()
{
	ll t,n;
	cin>>t>>n;
	//take A = 100/t *n
	ll ans = 100*n;
	ans=(ans+t-1)/t;
	ans+=n-1;
	cout<<ans<<'\n';
}


#include <bits/stdc++.h>
using namespace std;
long long n,q,a[200005],t[200005],z;
struct name
{
    long long x,i;
}f[200005];

int cmp1(struct name f1,struct name f2)
{return f1.x < f2.x;}

int cmp2(struct name f1,struct name f2)
{return f1.i < f2.i;}

int main ()
{
    scanf ("%lld",&n);
    for (int i = 1;i <= n;++i)
        scanf ("%lld %lld",a+i,t+i);
    scanf ("%lld",&q);
    for (int i = 1;i <= q;++i)
        scanf ("%lld",&f[i].x),f[i].i = i;
    sort(f+1,f+q+1,cmp1);
    for (int i = 1;i <= n;++i)
    {
        if (t[i] == 1) z += a[i];
        else if (t[i] == 2)
            for (int j = 1;j <= q && f[j].x+z < a[i];++j)
                f[j].x = a[i]-z;
        else
            for (int j = q;j >= 1 && f[j].x+z > a[i];--j)
                f[j].x = a[i]-z;
    }
    sort(f+1,f+1+q,cmp2);
    for (int i = 1;i <= q;++i)
        printf ("%lld\n",f[i].x+z);
    return 0;
}

#include<ctime>
#include<cstdio>
#include<cctype>
#include<algorithm>
#define le(p) ((p)<<1)
#define ri(p) ((p)<<1|1)
#define ll long long
using namespace std;
const ll N=1e6+7;
const ll ninf=-5e18;
ll read() {
	char c;
	ll x=0,f=1;
	while(!isdigit(c=getchar()))
		f-=2*(c=='-');
	while (isdigit(c)){
		x=x*10+(c-48)*f;
		c=getchar();
	}
	return x;
}
struct que{
	ll x,i;
	que(ll a=0,ll b=0){
		x=a;
		i=b;
	}
	friend bool operator <(que a,que b){
		return a.x<b.x;
	}
};
que s[N];
ll n,q,a[N],t[N],ans[N];
ll L[N],R[N],S[N],Z[N],mx[N],mn[N],add[N];
void up(ll p){
	mx[p]=max(mx[le(p)],mx[ri(p)]);
	mn[p]=min(mn[le(p)],mn[ri(p)]);
}
void down(ll p){
	if(S[p]^ninf){
		S[le(p)]=S[p];
		S[ri(p)]=S[p];
		mx[le(p)]=S[p];
		mn[le(p)]=S[p];
		mx[ri(p)]=S[p];
		mn[ri(p)]=S[p];
		S[p]=ninf;
	}
	if(Z[p]){
		Z[le(p)]=1;
		Z[ri(p)]=1;
		add[le(p)]=0;
		add[ri(p)]=0;
		Z[p]=0;
	}
	mx[le(p)]+=add[p];
	mn[le(p)]+=add[p];
	mx[ri(p)]+=add[p];
	mn[ri(p)]+=add[p];
	add[le(p)]+=add[p];
	add[ri(p)]+=add[p];
	add[p]=0;
}
void build(ll p,ll l,ll r){
	L[p]=l;
	R[p]=r;
	if(l==r){
		S[p]=s[l].x;
		mx[p]=s[l].x;
		mn[p]=s[l].x;
		return;
	}
	ll m=(l+r)>>1;
	build(le(p),l,m);
	build(ri(p),m+1,r);
	S[p]=ninf;
	up(p);
}
void tomin(ll p,ll l,ll r,ll k){
	if(mx[p]<k)
		return;
	if(mn[p]>=k){
		S[p]=k;
		mx[p]=k;
		mn[p]=k;
		add[p]=0;
		Z[p]=1;
		return;
	}
	down(p);
	tomin(le(p),l,r,k);
	tomin(ri(p),l,r,k);
	up(p);
}
void tomax(ll p,ll l,ll r,ll k){
	if(mn[p]>k)
		return;
	if(mx[p]<=k){
		S[p]=k;
		mx[p]=k;
		mn[p]=k;
		add[p]=0;
		Z[p]=1;
		return;
	}
	down(p);
	tomax(le(p),l,r,k);
	tomax(ri(p),l,r,k);
	up(p);
}
ll query(ll p,ll x){
	if(L[p]==R[p])
		return mx[p];
	down(p);
	ll m=(L[p]+R[p])>>1;
	if(x<=m)
		return query(le(p),x);
	return query(ri(p),x);
}
int main() {
	#ifndef ONLINE_JUDGE
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
	#endif
	clock_t t1=clock();
	//--------
	n=read();
	for(ll i=1;i<=n;++i){
		a[i]=read();
		t[i]=read();
	}
	q=read();
	for(ll i=1;i<=q;++i)
		s[i]=que(read(),i);
	sort(s+1,s+q+1);
	build(1,1,q);
	for(ll i=1;i<=n;++i){
		switch(t[i]){
			case 1:
				mx[1]+=a[i];
				mn[1]+=a[i];
				add[1]+=a[i];
				break;
			case 2:
				tomax(1,1,n,a[i]);
				break;
			case 3:
				tomin(1,1,n,a[i]);
				break;
		}
	}
	for(ll i=1;i<=q;++i)
		ans[s[i].i]=query(1,i);
	for(ll i=1;i<=q;++i)
		printf("%lld\n",ans[i]);
	//--------
	clock_t t2=clock();
	fprintf(stderr,"time:%0.3lfs",1.0*(t2-t1)/CLOCKS_PER_SEC);
	return 0;
}


#pragma warning(disable:4996)
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
int main() {
	//freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	ll n;
	while (cin >> n)
	{
		int a[18] = { 0 };
		int top = -1, sum = 0;
		int ans = INT_MAX;
		bool flag = true;
		ll tempn = n;
		while (tempn) {
			a[++top] = tempn % 10;
			sum += tempn % 10;
			tempn /= 10;
		}
		for (int i = 0; i <= (1 << 18); i += 1) {
			tempn = n;
			int state = i, pos = 0, num = 0;
			while (state) {
				if (state & 1) tempn -= a[pos], ++num;
				++pos;
				state >>= 1;
			}
			if (num > top) break;
			if (tempn % 3 == 0) ans = min(ans, num), flag = false;
		}
		if (flag) cout << "-1" << endl;
		else cout << ans << endl;
	}
	return 0;
}

#include <bits/stdc++.h>

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define setIO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#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()
#define lc(i) 2*i
#define rc(i) 2*i+1
//#define int long long
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vii = vector<ii>;
using vi = vector<int>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int N = 1e5 + 5, MOD = 1e9 + 7, INF = 1e9 + 5;

signed main() {
    FAST_IO;
#ifdef arujbansal_local
    setIO("input.txt", "output.txt");
#endif

    string s;
    cin >> s;

    int n = sz(s);

    vi a(n);
    for (int i = 0; i < n; i++) a[i] = s[i] - '0';

    int mn = n;

    for (int mask = 1; mask < (1 << n); mask++) {
        int num = 0, sum = 0;

        for (int i = 0; i < n; i++) {
            if (mask & (1 << i)) {
                sum += a[n - i - 1];
                num++;
            }
        }

        if (sum % 3 == 0)
            mn = min(mn, n - num);
    }

    cout << (mn == n ? -1 : mn);
}


/*---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---*/

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

// #define kyoa_a
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define rrep(a, b, c)  for(int a = (b); a > c; --a)
#define each(a, b)     for(auto& a : b)

#define sz(x)       (int)(x).size()
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(), (a).rend()

#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define f first
#define s second
#define dbg(x) cout << #x << " = " << x << endl;
#define vt vector
#define ar array
#define pii pair<int, int>
#define vi vector<int>
#define pll pair<ll, ll>
#define pct(x) __builtin_popcount(x)
#define fbo(x) find_by_order(x)
#define ook(x) order_of_key(x)
#define rsz resize

constexpr int log2(int x) { return x == 0 ? 0 : 31-__builtin_clz(x); } // floor(log2(x))

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> bool umin(T& a, const T& b){
	return b<a?a=b, 1:0;
}
template <class T> bool umax(T& a, const T& b){
	return a<b?a=b, 1:0;
}

using ll = long long;
using ld = long double;
using str = string;

const int inf = (int)1e9 + 5;
const ll infl = (ll)1e18 + 5;
const int mod = 1e9 + 7;
const int N = 55;
const int A = 911382323;
const int B = 972663749;

const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};

/*---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---*/

vt<int> p;
vt<ll> al;

int n, a[N], fi;

void solve(){
	rep(i, 2, 51){
		bool ok = 1;
		for(int j = 2; j*j <= i; ++j){
			if(i%j == 0){
				ok = 0;
				break;
			}
		}
		if(ok) p.eb(i);
	}
	fi = 1<<sz(p);
	rep(i, 1, fi){
		ll ans = 1;
		rep(j, 0, sz(p)){
			if(i&(1<<j)) ans *= p[j];
		}
		al.eb(ans);
	}
	sort(all(al));
	cin >> n;
	rep(i, 0, n) cin >> a[i];
	each(x, al){
		bool ok = 1;
		rep(i, 0, n){
			if(__gcd(x, (ll)a[i]) == 1){
				ok = 0;
				break;
			}
		}
		if(ok){
			cout << x << '\n';
			return;
		}
	}

}

int main(){
	#ifdef kyoa_a
		auto begin = std::chrono::high_resolution_clock::now();
	#endif

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

	#ifdef kyoa_a
		auto end = std::chrono::high_resolution_clock::now();
		cout << setprecision(3) << fixed;
		cout << "Execution time: " << std::chrono::duration_cast<std::chrono::duration<double>>(end - begin).count() << " seconds" << endl;
	#endif
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int nax=5005,mod=998244353;
int dp[15][nax],f[nax],invf[nax],pw[30];
int mul(int x,int y)
{
    return x*y%mod;
}
int nck(int n,int r)
{
    if(r<0 || r>n)
	return 0;
	return (f[n]*invf[n-r]%mod*invf[r]%mod);
}
int expo(int a,int b)
{
    int res=1;
	while(b>0)
	{
	    if(b%2==1)
	    res=mul(res,a);
	    a=mul(a,a);
	    b>>=1;
	}
	return res;
}
int inv(int x)
{
    return expo(x,mod-2);
}
void init()
{
    f[0]=1;
	for(int i=1;i<nax;i++)
	f[i]=(f[i-1]*i)%mod;
	invf[nax-1]=inv(f[nax-1]);
	for(int i=nax-2;i>=0;i--)
	invf[i]=(invf[i+1]*(i+1))%mod;
}
int n;
int dfs(int pos,int val)
{
    if(val&pw[pos])
    return 0;
    if(~dp[pos][val])
    return dp[pos][val];
    if(pos==13)
    {
        if(val)
        return 0;
        return 1;
    }
    int res=0;
    for(int i=0;pw[pos]*i<=val;i+=2)
    res=(res+mul(nck(n,i),dfs(pos+1,val-pw[pos]*i)))%mod;
    return dp[pos][val]=res;
}
int32_t main()
{
    init();
    memset(dp,-1,sizeof(dp));
    int m;
    cin>>n>>m;
    pw[0]=1;
    for(int i=1;i<30;i++)
    pw[i]=mul(pw[i-1],2LL);
    cout<<dfs(0,m);
    return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll MOD = 998244353;

long long modpow(long long x, long long n){
    long long  res = 1;
    long long mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

struct Combination
{
    int maxn;
    std::vector<long long> fact;
    std::vector<long long> ifact;

    Combination(int maxn) : maxn(maxn){
        fact.resize(maxn + 1);
        ifact.resize(maxn + 1);
        fact[0] = 1;
        for(int i = 1; i <= maxn; i++) fact[i] = fact[i - 1] * i % MOD;
        ifact[maxn] = modpow(fact[maxn], MOD - 2);
        for(int i = maxn - 1; i >= 0; i--) ifact[i] = ifact[i + 1] * (i + 1) % MOD;
    }

    long long com(int n, int k){
        if(k > n || k < 0) return 0;
        if(k == n || k == 0) return 1;
        return (fact[n] * ifact[k] % MOD) * ifact[n - k] % MOD;
    }
};

struct PrimeDecomposition
{
    int n;
    vector<bool> p;
    vector<int> prime;
    vector<int> d;

    PrimeDecomposition(int n) : n(n){
        p.resize(n + 1);
        d.resize(n + 1);
        d[1] = 1;
        for(int i = 2; i <= n; i++){
            if(!p[i]){
                prime.push_back(i);
                for(int j = i; j <= n; j += i){
                    if(!p[j]) d[j] = i;
                    p[j] = true;
                }
            }
        }
    }

    vector<int> decomposition(int x){
        vector<int> res;
        while(x > 1){
            res.push_back(d[x]);
            x /= d[x];
        }
        return res;
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    PrimeDecomposition dec(m);
    Combination com(n * 2 + m);
    ll ans = 1;
    for(int i = 2; i <= m; i++){
        vector<int> v = dec.decomposition(i);
        int l = v.size();
        ll s = 1;
        int c = 1;
        for(int i = 1; i <= l; i++){
            if(i == l || v[i] != v[i - 1]){
                s = s * com.com(n + c - 1, c) % MOD;
                c = 1;
            }
            else c++;
            if(i == l) break;
        }
        ans = (ans + s) % MOD;
    }
    cout << ans << endl;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int r, c;
    cin >> r >> c;

    vector<string> g(r);
    vector<vector<pair<int,int>>> occ(26);

    pair<int,int> start;
    pair<int,int> goal;

    for(int i = 0; i < r; i++) {
    	cin >> g[i];
    	for(int j = 0; j < c; j++) {
    		if(g[i][j] == 'S') {
    			start = mp(i, j);
    		} else if(g[i][j] == 'G') {
    			goal = mp(i, j);
    		} else if(isalpha(g[i][j])) {
    			occ[g[i][j] - 'a'].pb(mp(i, j));
    		}
    	}
    }

    queue<pair<int,int>> q;
    vector<vector<bool>> vis(r, vector<bool>(c));
    vector<bool> visColor(26);
    q.push(start);
    vector<vector<int>> dist(r, vector<int>(c, 1 << 30));
    dist[start.first][start.second] = 0;

    int dx[4] = {-1,1,0,0};
    int dy[4] = {0,0,1,-1};

    while(!q.empty()) {
    	pii p = q.front();
    	q.pop();

    	int i = p.first;
    	int j = p.second;

    	if(isalpha(g[i][j]) && g[i][j] != 'S' && g[i][j] != 'G' && !visColor[g[i][j] - 'a']) {
    		trav(e, occ[g[i][j] - 'a']) {
    			int nr = e.first;
    			int nc = e.second;
    			if(!vis[nr][nc] && g[nr][nc] != '#') {
    				dist[nr][nc] = 1 + dist[i][j];
    				vis[nr][nc] = true;
    				q.push(mp(nr, nc));
    			}
    		}
    		visColor[g[i][j] - 'a'] = true;
    	}

    	for(int x = 0; x < 4; x++) {
    		int nr = i + dx[x];
    		int nc = j + dy[x];
    		if(nr >= 0 && nr < r && nc < c && nc >= 0) {
    			if(!vis[nr][nc] && g[nr][nc] != '#') {
    				dist[nr][nc] = 1 + dist[i][j];
    				q.push(mp(nr, nc));
    				vis[nr][nc] = true;
    			}
    		}
    	}
    }

    cout << (dist[goal.first][goal.second] == 1 << 30 ? -1 : dist[goal.first][goal.second]) << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 200005;
int n;
int pos[N][2], ans[2];
int32_t main(int32_t argc, char const *argv[])
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        int x, c;
        cin >> x >> c;
        if (!pos[c][0])
            pos[c][0] = pos[c][1] = x;
        else
        {
            pos[c][0] = min(pos[c][0], x);
            pos[c][1] = max(pos[c][1], x);
        }
    }
    int pv = -1;
    for (int i = 1; i <= n; ++i)
    {
        if (!pos[i][0])
            continue;
        //cout << pos[i][0] << ' ' << pos[i][1] << '\n';
        if (pv == -1)
        {
            ans[0] += abs(pos[i][0]);
            ans[1] += abs(pos[i][1]);
            ans[0] += pos[i][1] - pos[i][0];
            ans[1] += pos[i][1] - pos[i][0];
            pv = i;
        }
        else
        {
            int x = ans[0];
            int y = ans[1];
            ans[0] = min(x + abs(pos[i][0] - pos[pv][1]), y + abs(pos[i][0] - pos[pv][0]));
            ans[1] = min(x + abs(pos[i][1] - pos[pv][1]), y + abs(pos[i][1] - pos[pv][0]));
            ans[0] += pos[i][1] - pos[i][0];
            ans[1] += pos[i][1] - pos[i][0];
            pv = i;
        }
    }
    cout << min(ans[0] + abs(pos[pv][1]), ans[1] + abs(pos[pv][0])) << '\n';
    return 0;
}

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set     tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k):    It returns to an iterator to the kth element (counting from zero) in the set
// order_of_key(k) :    It returns to the number of items that are strictly smaller than our item k
#define fast            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb              push_back
#define f               first
#define s               second
#define F(i,a,b)        for(i=a;i<b;i++)
#define nl              "\n"
#define sp              " "
#define all(c)          (c).begin(),(c).end()
#define rev(i,b,a)      for(int i=b;i>=a;i--)
#define iota            cout<<-1<<nl
#define cty             cout<<"YES"<<nl
#define ctn             cout<<"NO"<<nl
#define lmax            LLONG_MAX
#define lmin            LLONG_MIN
#define sz(v)           (v).size()
#define deci(n)         fixed<<setprecision(n)
#define c(x)            cout<<(x)
#define csp(x)          cout<<(x)<<" "
#define c1(x)           cout<<(x)<<nl
#define c2(x,y)         cout<<(x)<<" "<<(y)<<nl
#define c3(x,y,z)       cout<<(x)<<" "<<(y)<<" "<<(z)<<nl
#define c4(a,b,c,d)     cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<nl
#define c5(a,b,c,d,e)   cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<nl
#define c6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<nl
typedef long double     ld;
typedef long long       ll;
typedef vector<ll>      vll;
typedef pair<ll,ll>     pll;
typedef vector<pll>     vpll;
const int mod=998244353;
const double pi=3.14159265358979323846264338327950288419716939937510582097494459230;
// priority_queue<t>

ll poww(ll a, ll b) { ll res=1; while(b) { if(b&1)	res=(res*a); a=(a*a); b>>=1; } return res; }
ll modI(ll a, ll m=mod) { ll m0=m,y=0,x=1;  if(m==1) return 0;  while(a>1)  { ll q=a/m; ll t=m;  m=a%m;  a=t; t=y; y=x-q*y;  x=t; } if(x<0) x+=m0; return x;}
ll powm(ll a, ll b,ll m=mod) {ll res=1;	while(b) {	if(b&1)	res=(res*a)%m;	a=(a*a)%m; b>>=1;	}	return res;}
//*******************************************************************************************************************************************//
void iamzeus()
{ ll i,j,x=0,y,ans=0,n,m,d,cnt=0,z,c=2,k;

 cin>>n;
 vll v[n+1];
 for(i=0;i<n;i++){
     cin>>x>>y;
  v[y].pb(x);

 }
 pll dp[n+1];
 dp[0].f=0,dp[0].s=0;
 x=0,y=0;
 for(i=1;i<=n;i++)
     sort(all(v[i]));
 for(i=1;i<=n;i++)
 {
     if(v[i].size()==0){
         dp[i].f=dp[i-1].f,dp[i].s=dp[i-1].s;
         continue;
     }
   ll  x1=v[i][0],y1=v[i].back();
     dp[i].f=min(dp[i-1].f+2*max((ll)0,y1-x)+x-x1,dp[i-1].s+2*max((ll)0,y1-y)+y-x1);
      dp[i].s=min(dp[i-1].f+2*max((ll)0,x-x1)+y1-x,dp[i-1].s+2*max((ll)0,y-x1)+y1-y);
     x=x1,y=y1;
// c2(dp[i].f,dp[i].s);
 }
 dp[n].f+=abs(x),dp[n].s+=abs(y);
 c1(min(dp[n].f,dp[n].s));
};
int main()
{fast;
    int t;
  t=1;
//cin >>t;
 while(t--)
     iamzeus();
}


#line 1 "main.cpp"
#include <iostream>
#include <vector>

using namespace std;

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

    vector<vector<int>> graph(n);
    for (int i = n - 1; i--;) {
        int u, v;
        cin >> u >> v;
        --u, --v;

        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    // 伝達時刻で二分探索
    int ok = n, ng = 0;
    while (ok - ng > 1) {
        int mid = (ok + ng) / 2;

        int cnt = 0;  // 連絡先の個数

        // 部分木が全て被覆されている: -(連絡先の最小距離+1)
        // そうでない                : 被覆されていない子の最大距離
        auto dfs = [&](auto&& f, int v, int p) -> int {
            int uncovered_max = -1, center_min = n;

            for (auto u : graph[v]) {
                if (u == p) continue;

                auto d = f(f, u, v);
                if (d >= 0) {
                    uncovered_max = max(uncovered_max, d + 1);
                } else {
                    center_min = min(center_min, -d);
                }
            }

            // 葉の場合
            if (graph[v].size() <= 1) uncovered_max = 0;

            // 被覆されていない頂点を全て被覆できる場合
            if (uncovered_max + center_min <= mid) uncovered_max = -1;

            // 連絡先が既に無効の場合
            if (center_min > mid) uncovered_max = max(uncovered_max, 0);

            if (uncovered_max == mid) {
                ++cnt;  // vを連絡先にする
                uncovered_max = -1, center_min = 0;
            }

            return uncovered_max != -1 ? uncovered_max : -(center_min + 1);
        };

        // 根が被覆されていない場合は根を連絡先にする
        if (dfs(dfs, 0, -1) >= 0) ++cnt;

        if (cnt <= k) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    cout << ok << "\n";
}

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

    solve();

    return 0;
}

#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
//#define puts sdf
using std::vector;
//using std::cout;
//using std::endl;
using std::sort;
using std::swap;
using std::min;
using std::max;

int read(){//int 无负数
	int h=0;char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9')h=(h<<1)+(h<<3)+c-'0',c=getchar();
	return h;
}

const int MAXN=200100;
int K,n;
struct Edge{
    int to;
    int nxt;
}edge[MAXN<<1];
int frm[MAXN];
int cnt_e;

void insert_e(int u,int v){
    cnt_e++;
    edge[cnt_e].to=v;
    edge[cnt_e].nxt=frm[u];
    frm[u]=cnt_e;
}
int Fa[MAXN];

int Rt,mns,S;
int siz[MAXN];
bool vis[MAXN];
void get_rt(int x,int ff){
    siz[x]=1;int mxs=0;
    for(int i=frm[x];i;i=edge[i].nxt){
        int v=edge[i].to;if(v==ff||vis[v])continue;
        get_rt(v,x);
        siz[x]+=siz[v];
        mxs=max(mxs,siz[v]);
    }
    mxs=max(mxs,S-siz[x]);
    if(mxs<mns)Rt=x,mns=mxs;
}

int Dt[MAXN];//点分树上的深度
int dis[MAXN][21]; //x到点分树上深度为D的那个祖先的距离
int mndis[MAXN];//距离他最近的点

void get_dis1(int U,int x,int ff,int dep,int D){
    dis[x][D]=dep;
    for(int i=frm[x];i;i=edge[i].nxt){
        int v=edge[i].to;if(v==ff||vis[v])continue;
        get_dis1(U,v,x,dep+1,D);
    }
}

void divide(int x,int D){//D是点分树上的深度
    vis[x]=true;
    Dt[x]=D;
    get_dis1(x,x,x,0,D);
    for(int i=frm[x];i;i=edge[i].nxt){
        int v=edge[i].to;if(vis[v])continue;

        S=siz[v],mns=siz[v],get_rt(v,v);
        Fa[Rt]=x;divide(Rt,D+1);
    }
}

void Modify(int x){
    int rt=x;
    for(;rt;rt=Fa[rt]){
        mndis[rt]=min(mndis[rt],dis[x][Dt[rt]]);
//        cout<<"MODIFY"<<x<<" "<<rt<<" "<<mndis[rt]<<endl;
    }
}

bool Query(int x,int mid){
    int rt=x;
    for(;rt;rt=Fa[rt]){
//    	cout<<"QUERY "<<x<<' '<<rt<<" "<<mndis[rt]<<' '<<dis[x][Dt[rt]]<<endl;
        if(mndis[rt]+dis[x][Dt[rt]]<=mid)return true;
    }
    return false;
}

int fa[MAXN][19];
int dep[MAXN];
int qwq[MAXN];//按深度排序
bool cmp(int x,int y){
	return dep[x]>dep[y];
}
void pre_dfs(int x,int ff){
	fa[x][0]=ff;dep[x]=dep[ff]+1;
	for(int i=1;i<=18;i++)fa[x][i]=fa[fa[x][i-1]][i-1];
	for(int i=frm[x];i;i=edge[i].nxt){
		int v=edge[i].to;if(v==ff)continue;
		pre_dfs(v,x);
	}
}

int get_fa(int x,int k){
	int nw=x;
	for(int i=0;i<=18;i++){
		if(k&(1<<i))nw=fa[nw][i];
	}
	return nw;
}

bool ch_ck(int mid){
//	cout<<"MID"<<':'<<mid<<endl;
	memset(mndis,0x3f,sizeof(mndis));
//	for(int i=1;i<=n;i++)mndis[i]=-0x3f3f3f3f;
	int cnt=0;
	for(int i=1;i<=n;i++){
		int x=qwq[i];
		if(Query(x,mid))continue;
		int fk=get_fa(x,mid);
		cnt++;Modify(fk);
//		cout<<"WORK"<<x<<" "<<fk<<endl;
		if(cnt>K)return false;
	}
	return true;
}

int get_ans(){
	int l=0,r=n;
	while(l+1<r){
		int mid=(l+r)>>1;
		if(ch_ck(mid)){
			r=mid;
		}
		else l=mid+1;
	}
	if(l==r)return r;
	if(ch_ck(l))return l;
	return r;
}

int main(){
	n=read(),K=read();
    for(int i=1;i<=n-1;i++){
        int u=read(),v=read();
        insert_e(u,v),insert_e(v,u);
    }
    S=n,mns=n,get_rt(1,1);
    divide(Rt,0);
    pre_dfs(1,1);
    for(int i=1;i<=n;i++)qwq[i]=i;sort(qwq+1,qwq+n+1,cmp);
//    for(int i=1;i<=n;i++)cout<<qwq[i]<<" ";puts("");
//    for(int i=1;i<=n;i++){
//    	for(int j=0;j<=18;j++)cout<<fa[i][j]<<" ";puts("");
//	}
    printf("%d\n",get_ans());
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
//const int MOD = (int) 1e9 + 7;
const int MOD = 119 << 23 | 1;
const int FFTMOD = 119 << 23 | 1;
const int INF = (int) 1e9 + 23111992;
const ll LINF = (ll) 1e18 + 23111992;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ull isqrt(ull k) {ull r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int mrand() {return abs((int) mt());}
inline int mrand(int k) {return abs((int) mt()) % k;}
#define db(x) cerr << "[" << #x << ": " << (x) << "] ";
#define endln cerr << "\n";

void chemthan() {
    int n; cin >> n;
    vector<string> res;
    res.pb("AB");
    FOR(i, 1, n) {
        vector<string> nres;
        for (auto s : res) {
            nres.pb(s + s);
            string ss = s;
            for (char c : s) {
                if (c == 'A') {
                    ss += 'B';
                }
                else {
                    ss += 'A';
                }
            }
            nres.pb(ss);
        }
        string s;
        FOR(j, 0, 1 << i) {
            s += "A";
        }
        FOR(j, 0, 1 << i) {
            s += "B";
        }
        nres.pb(s);
        res = nres;
    }
    cout << sz(res) << "\n";
    for (auto s : res) {
        cout << s << "\n";
    }
}

int32_t main(int32_t argc, char* argv[]) {
    ios_base::sync_with_stdio(0), cin.tie(0);
    if (argc > 1) {
        assert(freopen(argv[1], "r", stdin));
    }
    if (argc > 2) {
        assert(freopen(argv[2], "wb", stdout));
    }
    chemthan();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	cout<<(1<<n)-1<<endl;
	for(int i=1;i<1<<n;i++){
		for(int j=0;j<1<<n;j++){
			if(__builtin_popcount(j&i)&1) cout<<'B';
			else cout<<'A';
		}
		cout<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<vector<int>> to(n);
	for(int i = 1; i < n; i++){
		int p;
		cin >> p;
		p--;
		to[p].push_back(i);
	}
	struct state {
		int change, first, second;
	};
	function<state(int)> dfs = [&](int u){
		if(to[u].size() == 0){
			state now;
			now.change = 1;
			now.first = 1;
			now.second = 0;
			return now;
		}
		int f = 1, s = 0;
		vector<state> unchanged, changed;
		for(auto v : to[u]){
			state nxt = dfs(v);
			if(!nxt.change){
				if(nxt.second >= nxt.first){
					f += nxt.first;
					s += nxt.second;
				} else {
					unchanged.push_back(nxt);
				}
			} else {
				changed.push_back(nxt);
			}
		}
		if(changed.size() & 1){
			for(auto nxt : unchanged){
				f += nxt.second;
				s += nxt.first;
			}
		} else {
			for(auto nxt : unchanged){
				s += nxt.second;
				f += nxt.first;
			}
		}
		sort(changed.begin(), changed.end(), [&](state a, state b){
			return a.first - a.second > b.first - b.second;
		});
		reverse(changed.begin(), changed.end());
		int len = changed.size();
		for(int i = 0; i < len; i++){
			if(i % 2 == 1){
				s += changed[i].first;
				f += changed[i].second;
			} else {
				s += changed[i].second;
				f += changed[i].first;
			}
		}
		state now;
		now.change = (changed.size() + 1) & 1;
		now.first = f;
		now.second = s;
		return now;
	};
	cout << dfs(0).first << '\n';
	return 0;
}

#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define bn(x) ((1<<(x))-1)
#define newline puts("")
using namespace std;
template<typename T> using vc = vector<T>;
template<typename T> using vv = vc<vc<T>>;
template<typename T> using PQ = priority_queue<T,vc<T>,greater<T> >;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;
using T3 = tuple<int,int,int>;
using vi = vc<int>;
using vvi = vv<int>;
using vl = vc<ll>;
using vp = vc<P>;
using vt = vc<T3>;
int getInt(){int x;scanf("%d",&x);return x;}
template<typename T>istream& operator>>(istream&i,vc<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vc<T>&v,const string& d=""){stringstream s;rep(i,sz(v))(i?s<<d:s)<<v[i];return s.str();}
template<typename T>ostream& operator<<(ostream&o,const vc<T>&v){if(sz(v))o<<join(v," ");return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
vc<string> split(const string& s,char d=' '){vc<string> r(1);for(char c:s)if(c==d)r.pb("");else r.back()+=c;return r;}
string operator*(const string& s,int t){return join(vc<string>(t,s));}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>T dup(T x, T y){return (x+y-1)/y;}
template<typename T>ll suma(const vc<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}
template<typename T>void uni(vc<T>& a){sort(rng(a));a.erase(unique(rng(a)),a.end());}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

// linear sieve
vi ps, pf;
void sieve(int mx) {
  pf = vi(mx+1);
  rep(i,mx+1) pf[i] = i;
  for (int i = 2; i <= mx; ++i) {
    if (pf[i] == i) ps.pb(i);
    for (int j = 0; j < sz(ps) && ps[j] <= pf[i]; ++j) {
      int x = ps[j]*i;
      if (x > mx) break;
      pf[x] = ps[j];
    }
  }
}
inline bool isp(int x) { return pf[x] == x && x >= 2;}
vp factor(int x) { // asc
  if (x == 1) return {};
  vp res(1, P(pf[x], 0));
  while (x != 1) {
    if (res.back().fi == pf[x]) res.back().se++;
    else res.pb(P(pf[x],1));
    x /= pf[x];
  }
  return res;
}
//

struct Solver {
  void solve() {
    int n;
    scanf("%d",&n);
    vi a(n+1,1);
    sieve(n);
    for (int p : ps) {
      ll x = p;
      while (x <= n) {
        for (int i = x; i <= n; i += x) a[i]++;
        x *= p;
      }
    }
    a.erase(a.begin());
    cout<<a<<endl;
  }
};

int main() {
  int ts = 1;
  // scanf("%d",&ts);
  rrep(ti,ts) {
    Solver solver;
    solver.solve();
  }
  return 0;
}


#include <bits/stdc++.h>

using i64 = int64_t;

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

    std::vector<int> s;
    int n;
    std::cin >> n;
    ++n;
    for (int i = 1; i < n; ++i) {
        std::string foo;
        std::cin >> foo;
        s.push_back(foo == "AND" ? 1 : 0);
    }

    std::vector<std::array<i64, 2>> dp(n);
    dp[0][0] = 1;
    dp[0][1] = 1;
    for (int i = 0; i < n - 1; ++i) {
        if (s[i] == 1) {
            dp[i + 1][1] += dp[i][1];
            dp[i + 1][0] += dp[i][0] + dp[i][1] + dp[i][0];
        } else {
            dp[i + 1][1] += dp[i][0] + dp[i][1] + dp[i][1];
            dp[i + 1][0] += dp[i][0];
        }
    }
    std::cout << dp[n - 1][1] << '\n';
    return 0;
}

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

int main(){
  int n; cin >> n;
  vector<int> a;

  long long ans = 1;
  for(long long i = 1; i <= n; ++i){
    string s; cin >> s;
    if(s == "OR"){ans += (long long)pow(2, i);}
  }
  cout << ans << endl;
}


//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.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>;
//~ while (clock()<=69*CLOCKS_PER_SEC)

#define ll long long
#define ld long double
#define pi pair<int,int>
#define pd pair<ld,ld>
#define ft first
#define sd second
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define FOR(i,a,b) for(int i=(a); i<=(b);i++)
#define F(i,a,b) FOR(i,(a),(b)-1)
#define REV(i,a,b) for(int i=(a); i>=(b);i--)
#define VI vector<int>
#define VPI vector<pi>
#define VPD vector<pd>
#define PI 3.14159265
#define all(x) (x).begin(), (x).end()
#define sz(a) (int)((a).size())
#define int long long

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long K = 1000;
const long long KK = K*K;
const long long MIL = KK*K;
const long long INF = MIL*MIL;
const long long MOD = 1e9 + 7;
const long long N = 1e3 + 10, M=10;

bool wins(char a, char b) {
    if (b == 'R' && a == 'S')
        return false;
    if (b == 'S' && a == 'P')
        return false;
    if (b == 'P' && a == 'R')
        return false;

    return true;
}

void solve() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    F(i, 0, k) {
        if (sz(s) % 2)
            s += s;
        string s1;
        for (int j = 0; j < sz(s); j += 2) {
            if (wins(s[j], s[j + 1])) {
                s1 += s[j];
            } else {
                s1 += s[j + 1];
            }
        }
        s = s1;
    }
    cout << s[0] << "\n";

}

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

    ios_base::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
    cerr.tie(0);
    cout << setprecision(9) << fixed;
    cerr << setprecision(6) << fixed;
    int test = 1, f;
//    cin >> test;
    F(_test, 0, test) {
        //cout<<"Case #"<<_test + 1<<": ";
        solve();
//		if(_test == 1)
//            return 0;
    }
}
/*

2 1 3
1 1 <= 3
2 1 <= 5
1 1 >= 4
2 2 4
1 1 <= 3
2 1 <= 4
1 2 >= 5
2 2 >= 7
0 0 0
 */

#pragma GCC optimize ("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
#include <x86intrin.h>
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

//gp_hash_table<key, int, chash> table;

#define PI 3.141592653589793L
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); srand(time(NULL));
// Use for file I/O;
#define FIN string _fname = "input"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

#define FIN2 freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define gsize(x) (int)((x).size())

using namespace std;
using namespace __gnu_pbds;

const char nl = '\n';

typedef long long ll;
typedef long double ld;
// typedef unsigned int uint;
typedef unsigned long long ull;

const ll inf = 1e9 + 10;
const ll inf2 = 1e18 + 99LL;
const ld inf3 = 1e14;
const __int128 mod = 1e9 + 7;
const ld eps = 5e-10;

const int logn = 10, maxn = 105, maxm = 8000001, K = 3;

ll n, k;
map<int, char> ttm[maxn];
int tk[maxn];
string s;

char solve(int si, int ck) {
	if (ck == 0) {
		// cout << si << ' ' << s[si] << endl;
		return s[si];
	} else {
		if (!ttm[ck].count(si)) {
			char r1 = solve(si, ck - 1), r2 = solve((si + tk[ck - 1]) % n, ck - 1);
			if (r1 == r2) {
				ttm[ck][si] = r1;
			} else {
				if (r1 == 'R') {
					if (r2 == 'S') {
						ttm[ck][si] = r1;
					} else {
						ttm[ck][si] = r2;
					}
				} else if (r1 == 'S') {
					if (r2 == 'P') ttm[ck][si] = r1;
					else ttm[ck][si] = r2;
				} else {
					if (r2 == 'S') ttm[ck][si] = r2;
					else ttm[ck][si] = r1;
				}
			}
			// cout << "HI" << endl;
		}
		// cout << si << ' ' << ck << ' ' << ttm[si][ck] << endl;
		return ttm[ck][si];
	}
}

int main() {
	FAST;

	cin >> n >> k;
	cin >> s;
	tk[0] = 1;
	for (int i = 1; i <= k; i++) {
		tk[i] = (tk[i - 1] * 2) % n;
	}
	cout << solve(0, k);
}


#pragma GCC optimize ("O2")
#pragma GCC target ("avx")
#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

char cn[1200010];
char *ci = cn, ct;
char tc[200002], *di = tc + 100000, *di2 = tc + 200000;
const char d[2] = "0";

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

	rep(i, 100000) tc[i] = '0';
	rep(i, 100000) di[i] = '1';
	di2[0] = '0';
	di2[1] = '\n';
	fread(cn, 1, 1200010, stdin);
	int T = 0;
	while ((ct = *ci++) >= '0') T = T * 10 + ct - '0';

	rep(t, T) {
		int N = 0;
		while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';
		fwrite(di - N, 1, N, stdout);
		fwrite(di2 - N, 1, N + 2, stdout);
		ci += 6 * N + 3;
	}

	Would you please return 0;
}

#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
#define INF 1e18
using namespace std;
typedef pair<int, int> pi;
const int MAX = 1e6 + 1;
// typedef vector<vector<ll>> matrix;
const ll PRIME = 1e9 + 7;
typedef pair<int,pair<int,int> >  ppi;
// const ll MAX = 1e6 + 1;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int a[MAX];
int b[MAX];
vector<int>graph[MAX];
vector<bool>vis(MAX,0);
// vector<bool> connected(MAX,0);
pi dfs(int src)
{
    vis[src]=1;
    pi temp;
    temp.first+=a[src];
    temp.second+=b[src];
    for(int i: graph[src])
    {
        if(!vis[i])
        {
          pi tmp2=dfs(i);
        temp.first+=tmp2.first;
        temp.second+=tmp2.second;
        }
    }
    return temp;

}
void solve()
{
    int n,m;
    cin>>n>>m;
    // int a[n],b[n];
    int sum1=0,sum2=0;
    fr(i,n)
    {
        cin>>a[i];
        sum1+=a[i];
    }
    // int st;
    bool flag=0;
    fr(i,n)
    {
        cin>>b[i];
        sum2+=b[i];
        if(a[i]!=b[i])
        {   flag=1;
        }

    }

    int u,v;
    while(m--)
    {
        cin>>u>>v;
        u--,v--;
        graph[u].pb(v);
        graph[v].pb(u);
    }
    if(sum1!=sum2)
    {
        cout<<"No\n";
        return;

    }
    if(flag==0)
    {cout<<"Yes\n";return;}
//  cout<<st;

    fr(i,n)
    {
        if(!vis[i])
        {
            pi temp=dfs(i);
            if(temp.first!=temp.second)
            {
                cout<<"No\n";
                return;
            }
        }
    }
    cout<<"Yes\n";

}

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

    // int k=1;
    while (t--)
    {
        // cout << "Case " << k++ << ":\n";
        solve();
    }
}


#include <bits/stdc++.h>
#ifdef LILY
#include "Debug.h"
#else
#define var(...) (0)
#define dbg(...) (0)
#endif
using int32 = int;
using int64 = long long;
using namespace std;

class Solution
{
#define int int64
#define sfor(i, n) for (int i = 1; i <= (n); ++i)
#define tfor(i, n) for (int i = 0; i < (n); ++i)
#define INF 0x3f3f3f3f
#define EPS 1e-5
#define M 1000000007

    int n;
    int p;

    int pow(int base, int ex)
    {
        int ret = 1;
        while (ex)
        {
            if (ex & 1) ret = ret * base % M;
            ex >>= 1;
            base = base * base % M;
        }
        return ret;
    }

    void reals()
    {
    }

public:
    Solution()
    {
        cin >> n >> p;
        int t = pow(p - 2, n - 1);
        cout << t * (p - 1) % M << endl;
    }
#undef int
#undef tfor
#undef sfor
};

int32 main()
{
#ifdef LILY
    while (1)
#endif
        Solution();
    return 0;
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  reverse(begin(ret), end(ret));
  return (ret);
}

signed main(){
    int A; cin>>A;
    int B; cin>>B;
    int ans = 1;

    for(int i=A;i<=B;i++){
        vec_int temp = divisor(i);
        for(auto num: temp){
            if(i+num<=B){
                ans = max(num, ans);
                break;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using p_qi = priority_queue<int>;
const int INF = 1001001001;

// Input
int n;
vi a;

int main() {
    cin >> n;
    a = vi(n);
    rep(i, n) cin >> a[i];
    set<int> s;
    rep(i, n) s.insert(a[i]);
    if (s.size() != n) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;

    return 0;
}

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

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

template<class T>
 bool comp(T a, T b){
  if(a.ss<b.ss)
    return true;
  return false;
 }
int main(){
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
   fast_io;
   int n;
   cin>>n;
   vi v(n),ch(n+1,0);
   for(int i=0; i<n; i++)
    cin>>v[i],ch[v[i]]++;
  bool ans=true;
  for(int i=1; i<=n; i++){
    if(ch[i]>1 || ch[i]==0)
      ans=false;
  }
  if(ans)
    cout<<"Yes";
  else cout<<"No";

}