#include <bits/stdc++.h>
#define INF 1000000007
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef long long int lli;

typedef vector<int> vi;
typedef unordered_map<int,int> umi ;
typedef unordered_set<int> usi ;
typedef pair<int,int> pi;
#include <bits/stdc++.h>

using namespace std;

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

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

//declare here -------------------------------------------------------------
const int N =2e3+1 ;
vector<pair<int,int>> adj[N] ;
priority_queue<pi> q ;
int n,m ;
vi visited(n+1) ;
int mybfs(int x){
	visited.assign(n+1,0) ;
	//debug(visited) ;
	//debug(adj[x],x);
	q= priority_queue<pi>() ;
	for(auto X:adj[x]){
		q.push( MP(- X.F , X.S)) ;
	}
	while(!q.empty()){
		auto temp =q.top() ;
		q.pop() ;
		if(visited[temp.S]) continue ;
	    //debug(x,temp.S, temp.F) ;
		visited[temp.S] =true ;
		if(temp.S== x) return -temp.F ;
		for(auto X:adj[temp.S]){
			q.push({temp.F - X.F , X.S}) ;
		}
 	}
 	return -1 ;

}

// solve here --------------------------------------------------------------

void solve(){
	cin>>n>>m ;
	int u,v,w;
	REP(i,0,m){
		cin>>u>>v>>w ;
		adj[u].PB(MP(w,v)) ;
	}
	REP(i,1,n+1){
		cout<<mybfs(i)<<"\n" ;
	}
}

//------------------------------------------------------------------

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

	ios::sync_with_stdio(0);
	cin.tie(0);
	long long test =1 ;
	//cin>>test ;
	while(test--){
		solve() ;
		cout<<"\n" ;
	}
	return 0 ;
}

#include <bits/stdc++.h>

const long long INF = 1e9;
const long long MOD = 1e9 + 7;
//const long long MOD = 998244353;
const long long LINF = 1e18;
using namespace std;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define COUT(x) cout<<(x)<<endl
#define SCOUT(x) cout<<(x)<<" "
#define VECCOUT(x) for(auto&youso_: (x) )cout<<right<<setw(10)<<youso_<<" ";cout<<endl
#define ENDL cout<<endl
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) long long __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define mp make_pair
#define PQ priority_queue<long long>
#define PQG priority_queue<long long,V,greater<long long>>

typedef long long ll;
typedef vector<long long> vl;
typedef vector<long long> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef pair<long long, long long> pll;

#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
template<class T>
void mod(T &x) {
    x %= MOD;
    x += MOD;
    x %= MOD;
}

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

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if(b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b*x;
    return d;
}

void Main() {
    LCIN(T);
    for(int i = 0; i < T; i++) {
        LCIN(N, S, K);
//        cout << "–––––––––––––" << endl;
        if((N - S)%GCD(N, K)) {
            cout << -1 << endl;
        } else {
            ll x, y;
            ll a = extGCD(K, N, x, y), b;
            S = N - S;
            ll s = S;
            ll M = ((S*y)%K - K)%K;
            ll tm = S*x - N*((M - S*y)/K);
//            cout << "N:" << N << endl;
//            cout << "S:" << S << endl;
//            cout << "K:" << K << endl;
//            cout << "M:" << M << endl;
//            cout << "x:" << x << endl;
//            cout << "y:" << y << endl;
//            cout << "a:" << a << endl;

            cout << tm/a << endl;
        }
    }
}

int main() {
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


#include<iostream>
using namespace std;
int main(){
	int n,w;
	cin>>n>>w;
	cout<<n/w;
}

#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
typedef long long ll;
// DP o Trees::http://cfrp.azurewebsites.net/blog/entry/20935
//********************TRIE******************
struct TrieNode{
    struct TrieNode*child[26];
    int end=0;
};
struct TrieNode* getnode(){
        struct TrieNode* temp=new TrieNode();
        for(int i=0;i<26;i++){
            temp->child[i]=NULL;
        }
        return temp;
    }
void insert(struct TrieNode* root,string s){
        struct TrieNode* temp=root;
        for(int i=0;i<s.size();i++){
            if(!temp->child[s[i]-'a']){
                temp->child[s[i]-'a']=getnode();
            }
            temp=temp->child[s[i]-'a'];
        }
        temp->end++;
    }
bool search(struct TrieNode*root,string s){
        struct TrieNode* temp=root;
        for(int i=0;i<s.size();i++){
            if(!temp->child[s[i]-'a']){
                return false;
            }
            temp=temp->child[s[i]-'a'];
        }
        return temp->end;
    }
//********************Trie*************
ll GCD(int a,int b){
    int maxi=max(a,b);
    int mini=min(a,b);
    while(maxi && mini){
        int t=mini;
        mini=maxi%mini;
        maxi=t;
    }
    return max(maxi,mini);
}
ll power(ll x,ll y){
    ll res=1;
    while (y){
        if (y & 1){
            res=res*x;
        }
        x=x*x;
        y=y>>1;
    }
    return res;
}
int minarr(int arr[],int n){
    int d=arr[0];
    for(int i=1;i<n;i++){
        d=d<arr[i]?d:arr[i];
    }
    return d;
}
int lower_bound(int v[],int x,int n){
    int l=0,r=n-1,mid;
    int ans=0;
    while (l<=r){
        mid=l+(r-l)/2;
        if (v[mid]>=x){
            ans=mid;
            r=mid-1;
        }
        else{
            l=mid+1;
        }
    }
    return ans;
}
int upper_bound(int v[],int x,int n){
    int l=0,r=n-1,mid;
    int ans=n;
    while (l<=r){
        mid=l+(r-l)/2;
        if (v[mid]>x){
            ans=mid;
            r=mid-1;
        }
        else{
            l=mid+1;
        }
    }
    return ans;
}
int maxarr(int arr[],int n){
    int d=arr[0];
    for(int i=1;i<n;i++){
        d=d>arr[i]?d:arr[i];
    }
    return d;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a,b;
	cin>>a>>b;
	cout<<2*a-b+100<<"\n";
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 5010
#define mod 998244353
#define LL long long
const int w=15;
int n,m,fac[N],ifac[N],f[20][N];
inline int quick_pow(int x,int b)
{
	int ret=1;
	while(b)
	{
		if(b&1) ret=(LL)ret*x%mod;
		x=(LL)x*x%mod,b>>=1;
	}
	return ret;
}
inline int inv(int x) {return quick_pow(x,mod-2);}
void init(int n)
{
	fac[0]=1;
	for(int i=1;i<=n;++i)
		fac[i]=(LL)fac[i-1]*i%mod;
	ifac[n]=inv(fac[n]);
	for(int i=n;i;--i)
		ifac[i-1]=(LL)ifac[i]*i%mod;
}
inline int C(int n,int m)
{
	return n<m?0:(LL)fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
inline void add(int &a,int b) {a+=b;if(a>=mod) a-=mod;}
int main()
{
	scanf("%d %d",&n,&m);
	init(n),f[0][0]=1;
	for(int i=0;i<w;++i)
		for(int k=0;(1<<i)*k<=m;k+=2)
			for(int j=0;j+(1<<i)*k<=m;++j)
				add(f[i+1][j+(1<<i)*k],(LL)f[i][j]*C(n,k)%mod);
	printf("%d",f[w][m]);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define mp make_pair
#define ld long double
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 1e6 + 100;
int T;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a + b) / 2 << " " << a - (a + b) / 2 << endl;
    return 0;
}

#include <iostream>
using namespace std;

int A,B;
int main(){
	cin>>A>>B;

	cout<<2*A+100-B;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846
#define        trace1(x)                cout<<#x<<": "<<x<<endl
#define        trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define        trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define        trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define        trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define        trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}
int lcm(int a, int b) {return a * b / gcd(a, b); }
int bpow(int a,int b)
{
  int res = 1;
  while (b > 0) {
    if (b & 1)res = ((res) * (a));
      a = ((a) * (a));
      b >>= 1;
  }
  return res;
}

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

signed main()
  {
      fast_io
       go();
      int a,b;cin>>a>>b;
      if(a==b){
        cout << a;
        return 0;
      }
      map<int,int> mp;
      mp[0]++;
      mp[1]++;
      mp[2]++;
      mp[a]--;
      mp[b]--;
      if(mp[0]==0)
        mp.erase(0);
      if(mp[1]==0)
        mp.erase(1);
      if(mp[2]==0)
        mp.erase(2);

      auto it=*mp.begin();
      cout << it.first << "\n";

}

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

#define endl "\n"
#define int long long
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define trace(x) cerr<<#x<<" : "<<x<<endl;

void solve()
{
    int a, b;
    cin >> a >> b;

    if(a==b)
    {
        cout << a;
    }
    else
    {
        if(a==0 && b==1)
            cout << 2;
        if(a==1 && b==0)
            cout << 2;
        else if(a==0 && b==2)
            cout << 1;
        if(a==2 && b==0)
            cout << 1;
        else if(a==1 && b==2)
            cout << 0;
        else if(a==2 && b==1)
            cout << 0;
    }

}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    for(int i=0;i<t;i++) solve();
    return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <string>
#include <iomanip>
#include <iostream>
#include <map>
#include <unordered_map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;

#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define fi first
#define sc second

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsort(v) sort(v.rbegin(),v.rend())

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)

// const int MOD = 998244353;
const int MOD = 1e9+7;
const int MAX = 2147483647;     // 1<<31-1
const int MIN = -2147483648;    // 1<<31
const ll INF = 1e18;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

#define ts to_string
string ts(char c) { return string(1, c); }
string ts(bool b) { return b ? "0" : "1"; }
string ts(const char* s) { return (string)s; }
string ts(string s) { return s; }
template<class A, class B> string ts(pair<A, B> p) {
    return "("+ts(p.fi)+", "+ts(p.sc)+")";
}
template<class T> string ts(T v) { // containers with begin(), end()
    string res = "";
    for (const auto& x: v) {
        res += ts(x) + " ";
    }
    return res;
}

void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
    cerr << ts(h); if (sizeof...(t)) cerr << ", ";
    DBG(t...);
}

#ifdef LOCAL
#include "../../snippits/debugger.cpp"
#define dbg(...) cerr << "L(" << __LINE__ << "): [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#define print_segtree(...) 0
#endif

const vector<vector<int>> dirs = { {0,1},{1,0},{-1,0},{0,-1} };

// distance from origin
struct cmp {
    bool operator()(const pii& lhs, const pii& rhs) const {
        return (abs(lhs.fi)+abs(lhs.sc))<((abs(rhs.fi)+abs(rhs.sc)));
    }
};

// getline(cin, str) for getting a line of string
// call cin.ignore() BETWEEEN cin >> x and getline()!!!
// don't mod before you sort!!!
// clear global state
// remember to %= the result!

// INITIALIZE CORRECTLY, ARE YOU DOING (i,0,*N+1*) WHEN NEEDED?
// PRIORITY QUEUES ARE SORTED BIG TO SMALL
// NEVER assign element to a reference and then pop!!!!!

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

    int t = 1;
    cin >> t;

    ll res = 0;
    while (t--) {
        int a, b;
        cin >> a >> b;
        res += 1LL*(a+b)*(b-a+1)/2;
    }

    cout << res << '\n';

    return 0;
}

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

