#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=1e9+7 ;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> ans(n+1);
    ans[1]=1;
    for(int i=1;i<=n;i++){
        for(int j=2*i;j<=n;j+=i){
            ans[j]=max(ans[i]+1,ans[j]);
        }
    }
    rep(i,n)cout<<ans[i+1]<<" \n"[i+1==n];
    return 0;
}

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

int main(){
    ll n;
    cin>>n;
    ll count=1;
    ll p=2;
    vector<ll>a(n);

    for(ll i=0;i<n;i++){
        a[i]=count;
        if(i+2==p){
            count++;
            p=p*2;
        }
    }

    for(ll i=0;i<n;i++){
        cout<<a[i]<<" ";
    }
}


//BY: YASH JAIN, CF: BitSane
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define May_the_fork_be_with_you ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define rall(v) v.rbegin(),v.rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define deb(x) cout<<#x<<": "<<x<<endl;
#define debn(x) cout<<#x<<": "<<x<<"  ";
#define MOD 1000000007
#define mod 998244353
#define INF 1e18
#define ll long long
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define int long long
#define N 100005
#define sq(x) ((x)*(x))
typedef vector<int> vi;
ll gcd(ll a, ll b) {if (!b)return a; return gcd(b, a % b);}
ll power(ll x, ll y, ll p = INF) {ll res = 1; x %= p; while (y > 0) {if (y & 1)res = (res * x) % p; y = y >> 1; x = (x * x) % p;} return res;}
// Do Not use power when calculating powers of 2 (its inefficient)

void solve() {
    double x, y, z; cin >> x >> y >> z;
    double pr = y / x;
    for (double i = 1000000; i >= 0; i--) {
        double cur = i / z;
        if (cur < pr) {
            cout << (int)i;
            break;
        }
    }
}

