/* author: jeetganatra */

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

#define ff              first
#define ss              second
#define int             long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define tr(it, a)       for(auto it = a.begin(); it != a.end(); it++)
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x)          x.begin(), x.end()
#define clr(x)          memset(x, 0, sizeof(x))
#define sortall(x)      sort(all(x))
#define PI              3.14159265
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

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

void jpg()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int mpow(int base, int exp);
int nCr(int n, int r, int p);

int32_t main()
{
   // jpg();
    // w(t)
    // {
    int n; cin >> n;
    int calc = 1.08 * n;
    if (calc < 206)
        cout << "Yay!";
    else if (calc == 206)
        cout << "so-so";
    else
        cout << ":(";

    // }

}

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
        if (exp & 1) result = ((int)result * base) % mod;
        base = ((int)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

int nCr(int n, int r, int p)
{
    if (r > n - r)
        r = n - r;

    int C[r + 1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (int i = 1; i <= n; i++) {
        for (int j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j - 1]) % p;
    }
    return C[r];
}


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

template <int mod = (int)(998244353)>
struct ModInt {
  int x;
  constexpr ModInt() : x(0) {}
  constexpr ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  constexpr ModInt &operator+=(const ModInt &p) noexcept {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt &p) noexcept {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt &p) noexcept {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  constexpr ModInt &operator/=(const ModInt &p) noexcept {
    *this *= p.inverse();
    return *this;
  }
  constexpr ModInt operator-() const { return ModInt(-x); }
  constexpr ModInt operator+(const ModInt &p) const noexcept {
    return ModInt(*this) += p;
  }
  constexpr ModInt operator-(const ModInt &p) const noexcept {
    return ModInt(*this) -= p;
  }
  constexpr ModInt operator*(const ModInt &p) const noexcept {
    return ModInt(*this) *= p;
  }
  constexpr ModInt operator/(const ModInt &p) const noexcept {
    return ModInt(*this) /= p;
  }
  constexpr bool operator==(const ModInt &p) const noexcept { return x == p.x; }
  constexpr bool operator!=(const ModInt &p) const noexcept { return x != p.x; }
  constexpr ModInt inverse() const noexcept {
    int a = x, b = mod, u = 1, v = 0, t = 0;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  constexpr ModInt pow(int64_t n) const {
    ModInt res(1), mul(x);
    while (n) {
      if (n & 1) res *= mul;
      mul *= mul;
      n >>= 1;
    }
    return res;
  }
  friend constexpr ostream &operator<<(ostream &os, const ModInt &p) noexcept {
    return os << p.x;
  }
  friend constexpr istream &operator>>(istream &is, ModInt &a) noexcept {
    int64_t t = 0;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  constexpr int get_mod() { return mod; }
};
using mint = ModInt<>;

int main() {
  mint res, now;
  long long a, b, c;
  cin >> a >> b >> c;
  res = 1;
  res *= (long long)a * (a + 1) / 2;
  res *= (long long)b * (b + 1) / 2;
  res *= (long long)c * (c + 1) / 2;

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

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
typedef long long ll;
template <typename T> inline void read(T &x) {
	x = 0; char c = getchar(); bool flag = false;
	while (!isdigit(c)) { if (c == '-')	flag = true; c = getchar(); }
	while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
	if (flag)	x = -x;
}
using namespace std;
const int P = 998244353;
inline ll F(ll n) {
	return (n * (n + 1) >> 1) % P;
}
int main() {
	ll a, b, c; read(a), read(b), read(c);
	ll res = F(a) * F(b) % P * F(c) % P;
	printf("%lld\n", (res % P + P) % P);
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")

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

// size(x), rbegin(x), rend(x) need C++17
#define sz(x) int((x).size())
#define all(x) begin(x), end(x)
#define rall(x) x.rbegin(), x.rend()
#define sor(x) sort(all(x))
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second

#define mset(a,b) memset(a, b, sizeof(a))
#define dbg(x) cout << "[" << #x << "]: " << x << endl;
#define forn(i,n) for(int i=0; i < n;i++)
#define nrof(i,n) for(int i = n-1; i >= 0; i--)
#define fori(i,a,b) for(int i = a; i <= b; i++)
#define irof(i,b,a) for(int i = b; i >= a; i--)
#define each(val, v) for(auto &val : v)

using ll = long long;
using db = long double; //pode ser double

using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<string>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const db EPS = 1e-9;
const db PI = acos((db)-1);

int M[3000][3000];
int dp[3000][3000];
void solve(){
	int n,m;
	cin >> n >> m;

	forn(i,3000){
		forn(j,3000){
			dp[i][j] = INF;
			M[i][j] = 0;
		}
	}
	forn(i,n){
		string s;
		cin >> s;

		forn(j,m){
			M[i][j] = (s[j] == '+'?1:-1);
		}
	}

	nrof(i,n){
		nrof(j,m){
			dp[i][j] = -INF;

			if(i == n-1 && j == m-1){
				dp[i][j] = 0;
				continue;
			}

			if(i != n-1){
				dp[i][j] = max(dp[i][j], M[i+1][j] - dp[i+1][j]);
			}

			if(j != m-1){
				dp[i][j] = max(dp[i][j], M[i][j+1] - dp[i][j+1]);
			}
		}
	}

	if(dp[0][0] == 0){

		cout << "Draw\n";
	}else{
		cout << (dp[0][0] > 0 ? "Takahashi":"Aoki") << '\n';
	}

}

int main(){

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

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

    return 0;
}

/*
PRESTA ATENCAO!!!!

NAO FIQUE PRESO EM UMA ABORDAGEM
A SUA INTUICAO PODE ESTAR ERRADA - TENTE OUTRAS COISAS
LIMPOU TUDO PARA O PROXIMO CASO?
caso especial? n == 1

*/

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;

void solve(int tc)
{
    int h, w; cin >> h >> w;
    vector<string> board(h);
    for (int i = 0; i < h; i++)
        cin >> board[i];

    auto inc = [&](int i, int j) {
        return (board[i][j] == '+') == ((i + j) % 2 == 1);
    };

    vector<vector<int>> dp(h, vector<int>(w));
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (i == 0 && j == 0)
                continue;
            if (inc(i, j))
                dp[i][j]++;
            else
                dp[i][j]--;
        }
    }
    for (int i = h-1; i >= 0; i--)
    {
        for (int j = w-1; j >= 0; j--)
        {
            bool taka = (i + j) % 2 == 0;
            if (i == h-1 && j == w-1)
                continue;
            else if (i == h-1)
                dp[i][j] += dp[i][j+1];
            else if (j == w-1)
                dp[i][j] += dp[i+1][j];
            else if (taka)
                dp[i][j] += max(dp[i][j+1], dp[i+1][j]);
            else
                dp[i][j] += min(dp[i][j+1], dp[i+1][j]);
        }
    }

    int score = dp[0][0];
    if (score > 0)
        cout << "Takahashi\n";
    else if (score < 0)
        cout << "Aoki\n";
    else
        cout << "Draw\n";
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	int T = 1;
	for (int t = 1; t <= T; t++)
        solve(t);
}


#include<bits/stdc++.h>
#define int long long
#define N 200015
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define lowbit(i) ((i)&(-i))
#define VI vector<int>
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
using namespace std;
int n,a[N];
signed main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%lld",&n);
	rep(i,1,n) scanf("%lld",&a[i]);
	int Max = 0,sum = 0,res = 0;
	rep(i,1,n){
		Max = max(Max,a[i]);
		sum += a[i];
		res += sum;
		printf("%lld\n",1ll*i*Max+res);
	}
	return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define el '\n'
#define bizarre  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<pair<int, int> , null_type,less<pair<int, int> >, rb_tree_tag,tree_order_statistics_node_update>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
using namespace std;
void err(istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << endl;err(++it, args...);}
const ll N = 500 + 5,mod = 1e9 + 7, inf = 1e18;

int main() {
    bizarre
    int t = 1;
    //cin >> t;
    while (t--) {
        int n,w;
        cin >> n >> w;
        cout << n/w;
    }
    return 0;
}


#include <stdio.h>
int t;
long long p = 1000000007;
long long n, a, b, x, y, z, w;
int main() {
	scanf("%d", &t);
	for (int q = 0; q < t; q++) {
		scanf("%lld%lld%lld", &n, &a, &b);
		if (a + b > n) {
			printf("0\n");
			continue;
		}
		x = n - a - b + 2;
		y = x - 1;
		z = (n - a + 1) * (n - b + 1) % p;
		z *= 2 * x;
		z %= p;
		z *= y;
		z %= p;
		w = x * y % p;
		w *= x * y % p;
		w %= p;
		z += p - w;
		printf("%lld\n", z % p);
	}
}

#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

LLI power(LLI a, LLI b) { LLI res = 1; while (b > 0) { if (b & 1)res = res * a % MOD; a = a * a % MOD; b >>= 1; }return res; }
int main()
{
	cout << fixed << setprecision(10);

	int t;
	cin >> t;

	REP(i, t)
	{
		LLI n, a, b;
		cin >> n >> a >> b;

		LLI x4 = (n - a - b + 2) * (n - a - b + 1) / 2;
		if (n - a - b < 0)x4 = 0;
		LLI x3 = 2 * x4;
		LLI x2 = (n - a + 1) * (n - b + 1) - x3;
		x2 %= MOD;
		LLI x1 = x2 * x2;

		cout << ((power(n - a + 1, 2) * power(n - b + 1, 2)) % MOD + MOD - x1 % MOD) % MOD << endl;
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
#define ld long double
int32_t main(){
   fastIO
   int n,d,h; cin>>n>>d>>h;
   ld dd=d,hh=h;
   vector<int> hs,ds;
   ld ans=0.0;
   rep(i,0,n){
       ld hi,di; cin>>di>>hi;
       ld x=dd*(hh-hi)/(dd-di);
       ans=max(ans,hh-x);
   }
   cout<<fixed<<setprecision(5);
    cout<<ans<<"\n";
   return 0;
}

/*  *Which of the favors of your Lord will you deny ?*  */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define vpnt(ans)                       \
    for (ll i = 0; i < ans.size(); i++) \
        cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
#define setbit(x, k) (x |= (1LL << k))
#define clearbit(x, k) (x &= ~(1LL << k)) //x er last theke k-1 tomo ghor
#define checkbit(x, k) (x & (1LL << k))
#define mp make_pair
#define scl(x) scanf("%lld", &x)
#define sci(x) scanf("%d", &x)
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ff first
#define ss second
#define pii pair<int, int>
#define YES printf("YES\n")
#define Yes printf("Yes\n")
#define yes printf("yes\n")
#define NO printf("NO\n")
#define No printf("No\n")
#define no printf("no\n")
#define nn cout << "\n";
#define INF (1 << 30)
#define LL_INF (1LL << 32)
#define pll pair<ll, ll>
#define pp(n, p) (ll)(pow(n, p) + 0.5)
#define ok ios::sync_with_stdio(false);
#define fine cin.tie(nullptr);
#define mod 1000000007
#define N 505

int main()
{
    int n, m;
    cin>>n>>m;
    int a[m+1];
    for(int i=0; i<m; i++) cin>>a[i];
    sort(a, a+m);
    int p = 0;
    int mn = INF;
    vector<int>v;
    for(int i=0; i<m; i++)
    {
        int d = a[i]-p-1;
        if(d)
        {
            mn = min(d, mn);
            v.pb(a[i]-p-1);
        }
        p = a[i];
    }
    if(n-p>0) mn = min(n-p, mn);
    v.pb(n-p);

    if(mn==0) {cout<<0;nn; return 0;}
    int res = 0;
    for(int i=0; i<v.size(); i++)
    {
        res += ceil((double) v[i]/mn);
    }
    cout<<res;nn;
}


#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
//using namespace atcoder;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

#define debug(v) cout<<#v<<": ",prt(v);
template <typename A,typename B>
inline void prt(pair<A,B> p){cout<<"("<<p.first<<", "<<p.second<<")\n";}
template <typename A,typename B,typename C>
inline void prt(tuple<A,B,C> p){cout<<"("<<get<0>(p)<<", "<<get<1>(p)<<", "<<get<2>(p)<<")\n";}
inline void prt(bool p){if(p)cout<<"True"<<'\n';else cout<<"False"<<'\n';}
template <typename T>
inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template<typename T>
inline void prt(vector<vector<T> >& vv){ for(const auto& v : vv){ prt(v); } }
template <typename T>
inline void prt(deque<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(unordered_map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename T>
inline void prt(set<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
template <typename T>
inline void prt(multiset<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}

/*
dp[i][S]=a[i]まで決まったときに使った集合がSであり条件を満たす場合の数
dp[S]=Sまで決まったときに条件を満たす場合の数

条件を満たさない場合はdp[i][S]=0にする
未訪問をdp[i][S]=-1にする
ans:dp[n][(1<<n)-1]
*/

ll n,m;
vector<ll>x,y,z;

vector<ll>dp;

ll rec(ll S){
	if(dp[S]!=-1)return dp[S];
	//条件を満たすかcheck
	int cnt = __builtin_popcount(S);
	rep(i,m){
		if(cnt!=x[i])continue;
		int now = 0;
		rep(j,y[i]){
			if((S>>j)&1)now++;
		}
		if(now>z[i]){
			return dp[S] = 0;
		}
	}
	ll res = 0;
	rep(i,n){
		if((S>>i)&1){
			res += rec(S^(1<<i));
		}
	}
	return dp[S] = res;
}

int main(){
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	cin >> n >> m;
	x.resize(m);
	y.resize(m);
	z.resize(m);
	rep(i,m)cin>>x[i]>>y[i]>>z[i];
	dp.resize((1<<n),-1);
	dp[0]=1;
	cout << rec((1<<n)-1) << endl;
	//debug(dp);

	return 0;
}

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

#define   FASTIO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   int  long long
#define    pii pair<int,int>
#define   vi vector<int >
#define   all(a) (a).begin(), (a).end()
#define   rep(i,a,b)  for(int  i=a;i<b;i++)
#define   tr(it, a)   for(auto it=a.begin();it!=a.end();it++)
#define   pb push_back
#define    F first
#define    S second
#define   endl  "\n"
#define   dbg(x,y) cout<<(x)<<" -->  "<<(y)<<endl

const int  N = 2e5 + 1;
const int  inf = 1e18 + 3;
const int  ninf = -1e9 ;
const int  mod = 1e9 + 7;
//--------------------------------------------------------------//

int find(int x)
{
    int r = 0;
    while (x)
    {
        r += (x % 10);
        x = x / 10;
    }
    return r;
}

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

    vector<pair<double, double>>v;

    rep(i, 0, n)
    {
        int x, y; cin >> x >> y;
        v.pb({x, y});
    }
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            double  m = ((v[j].S - v[i].S) / (v[j].F - v[i].F));

            if (m <= (double)1  and  m >= (double) - 1)
            {
                cnt++;
            }
        }
    }
    cout << cnt << endl;

}

signed main()
{

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

    FASTIO;
    int T = 1;
    //cin >> T;

    for (int t = 1; t <= T; t++)
    {
        solve();
    }
    return 0;
}


/* in the name of Anton */

/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#ifdef ARYANC403
    #include "/home/aryan/codes/PastCodes/template/header.h"
#else
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
    #pragma GCC optimize ("-ffloat-store")
    #include<iostream>
    #include<bits/stdc++.h>
    #define dbg(args...)
#endif

using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) ((lli)(x).size())
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

const auto start_time = std::chrono::high_resolution_clock::now();
void aryanc403()
{
#ifdef ARYANC403
auto end_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
#endif
}

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    repA(i,1,n) repA(j,1,n/i)   repA(k,1,n/i/j) cnt++;
    cout<<cnt<<endl;
}   aryanc403();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }
long long gcd(long long a, long long b) { return (a % b) ? gcd(b, a % b) : b; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

template<typename T>
vector<T> get_divisor(T n) {
    vector<T> res;
    for (long long i = 1; (i * i) <= n; i++) {
        if (n % i != 0) continue;
        res.push_back(i);
        if ((i * i) != n) res.push_back(n / i);
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    auto div = get_divisor(2 * n);
    ll ans = 0;
    for(auto x : div) {
        if ((x + 1) % 2 == 0) {
            ans++;
        }
    }
    cout << (ans * 2) << endl;
    return 0;
}

#include<bits/stdc++.h>
#define fi                first
#define se                 second
#define ll               long long
#define mod              1000000007LL
#define endl              "\n"
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                push_back
#define all(v)             v.begin(),v.end()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define pll              pair<long long,long long>
using namespace std;
//queue<ll> q;
ll cnt=0;
//vector<ll> adj[3000005];
//vector<ll> a(1000005),b(100005);
//vector<bool> vis(3000005,false);
//ll ed,ve;
ll timer =0;
vector<pll> vp;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<ll,ll> &a,
              const pair<ll,ll> &b)
{
        return (a.fi>b.fi);
}
ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}
/*ll  dfs(ll node)
{
   vis[node]=true;
   ll c=1;
   //ll c=adj[node].size();
   for(auto x:adj[node])
   {
       if(vis[x]==false)
       {
           c+=dfs(x);
       }
   }
   a[node]=c;
   return c;
}
void bfs(ll node)
{
    vis[node]=true;
    for(auto x:adj[node])
    {
        if(vis[x]==false)
        {
            bfs(x);
        }
    }
}*/
int main()
{
 fast;
     int t=1;
     //cin>>t;
     while(t--)
     {
      ll n,k,i,j,maxi=0,sum=0,c=0,d=0,e=0,f=0,g=0,h=0;
      cin>>n;
      set<ll> s;
      for(i=0;i<n;i++)
      {
          cin>>c;
          s.insert(c);
      }
      while(s.size()!=1)
      {
          auto it=s.begin(),it1=s.end();
          it1--;
          c=*it1;
          d=*it;
          s.erase(c);
          s.insert(c-d);
      }
      auto it=s.begin();
      c=*it;
      cout<<c<<endl;

     }
}


#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define endl "\n"
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
const ll INF = (ll)0x3f3f3f3f3f3f3f, MAX = 9e18, MIN = -9e18;
const double PI=acos(-1.0);
const double eps=1e-6;
const ll mod=1e9+7;
const int inf=0x3f3f3f3f;
const int maxn=1e2+10;
const int maxm=100+10;
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x&(-x))
using namespace std;
ll n,m,k;
ll a[maxn];
ll dp[maxn];
int vis[maxn];
ll ans = 0;
ll sum[maxn];
int r;
void dfs(ll sum1,int r){
    if(sum1 > k)
       return ;
    ans = max(ans,sum1);
    if(sum[r] + sum1 <= k){
        ans = max(sum[r] + sum1,ans);
        return ;
    }
    if(ans == k){
        return ;
    }
    for(int i = 1; i<=r; i++){
        if(vis[i] == 1)
            continue;
        if(sum1 + a[i] > k){
            return ;
        }
        vis[i] = 1;
        dfs(sum1+a[i],i-1);
        vis[i] = 0;
    }
}
void run_case(){
    cin>>n>>k;
    ll sum1 = 0;
    for(int i = 1; i<=n; i++){
        cin>>a[i];
        sum1 += a[i];
    }
    if(sum1 <= k){
        cout<<sum1<<endl;
        return ;
    }
    sort(a+1,a+n+1);
    for(int i = 1; i<=n; i++)
        sum[i] = sum[i-1] + a[i];
    for(int i = n; i>=1; i--){
        vis[i] = 1;
        dfs(a[i],i-1);
        vis[i] = 0;
    }
    cout<<ans<<endl;
}

int main(){
    ios;
    run_case();
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
ll power(ll base, ll exp)
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
ll powerm(ll base,ll exp,ll mod)
{ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
/*{{ x | (1 << k) sets the kth bit of x to one
x & ~(1 << k) sets the kth bit of x to zero
x ^ (1 << k) inverts the kth bit of x.
x & (x-1) sets the last one bit of x to zero
x & -x sets all the one bits to zero, except for the last one bit.
x | (x-1) inverts all the bits after the last one bit.}} SOME BIT MANIPULATION*/
//__builtin_clz(x): the number of zeros at the beginning of the number
//__builtin_ctz(x): the number of zeros at the end of the number
//__builtin_popcount(x): the number of ones in the number
//__builtin_parity(x): the parity (even or odd) of the number of ones
struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
	{
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const
	{
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
/*//DSU
int parent[200005];
int rankr[200005];
int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
void make_set(int v) {
    parent[v] = v;
    rankr[v] = 0;
}
void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rankr[a] < rankr[b])
            swap(a, b);
        parent[b] = a;
        if (rankr[a] == rankr[b])
            rankr[a]++;
    }
} */

int main()
{
	fast;
	ll t; t = 1;
	while(t--)
	{
		string s,t; cin>>s>>t;
		int a1 = 0, a2 = 0;
		for(auto &c : s)
			a1 += c - '0';
		for(auto &c : t)
			a2 += c - '0';
		if(a1 == a2)
			cout << a1 << endl;
		else
			cout << max(a1,a2) << endl;
	}
	return 0;
}

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

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

  a = A/100+(A/10)%10+A%10;
  b = B/100+(B/10)%10+B%10;
  if(a>=b){
    cout << a << endl;
  }else{
    cout << b << endl;
  }
}


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

int main() {
    int N;
    cin >> N;
    double x, y, X, Y;
    cin >> x >> y >> X >> Y;
    double dx = X - x;
    double dy = Y - y;
    double r = sqrt(dx * dx + dy * dy);
    double th = (double) 360 / N * acos(-1) / 180.0;
    double x0 = x - (x + X) / 2;
    double y0 = y - (y + Y) / 2;
    double x1 = cos(th) * x0 - sin(th) * y0;
    double y1 = sin(th) * x0 + cos(th) * y0;
    cout << x1 + (x + X) / 2 << " " << y1 + (y + Y) / 2 << "\n";
    return 0;
}

#include<bits/stdc++.h>
#include<vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MOD 1000000007
#define MAX 200005
#define PMAX 55
#define EPS 0.000001
#define INF 2000000000000000000
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
pair<double,double> polar_co(double x,double y)
{
    pair<double,double> ans;
    if(abs(x)<EPS)
    {
        if(y<0) ans.second=-acos(-1)/2;
        else ans.second=acos(-1)/2;
    }
    else
    {
        ans.second=atan(y/x);
        if(x<0)
        {
            if(y>0) ans.second=ans.second+acos(-1);
            else ans.second=ans.second-acos(-1);
        }
    }
    ans.first=sqrt(x*x+y*y);
    return ans;
}
pair<double,double> cart_co(pair<double,double> p)
{
    pair<double,double> ans=make_pair((p.first)*(cos(p.second)),(p.first)*(sin(p.second)));
    return ans;
}
int main()
{
    int n,i;
    scanf("%d",&n);
    double x[2],y[2];
    for(i=0;i<2;i++)
    {
        scanf("%lf %lf",&x[i],&y[i]);
    }
    double cx=(x[0]+x[1])/2;
    double cy=(y[0]+y[1])/2;
    double angle=acos(-1);
    angle=angle*2/n;
    for(i=0;i<2;i++)
    {
        x[i]-=cx;
        y[i]-=cy;
    }
    pair<double,double> p=polar_co(x[0],y[0]);
    //printf("Pol(%f,%f)\n",p.first,p.second);
    p.second=p.second+angle;
    p=cart_co(p);
    //printf("car(%f,%f)\n",p.first,p.second);
    p.first=p.first+cx;
    p.second=p.second+cy;
    printf("%f %f",p.first,p.second);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9+7;
const long long inv = (mod+1)/2;

long long mpow(long long a, long long b){
    if(b==0)return 1;
    if(b==1)return a;
    long long res = mpow(a, b/2);
    res *= res;
    res %= mod;
    if(b&1){
        res *= a;
        res %= mod;
    }
    return res;
}

vector<vector<long long>> mul(vector<vector<long long>>&A, vector<vector<long long>>&B){
    int n = A.size();
    vector<vector<long long>>C(n, vector<long long>(n, 0));
    int i, j, k;
    for(i=0;i<n;i++){
        for(k=0;k<n;k++){
            for(j=0;j<n;j++){
                C[i][j] += A[i][k]*B[k][j] % mod;
                if(C[i][j]>=mod)C[i][j] -= mod;
            }
        }
    }
    return C;
}

vector<vector<long long>> mmpow(vector<vector<long long>>&A, int n){
    if(n==0){
        int n = A.size();
        vector<vector<long long>> C(n, vector<long long>(n, 0));
        for(int i=0;i<n;i++)C[i][i] = 1;
        return C;
    }
    if(n==1)return A;
    vector<vector<long long>> C = mmpow(A, n/2);
    C = mul(C, C);
    if(n&1)C = mul(C, A);
    return C;
}

int main(){
    int a;
    int n, m, kk;
    int i, v, j;
    cin >> n >> m >> kk;
    vector<long long>A(n);
    for(i=0;i<n;i++){
        cin >> A[i];
    }
    vector<vector<long long>> P(n, vector<long long>(n, 0));
    for(i=0;i<n;i++)P[i][i] = 2*m;
    for(i=0;i<m;i++){
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        P[x][x] -= 1;
        if(P[x][x]<0)P[x][x] += mod;
        P[x][y] += 1;
        P[y][x] += 1;
        P[y][y] -= 1;
        if(P[y][y]<0)P[y][y] += mod;
    }
    vector<vector<long long>> Q = mmpow(P, kk);
    long long p = mpow(2*m, mod-2);
    long long l = mpow(p, kk);
    for(i=0;i<n;i++){
        long long ans = 0;
        for(j=0;j<n;j++){
            ans += Q[i][j]*A[j]%mod;
            ans %= mod;
        }
        ans *= l;
        ans %= mod;
        cout << ans << "\n";
    }
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007ll //998244353ll
#define lld long double
#define mii map<int, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
const long long N=100005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
typedef vector<int> row;
typedef vector<row> matrix;

matrix matrix_mul(matrix a, matrix b) {
    int n = a.size(), m = a[0].size(), p = b[0].size();
    assert(m == b.size());
    matrix ans(n, row(p, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < p; ++j) {
            for (int k = 0; k < m; ++k) {
                ans[i][j] += a[i][k] * b[k][j];
                ans[i][j] %= (mod);
            }
        }
    }
    return ans;
}

matrix matrix_pwr(matrix a, int e) {
    if(e==0)
    {
        matrix res=a;
        int n=res.size();
        rep(i,0,n)
        {
            rep(j,0,n)
            {
                if(i==j)
                res[i][j]=1;
                else
                res[i][j]=0;
            }
        }
        return res;
    }
    matrix res = a;
    --e;
    while (e) {
        if (e & 1) {
            res = matrix_mul(res, a);
        }
        a = matrix_mul(a, a);
        e /= 2ll;
    }
    return res;
}
int32_t main()
{
    IOS;
    int n, m, k;
    cin>>n>>m>>k;
    matrix og;
    row ar;
    int deg[n];
    fill(deg, 0);
    rep(i,0,n)
    {
        int x;
        cin>>x;
        ar.pb(x);
    }
    og.pb(ar);
    matrix a;
    ar.clear();
    rep(i,0,n)
    ar.pb(0);
    rep(i,0,n)
    a.pb(ar);
    int inv=power((2ll*m), mod-2, mod);
    rep(i,0,m)
    {
        int x, y;
        cin>>x>>y;
        x--, y--;
        deg[x]++;
        deg[y]++;
        a[x][y]=inv;
        a[y][x]=inv;
    }
    rep(i,0,n)
    {
        a[i][i]=(((2ll*m)-deg[i])*inv)%mod;
    }
    // cout<<inv<<"\n";
    // print2d(a, n-1, n-1);
    // rep(i,0,n)
    // cout<<og[0][i]<<" ";
    // print2d(a, n-1, n-1);
    a=matrix_pwr(a, k);
    // print2d(a, n-1, n-1);
    matrix fin=matrix_mul(og, a);
    rep(i,0,n)
    cout<<fin[0][i]<<"\n";
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define range(i, a, b) for (ll i = (a); i < (b); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << (x) << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
template<class T> using pri_s = priority_queue<T, vector<T>, greater<T>>;
template<class T> using pri_b = priority_queue<T>;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr int mod1e9 = 1000000007;
constexpr int mod998 = 998244353;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
constexpr ll ten(int n) { return n ? 10 * ten(n - 1) : 1; };
int dx[] = { 1,0,-1,0,1,1,-1,-1 }; int dy[] = { 0,1,0,-1,1,-1,1,-1 };
ll mul(ll a, ll b) { return (a > INF / b ? INF : a * b); }
void fail() { cout << "-1\n"; exit(0); } void no() { cout << "No\n"; exit(0); }
template<class T> void er(T a) { cout << a << '\n'; exit(0); }
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
template<class T> istream &operator >> (istream &s, vector<T> &v) { for (auto &e : v) s >> e; return s; }
template<class T> ostream &operator << (ostream &s, const vector<T> &v) { for (auto &e : v) s << e << ' '; return s; }
template<class T, class U> ostream &operator << (ostream &s, const pair<T, U> &p) { s << p.first << ' ' << p.second; return s; }

struct fastio {
	fastio() {
		cin.tie(0); cout.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(20);
		cerr << fixed << setprecision(20);
	}
}fastio_;

const int N = 200010;
vector<vector<int>> graph(N, vector<int>());
vector<int> xd(N), yd(N);

void dfs(int n, int p, int d, vector<int> &v) {
	v[n] = d;
	for (int i : graph[n]) {
		if (i != p) dfs(i, n, d + 1, v);
	}
}

vector<int> ans(N);

void tour(int n, int p, vector<int> &v) {
	v.pb(n);
	for (int i : graph[n]) {
		if (i != p && ans[i] == 0) {
			tour(i, n, v);
			v.pb(n);
		}
	}
}

int main() {
	int n;
	cin >> n;
	rep(i, n - 1) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		graph[u].pb(v);
		graph[v].pb(u);
	}
	dfs(0, -1, 0, xd);
	int ver = -1; int m = 0;
	rep(i, n) if (chmax(m, xd[i])) ver = i;
	dfs(ver, -1, 0, xd); int rver = 0; m = 0;
	rep(i, n) if (chmax(m, xd[i])) rver = i;
	dfs(rver, -1, 0, yd);
	rep(i, n) {
		int r = -1;
		vector<int> nv;
		for (int nxt : graph[i]) {
			if (yd[nxt] < yd[i]) {
				r = nxt;
			}
			else nv.pb(nxt);
		}
		if (r != -1) nv.pb(r);
		graph[i] = nv;
	}
	vector<int> vec;
	tour(ver, -1, vec);
	rep(i, vec.size()) {
		if (ans[vec[i]] == 0) ans[vec[i]] = i + 1;
	}
	rep(i, n) cout << ans[i] << ' ';
	cout << '\n';
}

//Author: RingweEH
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define ll long long
#define db double
using namespace std;
int min( int a,int b ) { return a<b ? a : b; }
int max( int a,int b ) { return a>b ? a : b; }
void bmax( int &a,int b ) { a=(a>b) ? a : b; }
void bmin( int &a,int b ) { a=(a<b) ? a : b; }
const int L=1<<20;
char buf[L],*p1,*p2;
#define getchar() (p1==p2?(p2=buf+fread(p1=buf,1,L,stdin),p1==p2?EOF:*p1++):*p1++)
int read()
{
    int x=0,w=1; char ch=getchar();
    while ( ch>'9' || ch<'0' ) { if ( ch=='-' ) w=-1; ch=getchar(); }
    while ( ch<='9' && ch>='0' ) x=x*10+ch-'0',ch=getchar();
    return x*w;
}

const int N=2e5+10;
//struct Edge{ int to,nxt; }e[N<<1];
int n,dep[N],rt,head[N],tot=1;
int height[N],ans[N],cnt=0;
vector<int> g[N];

void Adde( int u,int v ) { g[u].push_back(v); g[v].push_back(u); }
bool cmp( int x,int y ) { return height[x]<height[y]; }
void DFS( int u,int fat )
{
	for ( int v : g[u] )
		if ( v^fat ) dep[v]=dep[u]+1,DFS(v,u);
}
void DFS2( int u,int fat )
{
	height[u]=0;
	for ( int v : g[u] )
		if ( v^fat ) DFS2(v,u),bmax(height[u],height[v]);
	height[u]++;
}
void GetAns( int u,int fat )
{
	ans[u]=++cnt;
	for ( int v : g[u] )
		if ( v^fat ) GetAns(v,u);
	cnt++;
}

int main()
{
//freopen( "exam.in","r",stdin );

	n=read();
	for ( int i=1,u,v; i<n; i++ ) u=read(),v=read(),Adde(u,v);

	DFS(1,0); int tmp=0;
	for ( int i=1; i<=n; i++ ) if ( dep[i]>tmp ) tmp=dep[i],rt=i;
	DFS2(rt,0);
	for ( int i=1; i<=n; i++ ) sort(g[i].begin(),g[i].end(),cmp);
	GetAns(rt,0);

	for ( int i=1; i<=n; i++ ) printf("%d ",ans[i] );

	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  vector<vector<int>> t(n,vector<int>(n));
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j) cin >> t[i][j];
  }
  int x1,x2;
  vector<int> p;
  for(int i=1;i<n;++i) p.push_back(i);
  int sum;
  int num=0;
  do {
    sum = 0;
    x1 = 0;
      for(auto x2 : p){
        //cout<<x2+1<<" ";
        sum += t[x1][x2];
        x1 = x2;
      }
    sum += t[x1][0];
    //cout<<"sum= "<<sum<<" "<<x1<<endl;
    if(sum==k) num++;
  } while( next_permutation(p.begin(), p.end()) );

  cout<<num<<endl;

}

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using ll = long long;
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define ALL(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; i++)

#define INF (int)1e9
#define LLINF (long long)1e12
#define MOD (int)1e9 + 7
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define co cout <<
#define en << endl;
#define __MAGIC__              \
  ios::sync_with_stdio(false); \
  cin.tie(nullptr);

#define YESNO(T)           \
  if (T)                   \
  {                        \
    cout << "YES" << endl; \
  }                        \
  else                     \
  {                        \
    cout << "NO" << endl;  \
  }
#define yesno(T)           \
  if (T)                   \
  {                        \
    cout << "yes" << endl; \
  }                        \
  else                     \
  {                        \
    cout << "no" << endl;  \
  }
#define YesNo(T)           \
  if (T)                   \
  {                        \
    cout << "Yes" << endl; \
  }                        \
  else                     \
  {                        \
    cout << "No" << endl;  \
  }

#define Graph vector<vector<int>>
#define PII pair<int, int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int, int>>
#define VS vector<string>
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define DDD fixed << setprecision(10)

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/

/*.....................DEFINE FUNCTIONS ......................*/
ll dist(ll x, ll y)
{
  return (x * x) + (y * y);
};

vector<long long> divisor(long long n)
{
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end()); // 昇順に並べる
  return ret;
}

/*.........................kemkemG0...........................*/
signed main()
{
  __MAGIC__
  int n, k;
  cin >> n >> k;
  vector<vector<int>> root(n, vector<int>(n));
  rep(i, n)
  {
    rep(j, n)
    {
      cin >> root[i][j];
    };
  };
  vector<int> index;
  rep(i, n) index.push_back(i);

  int ans = 0;
  do
  {
    int time = 0;
    rep(i, n)
    {
      time += root[index[i]][index[(i + 1) % n]];
      if (time == k)
        ans++;
    };
  } while (next_permutation(index.begin() + 1, index.end()));
  co ans en

      return 0;
}


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

int main() {
  int n; cin >> n;
  int amax = 0;
  int bmin = 1000;

  int tmp;
  REP(i, n) {
    cin >> tmp;
    if (tmp > amax) amax = tmp;
  }
  REP(i, n) {
    cin >> tmp;
    if (tmp < bmin) bmin = tmp;
  }

  if (amax > bmin) {
    cout << 0 << endl;
  } else {
    cout << bmin - amax + 1 << endl;
  }

  return 0;
}

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

using namespace std;

int main(){
int n;
cin >> n;
vector<int> a(n), b(n);
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < n; i++) cin >> b[i];

int m = 0, M = 1001;
for(int i = 0; i < n; i++){
    m = max(m, min(a[i], b[i]));
    M = min(M, max(a[i], b[i]));
  }
if(M >= m) cout << M - m + 1 << endl;
else cout << 0 << endl;

return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long
#define double long double

#define vi vector<int>
#define pii pair<int,int>
#define si set<int>
#define mii map<int,int>

#define F first
#define S second

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define eb emplace_back
#define ef emplace_front

signed main(){

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

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<min( min(a,b) , min(c,d) )<<endl;

    return 0;

}

#include "bits/stdc++.h"
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

const int N=0;

void solve(){
	int a[4];
	int ans = INF;
	rep(i,0,4){
		cin>> a[i];
		amin(ans,a[i]);
	}
	cout <<  ans;
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SIEVE
		sieve();
	#endif
	#ifdef NCR
		init();
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


#include<bits/stdc++.h>
#define M_PI       3.14159265358979323846
#define Speed_UP  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define 	pb	push_back
#define 	ff	first
#define 	ss	second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#warning Remember to change t
inline void setIO();
using namespace std;
typedef long long ll;
typedef long double ld;

int solve(){
  ll n,m,t;
  cin>>n>>m>>t;
  vector<int>times(2*m+2);
  times[0]=0;
  for(int i=1;i<=2*m;i++){
    cin>>times[i];
  }
  times[2*m+1]=t;
  ll turn=0;
  ll curt=n;
  for(int i=0;i<=2*m;i++,turn^=1){
    ll j=i+1;
    if(turn==0){
      curt-=times[j]-times[i];
      if(curt<=0){
        cout<<"No";
        return 0;
      }
    }else{
      curt+=times[j]-times[i];
      if(curt>n)
        curt=n;
    }

  }
  cout<<"Yes";

  return 0;
  }

int main(){
	Speed_UP
	ll t = 1;
	while(t--){
		solve();
	}
}

inline void setIO(string name="") {
	#ifndef ONLINE_JUDGE
	freopen((name+".in").c_str(), "r", stdin);
	freopen((name+".out").c_str(), "w", stdout);
	#endif
	}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD 1000000007
#define MOD2 1000000009
#define endl "\n"
#define pii pair <int, int>
#define pll pair <ll, ll>
#define F first
#define S second

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

    ll n, m, t;
    cin >> n >> m >> t;
    std::vector<pll> v(m);

    ll limit = n;

    for(int i = 0; i < m; i++) {
        cin >> v[i].F >> v[i].S;
    }
    n -= v[0].F;

    for(int i = 0; i < m; i++) {
      //  n -= v[i].F;
        if(n <= 0) {
            break;
        }
        if(n >= limit)
            n = limit;
        if(n != limit)
            n += (v[i].S - v[i].F);
        if(n >= limit)
            n = limit;
        if(i < m - 1)
            n -= (v[i + 1].F - v[i].S);

        if(n <= 0) {
            break;
        }
    }
   // cout << n;
    n -= (t - v[m - 1].S);
    if(n <= 0) {
        cout << "No";
    }
    else {
        cout << "Yes";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,j,n) for(int i=j;i<n;i++)
#define readvec(v,n) for(int i=0;i<n;i++){cin>>v[i];}
#define MOD 1000000007
int main()
{
  int a,b,w;cin>>a>>b>>w;w*=1000;
  if(w<a){cout<<"UNSATISFIABLE";return 0;}
  int t=w%a;
  if(w<a||(a+((double)(t))/(w/a)>(double)b)){cout<<"UNSATISFIABLE";return 0;}

  int x=min(w,b);
  if(w%x==0)cout<<w/x; else cout<<w/x+1; cout<<" ";
  if(w%a==0)cout<<w/a; else cout<<w/a; cout<<"\n";
  return 0;
}

//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <array>
#include <unordered_map>
#include<unordered_set>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<complex>
#include<fstream>
#include<assert.h>

#include<stdio.h>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-16;

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

	int A, B, W;
	cin >> A >> B >> W;

	W *= 1000;
	int mi = INF, ma = 0;

	rep(i, 1, W + 1)
	{
		if (A*i <= W && W <= B * i)
		{
			chmin(mi, i);
			chmax(ma, i);
		}
	}

	if (mi == INF)cout << "UNSATISFIABLE" << endl;
	else
	cout << mi << " " << ma << endl;

	return 0;
}


#include <bits/stdc++.h>
#define rep(i,begin, end) for (ll i = begin; i < (ll)(end); i++)

using namespace std;
using ll = long long;

template<typename T>
using vec2 = vector<vector<T>>;
template<typename T>
using vec3 = vec2<vector<T>>;
template<typename T>
using vec4 = vec3<vector<T>>;
template<typename T>
using vec5 = vec4<vector<T>>;
template<typename T>
using vec6 = vec5<vector<T>>;

int gcd(int a, int b){
    if(b == 0)return a;
    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 g = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return g;
}
//ax+by=cをみたす整数x,y
bool solveLinearEquation2(ll a, ll b, ll c, ll &x, ll &y){
    if(c % gcd(a,b) != 0)return false;
    /*
        (a/d)X+(b/d)Y=c/d
        (a/d)x+(b/d)y=1
        (a/d)(c/d)x+(b/d)(c/d)y=c/d
        X=(c/d)x-k(b/d)
        Y=(c/d)y+k(a/d)
        必要に応じてkを決める
    */
    ll d = extGCD(a,b,x,y);
    ll k = 0;
    x = (c/d)*x-k*(b/d);
    y = (c/d)*y+k*(a/d);

    return true;
}
ll MOD = 1000000007;

vector<ll> mfact(1,1);

ll minv(ll a){
    ll x;ll y;
    extGCD(a, MOD, x, y);
    if(x<0){
        x+= ((-x)/MOD+1)*MOD;
        x %= MOD;
    }
    return x;
}

ll mpow(ll a,ll b){
    ll res = 1;
    while(b > 0){
        if(b%2==1)res=(res*a)%MOD;
        b/=2;
        a = (a*a)%MOD;
    }
    return res;
}

ll mfactorial(ll a){
    if(mfact.size()-1 >= a)return mfact[a];
    for(ll i = mfact.size();i<=a;i++){
        mfact.push_back((i * mfact[i-1])%MOD);
    }
    return mfact[a];
}

ll mcomb(ll n, ll r){
    return (((mfactorial(n) * minv(mfactorial(r)))%MOD) * minv(mfactorial(n-r)))%MOD;
}
ll ipow(ll a, ll b){
    ll res = 1;
    while(b > 0){
        if(b % 2 == 1)res*=a;
        a*=a;
        b/=2;
    }
    return res;
}

void factorize(map<ll,ll>& fac, vector<ll>& sieved, ll a){
    while(a != 1){
        if(fac.find(sieved[a]) == fac.end())fac[sieved[a]] = 0;
        fac[sieved[a]]++;
        a/=sieved[a];

    }
}
/**
 * エラトステネスのふるい
 * res[i]はiの最小の素因数
 */
void primesieve(vector<ll>& res,ll n){
    res = vector<ll>(n+1, -1);
    for(int i = 2;i <= n;i++){
        if(res[i] != -1)continue;
        res[i] = i;
        for(int j = 2;j*i <= n;j++){
            res[j*i] = i;
        }
    }
}
/**
 * ふるい->素数だけ取り出す
 */
vector<ll> primesuntil(ll n){
    vector<ll> res;
    vector<ll> sieved;
    primesieve(sieved, n);
    for(int i = 2;i <= n;i++){
        if(sieved[i] == i)res.push_back(i);
    }
    return res;
}

int main(){
    ll N,P;cin>>N>>P;
    ll ans = P-1;
    ans = ans * mpow(P-2, N-1);
    ans %= MOD;
    cout<<ans<<endl;
}

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define maxn
ll mod=1e9+7;
inline ll ksm(ll a,ll b){
	ll ans=1,base=a;
	while(b){
		if(b&1) ans=ans*base%mod;
		base=base*base%mod;
		b/=2;
	}
	return ans;
}

int main(){
	ll n,p;
	cin>>n>>p;
	cout<<(p-1)*ksm(p-2,n-1)%mod;
	return 0;
}


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

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

    vector<int> A(M+2);
    A.at(0) = 0;
    A.at(1) = N+1;
    rep(i,M) cin >> A.at(i+2);

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

    int k = 1000000000;
    vector<int> vec(M+1);
    rep(i,M+1){
        int width = A.at(i+1) - A.at(i) - 1;
        vec.at(i) = width;
        if(width != 0) k = min(k, width);
    }

    int ans = 0;
    rep(i,M+1){
        ans += vec.at(i)/k;
        if(vec.at(i) % k != 0) ans ++;
    }

    cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0 ; i < n ; i++)
#define repl(i, n) for (ll i = 0 ; i < n ; i++)
#define Rep(i, n) for (int i = 1 ; i <= n ; i++)
#define Repl(i, n) for (ll i = 1 ; i <= n ; i++)
#define rep3(i, a, n) for (int i = a ; i < n ; i++)
#define pi 3.141592653589793238462643

int main() {
    ios::sync_with_stdio(false);
	ll n, m; cin >> n >> m;
  	vector<ll> v(m); rep(i,m) cin >> v[i];
  	sort(v.begin(), v.end());
  	vector<ll> space;
  	ll y = 1;
  	rep(i, m) {
    	ll dis = v[i] - y;
    	y = v[i] + 1;
    	if (dis != 0) space.push_back(dis);
  	}
  	if (y != n + 1) space.push_back(n + 1 - y);
  	sort(space.begin(), space.end());
  	ll res = 0;
  	rep(i, space.size()) res += (space[i] + space[0] - 1) / space[0];
  	cout << res;

}


#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using cd = complex<ld>;

struct edge {
  int from, to;
  char c;
};

vector<edge> g[1000];
bool calced[1000][1000];
int dp[1000][1000];

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

  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    char c;
    cin >> u >> v >> c;
    --u;
    --v;
    g[u].push_back({u, v, c});
    g[v].push_back({v, u, c});
  }
  queue<pii> pq;
  for (int i = 0; i < n; i++) {
    calced[i][i] = true;
    pq.emplace(i, i);
  }
  for (int i = 0; i < n; i++) {
    for (edge e : g[i]) {
      if (e.to != i) {
        calced[i][e.to] = true;
        dp[i][e.to] = 1;
        pq.emplace(i, e.to);
      }
    }
  }
  while (!pq.empty()) {
    auto[u, v] = pq.front();
    pq.pop();
    for (char c = 'a'; c <= 'z'; c++) {
      for (auto e1 : g[u]) {
        if (e1.c != c) {
          continue;
        }
        for (auto e2 : g[v]) {
          if (e2.c != c) {
            continue;
          }
          if (!calced[e1.to][e2.to]) {
            dp[e1.to][e2.to] = dp[u][v] + 2;
            calced[e1.to][e2.to] = true;
            pq.emplace(e1.to, e2.to);
          }
        }
      }
    }
  }

  cout << (calced[0][n - 1] ? dp[0][n - 1] : -1);
  return 0;
}

#include<bits/stdc++.h>
#define M 100005
typedef long long ll;
using namespace std;
bool f2;
char IO;
int rd(){
	int num=0;bool f=0;
	while(IO=getchar(),IO<48||IO>57)if(IO=='-')f=1;
	do num=(num<<1)+(num<<3)+(IO^48);
	while(IO=getchar(),IO>=48&&IO<=57);
	return f?-num:num;
}
int n,m;
struct node{
	int v;ll C,D;
};
vector<node> E[M];
ll dis[M];
bool vis[M];
struct Data{
	int idx;ll dis;
	bool operator<(const Data &_)const{
		return dis>_.dis;
	}
};
priority_queue<Data> Q;
void Dijkstra(){
	memset(dis,127,sizeof(dis));
	dis[1]=0;Q.push((Data){1,0});
	int u,v;ll tmp,t;
	while(!Q.empty()){
		u=Q.top().idx;
		Q.pop();
		if(vis[u])continue;
		vis[u]=1;
		for(int i=0;i<E[u].size();++i){
			t=sqrt(E[u][i].D);v=E[u][i].v;
			if(dis[u]>=t){
				tmp=dis[u]+E[u][i].C+E[u][i].D/(dis[u]+1);
			}else{
				tmp=t+E[u][i].C+E[u][i].D/(t+1);
			}
			if(tmp<dis[v]){
				dis[v]=tmp;
				if(!vis[v])
					Q.push((Data){v,dis[v]});
			}
		}
	}
	if(vis[n]==0){
		cout<<-1;
	}else cout<<dis[n];

}
bool f1;
int main(){
//	cout<<(&f1-&f2)/1024.0/1024.0<<endl;
	n=rd();m=rd();
	for(int i=1,u,v,C,D;i<=m;++i){
		u=rd(),v=rd(),C=rd(),D=rd();
		E[u].push_back((node){v,C,D});
		E[v].push_back((node){u,C,D});
	}
	Dijkstra();
	return 0;
}


#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b,ll mod=MOD){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % mod;
      x = x * x % mod;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    cin >> res;
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n = in();
    ll lp = 1;
    ll rp = min<ll>(sqrt(n)*2 + 10,n+1);
    while(lp<rp){
        ll mid = (lp + rp) / 2;
        if(mid * (mid+1) / 2 <= n+1){
            lp = mid + 1;
        }else{
            rp = mid;
        }
    }
    cout << n - lp + 2 << endl;
  return 0;
}

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
#include<string.h>
using namespace std;
#define pb      push_back
#define all(v)  v.begin(),v.end()
#define see(x)  cout<<endl<<#x<<" : "<<(x)<<endl;
#define ya      cout<<"YES"<<endl;
#define no      cout<<"NO"<<endl;
#define ff      first
#define sc      second
#define inf     999999999
#define pi      3.14159265359
inline  int     random(int a=1,int b=10){return a+rand()%(b-a+1);}
typedef long long ll;
typedef pair<int,int> pii;
const int N=500009;

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

    ll n,ans=0,i,j,k,f=0,o=0,x=0;

    cin>>n;

    string s;

    cin>>s;

    ans=n;

    stack<char>q;

    for(i=0;i<n;i++)
    {
        if(s[i]=='x')
        {
            if(q.size()>=2)
            {
                char c=q.top();
                q.pop();
                char d=q.top();
                q.pop();
//                see(c)
//                see(d)
                if(c=='o' && d=='f')
                {
                    ans-=3;
                }
                else
                {
                     while(!q.empty())
                     {
                         q.pop();
                     }
                }
            }
            else
            {
                while(!q.empty())
                {
                    q.pop();
                }
            }
            continue;
        }
        if(s[i]=='f')q.push(s[i]);
        else if(s[i]=='o')q.push(s[i]);
        else
        {
            while(!q.empty())
            {
                q.pop();
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}


// 解き直し.
// https://atcoder.jp/contests/arc111/editorial/519
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using PQ = priority_queue<P, vector<P>, greater<P>>;
using vPQ = vector<PQ>;
using vp = vector<P>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define a first
#define b second
int a[202020];  // 人 i の 体重.
int b[202020];  // 荷物 j の 重さ.
int ip[202020]; // 荷物 の index.
int ui[202020]; // 荷物 の index(更新用).
int op[202020]; // 人 i に置くべき荷物が, どこ(index)にあるか？

int main(){

    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    rep(i, N) scanf("%d", &a[i]);
    rep(i, N) scanf("%d", &b[i]);
    rep(i, N){
        scanf("%d", &ip[i]);
        ip[i]--;
        ui[i] = ip[i];
        op[ip[i]] = i;
    }

    // 2. 特殊パターン(※すでに条件を満たしている場合).
    bool ok = true;
    rep(i, N){
        if(ip[i] != i){
            ok = false;
            break;
        }
    }
    if(ok){
        puts("0");
        return 0;
    }

    // 3. 初期状態チェック.
    ok = true;
    // rep(i, N) if(a[i] <= b[ip[i]]) ok = false;
    rep(i, N) if(ip[i] != i && a[i] <= b[ip[i]]) ok = false; // 1_026.txt対応.
    if(!ok){
        puts("-1");
        return 0;
    }

    // 4. サイクルを抽出.
    int cycle[N], cur;
    memset(cycle, 0, sizeof(cycle));
    vPQ C;
    rep(i, N){
        // 4-1. サイクル保存用.
        PQ c;

        // 4-2. 頂点 i から スタート.
        cur = i;

        // 4-3. サイクルをチェック.
        while(!cycle[cur]){
            // 4-4. 訪問済みフラグを立てる.
            cycle[cur] = 1;

            // 4-5. サイクルに頂点を保存.
            c.push({a[cur], cur}); // { 人 cur の 体重, 頂点 cur }.

            // 4-6. 現在頂点を更新し, 次の頂点へ.
            cur = ip[cur];
        }

        // 4-7. サイクルを追加.
        if(c.size()) C.pb(c);
    }
    // rep(i, C.size()){
    //     puts("----- start -----");
    //     PQ pq = C[i];
    //     while(!pq.empty()){
    //         int ta = pq.top().a, tb = pq.top().b;
    //         pq.pop();
    //         printf("a=%d b=%d\n", ta, tb);
    //     }
    //     puts("-----  end  -----");
    // }

    // 5. 各サイクル.
    // -> 軽い人から順番に確定させる.
    vp ans;
    int memo[N]; // 訪問済フラグ.
    memset(memo, 0, sizeof(memo));
    rep(i, C.size()){
        // 5-1. サイクル取得.
        PQ pq = C[i];

        // 5-2. サイクルの頂点をチェック.
        // -> 頂点数が, 1 に なったら終了.
        while(pq.size() > 1){
            // 5-3. 人 j を 取得.
            int j = pq.top().b;
            pq.pop();

            // 5-4. 人 j の 荷物(※人 l が 持つべきもの).
            int l = ui[j];

            // 5-5. 人 j の 荷物 を 確定.
            if(!memo[j]){
                // 訪問済みフラグ設定.
                memo[j] = 1;

                // 人 j の 荷物の場所(※人 k が 持っている).
                int k = op[j];

                // 人 j, k の 荷物 を 交換.
                swap(ui[j], ui[k]); // 人 j, k の 持っている荷物を交換.
                swap(op[j], op[l]); // 荷物の場所に対応する 人 の 番号 を 交換.

                // 操作情報を追加.
                ans.pb({j, k});
            }
        }
    }

    // 6. 出力.
    int al = ans.size();
    printf("%d\n", al);
    rep(i, al) printf("%d %d\n", ans[i].a + 1, ans[i].b + 1);
    return 0;

}

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    cin >> N;
    vector<int> a(N), b(N), p(N);
    for (int i=0; i<N; ++i) cin >> a[i];
    for (int i=0; i<N; ++i) cin >> b[i];
    for (int i=0; i<N; ++i) {
        cin >> p[i];
        --p[i];
    }

    for (int i=0; i<N; ++i) {
        if (p[i] != i && a[i] <= b[p[i]]) {
            cout << -1 << '\n';
            return;
        }
    }

    vector<int> rp(N);
    for (int i=0; i<N; ++i) rp[p[i]] = i;
    vector<pair<int, int>> ans;
    auto swp = [&p, &rp, &ans](int i, int j) {
        if (i == j) return;
        ans.emplace_back(i+1, j+1);
        swap(p[i], p[j]);
        rp[p[i]] = i;
        rp[p[j]] = j;
    };
    vector<int> ids(N);
    iota(ids.begin(), ids.end(), 0);
    sort(ids.begin(), ids.end(), [&b](int i, int j){return b[i] > b[j];});
    for (int idx : ids) {
        swp(idx, rp[idx]);
    }

    cout << (int)ans.size() << '\n';
    for (auto p : ans) cout << p.first << ' ' << p.second << '\n';
}

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

    solve();

    return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, m;
vector<int> adj[MAXN];
int c[MAXN];

int d[18][MAXN];
int dp[MAXN][20];
void djk(int src, int idx){
    d[idx][src] = 0;
    queue<int> q;
    q.push(src);

    while(!q.empty()){
        int cur = q.front();
        q.pop();

        for(int j: adj[cur]){
            if(d[idx][j] <= d[idx][cur] + 1)
                continue;
            d[idx][j] = d[idx][cur] + 1;
            q.push(j);
        }
    }
}

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

    #ifdef Local
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/int.txt","r",stdin);
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/out.txt","w",stdout);
    #endif

    memset(d, 0x7f, sizeof(d));
    memset(dp, 0x7f, sizeof(dp));

    cin>>n>>m;

    for(int i = 0; i < m; i++){
        int a, b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    int k;
    cin>>k;

    for(int i = 0; i < k; i++){
        cin>>c[i];
        djk(c[i], i);
        dp[(1<<i)][i] = 1;
    }

    for(int i = 0; i < (1<<k); i++){
        for(int j = 0; j < k; j++){
            if((1<<j) & i){
                for(int l = 0; l < k; l++){
                    if((1<<l) & i)
                        continue;
                    if(dp[i][j] < mod)
                        dp[i^(1<<l)][l] = min(dp[i^(1<<l)][l], dp[i][j] + d[j][c[l]]);
                }
            }
        }
    }

    int ans = mod;

    for(int i = 0; i < k; i++){
        ans = min(ans, dp[(1<<k) - 1][i]);
    }
    if(ans >= mod) ans = -1;

    cout<<ans<<endl;

    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

#include<bits/stdc++.h>
#define MAX 200000
#define MOD 1000000007
using namespace std;
vector<int> v[MAX+10];
vector<int> dist[MAX+10];
vector<int> path;
int in[MAX+10], out[MAX+10];
int count(int l,int r, int k)
{
	return upper_bound(dist[k].begin(),dist[k].end(),r)-lower_bound(dist[k].begin(),dist[k].end(),l);
}
void dfs(int x,int e, int pr)
{
	path.push_back(e);
	in[x] = (int)path.size()-1;
	dist[e].push_back(in[x]);
	for(int y:v[x])
	{
		if(y==pr)
			continue;
		dfs(y,e+1,x);
	}
	out[x] = (int)path.size()-1;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	for(int i=2,x;i<=n;++i)
		cin>>x, v[i].push_back(x), v[x].push_back(i);
	dfs(1,0,0);
	int q;
	cin>>q;
	while(q--)
	{
		int x, n;
		cin>>x>>n;
		int l = in[x], r = out[x];
		cout<<count(l,r,n)<<endl;
	}
	return 0;
}


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

int n, k;
char temp[105];
string s;

char getWin(char a, char b) {
	if (a == 'R') {
		if (b == 'R' || b == 'S') return a;
		else return b;
	} else if (a == 'P') {
		if (b == 'P' || b == 'R') return a;
		else return b;
	} else {
		if (b == 'S' || b == 'P') return a;
		else return b;
	}
}

int main() {
	scanf("%d%d", &n, &k);
	scanf(" %s", temp);
	s = temp;
	for (int i = 0; i < k; i++) {
		s = s + s;
		string ns = "";
		for (int j = 0; j < s.size() - 1; j += 2) {
			ns += getWin(s[j], s[j + 1]);
		}
		s = ns;
	}
	printf("%c\n", s[0]);
	return 0;
}

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

int inf = 1001001001;
ll INF = 1001001001001001001;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define rep(i, n) FOR(i, 0, n)
#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front
ll MOD = 1000000007;
using P = pair<ll, ll>;

int main() {
    ll t, N;cin >> t >> N;
    ll i = (100*N-1)/t;
    cout << i*(100+t)/100+1 << endl;
    return 0;
}


#include "bits/stdc++.h"
using namespace std;
#define int long long
using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 61);
ll mod = 998244353;

struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N, M, K; cin >> N >> M >> K;
	if (N == 1) {
		mint ans = mint(K).pow(M);
		cout << ans << endl; return 0;
	}
	if(M == 1){
		mint ans = mint(K).pow(N);
		cout << ans << endl; return 0;
	}
	mint ans = 0;
	for (int i = 1; i <= K; i++) {
		mint now = 0;
		now = mint(i).pow(N);
		now -= mint(i - 1).pow(N);

		mint now2 = 0;
		now2 = mint(K -i + 1).pow(M);

		now *= now2;
		ans += now;
	}
	cout << ans << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 998244353
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() const { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b, swap(a, b);
            u -= t * v, swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr istream& operator >> (istream& is, Fp<MOD>& x) noexcept {
        is >> x.val;
        x.val %= MOD;
        if (x.val < 0) x.val += MOD;
        return is;
    }
    friend constexpr ostream& operator << (ostream& os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> mpow(const Fp<MOD>& r, long long n) noexcept {
        if (n == 0) return 1;
        if (n < 0) return mpow(minv(r), -n);
        auto t = mpow(r, n / 2);
        t = t * t;
        if (n & 1) t = t * r;
        return t;
    }
    friend constexpr Fp<MOD> minv(const Fp<MOD>& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b, swap(a, b);
            u -= t * v, swap(u, v);
        }
        return Fp<MOD>(u);
    }
};
using mint = Fp<mod>;

int main() {
  ll n, k;
  cin >> n >> k;
  vl vec(n);
  rep(i, n) cin >> vec[i];
  vector<mint> fac(k+1);
  fac[0] = 1;
  rep(i, 1, k+1) fac[i] = fac[i-1]*i;
  vector<vector<mint>>  table(k+1, vector<mint>(n+1, 1));
  table[0][n] = n;
  rep(i, 1, k+1){
    mint tmp(0);
    rep(j, n){
      table[i][j] = table[i-1][j] *= vec[j];
      tmp += table[i][j];
    }
    table[i][n] = tmp;
  }
  rep(i, 1, k+1){
	mint ans(0);
 	rep(j, i+1){
      mint denom = fac[j]*fac[i-j];
      mint num = fac[i] * minv(denom);
      num *= table[j][n];
      num *= table[i-j][n];
      ans += num;
    }
    mint dup = mpow(mint(2), i) * table[i][n];
    ans -= dup;
    ans /= 2;
    cout << ans << endl;
  }
  return 0;
}


//void __(){
//    string tmp;
//    _(int,n);
//    _(string,s);
//    for(char c : s){
//        if(sz(tmp) >= 2 && tmp.substr(sz(tmp)-2) == "fo" && c == 'x'){
//            tmp.pop_back();
//            tmp.pop_back();
//        }
//        else
//            tmp.pb(c);
//    }
//    print(sz(tmp));
//}
//
#include <iomanip>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define sz(v) ll(v.size())
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
struct _print {
    string sep,end;
    bool space;
    ostream &stream;
    _print(string _sep=" ",string _end="\n",
            ostream &_stream = cout)
        : sep(_sep),end(_end),space(false),
            stream(_stream) {}
    ~_print() { stream << end; }

    template <typename T>
        _print &operator , (const T &t) {
            if (space) stream << sep;
            space = true;
            stream << t;
            return *this;
        }
};
#define print _print(),
#define INPUT_WITHOUT_INIT(type,name) type name; cin >> name
#define GET_INPUT_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define _(...) GET_INPUT_MACRO(__VA_ARGS__,_IWI,_IWI,_IWI,_IWI,_IWI,_IWI,INPUT_WITHOUT_INIT)(__VA_ARGS__)
void __(){
    string tmp;
    _(int,n);
    _(string,s);
    for(char c : s){
        if(sz(tmp) >= 2 && tmp.substr(sz(tmp)-2) == "fo" && c == 'x'){
            tmp.pop_back();
            tmp.pop_back();
        }
        else
            tmp.pb(c);
    }
    print(sz(tmp));
}

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

#include<iostream>
#include<vector>
using namespace std;
int main(){
	int N,len,ans=0;
	string S;
	vector<char> vec;
	cin>>N>>S;
	for(int i=0;i<N;i++){
		vec.push_back(S[i]);
		while(true){
			len = vec.size();
			if(len>=3 && vec[len-1]=='x' && vec[len-2]=='o' && vec[len-3]=='f'){
				vec.pop_back();
				vec.pop_back();
				vec.pop_back();
				ans++;
			}else break;
		}
	}
	cout<<N-3*ans;
	return 0;
}


//Solution By SlavicG
#include "bits/stdc++.h"

using namespace std;

#define              ll              long long

#define       forn(i,n)              for(int i=0;i<n;i++)
#define          all(v)              v.begin(), v.end()
#define         rall(v)              v.rbegin(),v.rend()

#define            pb                push_back
#define          sz(a)               (int)a.size()
#define         fastio               ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void solve()
{
	vector<char> v;
	int n;
	string s;
	cin >> n >> s;
	int cnt =0 ;
	for(int i= 0;i < n;i++)
	{
		v.pb(s[i]);
		if(sz(v) < 3)continue;
		string k = "";
		k += v[sz(v) - 3];
		k+= v[sz(v) - 2];
		k+= v[sz(v) - 1];
		if( k== "fox"){
			v.pop_back();
			v.pop_back();
			v.pop_back();
			cnt+=3;
		}
	}
	cout << n - cnt;
	//
}

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

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

using namespace std;
using ll=long long;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define cps CLOCKS_PER_SEC
#define yes cout<<"Yes"<<"\n"
#define no cout<<"No"<<"\n"
#define cset(x) cout<<fixed<<setprecision(x)

int st=0;
string S;
int h=0;
int ti;
void snu(string &S,int &h){
    if((clock()-ti)>196*cps/100){
      st=0;
      return;
    }
    int k=S.size();
    stack<int> l;
    bool a=true;
    if(k<=2){
        st=k;
        return;
    }
    else{
        for(int i=h;i<k-2;i++){

            if(S[i]=='f'&&S[i+1]=='o'&&S[i+2]=='x'){
                if(k<=5){
                    st=k-3;
                    return;
                }
                else{
                    l.push(i);
                    if(a){
                        h=max(0,i-2);
                        a=false;
                    }
                }
            }
        }
    }
    while(!l.empty()){
        int x=l.top();
        l.pop();
        S.erase(x,3);
    }
    if(a){
        st=S.size();
        return;
    }
    else{
        snu(S,h);
        return;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int ti=clock();
    int n;

    cin>>n>>S;

    snu(S,h);
    cout<<st<<"\n";
}


#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0, length = n; i < length; i++)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ep emplace
#define epb emplace_back
#define scll static_cast<long long>
#define sz(x) static_cast<int>((x).size())
#define pfll(x) printf("%lld\n", x)
#define ci(x) cin >> x
#define ci2(x, y) cin >> x >> y
#define ci3(x, y, z) cin >> x >> y >> z
#define ci4(w, x, y, z) cin >> w >> x >> y >> z
#define co(x) cout << x << endl
#define co2(x, y) cout << x << " " << y << endl
#define co3(x, y, z) cout << x << " " << y << " " << z << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> PQ;
typedef priority_queue<int, vector<int>, greater<int>> PQG;
typedef priority_queue<P> PQP;
typedef priority_queue<P, vector<P>, greater<P>> PQPG;

const int MAX_N = 2e5, MOD = 1e9 + 7, INF = 1e9;
int n, a[MAX_N];
ll sum[MAX_N];

int main() {
    ci(n);
    rep(i, n) ci(a[i]);
    sort(a, a + n);
    rep(i, n) sum[i + 1] = sum[i] + a[i];
    double ans = 0.0;
    ans += -double(n % 2) * a[n / 2] / 2 / n +
        double(sum[n] - sum[n / 2]) / n;
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  ll p=998244353;
  ll ans=1;
  ll x=a*(a+1)/2,y=b*(b+1)/2,z=c*(c+1)/2;
  x%=p;
  y%=p;
  z%=p;
  ans=x;
  ans%=p;
  ans*=y;
  ans%=p;
  ans*=z;
  ans%=p;
  if(ans<0){
    ans+=p;
  }
  cout << ans;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
int sl=9;
int ans=0;
string S;
cin>>S;
for (int i = 0; i < sl; i++)
{
   string zone=S.substr(i,4);
   if(zone=="ZONe") ans++;
}
cout<<ans;
}

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

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

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

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

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

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

int main(){

    string S;
    cin >> S;

    ll res = 0;
    REP(i, 9){
        if(S.substr(i, 4) == "ZONe") res++;
    }
    cout << res << endl;

    return 0;
}


#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
#define rep(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i <= _##i; ++i)
#define repd(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i >= _##i; --i)
#ifndef ONLINE_JUDGE
#define debug(x...) printf("["#x"]="),print(x);
#else
#define debug(x...) ;
#endif
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fcout cout<<setprecision(4)<<fixed
using namespace std;
typedef long long ll;
//======================================
namespace FastIO{
char print_f[105];void read() {}void print() {putchar('\n');}
template <typename T, typename... T2>
inline void read(T &x, T2 &... oth){x = 0;char ch = getchar();ll f = 1;while (!isdigit(ch)){if (ch == '-')f *= -1;ch = getchar();}while (isdigit(ch)){x = x * 10 + ch - 48;ch = getchar();}x *= f;read(oth...);}
template <typename T, typename... T2>
inline void print(T x, T2... oth){ll p3=-1;if(x<0) putchar('-'),x=-x;do{print_f[++p3] = x%10 + 48;}while(x/=10);while(p3>=0) putchar(print_f[p3--]);if(sizeof...(T2)) putchar(' ');print(oth...);}} // namespace FastIO

using FastIO::print;
using FastIO::read;
//======================================
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn = 1e6+5;

int re[maxn],siz[maxn];
int G[maxn];
int fin(int x){
    return re[x]==x?x:re[x]=fin(re[x]);
}
void merge(int x,int y){
    int fx=fin(x),fy=fin(y);
    if(fx!=fy){
        if(siz[fy]<siz[fx]) swap(fx,fy);
        siz[fy]+=siz[fx];
        G[fy]+=G[fx]+1;
        re[fx]=fy;
    }
    else{
        G[fx]++;
    }
}
int a[maxn],b[maxn];
int main() {
#ifndef ONLINE_JUDGE
    freopen("H:\\code\\in.in", "r", stdin);
    freopen("H:\\code\\out.out", "w", stdout);
    clock_t c1 = clock();
#endif
//**************************************
    rep(i,1,400000) re[i]=i,siz[i]=1;
    int m;
    read(m);
    unordered_set<int>se;
    rep(i,1,m){
        read(a[i],b[i]);
        se.insert(a[i]);
        se.insert(b[i]);
    }
    rep(i,1,m){
        merge(a[i],b[i]);
    }
    int ans=0;
    for(auto v:se){
        if(v==fin(v)){
            if(G[v]==siz[v]-1){
                ans+=G[v];
            }
            else ans+=siz[v];
        }
    }
    print(ans);
//**************************************

#ifndef ONLINE_JUDGE
    cerr << "Time:" << clock() - c1 << "ms" << endl;
#endif
    return 0;
}

#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int f[100];

signed main()
{
	ios::sync_with_stdio(false);
	f[0]=1;f[1]=1;
	int cnt=0;
	for(int i=2;;i++){
		f[i]=f[i-1]+f[i-2];
		if(f[i]>(int)1e18){
			cnt=i-1;break;
		}
	}
	int n;cin>>n;
	vector<int> v,ans;
	int pos=0,p=n;
	for(int i=cnt;i>=1;i--){
		if(p>=f[i]){
			p-=f[i];
			v.push_back(i);
		}
	}
	pos=v[0];
	ans.push_back(1);
	int now=0;
	for(int i=1;i<=pos;i++){
		if(i%2==0||i==pos) ans.push_back(3);
		else ans.push_back(4);
		if(now<v.size()-1&&i==pos-v[now+1]){
			if(i%2==0) ans.push_back(1);
			else ans.push_back(2);
			now++;
		}
	}
	cout<<ans.size()<<endl;
	for(int i=0;i<ans.size();i++) cout<<ans[i]<<endl;
	int x=0,y=0;
	for(int i=0;i<ans.size();i++){
		if(ans[i]==1) x++;
		else if(ans[i]==2) y++;
		else if(ans[i]==3) x=x+y;
		else if(ans[i]==4) y=x+y;
	}
	assert(x==n);
	return 0;
}


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

  if(N%100==0) cout<<N/100;
  else cout<<N/100+1;

  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(intt i=0;i<(intt)(n);i++)
#define repm(i,n) for(intt i=(intt)(n)-1;i>=0;i--)
#define rept(i,n) for(intt i=1;i<(intt)(n);i++)
#define reptm(i,n) for(intt i=(intt)(n);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define siz(s) (s).size()
#define fof(i,a,b) for(intt i=a;i<b;i++)
#define bitfor(bit,N) for (int bit = 0; bit < (1 << (intt)(N); ++bit)
#define eb emplace_back
using intt = int64_t;
using ldou = long double;
using vi=vector<int>;
using vt=vector<intt>;
using vc=vector<char>;
using vs=vector<string>;
using vd=vector<ldou>;
using vb=vector<bool>;
using vvi=vector<vi>;
using vvt=vector<vt>;
using vvc=vector<vc>;
using vvs=vector<string>;
using vvd=vector<vd>;
using pa=pair<intt,intt>;
using vpa=vector<pa>;
using mapt=map<intt,intt>;
using vmap=vector<mapt>;
using st=set<intt>;
using Graph = vector<vector<int>>; // グラフ型
intt gcd(intt a,intt b){if(a%b==0){return b;}else{return gcd(b,a%b);}}//最大公約数
intt lcm(intt a,intt b){return a*b/gcd(a,b);}//最小公倍数
intt sum(const long &a,const long &b){return(a+b)*(b-a+1)/2;}//合計
vector<long long>yakusu(long long N){vector<long long>res;for(long long i=1;i*i<=N;++i){if(N%i==0){res.push_back(i);if(N/i!=i)res.push_back(N/i);}}sort(res.begin(),res.end());return res;}//約数全部
intt sumi(intt n){int x=0;while(n>=10){x+=n%10;n/=10;}x+=n;return x;}//各桁の和
bool sque(long long N){long long r=(long long)floor(sqrt((long double)N));return(r*r)==N;}//平方数
intt max(intt a,intt b){if(a>b){return a;}else{return b;}}
intt min(intt a,intt b){if(a>b){return b;}else{return a;}}
#include <cmath>
bool integ(double x){return std::floor(x)==x;}
vector<intt> ruiseki(intt n,vector<intt> a){vector<intt>s(n+1,0);for(intt i=0;i<n;++i){s[i+1]=s[i]+a[i];}return s;}
void strsort(vector<string>&S){map<int,int>SwapInd;int maxi=0;for(int i=0;i<S.size();i++){if(S[i].size()>maxi)maxi=S[i].size();}for(int i=0;i<maxi;i++){int k=maxi-i;int sort_num=0;for(int j=0;j<S.size();j++){if(S[j].size()>=k){SwapInd[j]=1;sort_num++;}}int swapped=0;for(int j=0;j<S.size();j++){if(SwapInd[j]==1&&j<S.size()-sort_num){if(SwapInd[S.size()-sort_num+swapped]==0){iter_swap(S.begin()+j,S.begin()+S.size()-sort_num+swapped);}else{while(SwapInd[S.size()-sort_num+swapped]!=0){swapped++;if(S.size()-sort_num+swapped>=S.size()){break;}if(S.size()-sort_num+swapped<S.size()){iter_swap(S.begin()+j,S.begin()+S.size()-sort_num+swapped);}}}
     SwapInd[j]=0;SwapInd[S.size()-sort_num+swapped]=0;swapped++;}}vector<string>WhatSorted(sort_num);vector<pair<int,int>>char_and_index(sort_num);for(int j=0;j<sort_num;j++){if(S[S.size()-sort_num+j][k-1]>=65&&S[S.size()-sort_num+j][k-1]<=90){char_and_index[j].first=(int)S[S.size()-sort_num+j][k-1]+32;}else{char_and_index[j].first=(int)S[S.size()-sort_num+j][k-1];}char_and_index[j].second=j;WhatSorted[j]=S[S.size()-sort_num+j];}stable_sort(char_and_index.begin(),char_and_index.end());for(int j=0;j<sort_num;j++){S[S.size()-sort_num+j]=WhatSorted[char_and_index[j].second];}}}
intt fac(intt k){intt sum=1;for(intt i=1;i<=k;++i){sum*=i;}return sum;}
vector<bool> seen;
void dfs(const Graph &G,int v){seen[v]=true;for(auto next_v:G[v]){if(seen[next_v])continue;dfs(G,next_v);}}//DFS

Graph g;
intt mini=INT64_MAX;
intt maxi=INT64_MIN;
intt zero=0;
intt cnt=0;
intt su=0;
intt ans=0;
intt n;
string s;

int main() {
cout << fixed << setprecision(20);

cin>>n;
cnt++;
while(1){
     ans+=cnt;
     if(ans>=n){
          cout<<cnt<<endl;
          return 0;
     }

     cnt++;
}
}


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

typedef long long int ll;
#define deb(x) cout << #x << " " << x << endl;
#define debtwo(x,y) cout << x << ", " << y << endl;
#define mod 1000000007
#define N 1000001

void solve() {
	ll n, m, t, a, b, pre = 0;
	cin >> n >> m >> t;
	ll lim = n;

	bool f = 0;

	while (m--) {
		cin >> a >> b;
		n -= (a - pre);
		if (n <= 0) {
			f = 1;
		}
		n = min(lim, n + b - a);
		pre = b;
	}
	if (f) {
		cout << "No\n";
		return;
	}
	n -= (t - pre);

	if (n <= 0) {
		cout << "No\n";
		return;
	}
	cout << "Yes\n";
}

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

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

	while (t--) {
		solve();
	}
}

#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(a, n) for (int i = a; i < n; i++)
#define Fo(k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

void solve()
{
    ll n;
    cin >> n;
    ll a, b{}, c, mini{INT64_MAX};
    ll i = 0;
    while (pow(2, i) <= n)
    {
        ll d = pow(2, i);
        c = n % d;
        b = i;
        a = n / pow(2, i);
        mini = min(mini, a + b + c);
        i++;
    }
    cout << mini << endl;
}

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

    int t = 1;
    while (t--)
    {
        solve();
    }

    return 0;
}