int main(){
  int n;
  std::cin >> n;

  ll ans=0;
  rep(i,n){
    ll a,b;
    std::cin >> a>>b;

    ll add=(a+b)*(b-a+1)/2;
    ans+=add;
  }
  std::cout << ans << '\n';

  return 0;
}


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

int main()
{
	int x, y;
	cin >> x >> y;

	if (x != y){
            cout << 3 - x - y << endl;
        }else{
            cout << x << endl;
                }
	return 0;
}

//

#include <iostream>
#include <string>

using namespace std;

int main() {
  int x, y;
  cin >> x >> y;

  if (x == y)
    cout << x << "\n";

  else {
    if ((x + 1) % 3 != y) {
      cout << ((x+1) % 3) << "\n";
    }
    else {
      cout << ((y+1) % 3) << "\n";
    }
  }

  return 0;
}


#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 1000000007;
const double pi = acos(-1);

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

    vecvecl dp(h,vecl(w)), x(h+1,vecl(w+1)), y(h+1,vecl(w+1)), z(h+1,vecl(w+1));

    dp[0][0] = 1;

    REP(i,h) REP(j,w) {
        if(s[i][j] != '#') dp[i][j] += x[i][j] + y[i][j] + z[i][j];
        dp[i][j] %= MOD;
        if(j+1 < w) {
            if(s[i][j+1] != '#') x[i][j+1] = x[i][j] + dp[i][j];
            else x[i][j] = 0;
        }
        x[i][j+1] %= MOD;
        if(i+1 < h) if(s[i+1][j] != '#') y[i+1][j] = y[i][j] + dp[i][j]; else y[i+1][j] = 0;
        y[i+1][j] %= MOD;
        if(i+1 < h && j+1 < w) if(s[i+1][j+1] != '#') z[i+1][j+1] = z[i][j] + dp[i][j]; else z[i+1][j+1] = 0;
        z[i+1][j+1] %= MOD;
    }

    cout << dp[h-1][w-1] << endl;
}

#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
        ll i,j,H,W,r_yoko;;
        cin >> H >> W;
        vector<vector<ll>> dp(H,vector<ll>(W));
        vector<vector<char>> mp(H,vector<char>(W));
        dp.at(0).at(0) = 1;
        for(i=0;i<H;++i){
                for(j=0;j<W;++j){
                        cin >> mp.at(i).at(j);
                }
        }
        vector<ll> r_nana(H+W-1);
        vector<ll> r_tate(W);
        for(i=0;i<H;++i){
                r_yoko = 0;
                for(j=0;j<W;++j){
                        if(mp.at(i).at(j)=='#'){
                                r_yoko = 0;
                                r_tate.at(j)=0;
                                r_nana.at(j-i+H-1)=0;
                                continue;
                        }
                        dp.at(i).at(j) += r_yoko+r_tate.at(j);
                        dp.at(i).at(j) += r_nana.at(j-i+H-1);
                        dp.at(i).at(j) %= MOD;
                        r_tate.at(j) += dp.at(i).at(j);
                        r_tate.at(j) %= MOD;
                        r_yoko += dp.at(i).at(j);
                        r_yoko %= MOD;
                        r_nana.at(j-i+H-1) += dp.at(i).at(j);
                        r_nana.at(j-i+H-1) %= MOD;
                }
        }
        cout << dp.at(H-1).at(W-1) << endl;
        return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#define flush fflush(stdout)
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod1 = (int)1e9 + 7, mod2 = (int)998244353;
const int INF = (int)1e9;
const int di[8] = {1, 0, -1, 0, 1, 1, -1, -1}, dj[8] = {0, 1, 0, -1, -1, 1, -1, 1};

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep1(i, a, b) for (i = a; i < b; i++)

int main(void){
    int i, j;
    int n, a[100003] = {};

    cin >> n;

    rep1(i, 1, n + 1){
        a[i] = 1;
    }

    rep1(i, 1, n + 1){
        if (a[i] == 0){
            a[i] = 1;
        }
        j = i * 2;
        while (j <= n){
            if (a[j] == a[i]){
                a[j] = a[i] + 1;
            }
            j += i;
        }
    }

    rep1(i, 1, n + 1){
        cout << a[i] << ((i == n)? endl : ' ');
    }

    return (0);
}

#include<bits/stdc++.h>
using namespace std;
// 素因数分解
template <typename T>
map<T, T> prime_factor(T n) {
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++) {
        T tmp = 0;
        while (n % i == 0) {
            tmp++;
            n /= i;
        }
        ret[i] = tmp;
    }
    if (n != 1) ret[n] = 1;
    return ret;
}
template <typename T>
T divisor_num(T N) {
    map<T, T> pf = prime_factor(N);
    T ret = 1;
    for (auto p : pf) {
        ret += p.second;
    }
    return ret;
}
int main(){
  int n;
  cin>>n;
  int count=0;
  cout<<1<<" ";
  for (int i=2;i<=n;i++){
    cout<<divisor_num(i)<<" ";
  }
}


#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
//#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <time.h>
//#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <sstream> // std::stringstream
#include <bitset>  // std::bitset<N>
//#include <type_traits>
//#include <atcoder/scc>
#define rep(i,n) for(int i=0;i<n;i++)
#define llrep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define RFOR(i,a,b) for(int i=b-1;i>=a;i--)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<ll,ll>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define ALL(a)  (a).begin(),(a).end()
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
double pi = 3.141592653589793;
using namespace std;

int n;
vll a, b, c, d;

ll dis1(int i, int j) {
	return (a[i] - a[j]) * (a[i] - a[j]) + (b[i] - b[j]) * (b[i] - b[j]);
}
ll dis2(int i, int j) {
	return (c[i] - c[j]) * (c[i] - c[j]) + (d[i] - d[j]) * (d[i] - d[j]);
}

double angle1(int i, int j) {
	double radian = atan2(a[j] - a[i], b[j] - b[i]);
	return radian;
}
double angle2(int i, int j) {
	double radian = atan2(c[j] - c[i], d[j] - d[i]);
	return radian;
}

double rotex(int x, int y, double angle) {
	return x * cos(angle) - y * sin(angle);
}
double rotey(int x, int y, double angle) {
	return x * sin(angle) + y * cos(angle);
}

int main() {
	cin >> n;
	if (n == 1) {
		cout << "Yes" << endl;
		return 0;
	}
	a.resize(n);
	b.resize(n);
	c.resize(n);
	d.resize(n);
	rep(i, n) {
		cin >> a[i] >> b[i];
	}
	rep(i, n) {
		cin >> c[i] >> d[i];
	}

	rep(i, n) {
		rep(j, n) {
			//0 -> i 1->jに対応する
			if (i == j) continue;
			if (dis1(0, 1) != dis2(i, j)) continue;
			//回転角度
			double angle = angle1(0, 1) - angle2(i, j);

			auto newx1 = rotex(a[1], b[1], angle);
			auto newy1 = rotey(a[1], b[1], angle);
			//auto newx1 = a[1] * cos(angle) - b[1] * sin(angle);
			//auto newy1 = a[1] * sin(angle) + b[1] * cos(angle);

			double q = c[j] - newx1;
			double r = d[j] - newy1;;

			vector<int> use(n);
			/*use[0] = 0;
			use[1] = 0;*/
			bool F = 1;
			rep(k, n) {
				auto newx = rotex(a[k], b[k], angle) + q;
				auto newy = rotey(a[k], b[k], angle) + r;
				bool flg = 0;
				rep(m, n) {
					if (abs(newx - c[m]) < 0.0000001 && abs(newy - d[m]) < 0.0000001 && use[m] == 0) {
						use[m] = 1;
						flg = 1;
					}
				}
				if (!flg) {
					F = 0;
				}
			}
			if (F == 1) {
				cout << "Yes" << endl;
				return 0;
			}

		}
	}
	cout << "No" << endl;

}

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int A[4];

int main() {
  INCANT;
  rep(i, 4) cin >> A[i];
  sort(A, A+4);
  string ans = A[0]+A[3]==A[2]+A[1] || A[3] == A[2]+A[1]+A[0]?"Yes":"No";
  cout << ans << "\n";
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

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

ll inf = 1000000007;
ll INF = 1000000000000000007;

int main(){
  ll x, y;
  cin >> x >> y;
  //

  if(x == y){
    cout << x << endl;
  return 0;
  }

    cout << 3-(x+y) << endl;

  return 0;
}

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

int main()
{
  int n,x,count = 0;
  cin >> n >> x;
  x *= 100;
  int v[n], p[n];
  for (int i = 0; i < n; i++)
    cin >> v[i] >> p[i];
  for (int i = 0; i < n; i++)
  {
    v[i] *= p[i];
    x -= v[i];
    count++;
    if (x < 0)
    {
      cout << count << endl;
      return (0);
    }
  }
  cout << -1 << endl;
  return (0);
}


//#define _GLIBCXX_DEB // Iterator safety; out-of-bounds access for Containers, etc.
//#pragma GCC optimize "trapv" // abort() on (signed) integer overflow.
#include <bits/stdc++.h>

using namespace std;

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

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

#define ll long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << "\n"
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << "\n"
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define INF 1000000000
#define no_of_digits(n) floor(log10(n)) + 1
#define bits(n) __builtin_popcount(n)
#define lsb(n) __builtin_clz(n) // count leading zeroes before 1
#define rsb(n) __builtin_ctz(n) // count trailing zeroes before 1

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}
int sum_of_digits(int a)
{
    int s = 0;
    while (a > 0)
    {
        s += a % 10;
        a /= 10;
    }
    return s;
}
string toBinary(int n)
{
    string r;
    while (n != 0)
    {
        r = (n % 2 == 0 ? "0" : "1") + r;
        n /= 2;
    }
    return r;
}
int binaryToDecimal(string n)
{
    string num = n;
    int dec_value = 0;
    int base = 1;

    int len = num.length();
    for (int i = len - 1; i >= 0; i--)
    {
        if (num[i] == '1')
            dec_value += base;
        base = base * 2;
    }

    return dec_value;
}
ll add(ll a, ll b, ll m = mod)
{
    if (a >= m)
        a %= m;
    if (b >= m)
        b %= m;
    if (a < 0)
        a += m;
    if (b < 0)
        b += m;
    ll res = a + b;
    if (res >= m or res <= -m)
        res %= m;
    if (res < 0)
        res += m;
    return res;
}

ll mul(ll a, ll b, ll m = mod)
{
    if (a >= m)
        a %= m;
    if (b >= m)
        b %= m;
    if (a < 0)
        a += m;
    if (b < 0)
        b += m;
    ll res = a * b;
    if (res >= m or res <= -m)
        res %= m;
    if (res < 0)
        res += m;
    return res;
}

ll pow_mod(ll a, ll b, ll m = mod)
{
    ll res = 1LL;
    a = a % m;
    while (b)
    {
        if (b & 1)
            res = mul(res, a, m);
        b >>= 1;
        a = mul(a, a, m);
    }
    return res;
}

ll fastexp(ll a, ll b)
{
    ll res = 1LL;
    while (b)
    {
        if (b & 1)
            res = res * a;
        b >>= 1;
        a *= a;
    }
    return res;
}
void solve()
{
    string s;
    cin>>s;
    s='a'+s;
    for(int i=1;i<s.length();i++)
    {
        if(i&1)
        {
            if(!islower(s[i]))
            {
                cout<<"No\n";
                return;
            }
        }
        else
        {
            if(!isupper(s[i]))
            {
                cout<<"No\n";
                return;
            }
        }
    }
    cout<<"Yes\n";
}

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