int32_t main() {

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

    May_the_fork_be_with_you
    int t = 1;
    int x = 1;
    // cin >> t;
    cout << fixed << setprecision(12);
    while (t--) {
        // cout << "Case #" << x << ": ";
        solve();
        x++;
    }

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

/*

        بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ
      لَا إِلَٰهَ إِلَّا ٱللَّٰهُ مُحَمَّدٌ رَسُولُ ٱللَّٰهِ

*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define pb push_back

ll mod= 1000000007;

vector<ll>sv;
ll ar[1000000+9]= {0};
void seiv()
{
    ll n=1000000,i,j;
    ar[1]=1;
    for(i=4; i<=n; i+=2)ar[i]=1;
    for(i=3; i<=n; i+=2)
    {
        if(ar[i]==0)
        {
            for(j=i*i; j<=n; j+=i*2)ar[j]=1;
        }
    }
    for(i=2; i<=n; i++)
    {
        if(ar[i]==0)sv.pb(i);
    }
}

int main()
{
    // seiv();

    ll t;
//    cin>>t;
//    while(t--)
    {

        ll a,b,c=0,d=0,e=0,i,j,k=0,l=1;
       cin>>a>>b>>c;
      c=b*c;
      if(c%a==0){
        cout<<(c-1)/a<<endl;

      }
      else cout<<c/a<<endl;

    }

    return 0;
}


#include <bits/stdc++.h>

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define output(x) cout << ( x ? "Yes" : "No" ) << '\n' ;
#define mxn 100005
using namespace std;

void solve(){
    int x;
    cin >> x ;
    cout << max(0LL, x) << '\n' ;
}

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

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

int main()
{
    int x;
    cin>>x;
    if(x<0)
    {
        cout<<0<<"\n";
    }
    else
    {
        cout<<x<<"\n";
    }
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define ll 				long long
#define ld 				long double
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii               map<ll,ll>
#define pqi             priority_queue<ll>			//max pq
#define pqd             priority_queue<ll,vi,greater<ll> >
#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 pw(b,p)         pow(b,p) + 0.1
#define f(i,k,n)		for(ll i=k;i<n;i++)
#define fd(i,start,end)	for(ll i=start;i>=end;i--)

ll power(ll a, ll b, ll mod) {ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) {if (b & 1)res = res * a % mod; a = a * a % mod;} return res;}
ll power(ll a, ll b) {ll res = 1; assert(b >= 0); for (; b; b >>= 1) {if (b & 1)res = res * a ; a = a * a;} return res;}
ll min( ll a,  ll b) { return (a < b) ? a : b;}
ll max(ll a, ll b) {return (a > b) ? a : b;}
ll gcd (ll a, ll b) {if (a == 0) return  b; return gcd(b % a, a);}

void bwayne()
{
	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
}
// ll n;
// cin >> n;
// vi a(n);
// f(i, 0, n) {
// 	cin >> a[i];
// }

// vector<vi> a(n,vector<vi>(m,0));
// f(i,0,n){
// 	f(j,0,m){
// 		cin>>a[i][j];
// 	}
// }

void solve() {
	ll n;
	cin >> n;
	vi a(n), b(n);
	f(i, 0, n) {
		cin >> a[i] >> b[i];
	}
	ll ans = inf;
	f(i, 0, n) {
		ans = min(ans, a[i] + b[i]);
	}
	// cout << ans;
	f(i, 0, n) {
		f(j, 0, n) {
			if (i == j) continue;
			else ans = min(ans, max(a[i], b[j]));
		}
	}
	cout << ans;

}
int main()
{
	bwayne();// remember
	ll t = 1;
	// cin >> t;

	for (ll tt = 1; tt <= t; tt++)
	{
		// cout << "Case #" << tt << ": ";
		solve();
	}

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vec<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    vec<ll> s(n+1, 0);
    rep(i, n) s[i+1] = s[i] + a[i];

    ll ans = 0;
    rep(i, n) {
        ans += (s[n] - s[i]) - (n - i) * a[i];
    }
    cout << ans << endl;
}


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

using namespace std;

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

  vector<vector<int>> v (n, vector<int>(3));
  for (int i = 0; i < n; i++) {
      cin >> v[i][0] >> v[i][1] >> v[i][2];
      }
  vector<int> a(n), p(n), x(n);
  int counter = 0, min_price = 1000000000;
  for (int i = 0; i < n; i++){
    a[i] = v[i][0], p[i] = v[i][1], x[i] = v[i][2];
    if (x[i] - a[i] <= 0){
      counter++;
    }
    else{
      min_price = min (p[i], min_price);
    }
  }

  if (counter == n) cout << -1 << endl;
  else cout << min_price << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    auto nc2 = [](ll n){return n * (n-1) / 2;};
    int n; cin >> n;
    ll ans = 0;
    REP(i,n) {
        int a, b;
        cin >> a >> b;
        ans += nc2(b+1) - nc2(a);
    }

    cout << ans << '\n';

    return 0;
}


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

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

int main(){
    int N; cin >> N;
    ll X; cin >> X;
    X *= 100;

    ll S = 0;
    int ans = inf;
    rep(i, N){
        ll V, P;
        cin >> V >> P;
        S += V*P;
        if(S > X) chmin(ans, i);
    }

    cout << (ans == inf? -1 : ans+1) << '\n';
}

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

#define int long long
#define F first
#define S second
#define pii pair<int,int>
#define pb push_back
#define vi vector<int>
#define endl "\n"
#define all(a) a.begin(),a.end()

void solve() {
	int n; int m; cin >> n >> m;
	vector<int> v;
	for (int i = 0; i < n; i++) {
		int x, y; cin >> x >> y;
		v.pb(x * y);
	}

	int ans = -1;
	int sum = 0;
	int i = 0;
	while (i < n) {
		sum += v[i];
		//cout << sum << endl;
		if (sum > m * 100) {
			ans = i + 1;
			break;
		}
		i++;
	}
	cout << ans;
}

void init() {
	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

}

int32_t main() {
	init();
	//int t;cin>>t;while(t--)
	{
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i <= n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n)
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
using Edge = pair<int, ll>;
const ll INF = 1LL << 60;
const int MAX = 100000;
const int MOD = 1000000007;

int main()
{
    // cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a;
    // 入力。1オリジン
    cin >> n;
    int ans = 0;
    REP(i, n)
    {
        cin >> a;
        if (a > 10)
            ans += a - 10;
    }

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

#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define S second
#define F first
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

void setIO(string name = "") {
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);

	if (sz(name)) {
		freopen((name + ".in").c_str(), "r", stdin);
		freopen((name + ".out").c_str(), "w", stdout);
	}
}

const int inf = 1e9;
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

int n;

void solve() {
	cin >> n;

	int ret = 0;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		if (x > 10) ret += (x - 10);
	}

	cout << ret;
}

main() {
	setIO();

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

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define REP(i,a,b) for(int i = (a); i < (b); i++)
#define MOD 1000000007

int main(void) {
  int n;
  cin >> n;
  int res;
  // 1/2 res (res+1) >= n
  // res (res+1) >= 2n
  for(res=0; res<n; res++) {
    if(res*(res+1)/2 >= n) break;
  }
  cout << res << endl;
}

#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const LL MOD = (LL)1e9 + 7;

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

int main() {
    int N;
    scanf("%d", &N);
    vector<int> A;
    for (int i = 0; i < N; i++) {
        int tmp;
        scanf("%d", &tmp);
        A.push_back(tmp);
    }
    sort(A.begin(), A.end());
    A.erase(unique(A.begin(), A.end()), A.end());
    int pre = 0;
    LL ans = 1;
    for (int i : A) {
        int dif = i - pre;
        ans = mul(ans, dif + 1);
        pre = i;
    }
    printf("%lld\n", ans);
    return 0;
}


#include <iostream>
#include <map>

using namespace std;
using lint = long long;

void solve() {
    lint x, y;
    cin >> x >> y;

    map<lint, lint> dp;
    auto dfs = [&](auto&& f, lint p) -> lint {
        if (dp.count(p)) return dp[p];

        auto& ret = dp[p];

        // 2で割らない場合
        ret = abs(p - x);

        // 2で割る場合
        for (int d = -1; d <= 1; ++d) {
            lint np = p + d;
            if (np < 0 || np % 2 != 0 ||
                np / 2 >= p) continue;
            // 最後の条件は無限ループを省くのに必要

            ret = min(ret, f(f, np / 2) + abs(d) + 1);
        }
        return ret;
    };

    cout << dfs(dfs, y) << "\n";
}

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

    solve();

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if (i) os << " ";
    os << v[i];
  }
  return os;
}

template <class T>
void debug(const vector<T> &v) {
  cout << "[";
  REP(i, SZ(v)) {
    if(i) cout << ", ";
    cout << v[i];
  }
  cout << "]" << endl;
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  return os << p.first << " " << p.second;
}

template <class T, class U>
void debug(const pair<T, U> &p) {
  cout << "(" << p.first << " " << p.second << ")" << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll MOD998 = 998244353;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int inf = INT_MIN;
const ll linf = LLONG_MIN;
const ld eps = 1e-9;

template<int m>
struct mint {
  int x;

  mint(ll x = 0) : x(((x % m) + m) % m) {}

  mint operator-() const { return x ? m - x : 0; }

  mint &operator+=(mint r) {
    if ((x += r.x) >= m) x -= m;
    return *this;
  }

  mint &operator-=(mint r) {
    if ((x -= r.x) < 0) x += m;
    return *this;
  }

  mint &operator*=(mint r) {
    x = ((ll) x * r.x) % m;
    return *this;
  }

  mint inv() const { return pow(m - 2); }

  mint &operator/=(mint r) { return *this *= r.inv(); }

  friend mint operator+(mint l, mint r) { return l += r; }

  friend mint operator-(mint l, mint r) { return l -= r; }

  friend mint operator*(mint l, mint r) { return l *= r; }

  friend mint operator/(mint l, mint r) { return l /= r; }

  mint pow(ll n) const {
    mint ret = 1, tmp = *this;
    while (n) {
      if (n & 1) ret *= tmp;
      tmp *= tmp, n >>= 1;
    }
    return ret;
  }

  friend bool operator==(mint l, mint r) { return l.x == r.x; }

  friend bool operator!=(mint l, mint r) { return l.x != r.x; }

  friend ostream &operator<<(ostream &os, mint a) {
    return os << a.x;
  }

  friend istream &operator>>(istream &is, mint &a) {
    ll x;
    is >> x;
    a = x;
    return is;
  }
};

using Int = mint<MOD>;

ll modpow(ll x, ll n, ll m) {
  ll res = 1;
  while(n > 0) {
    if(n & 1) {
      res *= x;
      res %= m;
    }
    x *= x;
    x %= m;
    n /= 2;
  }
  return res;
}

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

  ll a, b, c; cin >> a >> b >> c;
  vll v = {a%10};
  ll now = a%10;
  while(1) {
    now *= a%10;
    now %= 10;
    if(now == a%10) break;
    v.push_back(now);
  }

  ll val = modpow(b, c, SZ(v));

  cout << v[(val+SZ(v)-1)%SZ(v)] << endl;

  return 0;
}


#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define pb push_back
#define pi pair<int, int>
#define l first
#define r second
#define all(x) x.begin(), x.end()

using namespace std;

const int maxn = 2e3 + 1;

int v[maxn];

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int a, b;
    cin >> a >> b;
    int cx = 1e9;
    int p = min(a, b);
    for (int i = 0; i < p; i++) {
        v[i] = cx;
        v[i + p] = -cx;
        --cx;
    }
    a -= p; b -= p;
    if (b) {
        int nbx = 0;
        for (int i = 2 * p - 1; i < 2 * p + b; i++)
            v[i] = -(++nbx);
        v[p - 1] = nbx * (nbx + 1) / 2;
    }
    if (a) {
        v[p - 1] = 1;
        int nbx = 1;
        for (int i = 2 * p; i < 2 * p + a; i++)
            v[i] = (++nbx);
        v[2 * p - 1] = - nbx * (nbx + 1) / 2;
    }
    for (int i = 0; i < 2 * p + a + b; i++)
        cout << v[i] << ' ';
    return 0;
}

#include<iostream>
#include<vector>
#include<stack>
#include<tuple>

using namespace std;

int main(int argc, char* argv[]) {
  int A, B, W;
  cin >> A >> B >> W;

  W *= 1000;
  auto D = B - A;

  const auto k = W / A;

  int maxCount = 0;
  int minCount = 2147483647;
  bool flag = false;

  for (auto i = 1; i <= k; i++) {
    const auto R = W - i * A;
    if (R <= D * i) {
      maxCount = max(maxCount, i);
      minCount = min(minCount, i);
      flag = true;
    }
  }

  if (flag) {
    cout << minCount << " " << maxCount << endl;
  } else {
    cout << "UNSATISFIABLE" << endl;
  }

  return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rrep(i,n) for(int i = (n-1);i>=0;--i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
const int INF=1<<30;
//const ll INF=1LL<<60;

int main() {

    int n;
    cin >> n;
    long double x;
    cin >> x;
    vector<int>  v(n);
    vector<int> p(n);
    rep(i,n)    cin >> v[i] >> p[i];

    ll ans = 0;
    rep(i,n) {
        ans+=(p[i]*v[i]);
        if(ans>x*100) {
            cout<<i+1<<endl;
            return 0;
        }
    }

    cout<<-1<<endl;

 return 0;
}

// 解き直し.
// https://atcoder.jp/contests/agc052/editorial/880
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
#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

int main(){

    // 1. 入力情報.
    int T;
    scanf("%d", &T);

    // 2. 各テストケースに解答.
    rep(i, T){
        // 2-1. 入力情報.
        int N;
        char s1[202020], s2[202020], s3[202020];
        scanf("%d %s %s %s", &N, s1, s2, s3);
        string S1(s1), S2(s2), S3(s3);

        // 2-2. 解説通り.
        string ans = "";
        rep(j, N) ans.pb('0');
        rep(j, N) ans.pb('1');
        ans.pb('0');

        // 2-3. 出力.
        printf("%s\n", ans.c_str());
    }
    return 0;

}


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

int main()
{
    int tc,o;
    scanf("%d",&tc);
    for(o=1;o<=tc;o++)
    {

        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz=0,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x=0,y=0,cnt=0,res=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr; string str,ttr,ntr;

        //scanf("%lld",&n);

        scanf("%lld %lld",&n,&m);

        g=m-n;

        if(g>=n)
        {
            h=g-n+1;

            f=h*(h+1); f=f/2; ans=f;

        }

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

    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(void) {
	long long int T,ans;
  scanf("%lld",&T);
  long long int L[T],R[T];
  for(int i=0;i<T;i++){
    ans = 0;
    scanf("%lld %lld",&L[i],&R[i]);
    if(R[i]-2*L[i]>=0){
	ans=(R[i]-2*L[i]+2)*(R[i]-2*L[i]+1)/2;
    }
    printf("%lld\n",ans);
  }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pdd;

#define lc u << 1
#define rc u << 1 | 1
#define mid (t[u].l + t[u].r) / 2
#define INF 0x3f3f3f3f
#define lowbit(x) x & (-x)
#define mem(a, b) memset(a , b , sizeof(a))
#define FOR(i, x, n) for(int i = x;i <= n; i++)

// const ll mod = 998244353;
// const ll mod = 1e9 + 7;
// const double eps = 1e-6;
// const double PI = acos(-1);
// const double R = 0.57721566490153286060651209;

const int N = 1e6 + 10;
ll t[N];

void modify(int x, int n) {
    while(x <= n) {
        t[x]++;
        x += lowbit(x);
    }
}

ll query(int x) {
    ll ans = 0;
    while(x) {
        ans += t[x];
        x -= lowbit(x);
    }
    return ans;
}

struct Point {
    int x, y;
    friend bool operator < (const Point &a,const Point &b){
        return a.x == b.x ? a.y < b.y : a.x < b.x;
    }
    friend bool operator == (const Point &a,const Point &b){
        return a.x == b.x && a.y == b.y;
    }
}p[N];

bool vis[N];

void solve() {
    int H, W, M;
    cin >> H >> W >> M;
    int upx = H + 1, upy = W + 1;
    for(int i = 1;i <= M; i++) {
        cin >> p[i].x >> p[i].y;
        if(p[i].x == 1) upy = min(upy, p[i].y);
        if(p[i].y == 1) upx = min(upx, p[i].x);
    }
    for(int i = upx + 1;i <= H; i++) {
        ++M;
        p[M].x = i; p[M].y = 1;
    }
    for(int j = upy + 1;j <= W; j++) {
        ++M;
        p[M].y = j; p[M].x = 1;
    }
    sort(p + 1, p + M + 1);
    M = unique(p + 1, p + M + 1) - (p + 1);

    int h = 1;
    ll ans = 0;
    for(int i = 1;i <= M; i++) {
        // 纵向扫描
        if(vis[p[i].y] == 0) {
            vis[p[i].y] = 1;
            modify(p[i].y, W);
        }

        // 横向扫描
        if(i == M || p[i + 1].x != p[i].x) {
            ans += query(W) - query(p[h].y - 1);
            h = i + 1;
        }
    }
    cout << (1ll * H * W - ans) << endl;
}

signed main() {
    ios_base::sync_with_stdio(false);
    //cin.tie(nullptr);
    //cout.tie(nullptr);
#ifdef FZT_ACM_LOCAL
//    int size=40<<20;
//    __asm__ ("movq %0,%%rsp\n"::"r"((char*)malloc(size)+size));
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    signed test_index_for_debug = 1;
    char acm_local_for_debug = 0;
    do {
        if (acm_local_for_debug == '$') exit(0);
        if (test_index_for_debug > 20)
            throw runtime_error("Check the stdin!!!");
        auto start_clock_for_debug = clock();
        solve();
        auto end_clock_for_debug = clock();
        cout << "Test " << test_index_for_debug << " successful" << endl;
        cerr << "Test " << test_index_for_debug++ << " Run Time: "
             << double(end_clock_for_debug - start_clock_for_debug) / CLOCKS_PER_SEC << "s" << endl;
        cout << "--------------------------------------------------" << endl;
    } while (cin >> acm_local_for_debug && cin.putback(acm_local_for_debug));
#else
    solve();
#endif
    return 0;
}

// I SELL YOU...!
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
template <typename Monoid >
struct SegmentTree{
  using F = function< Monoid(Monoid,Monoid) >;

  int sz;
  vector<Monoid> seg;

  const F f;
  const Monoid M;

  SegmentTree(int n,const F f,const Monoid &M) : f(f),M(M){
    sz = 1;
    while(sz<n) sz<<=1;
    seg.assign(sz*2,M);
  }
  void set(int k,const Monoid &v){
    seg[k+sz] = v;
  }
  void build(){
    for(int k=sz-1;k>0;k--){
      seg[k] = f(seg[2*k],seg[2*k+1]);
    }
  }
  void update(int k,const Monoid &v){
    k += sz;
    seg[k] = v;
    while(k >>= 1){
      seg[k] = f(seg[2*k],seg[2*k+1]);
    }
  }
  Monoid que(int a,int b){
    Monoid L=M,R=M;
    for(a+=sz, b+=sz;a<b;a>>=1,b>>=1){
      if(a&1) L = f(L,seg[a++]);
      if(b&1) R = f(seg[--b],R);
    }
    return f(L,R);
  }
  Monoid operator[](const int &k) const{
    return seg[k+sz];
  }
};
signed main(){
  init_io();
  ll h,w,m;
  cin >> h >> w >> m;
  vector<vector<ll>> xb(h,vector<ll>());
  vector<vector<ll>> yb(w,vector<ll>());
  SegmentTree<ll> seg(w,[](ll a,ll b){return a+b;}, 0ll);
  vector<ll> xlen(h+1);
  vector<ll> ylen(w+1);
  vector<ll> x(m),y(m);
  for(int i=0;i<m;i++){
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
    xb[x[i]].push_back(y[i]);
    yb[y[i]].push_back(x[i]);
  }
  ll ans = 0;
  for(int i=0;i<w;i++){
    sort(yb[i].begin(),yb[i].end());
    if(yb[i].empty()){
      ans += h;
    }else{
      if(yb[i].front()==0){
        for(int j=i;j<w;j++){
          seg.update(j, 1ll);
        }
        break;
      }else{
        ans += yb[i].front();
      }
    }
  }
  for(int i=1;i<h;i++){
    sort(xb[i].begin(),xb[i].end());
    ll r = -1;
    if(xb[i].empty()){
      r = w;
    }else if(xb[i].front()!=0){
      r = xb[i].front();
    }else{
      break;
    }
    ans += seg.que(0, r);
    for(auto py: xb[i]){
      seg.update(py, 1);
    }
  }
  cout << ans << endl;
}


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

#ifdef LOCAL
#include "../../../cp/lib/debug.hpp"
#else
#define debug(...)
#endif

int main() {
	cin.tie(0)->sync_with_stdio(0);
	ll n, c;
	cin >> n >> c;
	multiset<pair<ll, ll>> st;
	for (int i = 0; i < n; i++) {
		int a, b, x;
		cin >> a >> b >> x;
		st.insert({a, x});
		st.insert({b + 1, -x});
	}
	ll cur = 0, ans = 0, prev = -1;
	for (auto&& [x, y] : st) {
		if (prev != -1) ans += min(cur, c) * (x - prev);
		cur += y;
		debug(x, y, cur, ans);
		prev = x;
	}
	cout << ans << '\n';
}

#include <bits/stdc++.h>
using namespace std;
const int N=1050;
const int INF=0x3f3f3f3f;
// dp[i][j]表示点i到点j的最短回文串路径
int dp[N][N];
int n,m,u,v;
char c[2];
vector<int> g[N][30];
int main(){
//    freopen("in.txt","r",stdin);
    scanf("%d%d",&n,&m);
    queue<pair<int,int>> q;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            dp[i][j]=INF;
        }
    }
    for(int i=1;i<=n;i++){
        dp[i][i]=0;
        q.push({i,i});
    }
    for(int i=1;i<=m;i++){
        scanf("%d%d %s",&u,&v,c);
        int w=c[0]-'a';
        g[u][w].push_back(v);
        g[v][w].push_back(u);
        if(u!=v){
            // important
            dp[u][v]=1;
            dp[v][u]=1;
            q.push({u,v});
        }
    }
    while(!q.empty()){
        auto t=q.front();
        q.pop();
        int tu=t.first;
        int tv=t.second;
        for(int i=0;i<26;i++){
            if(!g[tu][i].empty() && !g[tv][i].empty()){
                // 可以向两边拓展这个字符
                for(int j=0,us=g[tu][i].size();j<us;j++){
                    for(int k=0,ts=g[tv][i].size();k<ts;k++){
                        int ttu=g[tu][i][j];
                        int ttv=g[tv][i][k];
                        if(dp[ttu][ttv]>dp[tu][tv]+2){
                            dp[ttu][ttv]=dp[tu][tv]+2;
                            dp[ttv][ttu]=dp[tu][tv]+2;
                            q.push({ttu,ttv});
                        }
                    }
                }
            }
        }
    }
    printf("%d\n",dp[1][n]==INF?-1:dp[1][n]);
    return 0;
}


#pragma GCC optimize("-Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
// #include <atcoder/all>
// #include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;
// using namespace atcoder;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<p64,p64> pp64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef pair<ll,p64> tp;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln '\n'
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define zero ll(0)
#define set_bits(x) __builtin_popcountll(x)
// #define mint modint998244353

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

ll mpow(ll a, ll b, ll p){
	if(a==0) return 0;
	if(b==0) return 1;
	ll t1 = mpow(a,b/2,p);
	t1 *= t1;
	t1 %= p;
	if(b%2) t1 *= a;
	t1 %= p;
	return t1;
}

ll modinverse(ll a, ll m){
	ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1) return 0;
    while (a > 1){
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0) x += m0;
    return x;
}

mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

ll range(ll l, ll r){
	return l + mt()%(r-l+1);
}

ll rev(ll v){
	return mpow(v,MOD-2);
}

ll nc2(ll n){
	return (n*(n-1))/2;
}

ll dp[101][10001][101];
ll fac[101];
void solve()
{
	fac[0] = 1;
	forsn(i, 1, 101)
	{
		fac[i] = i*fac[i-1];
		fac[i] %= MOD;
	}
	ll n;
	cin>>n;
	v64 w(n);
	forn(i, n) cin>>w[i];
	ll tot = 0;
	dp[0][0][0] = 1;
	forn(i, n)
	{
		tot += w[i];
		forn(j, 10001)
		{
			forn(k, n+1)
			{
				dp[i+1][j][k] = dp[i][j][k];
				if(j-w[i] >= 0 && k-1 >= 0)
				{
					dp[i+1][j][k] += dp[i][j-w[i]][k-1];
					dp[i+1][j][k] %= MOD;
				}
			}
		}
	}
	if(tot%2 == 1)
	{
		cout<<0<<ln;
	}
	else
	{
		ll ans = 0;
		forn(el, n+1)
		{
			//cout<<el<<" "<<dp[n][tot/2][el]<<ln;
			ll temp = dp[n][tot/2][el]*fac[el];
			temp %= MOD;
			temp *= fac[n-el];
			temp %= MOD;
			ans += temp;
			ans %= MOD;
		}
		cout<<ans<<ln;
	}
}

int main()
{
	fast_cin();
	ll t=1;
	// cin >> t;
    forn(i,t) {
    	// cout << "Case #" << i+1 << ": ";
    	solve();
    }
    return 0;
}

#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define LL long long
#define mod 998244353
using namespace std;
int n;
char s[110000];
int f[11010][110];
int a[110];
long long fac[110];
int main()
{
    fac[0]=1;
    for(int i=1;i<=100;i++)fac[i]=fac[i-1]*i%mod;

    cin>>n;
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    int sum=0;
    for(int i=1;i<=n;i++)sum+=a[i];
    if (sum%2!=0){ puts("0"); return 0; }
    f[0][0]=1;
    for(int i=1;i<=n;i++)
        for(int j=sum;j>=0;j--)
            for(int k=n;k>=0;k--)
                if (j-a[i]>=0 && k-1>=0)
                (f[j][k]+=f[j-a[i]][k-1])%=mod;
    long long ans=0;
    for(int i=1;i<=n;i++)
    {
        //cout<<i<<" "<<f[sum/2][i]<<endl;
        ans=(ans+f[sum/2][i]*fac[i]%mod*fac[n-i]%mod)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 0xcccccccccccccccLL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

//head

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll b, c;
  cin >> b >> c;
  ll ul = b-c/2, ur = max(b, b+c/2-1);
  ll dl = min(-b, -b-(c-1)/2), dr = max(-b, -b+(c-1)/2);
  ll l = min(ul, dl), r = max(ur, dr);
  ll ans = r-l+1;
  if(ul > dr) ans -= ul-dr-1;
  if(dl > ur) ans -= dl-ur-1;
  cout << ans << endl;
}

#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using graph = vector<vector<int>>;
using Grid = vector<vector<bool>>;

int main() {
    ll b, c, ans;
    ans = 0;
    cin >> b >> c;

    if(b == 0){
        if(c < 2){
            cout << 1 << endl;
            return 0;
        }else{
            ans = c;
        }
    }else if(b > 0){ // b > 0
        if(c < 3){
            cout << c+1 << endl;
            return 0;
        }else{
            if(2 * b - c > 0){
                ans = 3 + (c-2)*2;
            }else{
                ans = (c-2) + (2 * b + 1);
            }
        }
    }else{ // b < 0
        if(c < 3){
            cout << c+1 << endl;
            return 0;
        }else{
            if(-2 * (-b) + 1 - c > 0){
                ans = 3 + (c-2)*2;
            }else{
                ans = (c-1) + (2 * (-b) + 1);
            }
        }
    }
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
	char c1, c2, c3;
	cin >> c1 >> c2 >> c3;
	if (c1 == c2 && c1 == c3 && c2 == c3)
	{
		cout << "Won" << "\n";
	}
	else
	{
		cout << "Lost" << "\n";
	}
}

#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) int(x.size())
#define fk cout<<"fk"<<endl
#define db(x) cout<<(#x)<<'='<<(x)<<endl
#define db2(x,y) cout<<(#x)<<'='<<(x)<<' '<<(#y)<<'='<<(y)<<endl
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long i64;
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout<<fixed;}
//1.integer overflow (1e5 * 1e5) (2e9 + 2e9)
//2.runtime error
//3.boundary condition
int a,b,c;
int main() {
    fastio();

    cin>>a>>b>>c;
    if(!c){
    	cout<<(a-b>=1?"Takahashi":"Aoki")<<'\n';
    } else{
    	cout<<(b-a>=1?"Aoki":"Takahashi")<<'\n';
    }
    return 0;
}


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

using namespace std;

typedef long long LL;
static const LL INF = 1LL << 60;

struct Dijkstra {
	vector<vector<pair<long long, long long>>> edges;

	Dijkstra(long long size) : edges(size) { }

	void add_edges(std::vector<long long>& A, std::vector<long long>& B) {
		for (int i = 0; i < A.size(); ++i) {
			add_edge(A[i], B[i]);
		}
	}

	void add_edges(std::vector<long long>& A, std::vector<long long>& B, std::vector<long long>& C) {
		for (int i = 0; i < A.size(); ++i) {
			add_edge(A[i], B[i], C[i]);
		}
	}

	void add_edge(long long a, long long b, long long c = 1) {
		edges[a].push_back({ b, c });
	}

	vector<long long> get_min_costs(long long start) {
		vector<long long> min_costs(edges.size(), 1LL << 60);
		priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<>> q;
		q.emplace(make_pair(0, start));
		while (!q.empty()) {
			pair<long long, long long> top = q.top();
			q.pop();
			long long cost = top.first, node = top.second;
			if (cost > min_costs[node]) continue;
			for (auto kv : edges[top.second]) {
				long long next_node = kv.first;
				long long next_cost = top.first + kv.second;
				if (next_cost < min_costs[next_node]) {
					min_costs[next_node] = next_cost;
					q.emplace(make_pair(next_cost, next_node));
				}
			}
		}
		return min_costs;
	}
};

void solve(long long N, long long M, std::vector<long long>& A, std::vector<long long>& B, std::vector<long long>& C) {
	Dijkstra dijkstra(N);
	dijkstra.add_edges(A, B, C);
	for (int i = 0; i < N; i++) {
		vector<LL> costs = dijkstra.get_min_costs(i);
		LL ans = costs[i];
		cout << (ans < INF ? ans : -1) << endl;
	}
}

int main() {
	long long N, M;
	std::cin >> N >> M;
	std::vector<long long> A(M), B(M), C(M);
	for (int i = 0; i < M; i++) {
		std::cin >> A[i] >> B[i] >> C[i];
		--A[i];
		--B[i];
	}
	solve(N, M, A, B, C);
	return 0;
}

//================code===================//

#define TLE

#ifdef TLE
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#endif

#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>

#define ci(t) cin>>t
#define co(t) cout<<t
#define LL long long
#define fa(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>b;--i)
#define setp pair<pair<int,int>,int>
#define setl pair<LL,LL>
#define M_PI 3.14159265358979323846
#define micro 0.000001

using namespace std;

#ifdef OHSOLUTION
#define ce(t) cerr<<t
#define AT cerr << "\n=================ANS=================\n"
#define AE cerr << "\n=====================================\n"
#else
#define AT
#define AE
#define ce(t)
#define __popcnt __builtin_popcount
#endif

LL gcd(LL a, LL b) { return a % b ? gcd(b, a % b) : b; }
LL lcm(LL a, LL b) { return (a * b) / gcd(a, b); }

pair <int, int> vu[9] = { {0,1},{0,-1},{1,0} ,{-1,0},{0,0},{1,1}, {-1,1} , {1,-1},{-1,-1} }; //RDLU EWSN

template<typename T, typename U> void ckmax(T& a, U b) { a = a < b ? b : a; }
template<typename T, typename U> void ckmin(T& a, U b) { a = a > b ? b : a; }
struct gcmp { bool operator()(LL a, LL b) { return a < b; } bool operator()(setl a, setl b) { return a.second < b.second; } };
struct lcmp { bool operator()(LL a, LL b) { return a > b; } bool operator()(setl a, setl b) { return a.second > b.second; } };

const int max_v = 2e3 + 7;
const int INF = 1e8 + 7;
const LL LNF = 1e18 + 7;
const LL mod = 1e9+7;

int v, e;
priority_queue<setl, vector<setl>, lcmp> pq;
vector<setl> adj[max_v];
int dist[max_v];
bool vist[max_v];

int dijk(int sp)
{
	while (!pq.empty()) pq.pop();

	fill(dist, dist + v, INF);
	memset(vist, 0, sizeof(vist));
	pq.push({ sp,0 });
	dist[sp] = 0;
	int ret = INF;

	while (!pq.empty())
	{
		setl cur;
		do
		{
			cur = pq.top(); pq.pop();
		} while (!pq.empty() && vist[cur.first]);

		if (vist[cur.first]) break;

		vist[cur.first] = 1;

		for (auto x : adj[cur.first])
		{
			if (dist[x.first] > dist[cur.first] + x.second)
			{
				dist[x.first] = dist[cur.first] + x.second;
				pq.push({ x.first,dist[x.first] });
			}

			if (x.first == sp)
			{
				ckmin(ret, dist[cur.first] + x.second);
			}
		}
	}

	return ret == INF ? -1 : ret;
}

int main()
{
#ifdef OHSOLUTION
	freopen("input.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ci(v >> e);
	fa(i, 0, e)
	{
		int x, y, cost; ci(x >> y >> cost); --x, --y;
		adj[x].push_back({ y,cost });
	}

	fa(i, 0, v) co(dijk(i) << "\n");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[1000];
	long long sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>=10) sum+=a[i]-10;
	}
	cout<<sum<<endl;
	return 0;
}

/*   “A man wrapped up in himself makes a very small bundle.”   */
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#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

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================
#ifndef ONLINE_JUDGE
template<typename T>
void __p(T a) {
  cerr<<a;
}
template<typename T, typename F>
void __p(pair<T, F> a) {
  cerr<<"[";
  __p(a.first);
  cerr<<",";
  __p(a.second);
  cerr<<"]";
}
template<typename T>
void __p(std::vector<T> a) {
  cerr<<"[";
  for(auto it=a.begin(); it<a.end(); it++)
    __p(*it),cerr<<",]"[it+1==a.end()];
}
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) {
  __p(a1);
  __p(a...);
}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cerr<<name<<" : ";
  __p(arg1);
  cerr<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  int bracket=0,i=0;
  for(;; i++)
    if(names[i]==','&&bracket==0)
      break;
    else if(names[i]=='(')
      bracket++;
    else if(names[i]==')')
      bracket--;
  const char *comma=names+i;
  cerr.write(names,comma-names)<<" : ";
  __p(arg1);
  cerr<<" | ";
  __f(comma+1,args...);
}
#define trace(...) cerr<<"Line:"<<__LINE__<<" ", __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...)
#endif
//=======================
void precompute(){

}
void solve() {
  int a,b;
  cin>>a;
  int ans=0;
  for(int i=0;i<a;i++){
      cin>>b;
      if(b>10)ans+=b-10;
  }
  cout<<ans;
  return;
}

int32_t main(){

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

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

    return 0;
}


#include <bits/stdc++.h>

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

const int MAXN = 1e5 + 5;
int n,a[MAXN];

int main(){
	scanf("%d",&n);LL sm = 0,now = 0;
	FOR(i,1,n) scanf("%d",a+i),sm += a[i];
	std::sort(a+1,a+n+1);
	LL ans = 1e18;
	FOR(i,1,n){
		// 2x = a[i]
		now += a[i];
		ans = std::min(ans,2ll*sm+1ll*a[i]*n-2ll*now-2ll*(n-i)*a[i]);
	}
	printf("%.10f\n",1.0*ans/(2*n));
	return 0;
}

#include <bits/stdc++.h>

#define Mod 1000000007

using namespace std;

typedef long long ll;

inline int read() {
	int out = 0;
	bool flag = false;
	register char cc = getchar();
	while (cc < '0' || cc > '9') {
		if (cc == '-') flag = true;
		cc = getchar();
	}
	while (cc >= '0' && cc <= '9') {
		out = (out << 3) + (out << 1) + (cc ^ 48);
		cc = getchar();
	}
	return flag ? -out : out;
}

inline void write(int x, char ch) {
	if (x < 0) putchar('-'), x = -x;
	if (x == 0) putchar('0');
	else {
		int num = 0;
		char cc[22];
		while (x) cc[++num] = x % 10 + 48, x /= 10;
		while (num) putchar(cc[num--]);
	}
	putchar(ch);
}