#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200008
#define mod 1000000007
#define f first
#define s second
ll arr[sz+10],brr[sz+10];
char c[sz];
int main()
{
  int t=1;
  //scanf("%d",&t);
  while(t--)
  {
   int n;
   scanf("%s",&c);
   n=strlen(c);
   int cnt=0;
   for(int i=0;i<n;i++)
   {
    if(i%2 && c[i]>='a' && c[i]<='z')
      cnt++;
    if(i%2==0 && c[i]>='A' && c[i]<='Z')
      cnt++;
   }
  printf("%s\n",cnt?"No":"Yes");
  }
  return 0;
}


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

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

const double EPS = 1e-10;

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

int n,m;
vector<vector<Pi>> G;
vector<int> ans;
vector<bool> visited;

void dfs(int u){
    visited[u] = true;
    for(auto v : G[u]){
        if(visited[v.first]) continue;
        if(ans[u] != v.second) ans[v.first] = v.second;
        else ans[v.first] = n+1-v.second;
        dfs(v.first);
    }
}

int main(){
    cin >> n >> m;
    G.resize(n);
    ans.resize(n);
    visited.resize(n,false);
    rep(i,m){
        int u,v,c; cin >> u >> v >> c;
        u--; v--;
        G[u].emplace_back(v,c);
        G[v].emplace_back(u,c);
    }
    ans[0] = G[0][0].second;
    dfs(0);
    rep(i,n){
        cout << ans[i] << endl;
    }
}

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef pair<int, int> II;

void solve(long long N, long long M, std::vector<int> &u, std::vector<int> &v, std::vector<int> &c) {
	vector<vector<II>> edges(N);
	vector<int> color(N, -1), used(N + 1);
	for (int i = 0; i < M; ++i) {
		edges[u[i]].emplace_back(II(v[i], c[i]));
		edges[v[i]].emplace_back(II(u[i], c[i]));
	}
	vector<int> q;
	q.emplace_back(0);
	while (!q.empty()) {
		vector<int> nq;
		for (auto from : q) {
			for (auto kv : edges[from]) {
				int to = kv.first, col = kv.second;
				if (color[to] >= 0) continue;
				if (color[from] == col) {
					for (col = 1; col <= N; ++col) {
						if (color[from] != col) {
							break;
						}
					}
				}
				color[to] = col;
				used[col] = 1;
				nq.emplace_back(to);
			}
		}
		q = nq;
	}
	for (int i = 1; i <= N; ++i) {
		if (!used[i]) {
			color[0] = i;
			break;
		}
	}
	for (int i = 0; i < N; ++i) {
		cout << color[i] << endl;
	}
}

int main() {
    long long N;
	std::cin >> N;
	long long M;
	std::cin >> M;
	std::vector<int> u(M), v(M), c(M);
	for (int i = 0; i < M; i++) {
		std::cin >> u[i]; u[i]--;
		std::cin >> v[i]; v[i]--;
		std::cin >> c[i]; // c[i]--;
	}
	solve(N, M, u, v, c);
	return 0;
}


#include <iostream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <tuple>
#include <stdlib.h>
#include <stdio.h>
#include <set>
#include <limits>
#include <iomanip>
#include <cstring> //memset
using namespace std;

#define ll long long
#define imi INT_MIN
#define ima INT_MAX
#define llmi LLONG_MIN
#define llma LLONG_MAX
#define dmi (double)llmi
#define dma (double)llma
#define forn(i,a,b) for(ll i = a; i < b; i++)
#define forn2(i,a,b) for(ll i = a; i >= b; i--)
#define fork(i,a,b,k) for(ll i = a; i <= b; i+=k)
#define fork2(i,a,b,k) for(ll i = a; i>=b; i-=k)
#define vl vector<ll>
#define eb emplace_back
#define ef emplace_front
#define ppf pop_front
#define ppb pop_back
#define gt greater<int>()
#define w(t) while(t--)

const int nmax = 2e5+1;
const int mod = 1e9+7;
const double eps = 1e-9;

bool checkPR(ll n) {
    ll tmp = sqrt(n);
    if(n == 2 || n == 3) return 1;
    if(n <= 1 || n == 4) return 0;
    if(n%2 == 0 || n%3 == 0) return 0;
    fork(i,5,tmp,6) {
        if(n%i == 0 || n%(i+2) == 0) return 0;
    }
    return 1;
}

bool checkSQ(ll n) {
    ll tmp = trunc(sqrt(n));
    return tmp*tmp == n;
}

int gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b, a%b);
}
int sumD(ll n) {
    int ans = 0;
    while(n) {
        ans += n%10;
        n /= 10;
    }
    return ans;
}

int cntD(ll n) {
    int ans = 0;
    while(n) {
        ans++;
        n/=10;
    }
    return ans;
}
void setP(int n) {
    cout << setprecision(n) << fixed;
}
bool pr[(int)1e6];
void eratos(ll n) {
    forn(i,2,sqrt(n)) {
        if(!pr[i]) fork(j, i*i, n, i) pr[j] = 1;
    }
}

int cntDiv(ll n) {
    int ans = 0;
    forn(i,1,trunc(sqrt(n))+1) {
        if(n%i == 0) ans += 2;
    }
    if(checkSQ(n)) ans--;
    return ans;
}

ll fastMul(ll base, ll p) {
    if(p == 1) return base;
    ll tmp = fastMul(base, p/2) % mod;
    ll res = (tmp*tmp) % mod;
    if(p&1) res = (res*base) % mod;
    return res;
}
double fastMul(double base, ll p) {
    if(p == 1) return base;
    double tmp = fastMul(base, p/2);
    double res = tmp*tmp;
    if(p&1) res *= base;
    return res;
}

ll iMod(ll n) {
    return fastMul(n, mod-2);
}

struct key {
    ll v, pos;
};
struct itv {
    ll b, e, pos;
};

bool ss1(key p, key q) {
    return p.v < q.v;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    double m,n,x,y,z,t,l;
    string s,s1,s2;
    cin >> n >> x;
    vl v;
    forn(i,0,n) {
        cin >> y;
        if(x != y) v.eb(y);
    }
    for(auto i: v) cout << i << " ";
}

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

using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()

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

    int n,x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    rep(i,n){
        if(a[i]!=x)cout << a[i] << endl;
    }

}


#include<bits/stdc++.h>
#define int long long
#define uc getchar()
#define ph putchar
#define R register
#define CN const
#define rint register int
#define cint const int
#define pe ph('\n')
#define ps ph(' ')
using namespace std;
cint inf=998244353;
cint mix=1e6+5;
inline int in();
inline void out(rint x);
int n=in(),m=in(),ct=1;
int hea[mix],nxt[mix],tor[mix];
int ans[mix],val[mix];
inline void adedge(rint x,rint y){
	nxt[++ct]=hea[x],tor[hea[x]=ct]=y;
	nxt[ct^=1]=hea[y],tor[hea[y]=ct]=x;
	val[ct]=val[ct^1]=in();
}
inline void dfs(rint x){
	for(rint u,i=hea[x];i;i=nxt[i])
	if(!ans[u=tor[i]]){
		if(val[i]!=ans[x])ans[u]=val[i];
		else ans[u]=(val[i]%n)+1;
		dfs(u);
	}

}
#undef int
int main() {
#define int long long
	for(rint i=1;i<=m;++i)
	adedge(in(),in());
	dfs(ans[1]=1);
	for(rint i=1;i<=n;++i)
	out(ans[i]),pe;
}
inline int in() {
	rint x=0;
	R char s=uc;
	R bool f=0;
	while((s<'0'||s>'9')&&s!='-')s=uc;
	if(s=='-')f=1,s=uc;
	while(s>='0'&&s<='9')(x*=10)+=(s^48),s=uc;
	return f?-x:x;
}
inline void out(rint x) {
	if(x<0)ph('-'),x=-x;
	rint y=x/10;
	if(y)out(y);
	ph((x-y*10)^48);
}

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll mod;
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
ll modinv(ll a) { ll b = mod, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }u %= mod; if (u < 0) u += mod; return u; }