int fpow(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = 1ll * res * x % Mod;
		x = 1ll * x * x % Mod;
		y >>= 1;
	}
	return res;
}

const int N = 1e5 + 10;

void inc(int &x, int y) {
	x += y; if (x >= Mod) x -= Mod;
}

int n, a[N]; double ans = 1e15, sum, p;

int main() {
	n = read();
	for (int i = 1; i <= n; i++) a[i] = read(), p += a[i];
	sort(a + 1, a + n + 1);
	for (int k = 0; k < n; k++) {
		sum += a[k];
		if (2 * k - n < 0) {
			ans = min(ans, -sum + (2.0 * k - n) * (a[k + 1] * 0.5));
		}
		else ans = min(ans, -sum + (2.0 * k - n) * (a[k] * 0.5));
	}
	ans += p; ans /= n;
	printf("%.10lf", ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (long long i = 0; i < (n); i++)
using ll = long long;
using P = pair<ll, ll>;
template<class T>
bool chmax(T &a, T b) {if (a < b) {a = b;return true;}else return false;}
template<class T>
bool chmin(T &a, T b) {if (a > b) {a = b;return true;}else return false;}

int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> sum(n+1);
    sum[0] = 0;
    for (int i = 1; i <= n; i++) {
        sum[i] = sum[i-1] + a[i-1]*a[i-1];
    }
    vector<ll> sum2(n+1);
    sum2[0] = 0;
    for (int i = 1; i <= n; i++) {
        sum2[i] = sum2[i-1] + a[i-1];
    }
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        ans += i * a[i]*a[i] -2 * a[i] * sum2[i] + sum[i];
    }
    cout << ans << endl;
}

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (ll i = x; i < y; i++)
#define DEC(i, x, y) for (ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n

using namespace std;

// Some typedef's
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

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

// Some constants
const int inf = 1e9 + 7;
const double eps = 1e-6;
const double pi = 1.00 * acos(-1.00);
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(ll t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}
template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
void solve()
{
   int a[3];
   rep(3)
   cin>>a[i];
   sort(a,a+3);
   cout<<a[1]+a[2];

}
signed main()
{

    #ifndef ONLINE_JUDGE
    freopen("Error.txt", "w", stderr);
    freopen("Input.txt","r",stdin);
    freopen("Output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t = 1;
  //  cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define frn(i,a,n) for(i=a;i<=n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define qll queue<ll>
#define sll set<ll>
//(a/b)%mod = (a%mod*powermod(b,mod-2,mod))%mod
ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power(x*x,n/2);
    else                    //n is odd
        return x*power(x*x,(n-1)/2);
}
int highestPowerof2(int n)
{
    int p = (int)log2(n);
    return (int)pow(2, p);
}
ll powermod(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
return res;
}
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    ll b[n];
    ll i,val=0,ans;
    vector<int>mx(n,0);
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        cin>>b[i];
    }
    mx[0]=a[0];
    ll  res=a[0];

     for(i=0;i<n;i++)
     {
         res=max(a[i],res);
         mx[i]=res;
     }

     ans=a[0]*b[0];
     cout<<ans<<endl;
     ll  ans1=ans;
     for(i=1;i<n;i++)
     {
         ans1=max(ans1,b[i]*mx[i]);

         cout<<ans1<<endl;
     }

}

#include <iostream>
#include <set>

#define int long long

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

  int ans = 0;
  std::set<std::pair<int, int> > chosen;

  int n;
  std::cin >> n;

  int m = 2*n-1;
  int a[2*n];
  for(int i = 0; i < 2*n; i++)
    std::cin >> a[i];

  for(int i = n-1; i >= 0; i--) {
    std::pair<int, int> x = {a[i], i}, y = {a[m-i], m-i};
    std::pair<int, int> next = std::max(x, y);

    ans += next.first;
    chosen.insert(next);

    std::pair<int, int> nopt = std::min(x, y);
    if((*chosen.begin()).first < nopt.first) {
      ans -= (*chosen.begin()).first;
      chosen.erase(chosen.begin());
      chosen.insert(nopt);
      ans += nopt.first;
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


#include <bits/stdc++.h>

using ull = unsigned long long int;
using ll = long long;
using ld = long double;
using pii = std::pair<int,int>;
using pll = std::pair<ll, ll>;
using vi = std::vector<int> ;
using vvi = std::vector<vi> ;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vd = std::vector<double> ;
using vvd = std::vector<vd> ;
using qi = std::queue<int> ;
using vpii = std::vector<std::pair<int, int> >;
using vpll = std::vector<pll>;
using namespace std;

#define rep(i,j) for(int (i)=0;(i)<(j);(i)++)
#define drep(i,j) for(int (i)=(j);(i) >= 0;(i)--)

template<class T1, class T2> inline void chmin(T1 &a, T2 b){if(a > b) a = b;}
template<class T1, class T2> inline void chmax(T1 &a, T2 b){if(a < b) a = b;}
template<class T> inline void pri(T a){cout << a << endl;}
template<class Z> using vec = vector<Z>;
template<class T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
 cout << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
cout << first << " " ;
OUT(rest...);
   return;
}
const int max_n = 3 * (1e5) + 1;
const int max_m = 83 * (1e5) + 1;
const int INF = int(1e9);
const long long int INFL = (long long int)1e18;

int n,m,k;
string S;
int ans;

void solve()
{
  int N;
  ll C; IN(N,C);
  vector<pair<int,int>> eve(2*N);
  for(int i=0;i < 2*N; i+= 2)
  {
    int a,b,c;IN(a,b,c);
    eve[i] = {a,c};
    eve[i+1] = {b+1,-c};
  }
  sort(eve.begin(),eve.end());
  ll ans = 0;
  ll cost = 0;
  int day = 1;
  rep(i,2*N)
  {
    auto e = eve[i];
    ll t = e.first - day;
    day = e.first;
    if(cost > C)ans += t * C;
    else ans += t * cost;
    cost += e.second;
  }
  cout << ans << endl;
}

signed main (int argc, char* argv[])
{
   cin.tie(0);
   ios::sync_with_stdio(false);
   int cases=1;
   //IN(cases);
   while(cases--)solve();
   //pri(ans);
   //for(auto c : ans){cout << c << endl;}
   //cout << fixed << setprecision(15) << ans << endl;
   return 0;
}

#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) rep2(i,0,n)
#define rep1(i,n) rep2(i,1,n+1)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
int n,t[2222],l[2222],r[2222],ans=0;
int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>t[i]>>l[i]>>r[i];
		if(t[i]%2==0) r[i]-=1;
		if(t[i]>2) l[i]+=1;
	}
	rep(i,n)
	rep2(j,i+1,n)
	{
		if((l[i]<=r[j]&&r[i]>=l[j])||(l[j]<=r[i]&&r[j]>=l[i])||(r[j]+1==l[i]&&t[j]%2==0&&t[i]>2)||(r[i]+1==l[j]&&t[i]%2==0&&t[j]>2)) ans++;
	}
	re(ans)
	return 0;}


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

typedef long long ll;
typedef unsigned int ui;

ll read() {
	ll x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return x*f;
}
void write(ll x) {
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+48);
}
void writes(ll x) {write(x),putchar(' ');}
void Writes(ll x) {write(x),putchar('\n');}

#define mp make_pair
#define pb push_back
#define N 3030

int n;
int A[N];

int main() {
	n=read();
	A[1]=2*89,A[2]=3*5*7*89;
	for(int i=1,j=3;i<=10000 and j<=1100;++i) {
		if(i%89 != 0 and i%7 != 0 and i%5 !=0 and i%3 == 0 and i%2 == 0)
			A[j++]=i;
	}
	for(int i=1,j=1101;i<=10000 and j<=1900;++i) {
		if(i%89 != 0 and i%7 != 0 and i%5 == 0 and i%2 == 0)
			A[j++]=i;
	}
	for(int i=1,j=1901;i<=10000 and j<=2500;++i) {
		if(i%89 != 0 and i%7 == 0 and i%2 == 0)
			A[j++]=i;
	}
	for(int i=1;i<=n;++i)
		writes(A[i]);

	return 0;
}

#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <functional>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vec>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

double len(double a,double b,double c, double d){
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
}

 struct UnionFindTree{
    vec par,size,rank,height;//par[i]:iの親,size[i]:iの属する木の要素数,rank[i]:iが、自分の属する木の何階層目にあるか,height[i]:iを根とする部分木の高さ
    int setNum;//木が何本あるか
    UnionFindTree(int n):par(n),size(n),rank(n),height(n){
        rep(i,n){
            par[i]=i;
            size[i]=1;
            rank[i]=-1;
            height[i]=1;
        }
        setNum=n;
    }
    int root(int x){
        if(par[x]==x)return x;
        return root(par[x]);
    }
    void unite(int x, int y){
        int rx=root(x);
        int ry=root(y);
        if(rx==ry)return;
        if(height[rx]<height[ry]){
            par[rx]=ry;
            size[ry]+=size[rx];
        }else{
            par[ry]=rx;
            size[rx]+=size[ry];
            if(height[rx]==height[y]) height[rx]++;
        }
        setNum--;
    }
    bool same(int x, int y){
        return root(x)==root(y);
    }
    int getSize(int x){//xの属する木の要素数
        return size[root(x)];
    }
    int getSetNum(){//木の本数
        return setNum;
    }
    int getRank(int x){//xが何階層目にあるか
         if(par[x]==x)return 0;
         return getRank(par[x])+1;
    }
    int getHeight(int x){//xの属する木の高さ
         return height[root(x)];
    }
};