vector<vector<pair<int, int>>> G;
vector<int> la;
int n;
void sim(int v) {
	for (auto e : G[v]) {
		if (la[e.first] == 0) {
			if (e.second != la[v])la[e.first] = e.second;
			else la[e.first] = la[v] % n + 1;
			sim(e.first);
		}
	}
}
int main() {
	int m, a, b, c;
	cin >> n >> m;
	G.resize(n);
	la.resize(n);
	rep(i, 0, m) {
		cin >> a >> b >> c;
		a--, b--;
		G[a].push_back({ b, c });
		G[b].push_back({ a, c });
	}
	la[0] = 1;
	sim(0);
	for (auto v : la)printf("%d\n", v);
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef   long long int ll;
typedef long double db;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define np(str) next_permutation(str.begin(),str.end())
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for(i=n-1;i>=0;i--)
#define rep(i,n) for(i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define at(s,pos) *(s.find_by_order(pos))
#define set_ind(s,val) s.order_of_key(val)
long long int M = 1e9 + 7 ;
long long int inf = 9 * 1e18;
const double PI = acos(-1);
//CLOCK
ll begtime = clock();
#define time() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//CLOCK ENDED
ll n, m;
// modular exponentiation
ll binpow(ll val, ll deg)
{
	if (deg < 0)
		return 0;
	if (!deg)
		return 1 % M;
	if (deg & 1)
		return binpow(val, deg - 1) * val % M;
	ll res = binpow(val, deg >> 1);
	return (res * res) % M;
}
//binomial
ll modinv(ll n) {
	return binpow(n, M - 2);
}
#define tll tuple<ll,ll,ll>
int main() {
	// your code goes here
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll i, j, t, k, x, y, z,  N;

	ll q;
	cin >> n >> q;
	vector<ll> vec;
	rep(i, n) {
		cin >> x;
		vec.pb(x);
	}
	vector<pll> query;
	rep(i, q) {
		cin >> x;
		query.pb({x, i});
	}
	vector<pll> out;

	sortv(query);

	ll last = 0;
	k = 0;
	j = 0;
	for (auto u : vec) {

		ll rem = u - last - 1;

		while (j < query.size()) {
			if (query[j].fi <= k + rem) {
				out.push_back({query[j].se, last + query[j].fi - k});
			}
			else break;
			j++;
		}
		last = u;
		k += rem;

	}
	while (j < query.size()) {

		out.push_back({query[j].se, last + query[j].fi - k});

		j++;
	}
	sortv(out);
	for (auto u : out) {
		cout << u.se << '\n';
	}

	return 0;

}

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
template <class T> bool chmin(T& a, T b){ if(a > b){ a = b; return 1; } return 0; }
template <class T> bool chmax(T& a, T b){ if(a < b){ a = b; return 1; } return 0; }
#define MAX_LL 1000000000000000000
#define MAX_INT 1000000000
#define alfa "abcdefghijklmnopqrstuvwxyz"
#define pi 3.141592653589793
   // vector<> dp(100010,1000000000000000)
    using p = pair<int,int>;
    using graph = vector<vector<int>> ;
    int main () {
     int n,q;cin >> n >> q;
     vector<ll> v (n);
     for (ll &i : v)cin >> i;
     vector<ll> s (n+1);// 配列の間の個数うの合計
     s[0]=v[0]-1;
     for (int i = 1; i < n; i++) {
         s[i]=s[i-1]+(v[i]-v[i-1]-1);
     }
     //for (ll i:s)cout << i << endl;
     s[n]=MAX_LL*1.3;
     for (int i = 0; i < q; i++) {
         bool ok = 0;
         ll k;cin >> k;
         ll t=lower_bound(s.begin(),s.end(),k)-s.begin();
         if (t==n)cout << k-s[n-1]+v[n-1] << endl;
         else cout << v[t]-1-(s[t]-k) << endl;
     }
    }


#include<bits/stdc++.h>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<list>
#include<stack>
#define me(a,b) memset(a,b,sizeof(a));
#define ios ios::sync_with_stdio(0); cin.tie(0),cout.tie(0);
using namespace std;
typedef long long ll;
const int N = 1e7+7;
const double eps = 1e-7;
const double pi=3.1415926;
const ll mod =1000003;

int main(){
	ll a,b,c;
	int x,y,z;
	cin>>a>>b;
	ll arr[200005];
	ios
	for(int i=0;i<200005;i++){
		arr[i]=0;
	}
	for(int i=1;i<=a;i++){
		cin>>x>>y>>z;
		arr[x]+=z;
		arr[y]-=z;
	}
	ll sum=0;
	for(int i=0;i<200005;i++){
		sum+=arr[i];
		if(sum>b){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

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

int main() {
    int n, m; cin >> n >> m;
    int a[n], b[m];
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];

    set<int> ans;

    rep(i, n){
        bool flag = true;
        rep(j, m){
            if(a[i] == b[j]) flag = false;
        }
        if(flag) ans.insert(a[i]);
    }
    rep(j, m){
        bool flag = true;
        rep(i, n){
            if(a[i] == b[j]) flag = false;
        }
        if(flag) ans.insert(b[j]);
    }
    for(auto x:ans) cout << x << ' ';
    cout << endl;
}


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

struct StDish
{
  StDish() : m_nDish1(0), m_nDish2(0) { }

  int m_nDish1;
  int m_nDish2;
};

void input(int& rnDishSiz, vector<StDish>& rvoCond,
                           vector<StDish>& rvoPutDish)
{
  int nCondSiz;
  cin >> rnDishSiz >> nCondSiz;
  rvoCond.resize(nCondSiz);

  for (StDish& roCond : rvoCond)
  {
    cin >> roCond.m_nDish1 >> roCond.m_nDish2;
    --roCond.m_nDish1; --roCond.m_nDish2;
  }

  int nPutDishSiz;
  cin >> nPutDishSiz;
  rvoPutDish.resize(nPutDishSiz);

  for (StDish& roPutDish : rvoPutDish)
  {
    cin >> roPutDish.m_nDish1 >> roPutDish.m_nDish2;
    --roPutDish.m_nDish1; --roPutDish.m_nDish2;
  }
}

int calcMeetCond(const vector<StDish>& cnrvoCond,
                 const vector<int>& cnrvnSelDish)
{
  int nMeetCond = 0;

  for (StDish oCond : cnrvoCond)
    if ( cnrvnSelDish[ oCond.m_nDish1 ] &&
         cnrvnSelDish[ oCond.m_nDish2 ]    )
      ++nMeetCond;

  return nMeetCond;
}

int calcMaxMeetCond(int nDishSiz, const vector<StDish>& cnrvoCond,
                                  const vector<StDish>& cnrvoPutDish)
{
  int nMaxMeetCond = 0;

  for (int nBit = 0; nBit < ( 1 << cnrvoPutDish.size() ); ++nBit)
  {
    vector<int> vnSelDish(nDishSiz);

    for (int nEach = 0; nEach < cnrvoPutDish.size(); ++nEach)
      if ( nBit & ( 1 << nEach ) )
        vnSelDish[ cnrvoPutDish[nEach].m_nDish2 ] = 1;
      else
        vnSelDish[ cnrvoPutDish[nEach].m_nDish1 ] = 1;

    int nMeetCond = calcMeetCond(cnrvoCond, vnSelDish);
    nMaxMeetCond = max(nMaxMeetCond, nMeetCond);
  }
  return nMaxMeetCond;
}

int main()
{
  int nDishSiz;
  vector<StDish> voCond, voPutDish;

  input(nDishSiz, voCond, voPutDish);
  cout << calcMaxMeetCond(nDishSiz, voCond, voPutDish) << endl;

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ps(x,y) fixed<<setprecision(y)<<x
#define w(t) int x;cin>>x;while(x--)
#define pi 2*acos(0.0)
#define bg begin()
#define ed end()
#define all(x) x.begin(),x.end()
#define sortarr(x) sort(x,x+arrsize(x))
#define arrsize(x) sizeof(x)/sizeof(x[0])
#define sortall(x) sort(all(x))
#define formn(m,n) for(m;m<=n;m++)
#define el endl
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define REP(i,a,b) for (int i=a;i<=b;i++)
#define sq(a) (a)*(a)
//solution

int solve(){
   set<int> aset;
   int n;
   cin>>n;
   int arr[n],arr2[n];
   int c=0,res=0;
   int min1=0,min2=0;
   REP(i,0,n-1){ cin>>arr[i]; if(arr[i]>min1){min1=arr[i];}}
   REP(i,0,n-1){ cin>>arr2[i]; if(arr2[i]>min2){min2=arr2[i];}}
   if(min1<min2){
      min1 = min2;
   }
   REP(i,1,min1){

        REP(j,0,n-1){
           if(i>= arr[j] && i<= arr2[j]){
                c=1;
           }else{
              c=0;
              break;
           }

        }
        if(c==1) res++;
        c=0;
   }
   cout<<res;

return 0;
}
//end solution
int main(){
solve();
}


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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define f first
#define s second
#define pb push_back
#define ar array
#define all(x) x.begin(), x.end()
#define siz(x) (int) x.size()
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define FOR(i, a, b) for(auto i=(a); i<(b); i++)
#define ROF(i, a, b) for(auto i=(b)-1; i>=(a); i--)
#define F0R(i, n) FOR(i, 0, n)
#define R0F(i, n) ROF(i, 0, n)

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using pll=pair<ll, ll>;
using vi=vector<int>;
using vl=vector<ll>;
using vpii=vector<pii>;

template<class T> bool ckmin(T&a, const T&b) {return b<a?a=b,1:0;}
template<class T> bool ckmax(T&a, const T&b) {return b>a?a=b,1:0;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mxN=2e5+10;
const int MOD=1e9+7;
const ll infLL=1e18;
const ld eps=1e-6;

oset<int> o;
int n;

int a[mxN], b[mxN];

map<int, vi> proc;

ll ans;

int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	F0R(i, n)
		cin >> a[i], a[i]+=i, proc[a[i]].pb(i);
	F0R(i, n)
		cin >> b[i], b[i]+=i;
	for(auto&x:proc) reverse(all(x.s));
	F0R(i, n)
		o.insert(i);
	F0R(i, n){
		if(siz(proc[b[i]])==0){
			cout << "-1\n"; return 0;
		}
		int v=proc[b[i]].back(); proc[b[i]].pop_back();
		// cout << "V: " << v << endl;
		// for(auto x:o) cout << x << ' ';
		// cout << endl;
		ans+=o.order_of_key(v);
		o.erase(v);
	}
	cout << ans << "\n";
	return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int t[55][55];
int p[55][55];
bool bo[2600] = { false };
int b1[4];
int b2[4];
int b3[4] = { 1,-1,0,0 };
int b4[4] = { 0,0,1,-1 };
int b5[4] = { 0,1,2,3 };
int main() {
	int x, y;
	cin >> x >> y;
	stack<pair<int, int>> s;
	s.push(make_pair(x, y));
	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < 50; j++) {
			cin >> t[i][j];
		}
	}
	bo[t[x][y]] = true;
	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < 50; j++) {
			cin >> p[i][j];
		}
	}
	string ans = "";
	int score = -1000000007;
	do {
		for (int i = 0; i < 4; i++) {
			b1[i] = b3[b5[i]];
			b2[i] = b4[b5[i]];
		}
		string ans1 = "";
		int score1 = 0;
		while (1) {
			int nx = s.top().first;
			int ny = s.top().second;
			bool bo1 = false;
			for (int i = 0; i < 4; i++) {
				if (nx + b1[i] < 0 || nx + b1[i] >= 50 || ny + b2[i] < 0 || ny + b2[i] >= 50)continue;
				if (!bo[t[nx + b1[i]][ny + b2[i]]]) {
					bo[t[nx + b1[i]][ny + b2[i]]] = true;
					s.push(make_pair(nx + b1[i], ny + b2[i]));
					bo1 = true;
					break;
				}
			}
			if (!bo1) {
				score1 += p[nx][ny];
				while (s.size() > 1) {
					s.pop();
					if (nx == s.top().first + 1) {
						ans1 += 'D';
					}
					if (nx == s.top().first - 1) {
						ans1 += 'U';
					}
					if (ny == s.top().second + 1) {
						ans1 += 'R';
					}
					if (ny == s.top().second - 1) {
						ans1 += 'L';
					}
					nx = s.top().first;
					ny = s.top().second;
					score1 += p[nx][ny];
				}
				reverse(ans1.begin(), ans1.end());
				if (score < score1) {
					ans = ans1;
					score = score1;
				}
				break;
			}
		}
		while (!s.empty()) {
			s.pop();
		}
		s.push(make_pair(x, y));
		for (int i = 0; i <= 2500; i++) {
			bo[i] = false;
		}
		bo[t[x][y]] = true;
	} while (next_permutation(b5, b5 + 4));
	cout << ans << endl;
}


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

// #include <atcoder/all>
// using namespace atcoder;
// using mint = modint1000000007;
// using mint2 = modint998244353;

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()

const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;
//const Int mod = 998244353;

typedef struct {
    int64_t to, weight;
} edge;

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

template<class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (auto &e : v) {
        is >> e;
    }
    return is;
}

bool print_space_enable = false;
void print() {
    std::cout << '\n';
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    std::cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

template<class T>
vector<T> make_vec(size_t n, T val) {
    return vector<T>(n, val);
}

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

bool is_overflow(Int a, Int b) {
    return a > INF / b;
}

void solve() {
    Int t, n;
    cin >> t >> n;
    n *= 100;
    double a = (n - 1) / t;
    double b = a * (100.0 + (double)t) / 100.0;
    Int res = ceil(b);
    print(res);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    //Int _t; cin >> _t; while (_t--) solve();
    return 0;
}

#include "bits/stdc++.h"
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int64_t t;cin>>t;
    int64_t N;cin>>N;
    int64_t ans=N*100+t-1;
    ans/=t;
    cout<<(ans+N-1)<<"\n";
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <climits>
#include <vector>
#include <queue>
#include <array>

//martin02

using namespace std;

int main() {
	long long int k, n, m;
	scanf("%lld %lld %lld", &k, &n, &m);
	vector<long long int> a(k);
	vector<long long int> b(k);
	priority_queue<array<long double, 2>> pq;
	for (int i = 0; i < k; i++) {
		scanf("%lld", &a.at(i));
	}

	long long int r = m;
	for (int i = 0; i < k; i++) {
		b.at(i) = (m * a.at(i)) / n;
		r -= b.at(i);
		pq.push({ (long double)a.at(i) / (long double)n - (long double)b.at(i) / (long double)m, (long double) i });
	}

	while (r != 0) {
		array<long double, 2> f = pq.top();
		pq.pop();
		b.at(f.at(1)) += 1;
		pq.push({ (long double)a.at(f.at(1)) / (long double)n - (long double)b.at(f.at(1)) / (long double)m, f.at(1) });
		r--;
	}

	for (int i = 0; i < k; i++) {
		printf("%lld ", b.at(i));
	}
	printf("\n");

	return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <chrono>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define int long long
#define fin cin
#define fout cout
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
#define all(x) x.begin(), x.end()
#define left vadia
#define right puta
using namespace std;
void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0);
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
typedef pair<ll, ll> pii;
typedef vector<vector<char>> mat;
typedef pair<int, string> pis;
const ll mod = 1e9+7;
const int MAXN = 1e4+5;
typedef vector<int> vi;
typedef pair<int, pair<int, int>> piii;

int32_t main() {
    int tot = 0, ans = 0, kek = 0;

    int n;
    cin >> n;

    vi v(n);

    for(int &i : v)
        cin >> i;

    for(int i = 2; i <= 1000; kek = 0, i++) {
        for(int &j : v) {
            kek += (j % i == 0);
        }
        if(kek > tot) tot = kek, ans = i;
    }
    cout << ans << endl;
}


//@formatter:off
#include<bits/stdc++.h>
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(i,n) for (ll i = 0; i < ll(n); ++i)
#define rep2(i,s,n) for (ll i = ll(s); i < ll(n); ++i)
#define rep3(i,s,n,d) for(ll i = ll(s); i < ll(n); i+=d)
#define rep(...) overload4(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__)
#define rrep1(i,n) for (ll i = ll(n)-1; i >= 0; i--)
#define rrep2(i,n,t) for (ll i = ll(n)-1; i >= (ll)t; i--)
#define rrep3(i,n,t,d) for (ll i = ll(n)-1; i >= (ll)t; i-=d)
#define rrep(...) overload4(__VA_ARGS__,rrep3,rrep2,rrep1)(__VA_ARGS__)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define popcount(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#ifdef __LOCAL
#define debug(...) { cout << #__VA_ARGS__; cout << ": "; print(__VA_ARGS__); cout << flush; }
#else
#define debug(...) void(0)
#endif
#define INT(...) int __VA_ARGS__;scan(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;scan(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;scan(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;scan(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;scan(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;scan(__VA_ARGS__)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int,int>;
using LP = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vs = vector<string>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vp = vector<P>;
using vvp = vector<vector<P>>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?"":","); return os<<']'; }
template<class T> void vecout(const vector<T> &v,char div='\n') { rep(i,v.size()) cout<<v[i]<<(i==int(v.size()-1)?'\n':div);}
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
void scan(){}
template <class Head, class... Tail> void scan(Head& head, Tail&... tail){ cin >> head; scan(tail...); }
template<class T> void print(const T& t){ cout << t << '\n'; }
template <class Head, class... Tail> void print(const Head& head, const Tail&... tail){ cout<<head<<' '; print(tail...); }
template<class... T> void fin(const T&... a) { print(a...); exit(0); }
struct Init_io {
    Init_io() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        cout.tie(nullptr);
        cout << boolalpha << fixed << setprecision(15);
    }
} init_io;
const string yes[] = {"no","yes"};
const string Yes[] = {"No","Yes"};
const string YES[] = {"NO","YES"};
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int main() {
    LL(a, b);
    rrep(i, b + 1) {
        ll mn = (a + i - 1) / i * i;
        mn += i;
        if (mn <= b) fin(i);
    }
}

#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(ll i=ll(m); i<ll(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<ll,ll>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

const int  INF = (1 << 30) - 1;
const ll INFL = 1LL << 60;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;

int main(){

	VI a(3);
	REP(i, 3)cin >> a[i];
	sort(ALL(a));
	cout << a[1] + a[2] << endl;

}


#include<iostream>
#include<cstdio>
using namespace std;
struct Edge{
	int to,nxt;
}e[400005];
int n,k,h[200005],num,f[200005],g[200005],cnt;
void add(int u,int v){
	e[++num].to=v;
	e[num].nxt=h[u];
	h[u]=num;
}
void dfs(int u,int fa,int lim){
	int i,v;
	f[u]=1e9;
	g[u]=0;
	for(i=h[u];i;i=e[i].nxt){
		v=e[i].to;
		if(v!=fa){
			dfs(v,u,lim);
			f[u]=min(f[u],f[v]+1);
			g[u]=max(g[u],g[v]+1);
		}
	}
	if(f[u]+g[u]<=lim)
		g[u]=-1e9;
	if(g[u]>=lim)
		++cnt,f[u]=0,g[u]=-1e9;
}
bool judge(int lim){
	cnt=0;
	dfs(1,0,lim);
	return (cnt+(g[1]>=0))<=k;
}
int solve(){
	int l=1,r=n,mid,res;
	while(l<=r){
		mid=(l+r)>>1;
		if(judge(mid))
			r=mid-1,res=mid;
		else
			l=mid+1;
	}
	return res;
}
int main(){
	ios::sync_with_stdio(false);
	int i,u,v;
	cin>>n>>k;
	for(i=1;i<n;i++){
		cin>>u>>v;
		add(u,v);add(v,u);
	}
	cout<<solve()<<endl;
	return 0;
}

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

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
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;}
//-------------------------------------------------------

int N,K,V;
vector<int> E[202020];

int need[202020],aff[202020];
int num;

void dfs(int cur,int pre) {
	need[cur]=0;
	aff[cur]=-1;

	FORR(e,E[cur]) if(e!=pre) {
		dfs(e,cur);
		if(aff[e]>=0) aff[cur]=max(aff[cur],aff[e]-1);
		if(need[e]>=0) need[cur]=max(need[cur],need[e]+1);
	}

	if(aff[cur]>=need[cur]) {
		need[cur]=-1;
	}
	else {
		if(need[cur]>=V) {
			need[cur]=-1;
			aff[cur]=V;
			num++;
		}
		else {
			aff[cur]=-1;
		}
	}

}

int ok(int v) {
	if(v<=0) return 0;

	V=v;
	num=0;
	dfs(0,0);
	if(need[0]>=0) num++;
	return num<=K;
}

void solve() {
	int i,j,k,l,r,x,y; string s;

	cin>>N>>K;
	FOR(i,N-1) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	int ret=N;
	for(j=20;j>=0;j--) if(ok(ret-(1<<j))) ret-=1<<j;
	cout<<ret<<endl;

}

int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

#define LL long long

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

    char c, d; cin >> c >> d;
    if(c == 'Y') if(d >= 97) d -= 32;
    cout << d;
}

#include<bits/stdc++.h>
#define FastRead                      \
                                    ios_base::sync_with_stdio(false); \
                                    cin.tie(0);
#define ll long long
#define endl "\n"
#define f for
#define ml ll t,g; cin>>t; f(g=0;g<t;g++)
#define pi acos(-1)
using namespace std;
bool cmp(const pair<string,ll> &a,
         const pair<string,ll> &b)
{
    if(a.second!=b.second)
        return (a.second > b.second);
    else
        return (a.first < b.first);
}
int main()
{
    FastRead
   ll a,b;
   cin>>a>>b;
   cout<<((2*a)+100)-b;
    return 0;
}


#include <bits/stdc++.h>

typedef long long ll;

const int N = 100;
const int S = N * N;
const int P = 998244353;

inline int norm(int x) {if (x >= P) x -= P; return x;}
inline int reduce(int x) {if (x < 0) x += P; return x;}
inline void add(int &x, int y) {if ((x += y) >= P) x -= P;}
inline void sub(int &x, int y) {if ((x -= y) < 0) x += P;}
int mpow(int b, int p) {
	int r = 1;
	for (; p; p >>= 1, b = (ll)b * b % P)
		if (p & 1) r = (ll)r * b % P;
	return r;
}

int fct[N + 5];
int f[N + 5][N + 5][2*S + 5], w[N + 5], n;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &w[i]);

	fct[0] = 1; for (int i = 1; i <= n; i++) fct[i] = (ll)fct[i - 1] * i % P;

	f[0][0][S] = 1;
	for (int i = 0; i < n; i++) for (int j = 0; i + j < n; j++) {
		int p = w[i + j + 1];
		for (int k = p; k <= (S << 1); k++) add(f[i + 1][j][k], f[i][j][k - p]);
		for (int k = (S << 1) - p; k >= 0; k--) add(f[i][j + 1][k], f[i][j][k + p]);
	}

	int ans = 0;
	for (int i = 0; i <= n; i++) ans = (ans + (ll)fct[i] * fct[n - i] % P * f[i][n - i][S]) % P;
	printf("%d\n", ans);
}

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()

#define MOD 998244353

long long pow_mod(long long x, long long y) {
	int res = 1;
	while (y) {
		if (y & 1)res = (res * x) % MOD;
		y >>= 1;
		x = (x * x) % MOD;
	}
	return res;
}

long long inv_mod(long long a) {
	return pow_mod(a,MOD-2);
}

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

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];

	map<int, int> mp;
	rep(i, n) {
		mp[a[i]]++;
	}

	int cnt = 0;
	long long sum = 0;
	for (auto p : mp) {
		long long c = p.first * pow_mod(2, cnt) % MOD * (pow_mod(2, p.second) - 1) % MOD;
		sum += c;
		cnt += p.second;
	}
	sum %= MOD;
	long long ans = 0;

	long long inv2 = inv_mod(2);
	for (auto p : mp) {
		sum -= p.first * (pow_mod(2, p.second) - 1) % MOD;
		sum *= pow_mod(inv2, p.second);
		sum = (sum % MOD + MOD) % MOD;

		ans += p.first * (pow_mod(2, p.second) - 1) %MOD * sum % MOD;
	}
	for (auto p : mp) ans += (long long)p.first * p.first % MOD * (pow_mod(2, p.second) - 1) % MOD;
	ans = (ans % MOD + MOD) % MOD;

	cout << ans << endl;

	return 0;
}


#include<bits/stdc++.h>
#define eps 1e-9
#define MOD1 998244353
#define MOD2 1000000007
#define INV_2 499122177
#define INF 1000000000
#define PI 3.14159265358979323846

using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int a, b, w;
	cin >> a >> b >> w;
	w*=1000;
	if(w < a || ((b-a)*(w/a)) < (w%a))
		cout << "UNSATISFIABLE\n";
	else
	{
		int x=0;
		if(w%b)
			x++;
		cout << w/b + x << ' ';
		cout << w/a << '\n';
	}
}
//size

// 2021-03-14 18:10:57
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

// clang-format on
const ll inf = 1e18;
void answer() {
  ll a, b, w;
  cin >> a >> b >> w;
  w *= 1000;
  ll l = inf, r = -inf;
  REPC(i, 1, 1000000) {
    if (a * i <= w && w <= b * i) {
      chmin(l, ll(i));
      chmax(r, ll(i));
    }
  }
  if (l == inf) {
    cout << "UNSATISFIABLE" << '\n';
  } else {
    cout << l << ' ' << r << '\n';
  }
}

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


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

const int MAXN = 1e5 + 5;

int N, M;
int a[MAXN][2];
vector <pair <int, int>> adj[MAXN];
int bio[MAXN], ans[MAXN];
int c[MAXN];

void load() {
  scanf("%d%d", &N, &M);
  for (int i = 0; i < M; i++)
    for (int j = 0; j < 2; j++)
      scanf("%d", a[i] + j);
  for (int i = 1; i <= N; i++)
    scanf("%d", c + i);
}