int main(){
    int n=in();
    vector<double> x(n),y(n);
    rep(i,n){
        x[i]=in()*1.0;
        y[i]=in()*1.0;
    }

    UnionFindTree tree(n+2);
    vector<pair<double,pii>> v;
    double ans=100.0;
    rep(i,n){
        v.pb(mp(50.0-y[i]/2,mp(i,n)));
        v.pb(mp(y[i]/2+50.0,mp(i,n+1)));
        rep(j,n)if(i!=j){
            v.pb(mp(len(x[i],y[i],x[j],y[j])*1.0/2,mp(i,j)));
        }
    }
    sort(ALL(v));
    REP(e,v){
        int a = e.second.first,b = e.second.second;
        tree.unite(a,b);
        if(tree.same(n,n+1)){
            cout << fixed << setprecision(10) << e.first << endl;
            return 0;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int res=0;
	bool zf=0;
	char c;
	while(((c=getchar())<'0'||c>'9')&&c!='-');
	if(c=='-')zf=1;
	else res=c-'0';
	while((c=getchar())>='0'&&c<='9')res=(res<<3)+(res<<1)+c-'0';
	return (zf?-res:res);
}
inline bool check(int x){
	int tmp=x;
	while(x){
		if(x%10==7)return 0;
		x/=10;
	}
	x=tmp;
	while(x){
		if(x%8==7)return 0;
		x/=8;
	}
	return 1;
}
signed main(){
	int n=read(),ans=0;
	for(register int i=1;i<=n;++i){
		if(check(i))++ans;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  int n,tmp;
  int amax=-1;
  int bmin=10000;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>tmp;
    if(tmp>amax){
      amax=tmp;
    }
  }
  for(int i=0;i<n;i++){
    cin>>tmp;
    if(tmp<bmin){
      bmin=tmp;
    }
  }
  if(bmin<amax){
    cout<<0;
  }else{
    cout<<(bmin-amax+1);
  }
  cout<<endl;
  //cout<<amax<<endl;
  //cout<<bmin<<endl;
}


#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main() {
    vector<ll> rui(1000001);
    ll sum = 0;
    rep(i, 1000001){
        rui[i] = sum;
        sum += (i+1);
    }

    int n;
    cin >> n;

    ll res = 0;
    rep(i, n){
        int a, b;
        cin >> a >> b;
        res += rui[b] - rui[a-1];
    }

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

#include<cstdio>
#include<algorithm>
using namespace std;

#define fi first
#define se second
#define rep(i, l, r) for(int i=(l), i##_end_=(r); i<=i##_end_; ++i)
#define fep(i, l, r) for(int i=(l), i##_end_=(r); i>=i##_end_; --i)
typedef long long ll;
template<class T>inline T fab(T x){ return x<0? -x: x; }
template<class T>inline T readin(T x){
    x=0; int f=0; char c;
    while((c=getchar())<'0' || '9'<c) if(c=='-') f=1;
    for(x=(c^48); '0'<=(c=getchar()) && c<='9'; x=(x<<1)+(x<<3)+(c^48));
    return f? -x: x;
}

const int maxn=2e5;

int a[maxn+5], n;

int cnt[205];

inline void input(){
    n=readin(1);
    rep(i, 1, n) a[i]=readin(1);
}

signed main(){
    input();
    rep(i, 1, n) ++cnt[a[i]%200];
    ll ans=0;
    rep(i, 1, n) ans+=cnt[a[i]%200]-1;
    ans>>=1;
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
#define mod 1000000007 //10e9+7
#define pb push_back
#define mod1 998244353
// want to become a good coder :p
 void chalega()
{
    ll a,b;
    cin>>a>>b;
    ll sum1=0,sum2=0;
    ll x=0,y=0;
    while(a>0)
    {
        x=a%10;
        sum1+=x;
        a/=10;
    }
    while(b>0)
    {
        y=b%10;
        sum2+=y;
        b/=10;
    }
    if(sum1>sum2)
    {
      cout<<sum1<<endl;
    }
    else
    {
      cout<<sum2<<endl;
    }
}
  int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    chalega();
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
using pld = pair<ld,ld>;
using vll = vector<ll>;
using vld = vector<ld>;
using vstr = vector<string>;
#define _GLIBCXX_DEBUG
#define rep(j, m) for (ll j = 0; j < (ll)(m); j++)
#define rep2(i, l, n) for (ll i = l; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
const ld PI = 3.1415926535897932;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
vll dx = {-1,0,1,0};
vll dy = {0,-1,0,1};
vll Dx = {-1,-1,-1,0,0,1,1,1};
vll Dy = {-1,0,1,-1,1,-1,0,1};
const ll INF = 1000000000000000;

int main() {
    ll N;
    cin >> N;
    string S;
    cin >> S;
    if (S[0] != S[N - 1]) {cout << 1 << endl;}
    else {
        ll flag = 0;
        rep(i,N - 1) {
            if (S[i] != S[0] && S[i + 1] != S[0]) {cout << 2 << endl;flag++;break;}
        }
        if (flag == 0) {cout << -1 << endl;}
    }
}


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

using ll = long long;

#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)

const int mxn=200100;

int link[mxn];
int sz[mxn];
map<int,int> M[mxn];

int C[mxn];

int head(int u)
{
	while(u!=link[u]) u=link[u];
	return u;
}

void join(int a, int b)
{
	a=head(a);
	b=head(b);
	if(a==b) return;

	if(sz[a]<sz[b]) swap(a,b);
	sz[a]+=sz[b];
	link[b]=a;

	// if(len(M[b])>len(M[a])) swap(M[a],M[b]);

	for(auto thing:M[b]){
		M[a][thing.ff] += thing.ss;
	}
}

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int n,q;
	cin>>n>>q;

	// cout << len(M[200]);

	for(int i=1; i<=n; i++) cin>>C[i];

	for(int i=1; i<=n; i++){
		link[i]=i;
		sz[i]=1;
		M[i][C[i]] = 1;
	}

	while(q--){
		int t;
		cin>>t;

		if(t==1){
			int a,b;
			cin>>a>>b;

			join(a,b);
		}

		else{
			int x,y;
			cin>>x>>y;

			cout << M[head(x)][y] << "\n";
		}
	}
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(a) (a).begin(), (a).end()
#define uniq(a) (a).erase(unique(all(a)), (a).end())
#define dump(a) cerr << #a " = " << (a) << endl
using vint = vector<int>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int bit(int n) { return 1LL << n; }
int sign(int a) { return (a > 0) - (a < 0); }
int cdiv(int a, int b) { return (a - 1 + b) / b; }
template<typename T> T sq(T a) { return a * a; }
template<typename T> void fin(T a) {
    cout << a << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &a) {
    os << "(" << a.first << ", " << a.second << ")";
    return os;
}
template<typename T, typename U, typename V> ostream &operator<<(ostream &os, const tuple<T, U, V> &a) {
    os << "(" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &a) {
    os << "(";
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        os << *itr << (next(itr) != a.end() ? ", " : "");
    }
    os << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const deque<T> &a) {
    os << "(";
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        os << *itr << (next(itr) != a.end() ? ", " : "");
    }
    os << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &a) {
    os << "{";
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        os << *itr << (next(itr) != a.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &a) {
    os << "{";
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        os << *itr << (next(itr) != a.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &a) {
    os << "{";
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        os << *itr << (next(itr) != a.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    }
} setup;

signed main() {
    int N;
    string T;
    cin >> N >> T;
    if (N == 1) {
        if (T == "1") { fin((int) 2e10); }
        else { fin((int) 1e10); }
    }
    string S_ = "";
    rep(i, 100000) {
        S_.push_back('1');
        S_.push_back('1');
        S_.push_back('0');
    }
    int ans = 0;
    rep(i, 3) {
        if (S_.substr(i, N) == T) {
            ans = (int) 1e10 - (N + i - 1) / 3;
        }
    }
    cout << ans << endl;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
using namespace std;
using ll = long long int;

vector<string> myspliter(const string &s, const char delimiter){
    vector<string> res;
    string part = "";
    for(auto &p: s){
        if(p == delimiter){
            if(part.length() > 0) res.push_back(part);
            part = "";
        }else{
            part += p;
        }
    }
    if(part.length() > 0) res.push_back(part);
    return res;
}

ll transToInt(vector<string> str){
    ll ans = 0;
    ans += stoi(str[0])*10000;
    if(str.size() == 2){
        while(str[1].length() < 4) str[1] += '0';
        ans += stoi(str[1]);
    }
    return ans;
}

ll solve(ll x, ll y, ll r){
    ll ans = 0;
    for(ll i = -2'000'000'000; i <= 2'000'000'000; i += 10000){
        if(r*r-(i-y)*(i-y) < 0) continue;

        ll inner = x;
        ll outer = 4'000'000'000;
        ll border = r*r-(i-y)*(i-y);
        while(outer-inner > 1){
            ll mid = (outer+inner)/2;
            if((mid-x)*(mid-x) <= border) inner = mid;
            else outer = mid;
        }
        ll left = x*2-inner;
        ll right = inner;
        if(left <= 0){
            left = left/10000 - 1;
        }else{
            left = (left-1)/10000;
        }
        if(right < 0){
            right = (right+1)/10000;
        }else{
            right = right/10000 + 1;
        }
        ans += max(right - left - 1, 0LL);
        // if(right > 1 && left < -1) ans++;
        // if(i == 00000) cerr << left << " " << right << " " << inner << endl;
    }
    return ans;
}

int main(){
    string x0, y0, r0;
    cin >> x0 >> y0 >> r0;
    ll x = transToInt(myspliter(x0, '.'));
    ll y = transToInt(myspliter(y0, '.'));
    ll r = transToInt(myspliter(r0, '.'));

    cout << solve(x, y, r) << endl;
    return 0;
}

#include<iostream>
#include<math.h>
using namespace std;
int main()
{
	long double x,y,r;
	cin>>x>>y>>r;
	r+=1e-14;
	long long ans=0;

	long long ll=ceil(x-r);
	long long rr=floor(x+r);
	//cout<<ll<<" "<<rr<<endl;
	for(int i=ll;i<=rr;i++){
		if(r*r-(1.0*i-x)*(1.0*i-x)<0)
			continue;
		long double yy=sqrt(r*r-(1.0*i-x)*(1.0*i-x));
		long long tmp=floor(y+yy)-ceil(y-yy)+1;

		ans+=tmp;
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long N=1e6+10;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
    return x*f;
}
long long n,a[N],tot;
signed main(){
    cin>>n;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            a[++tot]=i;
            if(i!=sqrt(n)) a[++tot]=n/i;
        }
    }
    sort(a+1,a+tot+1);
    for(int i=1;i<=tot;i++) {
         printf("%lld\n",a[i]);
    }
    return 0;
}

/*** I came, I saw, I conquered. ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;typedef unsigned long long ull;
#define sc(a) cin >> a
#define pf(a) cout << a << endl
#define forIn(arr, num) for(ll i = 0; i < num; i++) cin >> arr[i];
#define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
#define mod 1000000007
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define GET_SET_BITS(a) (__builtin_popcount(a))
#define GET_SET_BITSLL(a) ( __builtin_popcountll(a))
#define GET_TRAIL_ZERO(a) (__builtin_ctz(a))
#define GET_LEAD_ZERO(a) (__builtin_clz(a))
#define GET_PARITY(a) (__builtin_parity(a))
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
void go() {
    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
}
/*----------------------------------------------------------------*/
void solve() {
    ll n;
    sc(n);

    set<ll> s;
    s.insert(1);
    s.insert(n);
    for(ll i = 2;i * i <= n;i++) {
        if(n % i == 0) {
            s.insert(i);
            s.insert(n / i);
        }
    }

    for(auto it : s) {
        pf(it);
    }
}

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


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

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

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

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

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

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

template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int n, m, q;
int zan[3][3];
int x[200005], y[200005];
int ty[200005], val[200005];
int ans[2][200005];
vc<P>Q[200005];

void solve(){
	rep(i, 3) zan[i][i] = 1;
	cin >> n;
	repn(i, n) cin >> x[i] >> y[i];
	cin>>m;
	repn(i, m){
		cin >> ty[i];
		if(ty[i] >= 3) cin >> val[i];
	}
	cin>>q;
	rep(i, q){
		int a, b; cin >> a >> b;
		Q[a].eb(b, i);
	}
	repn(i, m+1){
		for(auto at:Q[i-1]){
			int v = at.a, id = at.b;
			ans[0][id] = x[v] * zan[0][0] + y[v] * zan[0][1] + zan[0][2];
			ans[1][id] = x[v] * zan[1][0] + y[v] * zan[1][1] + zan[1][2];
		}
		if(i == m+1) break;
		int nxt[3][3] = {};
		int v[3][3] = {};
		if(ty[i] == 1){
			v[0][1] = 1;
			v[1][0] = -1;
			v[2][2] = 1;
		}
		else if(ty[i] == 2){
			v[0][1] = -1;
			v[1][0] = 1;
			v[2][2] = 1;
		}
		else if(ty[i] == 3){
			v[0][0] = -1; v[0][2] = 2LL * val[i];
			v[1][1] = v[2][2] = 1;
		}
		else{
			v[0][0] = 1;
			v[1][1] = -1; v[1][2] = 2LL*val[i];
			v[2][2] = 1;
		}
		rep(i, 3) rep(j, 3) rep(k, 3){
			nxt[i][k] += v[i][j] * zan[j][k];
		}
		rep(i, 3) rep(j, 3) zan[i][j] = nxt[i][j];
	}
	rep(i, q) cout<<ans[0][i]<<" "<<ans[1][i]<<'\n';
}
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	int t; t = 1; //cin >> t;
	while(t--) solve();
}

//#pragma GCC optimize(2)
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<cmath>
#include<cctype>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<sstream>
#include<ctime>
#include<cstdlib>
#define X first
#define Y second
#define L (u<<1)
#define R (u<<1|1)
#define pb push_back
#define mk make_pair
#define Mid (tr[u].l+tr[u].r>>1)
#define Len(u) (tr[u].r-tr[u].l+1)
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define db puts("---")
using namespace std;

//void rd_cre() { freopen("d://dp//data.txt","w",stdout); srand(time(NULL)); }
//void rd_ac() { freopen("d://dp//data.txt","r",stdin); freopen("d://dp//AC.txt","w",stdout); }
//void rd_wa() { freopen("d://dp//data.txt","r",stdin); freopen("d://dp//WA.txt","w",stdout); }

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;

const int N=200010,mod=1e9+7,INF=0x3f3f3f3f;
const double eps=1e-6;

int n,k;
int a[N];
char s[N];
int f[N][20];

int dfs(int pos,int state,int flag,int lead)
{
    int cnt=__builtin_popcount(state);
    if(cnt>k) return 0;
    if(pos==n+1) return cnt==k&&lead;
    if(flag&&lead&&f[pos][cnt]!=-1) return f[pos][cnt];
    int x=flag? 15:a[pos];
    int ans=0;
    for(int i=0;i<=x;i++)
        (ans+=dfs(pos+1,(!lead&&i==0)? state:state|(1<<i),flag||i<x,lead||i!=0))%=mod;
    if(flag&&lead) f[pos][cnt]=ans;
    return ans;
}

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

    scanf("%s%d",s+1,&k);
    n=strlen(s+1);
    for(int i=1;i<=n;i++)
        if(s[i]>='A'&&s[i]<='Z') a[i]=s[i]-'A'+10;
        else a[i]=s[i]-'0';
    memset(f,-1,sizeof(f));
    printf("%d",dfs(1,0,0,0));

	return 0;
}
/*

*/


#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll INF = 1e15;
ll n, m, k;

ll dp[1 << 17][20];

ll helper(vector<vector<ll>>& adj, ll from, ll to)
{
    queue<ll> q;
    q.push(from);
    ll ret = 0;
    vector<bool> visited(n + 1, false);
    visited[from] = true;
    while(!q.empty())
    {
        ret++;
        ll sz = q.size();
        while(sz--)
        {
            auto t = q.front();
            q.pop();
            for(auto nt : adj[t])
            {
                if(visited[nt])
                    continue;
                visited[nt] = true;
                if(nt == to)
                    return ret;
                q.push(nt);
            }
        }
    }
    return INF;
}

ll helper2(vector<vector<ll>>& dist, ll idx, ll status)
{
    if(status == ((1 << k) - 1))
        return 0;
    if(dp[status][idx] != -1)
        return dp[status][idx];

    ll ret = INF;
    for(ll i = 0; i < k; i++)
    {
        if(!((status >> i) & 1))
        {
            ll can = dist[idx][i] + helper2(dist, i, status | (1 << i));
            ret = min(ret, can);
        }
    }
    dp[status][idx] = ret;
    return ret;
}

ll mst(vector<vector<ll>>& dist)
{
    ll ret = INF;
    memset(dp, -1, sizeof(dp));
    for(ll i = 0; i < k; i++)
    {
        ll status = (1 << i);
        ll can = helper2(dist, i, status);
        ret = min(ret, can);
    }
    return ret;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    vector<vector<ll>> adj(n + 1);
    ll a, b;
    for(ll i = 0; i < m; i++)
    {
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    cin >> k;
    vector<ll> c(k);
    for(ll i = 0; i < k; i++)
        cin >> c[i];

    vector<vector<ll>> dist(k, vector<ll>(k, 0));
    for(ll i = 0; i < k; i++)
    {
        for(ll j = i + 1; j < k; j++)
        {
            ll num = helper(adj, c[i], c[j]);
            if(num >= INF)
            {
                cout << -1 << endl;
                return 0;
            }
            dist[i][j] = num;
            dist[j][i] = num;
        }
    }

    cout << mst(dist) + 1 << endl;

    return 0;
}

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

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

    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    vector<vector<int>> e(n), er(n);
    for(int i=0; i<m; i++){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        e[a[i]].push_back(b[i]);
        er[b[i]].push_back(a[i]);
    }

    int ans = 0;
    for(int i=0; i<n; i++){
        vector<int> vis(n, 0);
        vis[i] = 1;
        queue<int> q;
        for(int j=0; j<e[i].size(); j++){
            q.push(e[i][j]);
        }
        while(!q.empty()){
            int v = q.front();
            q.pop();
            if(vis[v]) continue;
            vis[v] = 1;
            for(int k=0; k<e[v].size(); k++){
                if(!vis[e[v][k]]) q.push(e[v][k]);
            }
        }
        for(auto v: vis){
            ans += v;
        }
    }
    cout << ans << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
  	cin >> N;
  	if(N%100==0){
    	cout << N/100 << endl;
    }
  	else{
    	cout << N/100+1 << endl;
    }
}

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

int main(int argc, char **argv) {
	int n; cin >> n;
	cout << ((n + 99) / 100) << endl;
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define ld long double
#define For(i,x,y) for(ll i = (ll)(x);i <= (ll)(y);++i)
#define FOr(i,x,y) for(ll i = (ll)(x);i >= (ll)(y);--i)
#define rep(i,x,y) for(ll i = (ll)(x);i < (ll)(y);++i)
#define fi first
#define se second
#define pa pair<ll,ll>
#define pb push_back
#define y1 y11111111111111
#define debug puts("@@@@@@@@@@@@@@@@@@@")

#define cpy(a,b) memcpy(a,b,sizeof(b))
inline ll read()
{
	ll x = 0,f = 1;char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-')f = -1;ch = getchar();}
	while(ch >= '0' && ch <= '9'){x = x*10+ch-'0';ch = getchar();}
	return x*f;
}

void write(ll x)
{
	if(x < 0) putchar('-'), x= -x;
	if(x > 9)write(x/10);
	putchar(x%10+'0');
}
const ll N=200010;
ll n,a[N];
vector<ll>ans;
bool ok(){
	For(i,1,n-1)if(a[i]>a[i+1])return 0;
	return 1;
}
void swp(ll i,ll j){
	swap(a[i],a[j]);
	ans.pb(i);
}
int main(){
	ll T=read();
	for(;T--;){
		n=read();	ans.clear();
		For(i,1,n)a[i]=read();
		for(;;){
			if (ok())break;
			bool fl=0;
			For(i,1,n-1)if(i&1){
				if (a[i]>a[i+1]){
					swp(i,i+1);
					fl=1;
					break;
				}
			}
			if(!fl){
				if(n&1)	swp(n-2,n-1);
				else	swp(n-1,n);
			}
			if (ok())break;
			fl=0;
			For(i,1,n-1)if(!(i&1)){
				if (a[i]>a[i+1]){
					swp(i,i+1);
					fl=1;
					break;
				}
			}
			if(!fl){
				if(n&1) swp(n-1,n);
				else	swp(n-2,n-1);
			}
		}
		cout<<ans.size()<<endl;;
		rep(i,0,ans.size())write(ans[i]),putchar(' ');puts("");
	}
}

#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define inf LLONG_MAX>>2
#define MAX 1000000
#define mod 1000000007
#define pb push_back
#define f(i,a,n,x) for ((i)=(a);(i)<(n);(i)+=(x))
#define fd(i,a,n,x) for ((i)=(a);(i)>=(n);(i)-=(x))
#define fi first
#define se second
#define mk make_pair
#define pi pair
#define vt vector
#define ms multiset
#define is insert
#define um unordered_map
using namespace std;
void read(vt<ll> &a,ll n){ll i,temp;f(i,0,n,1){cin>>temp;a.pb(temp);}}
ll fa[MAX];
ll power(ll p,ll q){
    ll res=1;
    p%=mod;
    while(q){
        if (q&1)
            res=(res*p)%mod;
        q>>=1;
        p=(p*p)%mod;
    }
    return res;
}
ll fact(ll n){
    if (n<=1)
        return fa[n]=1;
    if (fa[n])
        return fa[n];
    return fa[n]=(n*fact(n-1))%mod;
}
ll ncr(ll n,ll r){
    if (!r)
        return 1;
    return (((fact(n)*power(fact(n-r),mod-2))%mod)*power(fact(r),mod-2))%mod;
}
void solve(){
    ll i,j,sum,ans=inf,count;
    string s;
    cin>>s;
    f(j,0,1<<s.length(),1){
        sum=count=0;
        f(i,0,s.length(),1)
            if (!((1<<i)&j))
                sum+=s[i]-'0';
            else
                count++;
        if (!(sum%3))
            ans=min(ans,count);
    }
    cout<<(ans==s.length()?-1:ans)<<endl;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef vector<vi> vii;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  int n;
  cin >> n;
  string s; cin>>s;
  int q;
  cin >> q;
  int sw = 0;
  while(q--){
  	int t; cin >> t;
  	int a, b; cin >> a >> b;
  	a--, b--;
  	if(t == 2){
  		sw^=1;
  	}
  	else{
  		if(sw){
  			if(a < n){
  				a+= n;
  			}
  			else{
  				a-=n;
  			}
  			if(b < n){
  				b+= n;
  			}
  			else{
  				b-=n;
  			}
  		}
  		swap(s[a], s[b]);
  	}
  }
  if(sw){
  	for(int i = n; i < 2*n ; i++)
  		cout << s[i];
  	forn(i, n){
  		cout << s[i];
  	}
  	cout << "\n";
  }
  else{
  	for(auto i:s)
  		cout << i;
  	cout << "\n";
  }
  return 0;
}

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, ll> PIL;
typedef pair<ll, int> PLI;
typedef pair<ll, ll> PLL;
typedef bitset<16> BS;
struct edge {
    int to, cost, id;
};
const double PI = 3.14159265358979323846;
const double EPS = 1E-09;
const ll MOD = 1E+09 + 7; // =998244353;
const ll INFL = 1E18;
const int INFI = 1E09;
const int MAX_N = 2E+05;

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

int N, Q;

string S;

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

    cin >> N >> S >> Q;
    //cout << "S = " << S << ", T = " << T << "\n";

    bool mv = false;
    for (int i = 1; i <= Q; i++) {
        int t, a, b;
        cin >> t >> a >> b;
        a--;
        b--;
        if (t == 1) {
            if (!mv) {
                swap(S[a], S[b]);
            } else {
                if (a >= N)
                    a -= N;
                else
                    a += N;

                if (b >= N)
                    b -= N;
                else
                    b += N;

                swap(S[a], S[b]);
            }
        } else {
            mv = !mv;
        }
    }

    /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n";
        }
    }
    */
    string ans = "";
    if (mv) {
        string l = S.substr(0, N);
        string r = S.substr(N, N);
        ans = ans + r + l;
    } else {
        ans = S;
    }

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


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

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef float flt;