void dfs(int x, int p) {
  bio[x] = 1;
  for (auto it : adj[x]) {
    int nxt = a[it.first][it.second];
    if (nxt == p || bio[nxt] == 2)
      continue;
    ans[it.first] = it.second;
    if (!bio[nxt])
      dfs(nxt, x);
  }
  bio[x] = 2;
}

void solve() {
  for (int i = 0; i < M; i++)
    if (c[a[i][0]] != c[a[i][1]])
      ans[i] = c[a[i][0]] > c[a[i][1]];
    else
      for (int j = 0; j < 2; j++)
        adj[a[i][j]].push_back({i, j ^ 1});
  for (int i = 1; i <= N; i++)
    if (!bio[i])
      dfs(i, 0);
  for (int i = 0; i < M; i++)
    printf("%s\n", ans[i] ? "->" : "<-");
}

int main() {
  load();
  solve();
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<vector<int>>a;
vector<pair<int,int>>ds;
int b[104][104];
const int nmax=1e6;
int c[nmax+4];
int mau[105];
int cha[105];
int hang[105];
vector<pair<int,int>>kq;
void dfs(int u)
{
    mau[u]=1;
    for(int i=0; i<a[u].size(); ++i)
    {
        int v=a[u][i];
        //   cout<<v<<' ';
        if(!mau[v]&&c[u]==c[v])
        {
            b[u][v]=1;
            cha[v]=u;
            hang[v]=hang[u]+1;
            dfs(v);
        }

    }
}
int main()
{
    //ifstream cin("chuyen.inp");
    //ofstream cout("chuyen.out");
    cin>>n>>m;
    a.assign(n+1,vector<int>());
    for(int i=1; i<=m; ++i)
    {
        int x,y;
        cin>>x>>y;
        a[x].push_back(y);
        a[y].push_back(x);
        kq.push_back({x,y});
    }
    for(int i=1; i<=n; ++i)
    {
        cin>>c[i];
        ds.push_back({c[i],i});
    }

    for(int i=1; i<=n; ++i)
    {
        if(!mau[i])
            dfs(i);
    }

    for(int i=0; i<m; ++i)
    {
        int x=kq[i].first;
        int y=kq[i].second;
        if(c[x]==c[y])
        {
            if(cha[y]==x||(cha[x]!=y&&hang[x]>hang[y]))
                cout<<"->"<<'\n';
            else
                cout<<"<-"<<'\n';
            //continue;
        }
        else
        {
            if(c[x]>c[y])
                cout<<"->"<<'\n';
            else
                cout<<"<-"<<'\n';
        }
    }

}


#include <bits/stdc++.h>
using namespace std;
using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=int(a);i<=(int)(b);i++)
#define per(i,a,b) for(int i=int(a);i>=(int)(b);i--)
const int mod  = 1e9+7;
const int maxn = 2e5+10;
const int inf  = 0x3f3f3f3f;
int main() {
#ifndef WA_DEBUG
    ios::sync_with_stdio(false);cin.tie(nullptr);
#endif
    int _;
    cin>>_;
    while(_--) {
        ll n,s,k;
        cin>>n>>s>>k;
        s=n-s;
        if(s%__gcd(k,n)) {
            cout<<-1<<'\n';
            continue;
        }
        ll x,y;
        function<ll(ll,ll,ll &,ll &)> Exgcd=[&](ll a, ll b, ll &x, ll &y) {
          if (!b) {
            x = 1;
            y = 0;
            return a;
          }
          ll d = Exgcd(b, a % b, x, y);
          ll t = x;
          x = y;
          y = t - (a / b) * y;
          return d;
        };
        Exgcd(k,n,x,y);
        x*=s/__gcd(k,n);
        y*=s/__gcd(k,n);
        ll lc=k*n/__gcd(k,n);
        ll tmp=lc/n,up=abs(y);
        //cout<<x<<' '<<y<<' '<<tmp<<'\n';
        if(y>0) {
            ll num=up/tmp;
            if(up%tmp) num++;
            x+=(lc/k*num);
        }
        else {
            ll num=up/tmp;
            x-=(lc/k*num);
        }
        cout<<x<<'\n';
    }
    return 0;
}

// Jai Shree Ram

#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define max2(a,b) (a>b)?a:b
#define mi2(a,b) (a<=b)?a:b
#define fori(i,n) for(ll i=0;i<(ll)n;i++)
#define ford(i,n) for(ll i=n;i>=0;i--)
#define pll pair<ll,ll>
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
#define MAXI 1e15
#define MAX_LIMIT 500001

void solve()
{

    ll n,m;
    cin>>n>>m;
    vector<vector<ll>> adj(n+1);
    fori(i,m)
    {
        ll a,b;
        cin>>a>>b;
        adj[a].pb(b);
    }
    ll ans=0;

    for(int i=1;i<=n;i++)
    {
        stack<ll> st;
        vector<bool> visited(n+1,0);
        vector<ll> covered(n+1,0);
        visited[i]=1;
        st.push(i);
        while(!st.empty())
        {
            ll tmp=st.top();
            visited[tmp]=1;
            bool fl=0;
            for(int j=covered[tmp];j<adj[tmp].size();j++)
            {
                if(!visited[adj[tmp][j]])
                {
                    fl=1;
                    covered[tmp]=j;
                    st.push(adj[tmp][j]);
                    visited[tmp]=1;
                    break;
                }
            }
            if(!fl)
            {
                ans++;
                st.pop();
            }

        }
    }
    cout<<ans<<"\n";

}

int main()
{

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

    ll T;
    T=1;
    //cin>>T;

    fori(_,T)
    {
        solve();
    }

}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rrep(i,n) for (int i = 1; i <= (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
const long long INF = 1LL << 60;
const int dh[4] = {1,-1,0,0};
const int dw[4] = {0,0,1,-1};
const int MOD = 1000000009;
void add(ll &a, ll b) {a = (a+b) % MOD;}

int main() {
  ll N; cin >> N;
  ll a = 3;
  ll ai = 1;
  while(N >= a) {
    ll tmp = N - a;
    ll b = 5,bi = 1;
    while (tmp >= b) {
      if (tmp - b == 0) {
        cout << ai << " " << bi << endl;
        return 0;
      }
      b *= 5;
      bi++;
    }
    a *= 3;
    ai++;
  }
  cout << -1 << endl;
}

#include<bits/stdc++.h>
using namespace std;
#define  	fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  	debug       printf("\n<<CameHere>>\n")
#define  	mem(x,y)    memset(x, y, sizeof(x))
#define  	all(qz)     qz.begin(),qz.end()
#define  	rall(qz)    qz.rbegin(),qz.rend()
#define  	inf         1000000000000000000
#define     mod         1000000007
#define     Sqr(x)      ((x)*(x))
#define     ll          long long
#define     mk          make_pair
#define     pb          push_back
#define     pi          acos(-1.0)
#define     cos(a)      cos(a*pi/180)
#define     sin(a)      sin(a*pi/180)
#define     tan(a)      tan(a*pi/180)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll ppow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}
/*---------AL ASAD NUR RIYAD------------*/

int main()
{
	fastt

    ll n;
    cin>>n;
    vector<ll> v;
    ll cnt=1;
    for(ll i=1;i<40;i++){
    	cnt=cnt*3;
    	v.push_back(cnt);
    	//cout<<cnt<<endl;
    }
    for(ll i=0;i<v.size();i++){
    	ll x=n-v[i];
    	if(x>0){
    		ll y=0;
    		while(x%5==0){
    			x/=5;
    			y++;
    		}
    		if(x==1&&y!=0){
    			cout<<i+1<<" "<<y<<endl;
    			return 0;
    		}
    	}
    }
    cout<<-1<<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
namespace SimpleModInt {
    constexpr int md = (int)1e9 + 7;
    inline int norm(long long a) {
        return (a % md + md) % md;
    }
    inline int add(int a, int b) {
        a += b;
        if (a >= md) a -= md;
        return a;
    }
    inline int sub(int a, int b) {
        a -= b;
        if (a < 0) a += md;
        return a;
    }
    inline int mul(int a, int b) {
        return (int)((long long)a * b % md);
    }
    inline int powmod(int a, long long b) {
        int res = 1;
        while (b > 0) {
            if (b & 1) res = mul(res, a);
            a = mul(a, a);
            b >>= 1;
        }
        return res;
    }
    inline int inv(int a) {
        a %= md;
        if (a < 0) a += md;
        int b = md, u = 0, v = 1;
        while (a) {
            int t = b / a;
            b -= t * a; swap(a, b);
            u -= t * v; swap(u, v);
        }
        assert(b == 1);
        if (u < 0) u += md;
        return u;
    }
}
using namespace SimpleModInt;
struct matrix {
    int n, m;
    vector<vector<int>> a;
    matrix() {}
    matrix(vector<vector<int>> k) {
        n = k.size();
        m = k[0].size();
        a = k;
    }
    matrix operator* (const matrix& c) const {
        int n = a.size();
        int m = c.a[0].size();
        vector<vector<int>> b(n, vector<int>(m, 0));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                for (int k = 0; k < a[i].size(); k++) {
                    b[i][j] = add(b[i][j], mul(a[i][k], c.a[k][j]));
                }
            }
        }
        return matrix(b);
    }
    matrix powmod(long long k) {
        k--;
        vector<vector<int>> res = a;
        vector<vector<int>> b = a;
        while (k > 0) {
            if (k & 1) res = (matrix(res) * matrix(b)).a;
            b = (matrix(b) * matrix(b)).a;
            k >>= 1;
        }
        return matrix(res);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int INV2 = inv(2);
    int n, m, k;
    cin >> n >> m >> k;
    int INVM = inv(m);
    vector<vector<int>> g(n);
    vector<vector<int>> c(n, vector<int>(n, 0));
    vector<int> a(n);
    for (auto& i : a) cin >> i;
    if (!k) {
        for (auto i : a) {
            cout << i << "\n";
        }
        return 0;
    }
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for (int i = 0; i < n; i++) {
        c[i][i] = mul((m - g[i].size()) + mul(INV2, g[i].size()), INVM);
        for (auto to : g[i]) {
            c[i][to] = mul(INVM, INV2);
        }
    }
    auto res = matrix(c).powmod(k);
    for (int i = 0; i < n; i++) {
        int val = 0;
        for (int j = 0; j < n; j++) {
            val = add(val, mul(a[j], res.a[i][j]));
        }
        cout << val << "\n";
    }
    return 0;
}

#include<bits/stdc++.h>
#define db double
#define reg register
#define LL long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ull unsigned long long
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)
#define erep(i,a) for(int i=head[a];i;i=e[i].nxt)

using namespace std;
bool Handsome;
inline void Mi(int &x,int y){if(x>y && (x=y));}
inline void Mx(int &x,int y){if(x<y && (x=y));}
const int M=105,P=1e9+7,INV=5e8+4;
int n,m,mv,k,A[M];
void Add(int &x,int y){
	x+=y;
	if(x>=P)x-=P;
	if(x<0)x+=P;
}
int FAST(int x,int y){
	int res=1;
	for(;y;y>>=1){
		if(y&1)res=1ll*res*x%P;
		x=1ll*x*x%P;
	}
	return res;
}
struct Mtx{
	int a[M][M];
	Mtx (){memset(a,0,sizeof(a));}
	Mtx operator * (const Mtx x)const{
		Mtx y;
		rep(i,1,n)rep(j,1,n)rep(k,1,n)
			Add(y.a[i][k],1ll*a[i][j]*x.a[j][k]%P);
		return y;
	}
	void Print(){
		rep(i,1,n){
			int x=0;
			rep(j,1,n)Add(x,1ll*a[i][j]*A[j]%P);
			printf("%d\n",x);
		}
	}
}f,res;
bool Most;
int main(){
//	printf("%.2lfMB\n",(&Most-&Handsome)/1024.0/1024.0);
	scanf("%d%d%d",&n,&m,&k);
	mv=FAST(m,P-2);
	rep(i,1,n)scanf("%d",&A[i]);
	rep(i,1,n)f.a[i][i]=res.a[i][i]=1;
	rep(i,1,m){
		int x,y;scanf("%d%d",&x,&y);
		Add(f.a[x][y],1ll*mv*INV%P);
		Add(f.a[x][x],-1ll*mv*INV%P);

		Add(f.a[y][x],1ll*mv*INV%P);
		Add(f.a[y][y],-1ll*mv*INV%P);
	}
	for(;k;k>>=1){
		if(k&1)res=res*f;
		f=f*f;
	}
	res.Print();
	return 0;
}


//BY: YASH JAIN, CF: yashjain0333
#include <bits/stdc++.h>
using namespace std;
#define May_the_fork_be_with_you ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define rall(v) v.rbegin(),v.rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define deb(x) cout<<#x<<": "<<x<<endl;
#define debn(x) cout<<#x<<": "<<x<<"  ";
#define MOD 1000000007
#define INF 1e18
#define ll long long
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define int long long
#define N 100005
#define sq(x) ((x)*(x))
typedef vector<int> vi;
ll gcd(ll a, ll b) {if (!b)return a; return gcd(b, a % b);}
ll power(ll x, ll y, ll p = INF) {ll res = 1; x %= p; while (y > 0) {if (y & 1)res = (res * x) % p; y = y >> 1; x = (x * x) % p;} return res;}

void solve() {
    int n; cin >> n;
    int res = 0;
    int l = 1, r = sqrt(2 * n + 2), comp = 2 * n + 2;
    // deb(comp)
    while (r > l) {
        int m = l + (r - l) / 2;
        int x = sq(m) + m;
        // debn(m) deb(x)
        if (x <= comp) l = m + 1;
        else r = m;
    }
    if ((l * (l + 1)) <= 2 * (n + 1)) cout << n + 1 - l;
    else cout << n + 1 - (l - 1);
}

int32_t main() {

#ifndef ONLINE_JUDGE
    // for geting input form input.txt
    freopen("input.txt", "r", stdin);
    // for wrting output to output.txt
    freopen("output.txt", "w", stdout);
#endif

    May_the_fork_be_with_you
    int t = 1;
    // cin >> t;
    cout << fixed << setprecision(12);
    while (t--) {
        solve();
    }

    cerr << "Time Taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
}

#include <bits/stdc++.h>
using namespace std;
int N, Q;
const int maxn = 2e5 + 5;
typedef long long ll;
inline ll read()
{
    ll x = 0;
    int s = 1;
    char c = getchar();
    while (c < 48 || c > 57)
    {
        if (c == '-')
            s = -1;
        c = getchar();
    }
    while (c >= 48 && c <= 57)
    {
        x = (x << 3) + (x << 1) + c - '0';
        c = getchar();
    }
    return x * s;
}
int main()
{
    int N, Q;
    N = read();
    ll a, t;
    ll l = -1e9, r = 1e9, b = 0;
    for (int i = 0; i < N; i++)
    {
        a = read();
        t = read();
        if (t == 1)
        {
            l += a;
            r += a;
            b += a;
        }
        else if (t == 2)
        {
            l = max(l, a);
            r = max(r, a);
        }
        else
        {
            l = min(l, a);
            r = min(r, a);
        }
    }
    Q = read();
    while (Q--)
    {
        ll x = read() + b;
        if (x < l)
            cout << l;
        else if (x > r)
            cout << r;
        else
            cout << x;
        cout << ' ';
    }
}


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

using lint = long long;

#define fi first
#define se second

const int N = 2e5 + 5;
const int INF = 2e9;
const lint LINF = 9e18;

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

  int n;
  cin >> n;
  cout << ((n + 99) / 100) << "\n";
}

#define ll long long
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define tll tuple<ll ,ll ,ll , ll>
#define tri tuple<ll ,ll ,ll>
#define pll pair<ll ,ll>
//#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>
ll pi = acos(-1) ;
ll z =  998244353 ;
ll inf = 100000000000;
ll p1 = 37 ;
ll p2 = 53 ;
ll mod1 =  202976689 ;
ll mod2 =  203034253 ;
ll fact[100] ;
ll gdp(ll a , ll b){return (a - (a%b)) ;}
ll ld(ll a , ll b){if(a < 0) return -1*gdp(abs(a) , b) ; if(a%b == 0) return a ; return (a + (b - a%b)) ;} // least number >=a divisible by b
ll gd(ll a , ll b){if(a < 0) return(-1 * ld(abs(a) , b)) ;    return (a - (a%b)) ;} // greatest number <= a divisible by b
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll e_gcd(ll a , ll b , ll &x , ll &y){ if(b > a) return e_gcd(b , a , y , x) ; if(b == 0){x = 1 ; y = 0 ; return a ;}
ll x1 , y1 ; e_gcd(b , a%b , x1 , y1) ; x = y1 ; y = (x1 - ((a/b) * y1)) ; return e_gcd(b , a%b , x1 , y1) ;}
ll power(ll a ,ll b , ll p){if(b == 0) return 1 ; ll c = power(a , b/2 , p) ; if(b%2 == 0) return ((c*c)%p) ; else return ((((c*c)%p)*a)%p) ;}
ll inverse(ll a ,ll n){return power(a , n-2 , n) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
ll min(ll a , ll b){if(a < b) return a ; return b ;}
ll left(ll i){return ((2*i)+1) ;}
ll right(ll i){return ((2*i) + 2) ;}
ll ncr(ll n , ll r){if(n < r) return 0 ; return ((((fact[n] * inverse(fact[r] , z)) % z) * inverse(fact[n-r] , z)) % z);}
void swap(ll&a , ll&b){ll c = a ; a = b ; b = c ; return ;}
//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
using namespace std ;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
//__builtin_popcount(n) -> returns number of set bits in n

void solve()
{
    ll n ;
    cin >> n ;
    cout << (n+99)/100 << endl ;
    return ;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("errorf.txt" , "w" , stderr) ;
    #endif*/

    ll t ;
    //cin >> t ;
    t = 1 ;

    for(ll x = 1 ; x <= t ; x++)
    {
        solve() ;
    }
    //cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

    return 0;
}


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

int main() {
  int N;
  bool ans=true;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++)  cin>>a.at(i);
  sort(a.begin(),a.end());
  for(int i=1;i<=N;i++) if(a[i-1]!=i) ans=false;
  if(ans)   cout<<"Yes"<<endl;
  else      cout<<"No"<<endl;
}

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define pb push_back
#define ll long long
#define mk make_pair
#define endl '\n'
#define M  1000000007
ull dp[101][101];
ull nCr(ull n,ull r)
{
    if(n==r)return dp[n][r]=1;
    if(r==1)return dp[n][r]=n;
    if(r==0)return dp[n][r]=1;
    if(dp[n][r])return dp[n][r];
    return dp[n][r]=nCr(n-1,r-1)+nCr(n-1,r);
}

ll mod(ll x)
{
    return ((x%M+M)%M);    // x will be negative or positive
}
ll add(ll a,ll b)
{
    return mod((mod(a)+mod(b)));
}
ll mul(ll a,ll b)
{
    return mod(mod(a)*mod(b));
}
bool cmp(const pair<ll,ll>&p1, pair<ll,ll>&p2)
{
    if(p1.first>p2.first)return 1;
    else if(p1.first==p2.first)return (p1.second<p2.second);
    else return 0;
}
bool is_balanced(char first,char second )
{
    return ((first=='('&& second==')')||(first=='{' && second=='}') || (first=='[' && second==']'));
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
    {
       ll n;
       cin>>n;
       ll a[n];
       set<ll>s;
       for(ll i=0;i<n;i++)
       {
           cin>>a[i];
           s.insert(a[i]);
       }
       if(s.size()==n)cout<<"Yes"<<endl;
       else cout<<"No"<<endl;
    }

}
//Alhamdulillah...


#include <iostream>
using namespace std;

int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if (a==b)
    cout<<c;
  else if (b==c)
    cout<<a;
  else if (a==c)
    cout<<b;
  else
    cout<<0;

  return 0;
}

// #define ONLINE_JUDGE
//                 _
//                (_)
// _ __ ___   __ _ _  ___  _ __ _ __ ___
//| '_ ` _ \ / _` | |/ _ \| '__| '__/ _ \
//| | | | | | (_| | | (_) | |  | | | (_) |
//|_| |_| |_|\__,_| |\___/|_|  |_|  \___/
//               _/ |
//              |__/
#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;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef tree<
    pll,//
    null_type,
    less<pll>,//
    rb_tree_tag,
    tree_order_statistics_node_update>
ordered_set;

#define majorro cout.precision(20); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define forn(i, n) for(ll (i) = 0; (i) < (n); ++(i))
#define fornm(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define rfornm(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define readvec(vector, n) {ll temp_vec_val;forn(inc, n){cin >> temp_vec_val;vector.push_back(temp_vec_val);}}
#define printvec(vector, delimeter) {ll length_of_vector=vector.size();                                    forn(elementvec, length_of_vector){cout << vector[elementvec] << delimeter;}}
#define all(vector) (vector).begin(), (vector).end()
#define rall(vector) (vector).rbegin(), (vector).rend()
#define endl "\n"
#define sz(something) (ll)something.size()

struct pair_hash
{
    template <class T1, class T2>
    size_t operator() (const pair<T1, T2>& pair) const
    {
        return hash<T1>()(pair.first) ^ hash<T2>()(pair.second);
    }
};

const ld EPS = 1e-8;
const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1e18;
const ld pi = 2.0*acos(0.0);
ll n, m, k, p, q, t, sum=0, cnt=0;
ll mx = -INF;
ll mn = INF;
bool flag = 0;
vll v;
string s = "", s1, s2;
char c;

void solve()
{
    ll a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    if(a[0]==a[1]) cout << a[2];
    else if(a[1]==a[2]) cout << a[0];
    else cout << 0;
}

int main()
{
#if defined ACMP
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#elif !defined ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    majorro
    solve();
    return 0;
}


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

#define stp(var, init, end) for (auto var = init; var < end; ++var)
#define stpe(var, init, end) for (auto var = init; var <= end; ++var)
#define ll long long