#define for0(i, n) for(ll i=0; i<n; i++)
#define for1(i, n) for(ll i=1; i<=n; i++)
#define forab(i, a, b) for(ll i=a; i<=b; i++)
#define clr0(a) memset(a, 0, sizeof(a))

void solve() {
    ll n;
    cin >> n;
    ll a[n+5][n+5];
    for1(i, n) {
        for1(j, n) {
            cin >> a[i][j];
        }
    }
    ll row[n+5], col[n+5];
    bool pos = true;
    for1(j, n) {
        if (j==1) {
            row[j] = 0;
        }
        else {
            row[j] = a[1][j] - a[1][1];
        }
    }
    for1(i, n) {
        if (i==1) {
            col[i] = 0;
        }
        else {
            col[i] = a[i][1] - a[1][1];
        }
    }
    forab(i, 2, n) {
        forab(j, 2, n) {
            ll rd = a[i][j] - a[i][1];
            ll cd = a[i][j] - a[1][j];
            if (rd!=row[j] || cd!=col[i]) {
                pos = false;
            }
        }
    }
    if (!pos) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
        ll rmn=99999999;
        ll cmn=99999999;
        ll offset;

        for1(i, n) {
            rmn = min(rmn, row[i]);
            cmn = min(cmn, col[i]);
        }
        if (rmn<=cmn) {
            offset = abs(rmn);
        }
        else {
            offset = a[1][1] - abs(cmn);
        }

        /*
        forab(i, 0, a[1][1]) {
            bool fnd = true;
            for1(j, n) {
                if (row[1]+i + col[j]+a[1][1]-i != a[1][j]) {
                    fnd = false;
                    break;
                }
            }
            if (fnd==true) {
                offset = i;
                break;
            }
        }
        */

        for1(i, n) {
            cout << col[i]+a[1][1]-offset << " ";
        }
        cout << endl;
        for1(j, n) {
            cout << row[j]+offset << " ";
        }
        cout << endl;

    }
}