int main(void)
{
    int n, rnum = 0, gnum = 0, bnum = 0;
    cin >> n;

    vector<ll> rdogs;
    vector<ll> gdogs;
    vector<ll> bdogs;
    ll ina;
    char inc;
    stp(i, 0, 2 * n)
    {
        cin >> ina >> inc;
        if (inc == 'R')
        {
            rdogs.emplace_back(ina);
            ++rnum;
        }
        else if (inc == 'G')
        {
            gdogs.emplace_back(ina);
            ++gnum;
        }
        else if (inc == 'B')
        {
            bdogs.emplace_back(ina);
            ++bnum;
        }
    }
    sort(rdogs.begin(), rdogs.end());
    sort(gdogs.begin(), gdogs.end());
    sort(bdogs.begin(), bdogs.end());
    /*
    cout << "R: ";
    stp(i, 0, rnum)
    {
        cout << rdogs[i] << " ";
    }
    cout << "\n";
    cout << "G: ";
    stp(i, 0, gnum)
    {
        cout << gdogs[i] << " ";
    }
    cout << "\n";
    cout << "B: ";
    stp(i, 0, bnum)
    {
        cout << bdogs[i] << " ";
    }
    cout << "\n\n";
    */

    if (rnum % 2 == 0 && gnum % 2 == 0 && bnum % 2 == 0)
    {
        //cout << "even\n";
        cout << 0;
    }
    else
    {
        ll rgmin = 10000000000000000ll, gbmin = 10000000000000000ll, brmin = 10000000000000000ll;
        if (gnum > 0)
        {
            stp(i, 0, rnum)
            {
                auto iter = lower_bound(gdogs.begin(), gdogs.end(), rdogs[i]);
                if (iter == gdogs.begin())
                    rgmin = min(rgmin, abs(rdogs[i] - *iter));
                else if (iter == gdogs.end())
                    rgmin = min(rgmin, abs(rdogs[i] - *(iter - 1)));
                else
                    rgmin = min(rgmin, min(abs(rdogs[i] - *iter), abs(rdogs[i] - *(iter - 1))));
            }
        }
        if (bnum > 0)
        {
            stp(i, 0, gnum)
            {
                auto iter = lower_bound(bdogs.begin(), bdogs.end(), gdogs[i]);
                if (iter == bdogs.begin())
                    gbmin = min(gbmin, abs(gdogs[i] - *iter));
                else if (iter == bdogs.end())
                    gbmin = min(gbmin, abs(gdogs[i] - *(iter - 1)));
                else
                    gbmin = min(gbmin, min(abs(gdogs[i] - *iter), abs(gdogs[i] - *(iter - 1))));
            }
        }
        if (rnum > 0)
        {
            stp(i, 0, bnum)
            {
                auto iter = lower_bound(rdogs.begin(), rdogs.end(), bdogs[i]);
                if (iter == rdogs.begin())
                    brmin = min(brmin, abs(bdogs[i] - *iter));
                else if (iter == rdogs.end())
                    brmin = min(brmin, abs(bdogs[i] - *(iter - 1)));
                else
                    brmin = min(brmin, min(abs(bdogs[i] - *iter), abs(bdogs[i] - *(iter - 1))));
            }
        }

        if (rnum % 2 == 1 && gnum % 2 == 1)
        {
            if (bnum > 0)
                cout << min(rgmin, gbmin + brmin);
            else
                cout << rgmin;
        }
        else if (gnum % 2 == 1 && bnum % 2 == 1)
        {
            if (rnum > 0)
                cout << min(gbmin, brmin + rgmin);
            else
                cout << gbmin;
        }
        else if (bnum % 2 == 1 && rnum % 2 == 1)
        {
            if (gnum > 0)
                cout << min(brmin, rgmin + gbmin);
            else
                cout << brmin;
        }
    }
    return 0;
}

#include <bits/stdc++.h>
#define rei register int
using namespace std;
int K;
int cnt[11],qpow[11];
string S,T;
double ans;
int score(string A){
	memset(cnt,0,sizeof(cnt)); int res = 0;
	for(rei i = 0;i < A.size();++i) ++cnt[A[i] - '0'];
	for(rei i = 1;i <= 9;++i) res += i * qpow[cnt[i]];
	return res;
} void solve(string A,string B){
	int scoreA = score(A),scoreB = score(B);
	if(scoreA > scoreB){
//		cerr << A[4] << " " << B[4] << endl;
		double P = 1;
		memset(cnt,0,sizeof(cnt));
		for(rei i = 1;i <= 9;++i) cnt[i] = K;
		for(rei i = 0;i < A.size() - 1;++i) --cnt[A[i] - '0'];
		for(rei i = 0;i < B.size() - 1;++i) --cnt[B[i] - '0'];
		int now = 9 * K - 8;
		P *= (double)cnt[A[4] - '0'] / (double)now;--now,--cnt[A[4] - '0'];
		P *= (double)cnt[B[4] - '0'] / (double)now;--now,--cnt[B[4] - '0'];
//		printf("%.10lf\n",P);
		ans += P;
	}
}
int main(){
	cin >> K; cin >> S >> T;
	qpow[0] = 1;
	for(rei i = 1;i <= 9;++i) qpow[i] = qpow[i - 1] * 10;
	for(rei i = 1;i <= 9;++i)
	 for(rei j = 1;j <= 9;++j){
		S[4] = '0' + i,T[4] = '0' + j;
		solve(S,T);
	 } printf("%.10lf",ans); return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define INF LONG_MAX/3
//#define DIV 1000000007
//#define DIV 998244353

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; }
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//pos, C, D;
vector<tuple<ll, ll, ll> > to[100005];

ll cal(double c, double d, double curtime) {
	double s = 0;
	double e = 1000000000;

	while(s + 5 < e) {
		double diff = e - s;
		double p0 = s + diff/3;
		double p1 = s + 2*(diff/3);

		double cost0 = p0 + c + (d/(curtime + p0 + 1));
		double cost1 = p1 + c + (d/(curtime + p1 + 1));

		if(cost0 < cost1) {
			e = p1;
		} else {
			s = p0;
		}
	}

	ll ret = INF;
	for(ll x = max(0LL, (ll)s - 10); x <= s + 20; x++) {
		ll cost0 = x + c + (d/(curtime + x + 1));
		chmin(ret, cost0);
	}
	return ret;
}

int main(){
	ll N, M;
	cin >> N >> M;

	rep(i, M) {
		ll a, b, c, d;
		cin >> a >> b >> c >> d;
		a--;b--;
		to[a].push_back({b, c, d});
		to[b].push_back({a, c, d});
	}

	priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll> > >Q;
	Q.push(make_pair(0, 0));

	vector<ll> dis(N, -1);

	while(!Q.empty()) {
		ll cost = Q.top().first;
		ll pos = Q.top().second;
		Q.pop();
		if(dis[pos] != -1) continue;
		dis[pos] = cost;

		for(auto item: to[pos]) {
			ll next, c, d;
			tie(next, c, d) = item;
			ll minicost = cal(c, d, cost);
			//cout << "pos = " << pos << " next = " << next << " cost = " << cost << " mini = " << minicost << endl;
			Q.push({cost + minicost, next});
		}
	}

	cout << dis[N-1] << endl;
}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sys/types.h>
#include <unistd.h>
#include <vector>

#pragma region macros
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) _range(i, 0, n)
#define _range(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(...) _overload(__VA_ARGS__, _range, _rep, )(__VA_ARGS__)
#define _rrep(i, n) _rrange(i, n, 0)
#define _rrange(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)
#define rrep(...) _overload(__VA_ARGS__, _rrange, _rrep, )(__VA_ARGS__)
#pragma endregion macros

using namespace std;

template <class T> bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T> bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

using ll    = long long;
using R     = long double;
const R EPS = 1e-9L;  // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R &r) {
    return (r > EPS) - (r < -EPS);
}
inline R sq(R x) {
    return sqrt(max(x, 0.0L));
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int n, k;
const int limit = 200010;
vector<int> graph[limit];
int used[limit];

using state = struct {
    bool covered;
    int dist;
};

state dfs(int v, int p, int thr) {
    vector<int> children;
    for (auto &u: graph[v]) {
        if (u == p) {
            continue;
        }
        children.push_back(u);
    }

    if (children.empty()) {
        return {0, 0};
    }

    int farthest = 0;
    int closest  = 1 << 20;

    for (auto &u: children) {
        const state cur = dfs(u, v, thr);
        if (cur.covered) {
            chmin(closest, cur.dist + 1);
        } else {
            chmax(farthest, cur.dist + 1);
        }
    }

    if (farthest + closest <= thr) {
        return {1, closest};
    } else if (farthest >= thr) {
        used[v] = 1;
        return {1, 0};
    } else {
        return {0, farthest};
    }
}

bool check(int thr) {
    rep(i, n) {
        used[i] = 0;
    }
    const state ret = dfs(0, -1, thr);
    if (ret.covered == 0) {
        used[0] = 1;
    }
    int cnt = 0;
    rep(i, n) {
        cnt += used[i];
    }
    return (cnt <= k);
}

int main(void) {
    cin >> n >> k;

    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    int low = 0, high = n;
    while (high - low > 1) {
        const int mid = (low + high) / 2;
        if (check(mid)) {
            high = mid;
        } else {
            low = mid;
        }
    }

    cout << high << endl;
    return 0;
}


// CTRL+ALT+M
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define int long long int
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vpi vector<pair<int,int>>
#define pii pair<int,int>
#define pb push_back
#define inf 1e18
#define ff first
#define ss  second
#define deb(x) cout<<#x<<" "<<x<<endl;
#define all(x) x.begin(),x.end()
#define endl "\n"
const int maxn=1e5;
//*! look for binary search see if dp can fit or dp with bs
//*? Set or Priority_queue
//*! Number is upto 10^5 check if a[maxn] gives something
//*? Graph Question depedencies Topo sort
//todo For a Tree its shortest Path in  dfs is same as in bfs if it is acyclic
// *! Bridge Detection:: From Backedge we take low[u]=min(low[u],tin[x])
// *! Bridge Detection:: From Child we take low[u]=min(low[u],low[x])
// *! Bridge Detection:: this is a bridge if(low[x]>tin[u])
// vi adj[maxn];
// int visited[maxn];
int dp[20][10];
int solve(int s,int n,string & p,int sum)
{
  if(s>=n)
  {
    if(sum==0)
    {
      return 0;
    }
    return INT_MAX;
  }
  if(dp[s][sum]!=-1)
  {
    return dp[s][sum];
  }
   int l=sum+(p[s]-'0');
   l=l%3;
   int op1=solve(s+1,n,p,l);
   int op2=1+solve(s+1,n,p,sum);
   return  dp[s][sum]=min(op1,op2);
}
void runcases(int T)
{

   string s;
   cin>>s;
   int n=s.size();
   memset(dp,-1,sizeof(dp));
   int f=solve(0,n,s,0);
    if(f==n)
    {
      cout<<-1<<endl;

    }else cout<<f<<endl;

  //cout<<"Case #"<<T<<": ";
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T = 1;
    //cin >> T;
    for (int t=1;t<=T; t++) {
        runcases(t);
    }

    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        int n = s.length(),sum=0;
        vector<int> c(3,0);
        if(n==1)
        {
            if(int(s[0]-'0')%3==0)cout<<"0";
            else cout<<"-1";

            continue;
        }
        for(int i=0;i<n;i++)
        {
            int a = int(s[i]-'0')%3;
            c[a]++;
            sum+=a;
        }
        sum = sum%3;
        if(sum==0)cout<<"0";
        else if(sum==2)
        {
            if(c[2]>0){cout<<"1";continue;}

            if(c[1]>1 && n>2){cout<<"2";continue;}
            cout<<"-1";
        }
        else
        {
            if(c[1]>0)cout<<"1";
            else if(n>2 && c[2]>1)cout<<"2";
            else
            cout<<"-1";
        }

    }

	return 0;
}