void testcase() {
    ll t;
    cin >> t;
    while (t--) {
        solve();
    }
}

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

    //testcase();
    solve();

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
	cin >> n; vector<vector<int> > C( n,vector<int>( n ) );
	vector<int> A( n ), B( n );
	for( auto &i:C )	for( auto &j:i )	cin >> j;
	int minval=numeric_limits<int>::max(),mini=0,minj=0;
	for( int i=0;i<n;++i )
	{
		for( int j=0;j<n;++j )
		{
			if( C[i][j]<minval )	minval=C[i][j],mini=i,minj=j;
		}
	}
	for( int i=0;i<n;++i )	B[i]=C[mini][i];
	for( int i=0;i<n;++i )
	{
		if( C[i][minj]-minval<0 )	exit( ( puts( "No" ),0 ) );
		A[i]=C[i][minj]-minval;
		for( int j=0;j<n;++j )
		{
			if( ( C[i][minj]-minval )^( C[i][j]-B[j] ) )	exit( ( puts( "No" ),0 ) );
		}
	}
	puts( "Yes" );
	for( int i:A )	cout << i << ' '; cout << "\n";
	for( int i:B )	cout << i << ' '; cout << "\n";
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e5;
int parent[N], color[N];
vector<int> adj[N];
map<int, int> cnt_color;
set<int> ans;

void defineParents()
{
    memset(parent, -1, sizeof(parent));
    parent[0] = 0;

    queue<int> fila;
    fila.push(0);

    while(!fila.empty())
    {
        int v = fila.front();
        fila.pop();

        for(auto u: adj[v])
        {
            if(parent[u] == -1)
            {
                parent[u] = v;
                fila.push(u);
            }
        }
    }
}

void dfs(int x)
{
    if(cnt_color[color[x]] == 0) ans.insert(x + 1);
    cnt_color[color[x]]++;
    for(auto u: adj[x])
    {
        if(u != parent[x])
        {
            dfs(u);
        }
    }
    cnt_color[color[x]]--;
}

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

    defineParents();
    dfs(0);

    for(auto x: ans) cout << x << endl;
    return 0;
}

#include <stdio.h>
#include <set>
#include <utility>
typedef long long ll;

int main(void) {
  ll i, j, k, n, q;
  scanf("%lld", &n);
  ll a, t, b[2] = {(ll)-1e16, (ll)1e16}, s = 0, x;
  for(i = 0; i < n; ++i) {
    scanf("%lld%lld", &a, &t);
    if(t == 1) s += a;
    else if(t == 2) {
      if(b[1] + s < a) b[0] = b[1], s = a - b[0];
      else if(b[0] + s < a) b[0] = a - s;
    } else {
      if(b[0] + s > a) b[0] = b[1], s = a - b[0];
      else if(b[1] + s > a) b[1] = a - s;
    }
  }
  scanf("%lld", &q);
  for(i = 0; i < q; ++i) {
    scanf("%lld", &x);
    if(x < b[0]) printf("%lld\n", b[0] + s);
    else if(x < b[1]) printf("%lld\n", x + s);
    else printf("%lld\n", b[1] + s);
  }
  return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#include<iomanip>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define bpc(x) __builtin_popcount(x)
#define bpcll(x) __builtin_popcountll(x)
#define fps(n) fixed << setprecision(n)
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

double dp[105][105][105];
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int a,b,c; cin >> a >> b >> c;
    for(int i=99;i>=a;i--){
        for(int j=99;j>=b;j--){
            for(int k=99;k>=c;k--){
                dp[i][j][k] += (double)i/(i+j+k)*(dp[i+1][j][k]+1)+(double)j/(i+j+k)*(dp[i][j+1][k]+1)+(double)k/(i+j+k)*(dp[i][j][k+1]+1);
            }
        }
    }
    cout << fps(20) << dp[a][b][c] << endl;
    return 0;
}

#pragma GCC optimize("O3")
#pragma GCC target("sse4")

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#include <string> // ヘッダファイルインクルード
#include <typeinfo>
using namespace std; //  名前空間指定
using namespace std;
// using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

template <class T>

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; // check the limits, dummy

const ll infl = 1LL << 60;
template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
void print(const vector<T> v)
{
  cout << "[ ";
  F0R(i, v.size()) { cout << v[i] << ' '; }
  cout << "]" << '\n';
}

int mod(int i, int j)
{
  return (i % j) < 0 ? (i % j) + 0 + (j < 0 ? -j : j) : (i % j + 0);
}

// --------------------------------------------------------
// This is tool
// --------------------------------------------------------
void Main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int a, b, x, y, ans = 0;
  cin >> a >> b >> x >> y;
  if (a == b || a == b + 1)
  {
    ans = x;
  } else {
    int diff=0;
    diff = min(abs(b-a),abs(b-(a-1)));
    // cout << diff ;
    if (2*x <= y) {
      ans = x + diff *2*x;
    } else {
      ans =x + diff * y;
    }
  }
  cout << ans ;

}

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


#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<cmath>
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define per(i,a,b) for(ll i=a;i>=b;--i)
#define fi first
#define se second
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn=6e1+10,inf=0x3f3f3f3f3f3f3f3f;

ull maxbase[maxn];
void Init(){
	maxbase[1]=1e18;
	maxbase[2]=1e18;
	rep(i,3,60){
		int j=i-1;
		maxbase[i]=pow(1e18,1.0/j);
		while(pow((maxbase[i]+1)*1.0,j)<=1e18) maxbase[i]++;
		//cout<<i<<' '<<pow(maxbase[i]*1.0,j*1.0)<<endl;
	}
}

string X; ull M;
bool Check(ll b){

	ull tp=1,temp=0;
	per(i,X.size()-1,0) {
		temp+=(X[i]-'0')*tp;
		tp*=b;
		if(temp>M) return 0;
	}
	return 1;
}
int main()
{
	Init();
	cin>>X;
	cin>>M;

	if(X.size()==1){ cout<<(X[0]-'0'<=M?1:0)<<endl;return 0;}
	int large=0;
	rep(i,0,X.size()-1) large=max(large,X[i]-'0');

	ull l=large,r=maxbase[X.size()];
	while(l<r){
		ll mid=(l+r)/2+1;
		if(Check(mid)) l=mid;
		else r=mid-1;
	}
	cout<<l-large<<endl;
	return 0;
}

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

int main() {
    string X;
    ll M;
    cin >> X >> M;
    int d = 0;
    for (char c : X) if (c-'0'>d) d = c-'0';
    if (X.size() == 1) {
        cout << (d<=M) << endl;
        return 0;
    }
    ll L = d, R = M +1;
    while (R-L>1) {
        ll mid = (L+R)/2;
        bool ng = false;
        ll now = 0;
        for (char c : X) {
            if (now > M/mid) {ng = true; break;}
            now = now * mid + (c - '0');
        }
        if (ng | now > M) R = mid;
        else L = mid;
    }
    cout << L-d << endl;
}
// copy https://atcoder.jp/contests/abc192/submissions/20364184