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

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

    int n,k;
    cin>>n>>k;
    vector<int>cnt(n+1);
    for(int i=0;i<n;i++){
        int a;cin>>a;
        cnt[a]++;
    }
    int ans=0;
    int lst=k;
    for(int i=0;i<=n;i++){
        if(cnt[i]==0)break;

        lst=min(lst,cnt[i]);

        ans+=lst;
    }
    cout<<ans<<'\n';
    return 0;
}

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

ll solve(vl& A, map<P, ll>& m, ll x, int i) {
    if (i == int(A.size()) - 1) return 1;
    if (m.count(P(x, i))) return m[P(x, i)];
    ll d = x % A[i + 1];
    ll ret = solve(A, m, x - d, i + 1);
    if (d > 0) ret += solve(A, m, x + (A[i + 1] - d), i + 1);
    return m[P(x, i)] = ret;
}

int main() {
    // input
    ll N, X;
    cin >> N >> X;
    vl A(N);
    rep(i, N) cin >> A[i];

    // solve
    map<P, ll> m;
    ll ans = solve(A, m, X, 0);
    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 0x7fffffff
typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<ld> vld;

#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()

int main()
{
	fastIO;
	ll n; cin >> n;
	set<ll> s;
	for(ll i = 1; i*i <= n; i++)
	{
		if(n % i == 0)
		{
			s.insert(i);
			s.insert(n / i);
		}
	}
	for(auto x : s) cout << x << endl;

	return 0;
}

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

using namespace std;

typedef unsigned long long ull;

int main() {
	ull n, k, m, ans;

	cin >> n;

	k = 1;
	m = n + 1;
	ans = 1;

	m = n;
	k = 2;
	while (m > k) {
		ans++;

		m -= k;
		if (m > k) {
			ans += (k - 1);
		}
		else {
			ans += (m - 1);
		}
		k++;
	}

	cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,n;
	cin>>x;
	for(int i=1;i<=100000;i++)
	{
		if((x+i)%100==0)
		{
			cout<<i;
			return 0;
		}
		if(x%100==0)
		{
			break;
		}
	}
	cout<<"100";
	return 0;
}

#include <iostream>
using namespace std;

int main() {
	int n;
	cin>>n;
	if(n%100==0){
		cout<<"100";
	}
	else{
		cout<<100-(n%100);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<long long int> vi;
#define MOD 1000000007
#define INF 0x3f3f3f3f3f
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define RB pop_back
#define debug(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define tc ll test;cin >> test;while(test--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const double PI = 3.141592653589793238463;
//#pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

/*
   _        _____   _____               _____       _____
  | \    |  |       |    \    |        /     \     /
  |  \   |  |___    |     \   |       /       \   /   _____
  |   \  |  |       |     /   |       \       /   \       /
  |    \_|  |____   |____/    |______  \_____/     \_____/

*/

bool is_differbyone(string s1, string s2){
	if(s1.size() != s2.size()){
		return false;
	}
	ll count = 0;

	for(ll i = 0 ; i<s1.size();i++){
		if(s1[i] != s2[i]){
			count+=1;
		}
	}
	if(count == 1){
		return true;
	}
	return false;
}

ll getsum(ll n){
	ll ans = 0;
	while(n != 0){
		ll rem = n % 10;
		ans += rem;
		n = n/10;
	}
	return ans;
}

ll get_ans(ll n){
	ll cache = (n * (n + 1) / 2);
	return cache;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output1.out", "w", stdout);
	#endif

	ll n; cin>>n;
	ll arr[n];

	for(ll i = 0; i<n;i++){
		cin>>arr[i];
	}

	map<ll,ll> frequency;
	ll ans = 0;
	for(ll i = 0; i<n;i++){
		ans+= ( i - frequency[arr[i]]);
		frequency[arr[i]] += 1;

	}
	cout<<ans;

}

#include<bits/stdc++.h>
using namespace std;
int a[10010];
int main(){
	int n;
	cin >> n;
	for(int i=0;i<n;i++)cin >> a[i];
	int ans=0;
	for(int l=0;l<n;l++){
		int x=a[l];
		for(int r=l;r<n;r++){
			x=min(x,a[r]);
			ans=max(ans,x*(r-l+1));
		}
	}
	cout << ans;
}


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

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

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

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'
 #define mod 1000000007
typedef long long int ll;
typedef unsigned long long int  llu;

// PRIME NUMBER TEST//
bool prime(int n)
{
    if(n<2)return false;
    if(n<=3)return true;
    if(n%2==0)return false;
    for(int i=3;i*i<=n;i+=2)
    {
        if(n%i==0)return false;
    }
    return true;
}

// Graph Grid //
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main()
{
    int n;
    cin>>n;
    cout<<6<<" "<<10<<" "<<15<<" ";
    int cnt=n-3;
    int z=16;

    while(cnt!=0)
    {
        if(z%6==0 || z%10==0 || z%15==0)
        {
            cout<<z<<" ";
            cnt--;
        }
        z++;
    }
    cout<<nl;
    return 0;
}

/*_____________________
	|Author : canhnam357|
	|___________________|
*/
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <string> vs;
typedef vector <vector <int>> vvi;
typedef vector <vll> vvll;
typedef map<int, int> mi;
typedef map<string, int> ms;
typedef map<char, int> mc;
typedef map <int, bool> mb;
typedef map<ll, ll> mll;
typedef unordered_map<int, int> umi;
typedef unordered_map<string, int> ums;
typedef unordered_map<char, int> umc;
typedef unordered_map <int, bool> umb;
typedef unordered_map<ll, ll> umll;
typedef string S;
typedef vector <ld> vld;
typedef vector <bool> vb;
typedef pair <int, int> pii;
typedef pair<ll, ll> pll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
int CASE = 1;
const int mxn = 4e3 + 1;
const ll INF = 1e18;
#define FOR(i,N) for(ll i = 0 ; i < N;i++)
#define eFOR(i,a,b) for(ll i = a; i <=b;i++)
#define dFOR(i,N) for(ll i = N - 1; i>=0;i--)
#define edFOR(i,b,a) for(ll i = b ; i >=a;i--)
#define all(x) x.begin(),x.end()
#define SORT(x) sort(all(x))
#define RSORT(x) sort(x.rbegin(),x.rend())
#define UNQ(x)  unique(all(x))
#define mine(x) min_element(all(x))
#define maxe(x) max_element(all(x))
#define pb push_back
#define PI 3.141592653589793
#define FIX cout << fixed << setprecision(15)
const ll mod = 1e6 + 7;
bool prime(int n)
{
	if (n <= 1)
		return false;
	eFOR(i, 2, sqrt(n))
		if (!(n % i))
			return false;
	return true;
}
ll __gcd(ll a, ll b)
{
	return !b ? a : __gcd(b, a % b);
}
void solve()
{
	ll ans = 0;
	ll n;
	cin >> n;
	for (ll i = 4; i < to_string(n).length(); i++)
	{
		ans += 9 * pow(10LL, i - 1) * ((i - 1) / 3);
	}
	if (to_string(n).length() > 3)
		ans += (n - pow(10LL, to_string(n).length() - 1) + 1) * ((to_string(n).length() - 1) / 3);
	cout << ans;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T = 1;
	while (T--)
	{
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
typedef long long ll;

using namespace std;

int n;

bool cmp(int x1,int y1,int x2,int y2)
{
	if(min(x1,x2)==min(y1,y2)) return false;
	if(max(x1,x2)==max(y1,y2)) return false;
	return true;
}

void solve()
{
    cin >> n;
	vector<pair<int,int>> x,y;
	for(int i=1;i<=n;i++)
	{
		int tx,ty;
		cin >> tx >> ty;
		x.pb({tx,i}); y.pb({ty,i});
	}
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	int dy = y.back().fir-y[0].fir;
	int dy1 = y.back().fir-y[1].fir;
	int dy2 = y[y.size()-2].fir-y[0].fir;
	int dx = x.back().fir-x[0].fir;
	int dx1 = x.back().fir-x[1].fir;
	int dx2 = x[x.size()-2].fir-x[0].fir;
	int ret = 0;
	if(dy>=dx)
	{
		ret = max(dy1,dy2);
		ret = max(max(dx1,dx2),ret);
		if(cmp(x.back().sec,y.back().sec,x[0].sec,y[0].sec)) ret = max(dx,ret);
		cout << ret << endl;
	}
	else
	{
		ret = max(dx1,dx2);
		ret = max(max(dy1,dy2),ret);
		if(cmp(x.back().sec,y.back().sec,x[0].sec,y[0].sec)) ret = max(dy,ret);
		cout << ret << endl;
	}
    return;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int tc=1;
	//cin>>tc;
	for(int i=1;i<=tc;i++)
	{
		//cout << "Case #" << i << ": ";
		solve();
	}
 	return 0;
}

#include <bits/stdc++.h>
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define rep(i,n) Rep(i,0,n)
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
#define _GLIBCXX_DEBUG
using graph=vector<vi>;
vi d;
queue<int> q;
int bfs(graph &G,int s){
  d[s]=0;q.push(s);
  int last=0;
  while(!q.empty()){
    int t=q.front();q.pop();last=t;
    for(int v:G[t]){
      if(d[v]>=0) continue;
      d[v]=d[t]+1;q.push(v);
    }
  }
  return last;
};
vi ans;
void dfs(graph &G,int s,int &e,vi &dv){
  ans[s]=e;
  int last=-1;
  for(int v:G[s]){
    if(ans[v]>0) continue;
    if(dv[v]==0){
      last=v;
      continue;
    }
    e++;
    dfs(G,v,e,dv);
  }
  if(last>=0){
    e++;
    dfs(G,last,e,dv);
  }
  e++;
  return;
};
int main(){
  int N;cin>>N;
  graph G(N);
  rep(i,N-1){
    int x,y;cin>>x>>y;x--;y--;
    G[x].push_back(y);G[y].push_back(x);
  }
  d=vi(N,-1);
  int v=bfs(G,0);
  d=vi(N,-1);
  int u=bfs(G,v);
  vi dv=d;
  d=vi(N,-1);
  int s=bfs(G,u);
  vi du=d;
  int ds=d[s];

  rep(i,N){
    dv[i]+=(du[i]-ds);
  }
  ans=vi(N);
  int e=1;
  dfs(G,v,e,dv);
  rep(i,N){
    cout << ans[i];
    if(i<N-1) cout << ' ';
    else cout << endl;
  }
  return 0;
}


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

typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;

void solve()
{
    ll n;
    cin >> n;
    map<ll, ll> mp;
    for (ll i = 0; i < n; ++i)
    {
        ll x;
        cin >> x;
        mp[x]++;
    }
    ll ans = n * (n - 1) / 2;
    for (auto itr = mp.begin(); itr != mp.end(); itr++)
    {
        ll x = itr->second;
        ans -= x * (x - 1) / 2;
    }
    cout << ans << endl;
}

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

    //   ll t;
    //   cin >> t;
    //   while (t--)
    //   {
    cout << setprecision(15) << fixed;
    solve();
    //   }
    return 0;
}

#include <bits/stdc++.h>
#define ll    long long
#define pb    push_back
#define ld    long double
#define sz    size()
#define lala  for(ll i=0;i<n;i++)
#define pll   pair<ll,ll>
#define ed    "\n"
#define ct    cout
#define m_p   make_pair
#define vi    vector<ll>
#define vc    vector<char>
#define ff    first
#define ss    second

using namespace std;

void bahut_tezz()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void jai_bajrangbali()
{
    ll k,n,m,x,y,cnt=0,res=0,mx=1;
    ll sum=0;
    bool ash=false;
    string s;
    cin>>n;
    ll a[n];
    lala
    {
        cin>>a[i];
    }

    sort(a,a+n);

//    x=upper_bound(a,a+n,a[n-2])-a+1-1;
//    ct<<x<<ed;

    for(ll i=0;i<n-1;i++)
    {
        x=upper_bound(a,a+n,a[i])-a;
        cnt=cnt+abs(n-x);
    }

    ct<<cnt<<ed;

}

int main()
{
    bahut_tezz();
    long long t=1;
    //cin>>t;
    while(t--)jai_bajrangbali();

    return 0;
}


#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <vector>

using namespace std;
int facctorial(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
int H, W, A, B;

struct Point {
  Point(int x, int y) : x(x), y(y) {}
  int x, y;
};

bool erase_tile(std::vector<Point>& v, Point p) {
  bool s = false;
  for (auto it = v.begin(); it != v.end();) {
    if ((*it).x == p.x && (*it).y == p.y) {
      it = v.erase(it);
      s = true;
    } else {
      ++it;
    }
  }
  return s;
}

std::vector<Point> dir = {Point(0, 1), Point(1, 0)};

int fill_A(const std::vector<Point>& r, int n) {
  int ans = 0;
  bool has = false;
  if (n == 0) return 1;
  for (auto e : r) {
    for (auto d : dir) {
      auto r_ = r;
      bool s = erase_tile(r_, Point(e.x + d.x, e.y + d.y));
      if (s) {
        has = true;
        erase_tile(r_, e);
        ans += fill_A(r_, n-1);
      }
    }
  }
  return ans;
}

int main() {

  std::cin >> H >> W >> A >> B;
  std::vector<Point> rect;
  for (int h = 0; h < H; h++) {
    for (int w = 0; w < W; w++) {
      rect.emplace_back(Point(h, w));
    }
  }
  std::cout << fill_A(rect, A)/facctorial(A)<< endl;
  ;
}

// abc183_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int idx=0;idx<(n-1);idx++) cout << (vec)[idx] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << "\n";}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

// 区間add, 区間sum
template<typename T>
struct LazySegmentTree{
    int n;
    vector<T> val;
    vector<T> lazy;
    vector<int> width;

    explicit LazySegmentTree(int n_){
        n = 1;
        while (n < n_) n <<= 1;

        val = vector<T>(n<<1, 0);
        lazy = vector<T>(n<<1, 0);
        width = vector<int>(n<<1, 1);
        for (int i = n-2; i >= 0; i--) {
            width[i] = width[i*2+1] + width[i*2+2];
        }
    }
    void lazy_propagate(int k) {
        val[k] += lazy[k] * width[k];
        if (k < n-1) {
            lazy[k*2+1] += lazy[k];
            lazy[k*2+2] += lazy[k];
        }
        lazy[k] = 0;
    }
    void add(int a, int b, int k, int l, int r, int x) {
        lazy_propagate(k);

        if (b <= l || r <= a) {
            return;
        }
        if (a <= l && r <= b) {
            lazy[k] += x;
            lazy_propagate(k);
            return;
        }
        int mid = (l+r)/2;
        add(a, b, k*2+1, l, mid, x);
        add(a, b, k*2+2, mid, r, x);
        val[k] = val[k*2+1] + val[k*2+2];
    }

    void add(int a, int b, int x) {
        add(a, b, 0, 0, n, x);
    }

    T get_sum(int a, int b, int k, int l, int r) {
        lazy_propagate(k);

        if (b <= l || r <= a) {
            return 0;
        }
        if (a <= l && r <= b) {
            return val[k];
        }
        int mid = (l+r)/2;
        T sl = get_sum(a, b, k*2+1, l, mid);
        T sr = get_sum(a, b, k*2+2, mid, r);
        return sl + sr;
    }

    T get_sum(int a, int b) {
        return get_sum(a, b, 0, 0, n);
    }
};

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, W;
    cin >> N >> W;

    int mx = 2e5+1;
    LazySegmentTree<ll> st(mx);

    REP(i, N){
        int s, t, p;
        cin >> s >> t >> p;
        st.add(s, t, p);
    }

    REP(i, mx){
        ll w = st.get_sum(i, i+1);
        if (w > W){
            print("No");
            return 0;
        }
    }
    print("Yes");

    return 0;
}


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

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

void solver() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int N;
    cin >> N;

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

    vector<int> ans;
    for (int i = 0; i < N; i++) {
        int j = find(p.begin(), p.end(), i) - p.begin();
        if (i == j) {
            continue;
        }
        if (j % 2 == ans.size() % 2) {
            if (j >= i + 2) {
                ans.push_back(j - 2);
                swap(p[j - 2], p[j - 1]);
            } else {
                ans.push_back(i - 1);
                ans.push_back(i);
                ans.push_back(i - 1);
                ans.push_back(i);
                ans.push_back(i - 1);
                swap(p[i], p[i + 1]);
                continue;
            }
        }
        for (int k = j - 1; k >= i; k--) {
            ans.push_back(k);
            swap(p[k], p[k + 1]);
        }
    }

    cout << ans.size() << endl;
    for (auto v : ans) {
        cout << v + 1 << " ";
    }
    cout << endl;
}

int32_t main() {
    int N;
    cin >> N;

    for (int i = 0; i < N; i++) {
        solver();
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const ll mod = 1e9+7;

main(){
    int n;cin>>n;
    ll x[n];
    for(int i=0;i<n;i++) cin>>x[i];
    ll man=0,cheb = 0;
    double euc=0;
    for(int i=0;i<n;i++){
        man+= abs(x[i]);
        cheb = max(cheb,(ll)abs(x[i]));
        euc+= (x[i]*x[i]);
    }
    cout<<man<<"\n"<<fixed<<setprecision(10)<<sqrt(euc)<<"\n"<<cheb;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

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

	int N;
	cin >> N;
	VI A(N);
	REP(i, N) cin >> A[i];

	int a = 0, b;
	FOR(i, 2, 1001){
		int c = 0;
		REP(j, N) if(A[j] % i == 0) c++;
		if(a < c){
			a = c;
			b = i;
		}
	}
	cerr << a << endl;

	cout << b << endl;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
int main()
{
    int n;
    cin >> n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin >> arr[i];
    int ans=INT_MIN, res;
    for(int k=2; k<=1000; k++)
    {
        int cnt=0;
        for(int i=0;i<n;i++)
        {
            if(!(arr[i]%k))
                cnt++;
        }
        if(cnt>ans)
        {
            ans=cnt;
            res=k;
        }
    }
    cout << res;
}


#include <bits/stdc++.h>
#define endl "\n"
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define ll long long
#define llu unsigned long long
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define ABS(X) ((X) < 0 ? -(X) : (X))
#define LCM(X, Y) (((X) / (GCD((X), (Y)))) * (Y))
#define MEM(A, B) memset((A), (B), sizeof(A))
#define MEM_VEC(V, FILL) fill(V.begin(), V.end(), FILL)
#define FOR_EACH(IT, V) for (auto IT = V.begin(); IT != V.end(); IT++)
#define DEBUG_ARRAY_PRINT(A, I) cout << "at pos " << I << "  value is: " << A[I]
#define TURBO                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
using namespace std;
inline ll GCD(ll A, ll B)
{
    if (B == 0)
        return A;
    return GCD((B), (A % B));
}
inline ll POW(ll BASE, ll EXP)
{
    ll RES = 1;
    for (ll I = 0; I < EXP; I++)
        RES *= BASE;
    return RES;
}
inline ll BIGMOD(ll a, ll p, ll m)
{
    ll res = 1 % m;
    ll x = a % m;
    while (p > 0)
    {
        if ((p & 1) > 0)
            res = (res * x) % m;
        x = (x * x) % m;
        p >>= 1;
    }
    return res;
}
inline void FILE_HANDLE()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int main()
{
    TURBO;
    //FILE_HANDLE() ;
    ll n;
    scanf("%lld", &n);
    vector<ll> v;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            if (n / i == i)
                v.PB(i);

            else
            {
                v.PB(i);
                v.PB(n / i);
            }
        }
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size(); i++)
        printf("%lld\n", v[i]);
}

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

using namespace std;
using p=pair<int,int>;
typedef long long ll;

int main() {
  ll n;
  cin >> n;
  int counter = 0;
  for(int i=1; i <= sqrt(n);i++){
    if(n%i==0 && i!=sqrt(n)){
      counter+=2;
    }
    else if(n%i==0 && i==sqrt(n)){
      counter++;
    }
  }
  vector<ll>a(counter);
  int b = 0;
  for(int j = 1;j <= sqrt(n);j++){
    if(n%j == 0 && j != sqrt(n)){
      a[b] = j;
      a[counter-1-b] = n/j;
      b++;
    }
    else if(n%j == 0 && j == sqrt(n)){
      a[b] = j;
    }
  }
  for(int k = 0;k < counter;k++){
    cout << a[k] << endl;
  }

  return 0;

}


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

#define pb push_back
#define eb emplace_back
#define unused [[maybe_unused]]
#define tempT template<class T>
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << '\n'
#define ans_exit(x) { cout << x << endl; exit(0); }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (ll i = (ll)(n); i < (ll)(m); i++)

using ll   unused = long long;
using ld   unused = long double;
using vl   unused = vector<ll>;
using vvl  unused = vector<vl>;
using vvvl unused = vector<vvl>;
using lp   unused = pair<ll, ll>;
using lmap unused = map<int, int>;

unused constexpr ll MOD = 1e9 + 7;
unused constexpr ll INF = 1 << 30;
unused constexpr ll LINF = 1LL << 62;
unused constexpr int DX[8] = {0, 1, 0,-1, 1, 1,-1,-1};
unused constexpr int DY[8] = {1, 0,-1, 0, 1,-1, 1,-1};
unused inline bool bit(ll b, ll i) { return b & (1LL << i); }
unused inline ll ceiv(ll a, ll b) { return (a + b - 1) / b; }
unused inline ll mod(ll a, ll m = MOD) { return (a % m + m) % m; }
tempT unused bool chmin(T &a, T b) { if(a > b) {a = b; return 1;} return 0; }
tempT unused bool chmax(T &a, T b) { if(a < b) {a = b; return 1;} return 0; }

int main() {
    ll n, x;
    cin >> n >> x;
    vl ans;
    rep(i, n) {
        ll a; cin >> a;
        if(a != x) ans.pb(a);
    }
    rep(i, ans.size() - 1) {
        cout << ans[i] << " ";
    }
    if(ans.size() > 0) cout << ans.back();
    cout << endl;
}

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

int main(){
 long long N, X;
 vector<long long> A;
 cin >> N >> X;

 long long temp;
 long long a_cnt = 0;

  for(long long i = 0; i<N; i++){
    cin >>temp;
    if(temp != X){
      A.push_back(temp);
      cout << A[a_cnt] << " " ;
      a_cnt++;
    }
  }
}


#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
int N, A, ans=0; cin >> N; vector<int> T;
stack< vector<int> > S; S.push({0, -1});
REP(i, N+1){
  if(i<N){ cin >> A; }else{ A=0; }
  T=S.top();
  if(A>T[0]){ S.push({A, i}); continue; }
  while(A<T[0]){
    ans=max(ans, T[0]*(i-T[1]));
    S.pop(); T=S.top();
  }
  S.push({A, T[1]+1}); S.push({A, i});
}
cout << ans << "\n";
}

#include <bits/stdc++.h>

using namespace std;

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

#define rng_init mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define int long long

const int MXN = 1e5 + 5, INF = 1e9 + 5;

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

    vector<int> A(N);
    for (auto &x : A) cin >> x;

    int ans = 0;

    for (int i = 0; i < N; i++) {
        int mn = A[i];
        for (int j = i; j < N; j++) {
            mn = min(mn, A[j]);
            ans = max(ans, (j - i + 1) * mn);
        }
    }

    cout << ans;
}

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

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

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


//Thanks for viewing, hope it helps :)
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(ll i=(a);i<(b);i++)
#define fr(i,a,b) for(ll i=(a);i>=(b);i--)
#define  pb push_back
#define pob pop_back
#define F first
#define S second
#define P(a,n) f(i,0,n) cout<<a[i]<<" ";cout<<"\n"
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test int t; cin>>t; while(t--)
#define all(V) V.begin(),V.end()
typedef  long long int ll;
typedef  unsigned long long int ull;
#define MOD 1000000007
#define MAX LONG_LONG_MAX-1e8
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
//bool is_powerof_2(ll x){
//    return x&&(!(x&(x-1)));
//}
//map<ll,ll> fact(ll n) {
//    map<ll,ll> factorization;ll c=0;
//    while (n % 2 == 0) {
//        c++;
//        n /= 2;
//    }
//    if(c>0)
//    {
//        factorization.insert({2,c});
//    }c=0;
//    for (ll d = 3; d * d <= n; d += 2) {
//        while (n % d == 0) {
//            c++;
//            n /= d;
//        }
//        if(c>0)
//    {
//        factorization.insert({d,c});
//    }c=0;
//    }
//    if (n > 1)
//       {
//           factorization.insert({n,1});
//       }
//    return factorization;
//}
//ll mod_pow( ll x,ll n,ll m){ // =(x*n)mod m
//    ll res=1;
//    x%=m;
//    while(n){
//        if(n&1) res=res*x%m;
//        x=x*x%m;
//        n>>=1;
//    }
//    return res;
//
//}
//bool cmp(const pair<ll,ll>&a,const pair<ll,ll>&b){
//    if(a.F==b.F) return (a.S<b.S);
//    return (a.F>b.F);
//}
//
//bool Prime[1000000001]; // First make it Global
//void seive(){
//
//    memset(Prime,true,sizeof(Prime));
//    for(ll i=2;i*i<MAX;i++){
//        if(Prime[i]){
//
//            for(ll j=i*i;j<MAX;j+=i){
//                Prime[j]=false;
//            }
//
//        }
//    }
//    Prime[1]=false;
//}
//ll MN[MAX][20];
//ll MX[MAX][20];
//void Sparse_Table_min(vector<ll>A,ll n){
//
//    f(i,0,n) MN[i][0]=A[i];
//    for(ll j=1;(1<<j)<=n;j++){
//        for(ll i=0;(i+(1<<j)-1)<n;i++){
//            MN[i][j]=min(MN[i][j-1],MN[i+(1<<(j-1))][j-1]);
//        }
//    }
//}
//ll query_min(ll x,ll y){
//    ll j=log2(y-x+1);
//    ll ans=min(MN[x][j],MN[y-(1<<j)+1][j]);
//    return ans;
//}
//void Sparse_Table_max(vector<ll>A,ll n){
//
//    f(i,0,n) MX[i][0]=A[i];
//    for(ll j=1;(1<<j)<=n;j++){
//        for(ll i=0;(i+(1<<j)-1)<n;i++){
//            MX[i][j]=max(MX[i][j-1],MX[i+(1<<(j-1))][j-1]);
//        }
//    }
//}
//ll query_max(ll x,ll y){
//    ll j=log2(y-x+1);
//    ll ans=max(MX[x][j],MX[y-(1<<j)+1][j]);
//    return ans;
//}
//ll s[100005],e[100005];
//class ComparisonClass {
//public:
//
//    bool operator() (const pair<ll,ll>&a,const pair<ll,ll>&b) {
//      if(a.F<b.F) return 1;
//      else if(a.F>b.F) return 0;
//      else{
//        if(e[a.S]<e[b.S]) return 1;
//        else return 0;
//     }
//    }
//};
//bool cmp(const pair<ll,ll>&a,const pair<ll,ll>&b){
//    if(a.F<b.F) return 1;
//    else if(a.F>b.F) return 0;
//    else{
//        if(e[a.S]<e[b.S]) return 1;
//        else return 0;
//    }
//}
//bool can_go(int i,int j,int n,int m,int k){
//    if(k<0) return 0;
//    if(k==0){
//        if(i==n && j==m) return 1;
//        else return 0;
//    }
//    if(i>n || j>m) return 0;
//    bool a,b;
//    a=can_go(i,j+1,n,m,k-i);
//    b=can_go(i+1,j,n,m,k-j);
//    return (a||b);
//}
//

void solve(){
    ll a,b,c;cin>>a>>b>>c;
    cout<<21-(a+b+c)<<"\n";
}

int main(){
    fast
// test{
        solve();
 // }
}

#include <iostream>
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define inf 9223372036854775807
#define minf -9223372036854775808
#define mod 1000000007
//#include "stdc++.h"
using namespace std;
ll min(ll a,ll b){
    if(a<b)
    return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)
    return a;
    return b;
}
ll gcd(ll a,ll b){

    if(a==0)
    return b;
    if(b==0)
    return a;
    return gcd(b,a%b);
}
ll power(ll x,ll y){
    x=x%mod;
    if(x==1)
    return 1;
    if(y==0)
    return 1;
    if(y==1)
    return x;
    ll temp=power(x,y>>1);
    if(y&1){
        return ((((temp*temp)%mod)*x)%mod);
    }
    else
    return ((temp*temp)%mod);
}

void factorial(ll n,vector<ll> &fact){
    fact[0]=1;
    fact[1]=1;
    for(ll i=2;i<=n;i++)
    fact[i]=(fact[i-1]*(i%mod))%mod;
    return;
}

ll inv(ll n){
    return power(n,mod-2);
}

ll ncr(ll n,ll r,vector<ll> &fact){
    if(r>n)
    return 0;
    return ((((fact[n]*inv(fact[n-r]))%mod)*inv(fact[r]))%mod);
}

void find_primes(ll n,vector<ll> &primes){
    bool isprime[n+1];
    for(ll i=0;i<=n;i++)
    isprime[i]=1;
    isprime[0]=0;
    isprime[1]=0;
    for(ll i=2;i<=n;i++){
        if(isprime[i]){
            for(ll j=i*i;j<=n;j+=i){
                isprime[j]=0;
            }
        }
    }
    for(ll i=0;i<=n;i++){
        if(isprime[i]){
            primes.push_back(i);
        }
    }
    return;
}

void find_fact1(ll n,vector<ll> &primes,vector<unordered_map<ll,ll> > &primfact){
    vector<ll> cur(n+1);
    for(ll i=0;i<=n;i++){
        cur[i]=i;
    }
    for(auto x:primes){
        for(ll i=x;i<=n;i+=x){
            ll cnt=0;
            while(cur[i]%x==0){
                cur[i]/=x;
                cnt++;
            }
            primfact[i][x]=cnt;
        }
    }
    return;
}
void find_fact2(ll n,vector<ll> &primes,vector<ll> &sp){
    for(ll i=0;i<=n;i++){
        sp[i]=i;
    }
    for(auto x:primes){
        for(ll i=x*2;i<=n;i+=x){
            sp[i]=min(sp[i],x);
        }
    }
    return;
}

void bfs(ll u,vector<vector<ll> >&adj,vector<ll> &dist){
    ll n=adj.size()-1;
    vector<bool> vis(n+1,0);
    vis[u]=1;
    dist[u]=0;
    queue<ll> q;
    q.push(u);
    ll level=1;
    while(!q.empty()){
        ll k=q.size();
        for(ll i=0;i<k;i++){
            ll x=q.front();
            q.pop();
            for(auto y:adj[x]){
                if(!vis[y]){
                    vis[y]=1;
                    dist[y]=level;
                    q.push(y);
                }
            }
        }
        level++;
    }
    return;
}

void solve(){
ll a,b,c;
  cin>>a>>b>>c;
  ll sum=a+b+c;
  ll ans=21-sum;
  cout<<ans<<endl;
}

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

    /*ll n1=300000;
    vector<ll> fact(n1+1);
    factorial(n1,fact);*/

    /*vector<ll> primes;
    ll n2=10000;
    find_primes(n2,primes);*/

    /*ll n3=100000;
    vector<unordered_map<ll,ll> >primfact(n3+1);
    find_fact1(n3,primes,primfact);*/

    /*ll n3=100000;
    vector<ll>sp(n3+1);
    find_fact2(n3,primes,sp);*/

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


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

typedef long long LL;
const int MAXN = 2005;
const int INF = 0x3f3f3f3f;
int n,m;
char a[MAXN][MAXN];

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

int dp[MAXN][MAXN][2];
int p(int x,int y)
{
	if(a[x][y] == '+') return 1;
	return 0;
}
int dfs(int x,int y,int who)
{
	if(x == n && y == m) return 0;
	if(dp[x][y][who] != INF) return dp[x][y][who];
	int ret = -INF;
	if(x < n) ret = Max(ret,p(x+1,y)-dfs(x+1,y,who^1));
	if(y < m) ret = Max(ret,p(x,y+1)-dfs(x,y+1,who^1));
	return dp[x][y][who] = ret;
}

int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n = Read(); m = Read();
	for(int i = 1;i <= n;++ i)
		for(int j = 1;j <= m;++ j)
			for(int k = 0;k <= 1;++ k)
				dp[i][j][k] = INF;
	for(int i = 1;i <= n;++ i)
		scanf("%s",a[i]+1);
	int ans = dfs(1,1,0);
	if(ans > 0) printf("Takahashi");
	else if(ans < 0) printf("Aoki");
	else printf("Draw");
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
#ifndef LOCAL
    ios::sync_with_stdio(0);
    cin.tie(0);
#endif

    int h, w;
    cin >> h >> w;

    vector<string> field(h);
    for (auto &it : field) {
        cin >> it;
    }

    vector<vector<int>> score(h, vector<int>(w));

    auto getPlayer = [&](int y, int x) {
        return (y + x) % 2 == 0 ? 1 : -1;
    };

    map<char, int> symbol;
    symbol['+'] = 1;
    symbol['-'] = -1;

    for (int i = h - 2; i >= 0; i--) {
        score[i][w - 1] = score[i + 1][w - 1];
        score[i][w - 1] += symbol[field[i + 1][w - 1]] * getPlayer(i, w - 1);
    }
    for (int i = w - 2; i >= 0; i--) {
        score[h - 1][i] = score[h - 1][i + 1];
        score[h - 1][i] += symbol[field[h - 1][i + 1]] * getPlayer(h - 1, i);
    }
    for (int i = h - 2; i >= 0; i--) {
        for (int j = w - 2; j >= 0; j--) {
            int p = getPlayer(i, j);
            if (score[i + 1][j] * p > score[i][j + 1] * p || (score[i + 1][j] == score[i][j + 1] && field[i + 1][j] == '+' && field[i][j + 1] == '-')) {
                score[i][j] = score[i + 1][j];
                score[i][j] += symbol[field[i + 1][j]] * p;
            } else {
                score[i][j] = score[i][j + 1];
                score[i][j] += symbol[field[i][j + 1]] * p;
            }
        }
    }
    if (score[0][0] > 0) {
        cout << "Takahashi\n";
    } else if (score[0][0] < 0) {
        cout << "Aoki\n";
    } else {
        cout << "Draw\n";
    }
}


#include <iostream>
#include <cmath>

int main()
{
  long long A, B, C;
  std::cin >> A >> B >> C;

  char ans;
  if (C == 0)
  {
    ans = '=';
  }
  else if( C%2 == 0)
  {
    A = std::abs(A);
    B = std::abs(B);
    if (A == B)
    {
      ans = '=';
    }
    else if (A < B)
    {
      ans = '<';
    }
    else
    {
      ans = '>';
    }
  }
  else
  {
    bool notreverse = true;
    if (A == B)
    {
      ans = '=';
    }
    else if (A < B)
    {
      ans = '<';
    }
    else
    {
      ans = '>';
    }
  }

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

#include <bits/stdc++.h>
#include <vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 300005
#define MOD 1000000007
#define SMOD 998244353
#define ROOT 512
#define GMAX 10000
#define INF 8000000000000000000
#define EPS 0.000000001
#define NIL 0
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
int main()
{
    int a,b,c,A,B;
    scanf("%d %d %d",&a,&b,&c);
    if(a<0) A=-a;
    else A=a;
    if(b<0) B=-b;
    else B=b;
    if(c%2)
    {
        if(a>b)
        {
            printf(">");
        }
        else if(a<b)
        {
            printf("<");
        }
        else
        {
            printf("=");
        }
    }
    else
    {
        if(A>B)
        {
            printf(">");
        }
        else if(A<B)
        {
            printf("<");
        }
        else
        {
            printf("=");
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll inf=INF*INF;
const ll mod=998244353;
const ll MAX=110;

signed main(){
    ll n,x;cin>>n>>x;
    ll sum=0;
    x*=100LL;
    rep(i,n){
        ll v,p;cin>>v>>p;
        sum+=v*p;
        if(sum>x){
            cout<<i+1<<endl;
            return 0;
        }
    }
    if(sum<=x){
        cout<<-1<<endl;
    }
}

    #include <bits/stdc++.h>

    // #include <ext/pb_ds/assoc_container.hpp>
    // #include <ext/rope>
    // #include <ext/pb_ds/tree_policy.hpp>
    // #include <ext/pb_ds/trie_policy.hpp>
    // using namespace __gnu_pbds;
    // using namespace __gnu_cxx;
    // typedef tree<long long, null_type, std::less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;
    // typedef trie<std::string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>Trie;

    using namespace std;
    #define rep(i,a,n) for (int i=a;i<n;i++)
    #define per(i,a,n) for (int i=n-1;i>=a;i--)
    #define pb push_back
    #define mp make_pair
    #define all(x) (x).begin(),(x).end()
    #define fi first
    #define se second
    #define sz(x) ((int)(x).size())
    #define rdv(x) long long x; cin>>x;
    #define deb(x) cout<<#x<<"="<<x<<endl;
    #define inf 1e18
    #define endl "\n"

    typedef vector<long long> vll;
    typedef long long ll;
    typedef pair<long long,long long> pii;
    typedef long double ld;
    mt19937 mrand(random_device{}());
    const ll mod=1000000007;
    int rnd(int x) { return mrand() % x;}
    ll powmod(ll a,ll b) {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 gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
    bool prime[200001];
    void SieveOfEratosthenes()
    {
        memset(prime, true, sizeof(prime));
        prime[1]=false;
        for (int p=2; p*p<=200000; p++)
        {
            if (prime[p] == true)
            {
                for (int i=p*p; i<=200000; i += p)
                    prime[i] = false;
            }
        }
        return;
    }

    ll ceil(ll x,ll y)
    {
        ll ans=x/y;
        if(x%y)
            ans++;

        return ans;
    }

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

    void YN(bool flag)
    {
        if(flag)
            cout<<"Won";
        else
            cout<<"Lost";
    }

    // head

    void solve()
    {
        ll n,x;

        cin>>n>>x;

        ll con=0;
        ll ans=-1;
        rep(i,0,n)
        {
            ll a,b;
            cin>>a>>b;

            con+=(a*b);
            if(con>x*100)
            {
                ans=i+1;
                break;
            }
        }

        cout<<ans;

        cout<<"\n";
    }
    int main()
    {
        ios_base::sync_with_stdio(false); 			//Used to reduce the time
        cin.tie(NULL);
        cout.tie(NULL);

        file_i_o();

        ll T=1;
        //cin>>T;
        //ll temp=T;
        while(T--)
        {
            //cout<<"Case #"<<temp-T<<": ";
            solve();
        }
        cerr<<"Time : "<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<" ms\n";
    }


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){

    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N,K;cin>>N>>K;
    vector<int> cnt(N+1);
    for(int i=0;i<N;i++){
        int a;cin>>a;
        cnt[a]++;
    }

    ll ans=0;

    for(int t=0;t<K;t++){
        for(int i=0;i<=N;i++){
            if(cnt[i]==0){
                ans+=i;
                break;
            }else{
                cnt[i]--;
            }
        }
    }

    cout<<ans<<endl;
}

#include<iostream>
#include<map>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int n,k; cin >>n >>k;
  map<li,int> cnt;
  rep(i,n){
    li a; cin >>a;
    cnt[a]++;
  }
  li s=0;
  int i=0,a=k;
  while(1){
    int c=cnt[i];
    if(df)print(c);
    if(a>c){
      s+=(a-c)*i;
      if(df)print(a-c,i);
      a=c; if(a==0) break;
    }
    i++;
  }
  print(s);
}


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

typedef long long ll;

char X[1010];

ll m;
int len;

bool check(ll x)
{
    ll res = 0;
    for (int i = 1; i <= len; i++)
    {
        res = res * x + X[i] - '0';
        if (res > m || res < 0)
            return 0;
    }
    return 1;
}

int main()
{
    scanf("%s%lld", X + 1, &m);
    len = strlen(X + 1);
    if (len == 1)
    {
        if (X[1] - '0' <= m)
            puts("1");
        else
            puts("0");
        return 0;
    }
    ll l = 0, r = m, mid;
    int ans1 = 0;
    for (int i = 1; i <= len; i++)
        ans1 = max(ans1, X[i] - '0');
    ll ans2 = ans1;
    l = ans1 + 1;
    if (len > 2)
        r = sqrt(m) + 1;
    else
        r = m;
    while (l <= r)
    {
        mid = (l + r) / 2;
        if (check(mid))
        {
            l = mid + 1, ans2 = mid;
        }
        else
            r = mid - 1;
    }
    cout << ans2 - ans1 << endl;
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <math.h>
#include <queue>
#include <list>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <ctime>
#include <iomanip>
#include <fstream>
#include <random>
#include <numeric>
using namespace std;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define IN(x,c) (find(c.begin(),c.end(),x) != (c).end())
#define REP(i,n) for (int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define INIT(a,v) memset(a,v,sizeof(a))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
template<class A, class B> A cvt(B x) { stringstream ss; ss<<x; A y; ss>>y; return y; }

#define SPC << " " <<
#define DEBUG(x) cerr << #x << " = "; cerr << x << endl;
#define DEBUG_ITER(x) cerr << #x << " = "; for (auto _ : x) cerr << _ << ' '; cerr << endl;

typedef pair<int,int> PII;
typedef long long int64;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<double> VD;

int main() {
    //freopen("test.in","r",stdin);
    int64 b,c;
    cin >> b >> c;
    vector<pair<int64,int64> > seg;
    seg.PB({b-c/2, 1}); seg.PB({b+1, -1});
    if (c>=1) { seg.PB({-b-(c-1)/2, 1}); seg.PB({-b+(c-1)/2+1, -1}); }
    if (c>=2) { seg.PB({b-(c-2)/2, 1}); seg.PB({b+(c-2)/2+1, -1}); }
    sort(ALL(seg));
    int64 cov=0,y=-3e18;
    int64 r=0;
    for (auto [x, t] : seg) {
        if (cov>0) r+=x-y;
        cov+=t;
        y=x;
    }
    cout << r << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long i64;
typedef unsigned long long ui64;
typedef vector<i64> vi;
typedef vector<vi> vvi;
typedef pair<i64, i64> pi;

#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)
inline void RI(i64 &i) {scanf("%lld", &(i));}
inline void RVI(vi &v) { for(i64 i=0;i<sz(v);++i) { RI(v[i]); } }
inline void RVVI(vvi &vv) { for(i64 i=0;i<sz(vv);++i) { RVI(vv[i]); } }
inline void WI(const i64 &i) {printf("%lld\n", i);}
inline void WVI(const vi &v, char sep=' ') { for(i64 i=0;i<sz(v);++i) { if(i != 0){ printf("%c", sep); } printf("%lld", v[i]);} printf("\n"); }
inline void WS(const string &s) { printf("%s\n", s.c_str()); }
inline void WB(bool b, const string &yes, const string &no) { if(b){ WS(yes);} else { WS(no);} }
inline void YESNO(bool b) { WB(b, "YES", "NO"); }
inline void YesNo(bool b) { WB(b, "Yes", "No"); }
#define BUF_LENGTH 1000000
inline void RS(string &s) {static char buf[BUF_LENGTH]; scanf("%s", buf); s = buf;}
template<typename T> inline bool IN(T &S, const typename T::key_type &key) {
  return S.find(key) != S.end();
}
template<typename T> inline bool ON(const T &b, i64 idx) {
  return ((T(1) << idx) & b) != 0;
}

template<long long M, typename T=long long>
struct modint {
  modint(T v=T(0)) : val((v >= 0 ? v : (M - ((-v) % M))) % M) {}
  using this_type = modint<M, T>;
  T val;
  this_type operator++(int) {
    this_type ret = *this;
    val++; val %= M;
    return ret;
  }
  this_type operator--(int) {
    this_type ret = *this;
    val += M-1; val %= M;
    return ret;
  }
  this_type &operator++() {
    val++; val %= M;
    return *this;
  }
  this_type &operator--() {
    val += M-1; val %= M;
    return *this;
  }
  this_type operator+() const { return *this; }
  this_type operator-() const { return this_type(M-val); };
  friend this_type operator+(const this_type &lhs, const this_type &rhs) {
    return this_type(lhs) += rhs;
  }
  friend this_type operator-(const this_type &lhs, const this_type &rhs) {
    return this_type(lhs) -= rhs;
  }
  friend this_type operator*(const this_type &lhs, const this_type &rhs) {
    return this_type(lhs) *= rhs;
  }
  friend this_type operator/(const this_type &lhs, const this_type &rhs) {
    return this_type(lhs) /= rhs;
  }
  this_type pow(long long b) const {
    this_type ret = 1, a = *this;
    while(b != 0) {
      if(b % 2 != 0) {
        ret *= a;
      }
      b /= 2;
      a = a * a;
    }
    return ret;
  }
  this_type inv() const {
    return pow(M-2);
  }
  this_type& operator+=(const this_type &rhs) {
    val += rhs.val; val %= M; return *this;
  }
  this_type& operator-=(const this_type &rhs) {
    val += M - rhs.val; val %= M; return *this;
  }
  this_type& operator*=(const this_type &rhs) {
    val *= rhs.val; val %= M; return *this;
  }
  this_type& operator/=(const this_type &rhs) {
    *this *= rhs.inv(); return *this;
  }
  friend bool operator==(const this_type &lhs, const this_type &rhs) {
    return lhs.val == rhs.val;
  }
  friend bool operator!=(const this_type &lhs, const this_type &rhs) {
    return lhs.val != rhs.val;
  }
  T mod() const {return M;}
};

using mi = modint<1000000007>;
using vmi = vector<mi>;
using vvmi = vector<vmi>;

int main(int argc, char *argv[]) {
  i64 i, j, k;
  i64 N; RI(N);
  vi A(N); RVI(A);

  vvmi ans(N+1, vmi(N+1, 0));
  fill(all(ans[1]), 1);
  ans[1][0] = 0;
  REP(2, N+1, k) {
    vi prev(N+1, -1);

    i64 S = 0;
    vi res(k, -1);
    res[0] = 0;
    REP(1, N+1, i) {
      S += A[i-1];
      S %= k;
      prev[i] = res[S];
      res[S] = i;
    }

    REP(1, N+1, i) {
      ans[k][i] = 0;
      if(prev[i] != -1) {
        ans[k][i] += ans[k][prev[i]];
        ans[k][i] += ans[k-1][prev[i]];
      }
    }
  }

  mi a = 0;
  REP(1, N+1, k) {
    a += ans[k].back();
  }
  WI(a.val);

  return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long LL;
const int N = 200010;
const int mod = 998244353;
int qmi(int a, int b)
{
	int res = 1;
	while(b)
	{
		if(b & 1) res = (LL) res * a % mod;
		b >>= 1;
		a = (LL)a * a % mod;
	}
	return res;
}
int n, m, k;
int main ()
{
	LL ans = 0;
	cin >> n >> m >> k;
	if(n == 1 && m == 1){
		printf("%d\n", k);
		return 0;
	}
	if(m == 1)
	{
		printf("%d\n", qmi(k, n));
		return 0;
	}
	if(n == 1)
	{
		printf("%d\n", qmi(k, m));
		return 0;
	}
	for(int i = 1; i <= k; i ++)
	{
		ans = (ans + (LL)((qmi(i, n) - qmi(i - 1, n)) % mod + mod) % mod * qmi(k - i + 1, m) % mod) % mod;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a*a+b*b < c*c){
        cout << "Yes"<< endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

void debug_out() { cerr << endl; }

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

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

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

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

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int a,b,c; cin >> a >> b >> c;
	if(a*a+b*b < c*c){
		cout << "Yes\n";
		return 0;
	}
	cout << "No\n";
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


#include<bits/stdc++.h>
using namespace std;
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')';}
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) {os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
template<typename T> void dbg_a(T *a,int l,int r){cerr<<" {";for(int i = l;i<r;i++) cerr<<a[i]<<", ";cerr<<a[r]<<"}"<<endl;}
typedef long long ll;
#define int ll
//typedef unsigned long long ull;
inline int read(){
    int f(1),r(0);char c(getchar());
    while(c<'0'||c>'9'){if(c == '-') f = -1; c = getchar();}
    while(c>='0'&&c<='9'){ r = (r<<1) + (r<<3) + c - '0';c = getchar();}
    return f*r;
}
typedef pair<int,int> PII;
#define fi first
#define se second
#define mst(a,b) memset(a,b,sizeof(a))
#define For(i,a,b) for(int i = a;i<=b;i++)
#define For_(i,a,b) for(int i = a;i>=b;i--)
#define _for(i,a) for(int i = 0;i<a;i++)
#define _sum(a,l,r) accumulate(a + l,a + r + 1,0)
#define All(x) x.begin(),x.end()
#define lowbit(x) ((-x)&x)
//    For(i,1,n) For(j,1,m) printf("f[%lld][%lld] = %lld\n",i,j,f[i][j]);
//const ll INF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int N = 100 + 6,M = 2e5*2 + 6,Q = 2e6 + 5;
const int mod = 1e9 + 7;
int n,m,k;
struct UFs{
    vector<int> pre,num;
    UFs(int l){
        pre.resize(l+1);num.resize(l+1);
        for(int i = 0;i<=l;i++) pre[i] = i,num[i] = 1;
    }
    int Find(int x){
        int p = x,tmp;
        while(x != pre[x]) x = pre[x];
        while(x != p){ tmp = pre[p];pre[p] = x;p = tmp;}
        return x;
    }
    void join(int x,int y){//插到y上
        int q = Find(x),p = Find(y);
        if(q == p) return ;
        pre[q] = p; num[p] += num[q];
    }
    bool same(int x,int y){
        return Find(x) == Find(y);
    }
    bool is_root(int x){
        return pre[x] == x;
    }
};
int clr[N];
bool vis[N];
vector<int> G[25];
vector<int> v;
void dfs2(int x){
    v.emplace_back(x);
    vis[x] = 1;
    for(int y:G[x]){
        if(vis[y]) continue;
        dfs2(y);
    }
}
int res = 0;
void dfs(int idx){
    if(idx == v.size()){
        res++;
        return ;
    }
    set<int> s;
    s.insert({1,2,3});
    for(int y:G[v[idx]]){
        s.erase(clr[y]);
    }
    for(int c:s){
        clr[v[idx]] = c;
        dfs(idx + 1);
        clr[v[idx]] = 0;
    }
}

void solve(){
    n = read(),m = read();
    UFs ufs(n);
    For(i,1,m){
        int x = read(),y = read();
        G[x].emplace_back(y);
        G[y].emplace_back(x);
        ufs.join(x,y);
    }
    int ans = 1;

    For(i,1,n){
        if(ufs.is_root(i)){
            v.clear();
            dfs2(i);
            res = 0;
            dfs(0);
            ans *= res;
        }
    }
    cout<<ans<<"\n";
}

signed main(){
    int T = 1;
    //T = read();
    while(T--) solve();
    return 0;
}

#include <iostream>
#include <vector>
#include <queue>
#include <string>
using namespace std;
struct edge{
    int to;
    int cost;
};
int main(){
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for(int i = 0; i < H; i++) cin >> S[i];
    int gi = 0, gj = 0, si = 0, sj = 0;
    int INF = 1e9;
    vector<int> d(H * W + 26, INF);
    vector<vector<edge>> alp(H * W + 26);
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(S[i][j] == 'G'){
                gi = i;
                gj = j;
            }
            else if(S[i][j] == 'S'){
                si = i;
                sj = j;
            }
            else if('a' <= S[i][j] && S[i][j] <= 'z'){
                int ind = S[i][j] - 'a';
                alp[H * W + ind].push_back({i * W + j, 1});
                alp[i * W + j].push_back({H * W + ind, 0});
            }
        }
    }
    deque<int> q;
    q.push_back(si * W + sj);
    d[si * W + sj] = 0;
    int dx[4] = {0, -1, 0, 1}, dy[4] = {-1, 0, 1, 0};
    while(!q.empty()){
        int t = q.front();
        q.pop_front();
        if(t >= H * W){
            for(edge v: alp[t]){
                if(d[v.to] == INF){
                    d[v.to] = d[t] + v.cost;
                    if(v.cost == 0) q.push_front(v.to);
                    else q.push_back(v.to);
                }
            }
        }
        else{
            int x = t / W, y = t % W;
            for(int i = 0; i < 4; i++){
                int nx = dx[i] + x, ny = dy[i] + y;
                if(0 <= nx && nx < H && 0 <= ny && ny < W && d[nx * W + ny] == INF && S[nx][ny] != '#'){
                    d[nx * W + ny] = d[t] + 1;
                    q.push_back(nx * W + ny);
                }
            }
            for(edge v: alp[t]){
                if(d[v.to] == INF){
                    d[v.to] = d[t] + v.cost;
                    if(v.cost == 0) q.push_front(v.to);
                    else q.push_back(v.to);
                }
            }
        }
    }
    if(d[gi * W + gj] == INF) cout << -1 << endl;
    else cout << d[gi * W + gj] << endl;
}


#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()
#define MOD 1000000007
#define INF INT_MAX
#define FLOAT_ANS setprecision(20)
#define elif else if

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

//最大公約数
template<typename T>
T gcd(T a, T b) {
	if (a % b == 0) {
		return(b);
	}
	else {
		return(gcd(b, a % b));
	}
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}

//Segment Tree(遅延評価)
template<typename T>
class SegTreeLazy {

	//参照：https://algo-logic.info/segment-tree/
public:
	//変数定義
	ll N;  //長さ
	T e; //単位元
	vector<T>seg; //基本
	vector<T>lazy; //遅延用
	function<T(T, T)> f; //比較用

	SegTreeLazy(ll n, ll e_, function<T(T, T)> f_) {
		//サイズ・単位元・比較用の関数
		e = e_;
		f = f_;

		//サイズnのSegTreeに必要な要素数
		ll x = 1;
		while (n > x) {
			x *= 2;
		}
		N = x;

		seg.resize(2 * N - 1, e);
		lazy.resize(2 * N - 1, e);
	}

	T get(ll i){
		return seg[i+N-1];
	}

	void eval(ll k) {
		//lazyから更新情報を取得、segに反映
		if (lazy[k] == e) return; //更新情報がなければ終了
		if (k < N - 1) { //自身が葉でないのなら子にも伝搬させる(zipを解凍)
			lazy[k * 2 + 1] = lazy[k];
			lazy[k * 2 + 2] = lazy[k];
		}

		//最後に、自身を更新
		seg[k] = lazy[k];
		//もう更新情報に用はないので、初期化
		lazy[k] = e;
	}

	void update(ll a, ll b, T x, ll k, ll l, ll r) {
		// a･b:全体の範囲
		// k･l:現在更新するn層目の範囲
		// x:更新する値
		// k:セグ木の配列における位置

		eval(k); //まずは更新(sudo apt update　と同じ感じ?)
		if (a <= l && r <= b) {// 内部にある(端でない)
			//現在の層についてのみ更新させる
			lazy[k] = x;
			eval(k);
		}
		else if (a < r && l < b) {// 一部区間がかぶる
			update(a, b, x, k * 2 + 1, l, (l + r) / 2); //右の子に伝搬
			update(a, b, x, k * 2 + 2, (l + r) / 2, r); //左の子に伝搬
			seg[k] = f(seg[k * 2 + 1], seg[k * 2 + 2]);
		}
	}
	void update(ll a, ll b, T x) {
		//(a)-(b-1)の範囲をxに更新
		update(a, b, x, 0, 0, N);
	}
	void update(ll a, T x) {
		//aをxに更新
		update(a, a + 1, x, 0, 0, N);
	}

	T query_sub(ll a, ll b, ll k, ll l, ll r) {
		eval(k);
		if (r <= a || b <= l) {  //完全に外部
			return e;
		}
		else if (a <= l && r <= b) {  //完全に内部
			return seg[k];
		}
		else {
			T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
			T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);

			return f(vl, vr); //右の子と左の子の小さい方
		}
	}
	T query(int a, int b) {
		return query_sub(a, b, 0, 0, N);
	}
};

bool isLarger(string s,string t){
	/*SのほうがTより大きければtrue*/
	rep(i,min(s.length(),t.length())){
		if(s[i]>t[i]){
			return true;
		}
		if(s[i]<t[i]){
			return false;
		}
	}

	if(s.length()>t.length()){
		return true;
	}
	else{
		return false;
	}
}

int main(void) {
  ll n;
  cin>>n;
  vector<ll>ans;
  for(ll i=1;i*i<=n;++i){
    if(n%i==0){
      ans.push_back(i);
      if(i!=n/i){
        ans.push_back(n/i);
      }
    }
  }

  sort(ALL(ans));
  for(ll i:ans){
    cout<<i<<endl;
  }

}

/*

*/

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

//約数列挙
vector<ll> diviser_list(ll x){
    vector<ll> res;
    stack<ll> big;
    for(ll i = 2; i*i <= x; i++){
        if(x%i == 0){
            res.push_back(i);
            if(x/i != i)big.push(x/i);
        }
    }
    while(!big.empty()){
        res.push_back(big.top());
        big.pop();
    }
    res.push_back(x);
    return res;
}

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

    ll n;
    cin >> n;
    vector<ll> ans = diviser_list(n);
    if(n != 1) cout << 1 << endl;
    for(auto p:ans) cout << p << endl;
    return 0;
}


#include <stdio.h>

using namespace std;

long long pr[20] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71};
long long a, b, n, ans = 1;
long long dp[1 << 21];
long long te[73];

void dfs(long long now, long long t) {
  if (t == n) {
    return;
  }
  for (int i = t; i < n; i++) {
    if (!(now & te[i])) {
      dfs(now | te[i], i + 1);
      ans++;
    }
  }
}

int main() {
  long long a, b;
  scanf("%lld%lld", &a, &b);
  n = b - a + 1;
  for (long long i = a; i <= b; i++) {
    for (int j = 0; j < 20; j++) {
      if (i % pr[j] == 0) {
        te[i - a] = te[i - a] | (1 << j);
      }
    }
  }
  dfs(0, 0);
  printf("%lld", ans);
}

// Cookie197
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<string>
#include<iomanip>
#include<math.h>
using namespace std;
#define no_tle_please ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define pii pair<ll,ll>
#define mp make_pair
#define si short
#define mod 1000000007
#define endl "\n"
#define inf 1e18
typedef priority_queue<int,vector<int> > PQ;
ll prime[20]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71};
ll arr[75];  // the prime factors of the numbers from a~b    index 0 to b-a
ll dp[75][1050000];  //dp[i][bit]= the number of ways : seen the first i numbers , used the primes in bit

signed main(){
    no_tle_please;
    ll a,b,n;
    cin>>a>>b;
    if (a==b) {cout<<2<<endl; return 0;}
    n=b-a+1;
    for (ll x=a;x<=b;x++){
        for (ll i=0;i<20;i++){
            if (x%prime[i]==0) arr[x-a]+=(1<<i);
        }
    }
    //for (int i=0;i<n;i++) cout<<arr[i]<<endl;
    dp[0][0]+=1;
    dp[0][arr[0]]+=1;
    for (ll i=1;i<n;i++){
        for (ll bit=0;bit<(1<<20);bit++){
            dp[i][bit]+=dp[i-1][bit];
            if (bit<arr[i]) continue;
            if ((bit & arr[i]) == arr[i]){  // arr[i] 完全包在 bit裡面
                dp[i][bit]+=dp[i-1][bit-arr[i]];
            }
        }
    }
    ll ans=0;
    for (ll bit=0;bit<(1<<20);bit++){
        ans+=dp[n-1][bit];
    }

    cout<<ans<<endl;
}


#include <cstdio>
#include <cstring>
#define ll long long
using namespace std;
const ll mod=1e9+7;
ll f[200010][17][2][2],ans;int k,n,a[200010];
char s[200010];
int num(int x)
{
    if(s[x]<='9'&&s[x]>='0') return s[x]-'0';
    return s[x]-'A'+10;
}
ll dfs(int pos,int st,int maxx,bool zero)
{
    int cnt=__builtin_popcount(st);
    if(pos>n) return cnt==k;
    if(cnt>k) return 0ll;
    if(pos>n) return cnt==k&&!zero;
    if(f[pos][cnt][maxx][zero]!=-1) return f[pos][cnt][maxx][zero];
    int to=maxx?a[pos]:15;
    ll ans=0;
    for(int i=0;i<=to;i++)
        if(!i&&zero) ans=(ans+dfs(pos+1,0,0,1))%mod;
        else ans=(ans+dfs(pos+1,st|(1<<i),maxx&&i==to,0))%mod;
    f[pos][cnt][maxx][zero]=ans;
    return ans;
}
int main()
{
    scanf("%s %d",s+1,&k);
    n=strlen(s+1);
    for(int i=1;i<=n;i++)
        a[i]=num(i);
    memset(f,-1,sizeof(f));
    printf("%lld",dfs(1,0,1,1));
}

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

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

ll dp[18];
char S[200200];
int suuji(char c) {
	if (c < 'A') return c - '0';
	else return c - ('A' - 10);
}

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

	fread(S, 1, 200200, stdin);
	int K = 0;
	int N = 200200 - 1;
	while (S[N] != ' ') N--;
	int tmp = N + 1;
	while (S[tmp] >= '0') K = K * 10 + S[tmp++] - '0';

	const int mod = 1e9 + 7;
	int k = suuji(S[0]);
	dp[1] = k - 1;
	int kazu = 1 << 15 - k;

	rep1(i, N - 1) {
		if (!(i & 7)) for (int j = 2; j <= 16; j++) dp[j] %= mod;
		for (int j = 16; j >= 1; j--) {
			dp[j + 1] += (16 - j) * dp[j];
			dp[j] = j * dp[j];
		}
		dp[1] += 15;
		int k = suuji(S[i]);
		int k1 = __builtin_popcount(kazu >> 16 - k);
		int kazu0 = __builtin_popcount(kazu);
		dp[kazu0] += k1;
		dp[kazu0 + 1] += k - k1;
		kazu |= 1 << 15 - k;
	}

	ll kotae = dp[K];
	kotae += (__builtin_popcount(kazu) == K);
	printf("%lld", kotae % mod);

	Would you please return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool check(int x, string flag){
    for(int d = 0; d < 4; ++d){
        int id = x % 10;
        x/=10;
        if (flag[id] == 'x') return false;
        if (flag[id] == 'o') flag[id] = '?';
    }
    for(int d = 0; d < 10; ++d){
        if (flag[d] == 'o') return false;
    }
    return true;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int ans = 0;
    for(int num = 0; num < 10000; ++num){
        if (check(num, s)) ans++;

    }
    cout << ans;
}

#include <bits/stdc++.h>
#define M 1000000007
#define endl '\n'
#define ll long long
using namespace std;

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

   	string str;
   	cin>>str;
   	ll n=str.length();

   	ll cnt1{0}; //to count the number of 'o'
   	ll cnt2{0}; //to count the number of '?'
   	for(ll i=0;i<n;i++){
   		if(str[i]=='o')
   			cnt1++;
   		else if(str[i]=='?')
   			cnt2++;
   	}

   	if(cnt1>4){
   		cout<<0<<endl;
   	}
   	else if(cnt1==4){
   		cout<<24<<endl;
   	}
   	else if(cnt1==3){
   		ll ans=(36)+(24*cnt2);
   		cout<<ans<<endl;
   	}
   	else if(cnt1==2){
   		ll temp=(cnt2*(cnt2-1))/2;
   		ll ans=(14)+(cnt2*36)+(temp*24);
   		cout<<ans<<endl;
   	}
   	else if(cnt1==1){
   		ll temp1=(cnt2*(cnt2-1)*(cnt2-2))/6;
   		ll temp2=(cnt2*(cnt2-1))/2;
   		ll ans=(1)+(cnt2*14)+(temp2*36)+(temp1*24);
   		cout<<ans<<endl;
   	}
   	else if(cnt1==0){
   		ll temp1=(cnt2*(cnt2-1)*(cnt2-2)*(cnt2-3))/24;
   		ll temp2=(cnt2*(cnt2-1)*(cnt2-2))/6;
   		ll temp3=(cnt2*(cnt2-1))/2;
   		ll ans=(cnt2*1)+(temp3*14)+(temp2*36)+(temp1*24);
   		cout<<ans<<endl;
   	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int M;

#warning not checked
template <class T, class I = long long>
struct modint {
    T x;

    modint() : x() {}
    modint(T s) {
        x = s % M;
        if (x < 0) x += M;
    }

    explicit operator T() const { return x; }

    modint operator+() const { return *this; }
    modint operator-() const { return T(-x); }

    modint inv() {
        T a = x, b = M, as = 1, bs = 0;
        while (b) {
            T d = a / b;
            tie(a, b) = make_pair(b, a - b * d);
            tie(as, bs) = make_pair(bs, as - bs * d);
        }
        assert(a == 1);
        return as;
    }

    modint& operator+=(const modint &o) {
        x = x + o.x >= M ? x + o.x - M : x + o.x;
        return *this;
    }

    friend modint operator+(const modint &s, const modint &t) {
        return modint(s) += t;
    }

    modint& operator-=(const modint &o) {
        x = x - o.x < 0 ? x - o.x + M : x - o.x;
        return *this;
    }

    friend modint operator-(const modint &s, const modint &t) {
        return modint(s) -= t;
    }

    modint& operator*=(const modint &o) {
        x = I(x) * o.x % M;
        return *this;
    }

    friend modint operator*(const modint &s, const modint &t) {
        return modint(s) *= t;
    }

    modint& operator/=(const modint &o) {
        return *this = *this * o.inv();
    }

    friend modint operator/(const modint &s, const modint &t) {
        return modint(s) /= t;
    }

    modint& operator^=(I e) {
        T b = x;
        for (x = 1; e; e >>= 1, b = I(b) * b % M) {
            if (e & 1) x = I(x) * b % M;
        }
        return *this;
    }

    modint operator^(I e) {
        return modint(*this) ^= e;
    }

    // streams

    friend istream& operator>>(istream &is, modint &t) {
        T p;
        is >> p;
        t = modint(p);
        return is;
    }

    friend ostream& operator<<(ostream &os, const modint &t) {
        return os << t.x;
    }
};
using mint = modint<int>;

const int N = 100, S = 500000;
mint dp[N][S];

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

    int n, k;
    cin >> n >> k >> M;

    dp[0][0] = 1;
    for (int i = 1; i < n; i++) {
        vector<mint> a(i);
        for (int v = 0, r = 0; v < S; v++, r = r == i - 1 ? 0 : r + 1) {
            dp[i][v] = dp[i - 1][v] + a[r];

            if (int u = v; u >= 0) {
                a[r] = a[r] + dp[i - 1][u];
            }
            if (int u = v - i * k; u >= 0) {
                a[r] = a[r] - dp[i - 1][u];
            }
        }
    }

    for (int i = 0; i < n; i++) {
        mint ans = 0;
        for (int j = 0; j < S; j++) {
            ans += dp[i][j] * dp[n - i - 1][j];
        }
        ans = ans * (k + 1) - 1;

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

#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define rep(i, n) for(int i = 0; i < n; i++)
#define per(i, n) for(int i = n - 1; i >= 0; i--)
using ll = long long;
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using namespace std;

constexpr int h = 30, w = 30;
constexpr bool istest = false;

void answer_query(){
	int sy,sx, ty,tx;
	cin >> sy >> sx >> ty >> tx;
	if(istest){
		double a,b;
		cin >> a >> b;
	}
	if(sy < ty){
		for(int i = sy; i < ty; i++){
			cout << "D";
		}
	}
	else{
		for(int i = ty; i < sy; i++){
			cout << "U";
		}
	}

	if(sx < tx){
		for(int i = sx; i < tx; i++){
			cout << "R";
		}
	}
	else{
		for(int i = tx; i < sx; i++){
			cout << "L";
		}
	}
	cout << endl;

	if(!istest){
		int a; cin >> a;
	}
}
int main(){
	if(istest){
		vvi val_width(h, vi(w - 1));
		vvi val_height(h - 1, vi(w));
		rep(i, h) rep(j, w - 1) cin >> val_width[i][j];
		rep(i, h - 1) rep(j, w) cin >> val_height[i][j];
	}
	rep(i, 1000){
		answer_query();
	}
}


#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while(T--) {
    int N;
    cin >> N;
    vector<string> S(3);
    REP(i, 3) cin >> S[i];
    bool zerozero = false;
    bool zeroone = false;
    bool onezero = false;
    bool oneone = false;
    int idx = 0;
    REP(i, 3) {
      if(S[i][0] == '0') {
        if(S[i][S[i].size()-1] == '0') {
          zerozero = true;
          idx = i;
        } else zeroone = true;
      } else {
        if(S[i][S[i].size()-1] == '0') onezero = true;
        else oneone = true;
      }
    }
    string ans = "";
    if(!zerozero) {
      REP(i, N) ans += '0';
      ans += '1';
      REP(i, N) ans += '0';
    } else if(!oneone){
      REP(i, N) ans += '1';
      ans += '0';
      REP(i, N) ans += '1';
    } else if(!onezero) {
      ans += '0';
      REP(i, N) ans += '1';
      REP(i, N) ans += '0';
    } else {
      ans += '1';
      REP(i, N) ans += '0';
      REP(i, N) ans += '1';
    }
    cout << ans << "\n";
  }
}

#include<bits/stdc++.h>
using namespace std;
int cnt = 0;
struct tree {
	int n;
	vector<vector<int>> g;
	vector<int> vis;
	tree(int n) : n(n) {g = vector<vector<int>>(n); vis = vector<int>(n, 0);}

	void dfs(int root = 0) {
		cnt++;
		vis[root] = 1;
		for (auto i : g[root]) {
			if (!vis[i]) dfs(i);
		}
	}
};

int main() {

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

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

	tree t(200000);
	int n; cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i]; --a[i];
	}

	set<pair<int, int>> s;
	for (int i = 0; i < n / 2; i++) {
		if (a[i] != a[n - i - 1]) {
			int x = a[i], y = a[n - i - 1]; if (x > y)swap(x, y);
			if (s.find({x, y}) == s.end()) {
				t.g[x].push_back(y);
				t.g[y].push_back(x);
				s.insert({x, y});
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < 200000; i++) {
		if (!t.vis[i]) {
			cnt = 0;
			t.dfs(i);
			ans += cnt - 1;
		}
	}

	cout << ans << "\n";

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0)
#define setbit0(n, i) ((n) & (~(1LL << (i))))
#define setbit1(n, i) ((n) | (1LL << (i)))
#define togglebit(n, i) ((n) ^ (1LL << (i)))
#define lastone(n) ((n) & (-(n)))
char gap = 32;
#define ll long long
#define lll __int128_t
#define pb push_back
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
ll dp[20][2];
ll ans = 0;
ll recurse(vector<ll>&v , ll sz , string &s){
    if((ll)v.size() * 2==sz){
        for(int i = 0;i<sz;i++){
            if(v[i % (sz / 2)]>(s[i] - '0')){
                return 0;
            }
            else if(v[i % (sz / 2)] < (s[i] - '0')){
                return 1;
            }
        }
        return 1;
    }
    ll res = 0;
    if(v.empty()){
        for(ll i = 1;i<=9;i++){
            v.push_back(i);
            res += recurse(v , sz , s);
            v.pop_back();
        }
    }
    else{
        for(ll i = 0;i<=9;i++){
            v.push_back(i);
            res += recurse(v , sz , s);
            v.pop_back();
        }
    }
    return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    ll sz = s.size();
    ll i,j,k,l,n,m;
    ll gun = 1;
    for(i = 2;i<sz;i+=2){
        ans += (gun * 9);
        gun *= 10;
    }
    if(sz % 2 != 0){
        cout<<ans<<"\n";
        return 0;
    }
    ///cout<<ans<<"\n";
    vector<ll>kola;
    ans += recurse(kola , sz , s);
    cout<<ans<<"\n";
    return 0;
}

/*
 * @Author: zhl
 * @LastEditTime: 2020-12-05 20:02:46
 */
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 10;

int gcd(int a, int b) {
	return a % b == 0 ? b : gcd(b, a % b);
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
signed main() {
	int n; cin >> n;
	int ans = 1;
	for (int i = 2; i <= n; i++) {
		ans = lcm(ans, i);
	}
	cout << ans + 1 << endl;
}


#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
//define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define debug(x) cout << #x << '\t' << x << endl
#else
#define debug(x)
#endif
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0)
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
#define lowbit(x) ((x) & -(x))
#define mem(a, b) memset(a, b, sizeof(a))
#define PI acos(-1)
#define endl '\n'
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
// #define int long long
const double eps = 1e-4;
ll gcd(ll a, ll b){a = abs(a);b = abs(b);return a == 0 ? b : gcd(b % a, a);}
//inline ll Pow(ll a, ll n, ll MOD) { ll t = 1; a %= MOD; while (n > 0) { if (n & 1) t = t * a % MOD; a = a * a % MOD, n >>= 1; } return t % MOD; }
const int maxn = 5e5+100;

signed main()
{
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    #endif
    fast;
    int n;
    cin>>n;
    vector<int> a(n);
    map<int,int> mp;
    for(auto &v: a) cin>>v;
    for(auto v: a){
        for(int i = 1; i*i <= v; i++){
            if(v%i==0){
                mp[i] = gcd(mp[i],v);
                mp[v/i] = gcd(mp[v/i],v);
                debug(mp[i]);
                debug(mp[v/i]);
            }
        }
    }
    int ans = 1;
    int minn = *min_element(a.begin(),a.end());
    for(auto p :mp){
        if(p.first==p.second&&p.first<minn){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 2000 + 7;
int n, a[N];
bool b[N];

bool ok(int val) {
        int g = 0;
        for (int i = 1; i <= n; i++) {
                if (a[i] % val == 0) g = __gcd(g, a[i]);

        }
        return g == val;
}

mt19937 rng((long long) (new char));

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

       /// freopen ("input", "r", stdin);

        cin >> n;
        for (int i = 1; i <= n; i++)
                cin >> a[i];
        sort(a + 1, a + n + 1);
        int y = 0;
        for (int i = 1; i <= n; i++)
                if (y == 0 || a[y] != a[i])
                        a[++y] = a[i];
        n = y;
        shuffle(a + 2, a + n + 1, rng);
        int cnt = 0;
        set<int> st;
        for (int i = 1; i <= n; i++)
                for (int j = i; j <= n; j++)
                        st.insert(__gcd(a[i], a[j]));
        cnt += n * n;
        for (int i = 1; i <= n; i++) {
                int rad = sqrt(a[i]) + 1;
                cnt += rad;
                if (cnt >= (int) 5e7)
                        break;
                for (int d = 1; d <= rad; d++)
                        if (a[i] % d == 0) {
                                st.insert(d);
                                st.insert(a[i] / d);
                        }
        }
        int ret = 0;
        for (auto &x : st) {
                if (a[1] < x)
                        continue;
                if (ok(x))
                        ret++;

        }
        cout << ret << "\n";

}


#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll MOD2=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

void solve(int cn) {
    int sx, sy, gx, gy;
    cin>>sx>>sy>>gx>>gy;
    double x;
    x=1.0*(gx-sx)*sy/(double)(sy+gy)+sx;
    printf("%.10f\n",x);
}

#define SINGLE
int main() {
#ifdef SINGLE
    solve(1);
#else
    int N;
    cin>>N;
    for(int i=0;i<N;++i){
        solve(i);
    }
#endif
    return 0;
}

#include<cstdio>
int a,b,c,d;
int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&d);
	printf("%d",a*d-b*c);
	return 0;
}


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

#ifdef LOCAL
#include "../debug.h"
#else
#define debug(x...) 141
#endif
#define forn(i,x,n) for(int i = x; i < n; ++i)
#define forit(it, m) for(auto it = m.begin(); it!=m.end(); ++it)
typedef long long ll;

vector<vector<int>> adj;
vector<int> vis, col, good;
multiset<int> seen;

void dfs(int u){
	vis[u]=true;
	if(!seen.count(col[u]))
		good.push_back(u+1);
	seen.insert(col[u]);
	for(auto v:adj[u])
		if(!vis[v])
			dfs(v);
	seen.erase(seen.find(col[u]));
}

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

    cin>>n;
    adj.assign(n,vector<int>());
    vis.assign(n,false);
    col.assign(n,0);
    forn(i,0,n)
    	cin>>col[i];
    forn(i,0,n-1)
    	cin>>x>>y,
    	adj[x-1].push_back(y-1),
    	adj[y-1].push_back(x-1);

    dfs(0);
    sort(good.begin(),good.end());

    for(auto x:good)
    	cout<<x<<'\n';

    return 0;
}

#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
    #include <atcoder/all>
    using namespace atcoder;
#endif
using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 1; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  ll B, C;
  cin >> B >> C;
  ll a1 = B-C/2;
  ll a2 = B+(C-2)/2;
  ll a3 = -B-(C-1)/2;
  ll a4 = -B+(C-1)/2;
//   cout << a1 << ' ' << a2 << ' ' << a3 << ' ' << a4 << endl;
  if (min(a1, a2) > max(a3, a4) || min(a3, a4) > max(a1, a2)) {
      cout << max(a1, a2)-min(a1, a2)+1+max(a3, a4)-min(a3, a4)+1 << endl;
  } else {
      cout << max({a1, a2, a3, a4}) - min({a1, a2, a3, a4})+1 << endl;
  }
}


#include <bits/stdc++.h>

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
#define DIV 1000000007
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e9+7;

ll ceildiv(ll a, ll b) { return (a+b-1)/b; } // 切り上げ
ll floordiv(ll a, ll b) { return a/b; } // 切り下げ

int show_matrix(vector<vector<int>> &dp) {
  loop(0, dp.size(), i) {
    loop(0, dp[i].size(), j) {
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

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

  ll N, K;
  cin >> N >> K;

  vector<ll> A(N);

  ll mx = 0;
  map<ll, ll> M;
  loop(0, N, i) {
    ll a;
    cin >> a;
    M[a]++;
    mx = max(mx, a);
  }

  ll last = 0;
  ll sum = 0;
  loop(0, mx+1, i) {
    ll v = i;
    ll c = M[i];
    last = v;
    while (K - c > 0 && K > 0) {
      sum += v;
      K--;
    }
    if (K == 0) break;
  }
  sum += (last+1) * K;
  print(sum);
}

#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, s, n) for (ll i = s; i < (n); i++)

int main(){
  ll n, k;
  cin >> n >> k;
  vector<ll> count(n+1, 0);
  rep(i, n){
    int a;
    cin >> a;
    count[a]++;
  }
  ll ans = 0;
  rep(i, n+1){
    ll now = k - count[i];
    if (now < 0) now = 0;
    ans += i * now;
    k -= now;
    if (k <= 0) break;
  }
  cout << ans << endl;

  return 0;
}


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

#define int long long

struct edge {
    int to;
    int cost;
};

using namespace std;
// using namespace atcoder;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vb = vector<bool>;
using qi = queue<int>;
using P = pair<int, int>;
using graph = vector<vector<edge>>;
// using graph = vector<vector<int>>;
// using mint = modint1000000007;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define delim(i, n) cout << (i == n-1 ? "\n" : " ")
#define print1(v) cout << fixed << setprecision(10) << v << "\n"
#define print2(v1, v2) cout << fixed << setprecision(10) << v1 << " " << v2 << "\n"
#define print3(v1, v2, v3) cout << fixed << setprecision(10) << v1 << " " << v2 << " " << v3 << "\n"
#define printvi(v, n) REP(iiii, n) { cout << v[iiii]; delim(iiii, n); }
#define printvii(v, h, w) REP(iiiii, h) { printvi(v[iiiii], w); }

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

const int inf = 1LL << 60;
// const int inf = 100000000;
const int mod = 1000000007;

const int maxn = 5000+5;
int h, w;

vi dx = {-1, 0, 0, 1};
vi dy = {0, -1, 1, 0};

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

    cin >> h >> w;

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

    int cnt = 0;
    REP(i, h) {
        REP(j, w) {
            if (s[i][j] == '.') {
                if (i > 0) {
                    if (s[i-1][j] == '.') {
                        cnt++;
                    }
                }
                if (j > 0) {
                    if (s[i][j-1] == '.') {
                        cnt++;
                    }
                }
            }
        }
    }

    print1(cnt);
}

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

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> grid(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> grid[i][j];
    }
  }
  int ans=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(j!=w-1){
        if(grid[i][j]=='.' && grid[i][j+1]=='.') ans++;
      }
      if(i!=h-1){
        if(grid[i][j]=='.' && grid[i+1][j]=='.') ans++;
      }
    }
  }
  cout << ans << endl;
  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<MOD998>;

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

  int n, m; cin >> n >> m;
  Int ans = 0;

  FOR(k, 1, n) {
    Int mul1 = (n - k) * (Int(m).pow(n-k-1));
    Int mul2 = 0;
    FOR(x, 1, m+1) {
      mul2 += Int(m-x).pow(k-1);
    }
    ans += mul1 * mul2;
  }
  cout << n * Int(m).pow(n) - ans << endl;

  return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++)
#define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--)
#define all(v) v.begin(), v.end()
template<class in_chmax> void chmax(in_chmax &x, in_chmax y) {x = max(x,y);}
template<class in_chmin> void chmin(in_chmin &x, in_chmin y) {x = min(x,y);}
void Yes() {cout << "Yes" << endl; exit(0);}
void No() {cout << "No" << endl; exit(0);}
template<class in_Cout> void Cout(in_Cout x) {cout << x << endl; exit(0);}
template<class in_vec_cout>
void vec_cout(vector<in_vec_cout> vec) {
    for (in_vec_cout res : vec) {cout << res << " ";}
    cout << endl;
}

const ll inf = 1e18;
const ll mod = 1e9 + 7;

int main() {
    ll L, R;
    cin >> L >> R;

    vector<ll> f(R+1);
    for (ll g=R; g>=2; g--) {
        ll st = (L-1)/g, en = R/g;
        ll cnt = en-st;
        f[g] = cnt*cnt;
        for (ll i=2*g; i<=R; i+=g) {
            f[g] -= f[i];
        }
    }

    ll ans = 0;
    for (ll g=2; g<=R; g++) {
        if (L<=g && g<=R) {
            ll cnt = R/g;
            ans += f[g] - (2*cnt-1);
        } else {
            ans += f[g];
        }
    }

    Cout(ans);
}


#include <stdio.h>
#include <algorithm>
long long n;
long long a[100000];
double s, t, z;
int main() {
	scanf("%lld", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", a + i);
	}
	std::sort(a, a + n);
	t = a[n / 2];
	for (int i = 0; i < n; i++) {
		if (t < a[i])z += t - a[i];
	}
	printf("%.10lf\n", t / 2 - z / n);
}

  #include<bits/stdc++.h>
  using namespace std;
  using ll = long long;
  using C = complex<double>;
  #define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
  #define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
  #define repc(i,f,n) for(char i=(f); (i) <= (n); i++)
  //#define PI 3.14159265358979323846264338327950L
  #define debug(x) cout<<#x<<" :: "<<x<<"\n";
  #define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
  #define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
  #define Pl pair<ll, ll>
  #define OUT(x) cout << x << endl; return 0;
  #define ALL(x) (x).begin(),(x).end()
  #define UNIQUE(x) (x).erase(unique(ALL(x)),(x).end()) //x must be sorted
  //printf("%.10f\n")
  //cout << fixed << setprecision(10);
  template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
  template<class T> inline bool chmaxe(T& a, T b){if (a <= b) { a = b; return true; } return false;}
  template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
  const ll MOD = 1000000007ll;
  const ll INF = 1e+18;
  const int iINF = 1e9;
  const double EPS = 1e-8;
  //const double PI = acos(-1.0);

int
main()
{
  ll N; cin >> N;
  vector<ll> A(N);
  double asum = 0;
  rep(i, 0, N) cin >> A[i], asum += A[i];
  sort(ALL(A));
  vector<ll> acum(N + 1, 0);
  rep(i, 0, N) acum[i + 1] = acum[i] + A[i];

  double ok = 0;
  double ng = 1000000000;
  auto check = [&](double ins){
    double cst = (double)N * ins + asum;
    auto ps = lower_bound(ALL(A), 2 * ins) - A.begin();
    double rt = acum[ps] + (2 * ins * (N - ps));
    double e = (cst - rt) / (double)N;

    return e;
  };
  while(abs(ok - ng) >= 0.000001){
    double mid1 = (ok + ok + ng) / 3;
    double mid2 = (ok + ng + ng) / 3;
    if(check(mid1) < check(mid2)){
      ng = mid2;
    } else {
      ok = mid1;
    }
  }

  cout << fixed << setprecision(10);
  cout << check(ok) << endl;
}


/*
  /^--^\
  \____/
 /      \ _____  _ __  __ ____  _     ____   ____  _____
|        || ()_)| |\ \/ /| ===|| |__ / (__` / () \|_   _|
 \__  __/ |_|   |_|/_/\_\|____||____|\____)/__/\__\ |_|
|^|^\ \^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|
| | |\ \| | | | | | | | | | | | | | | | | | | | | | | | |
#####/ /#################################################
| | |\/ | | | | | | | | | | | | | | | | | | | | | | | | |
|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|*/
#pragma GCC optimize("O4,unroll-loops,no-stack-protector")
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<ll,ll>;
#define int ll
#define double long double

#define For(i,a,b)  for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define L(id) (id<<1)
#define R(id) (id<<1|1)
#define LO(x) (x&(-x))

#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define mkp make_pair

#define MOD (ll)(998244353)
#define INF (ll)(1e15)
#define EPS (1e-6)

#ifdef LOCALMEOW
#define debug(...) do{\
	cerr << __PRETTY_FUNCTION__ << " - " << __LINE__ <<\
	" : ("#__VA_ARGS__ << ") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T> void _OUT(T x) { cerr << x << "\n"; }
template<typename T,typename...I>
void _OUT(T x,I ...tail) { cerr << x << ", "; _OUT(tail...); }
#else
#define debug(...)
#endif
inline void IOS(){ ios::sync_with_stdio(false); cin.tie(0); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	int ans=1,now=b;
	while(p){
		if(p&1) ans=ans*now%MOD;
		p/=2; now=now*now%MOD;
	}
	return ans;
}
void minify(int &a,int b) { if(b<a) a=b; }
void maxify(int &a,int b) { if(b>a) a=b; }

int32_t main(){
	IOS();
	//code...
	int n,m,k; cin>>n>>m>>k;
	if(n==1){
		cout<<fpow(k,m)<<"\n";
		return 0;
	}
	if(m==1){
		cout<<fpow(k,n)<<"\n";
		return 0;
	}
	int ans=0;
	For(i,1,k) ans=(ans+fpow(k-i+1,m)*(fpow(i,n)-fpow(i-1,n)))%MOD;
	cout<<(ans+MOD)%MOD<<"\n";
	return 0;
}

#include <bits/stdc++.h>
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int a, b, c;
	std::cin >> a >> b >> c;
	a %= 10;
	int roundTime = 2, t = a * a % 10;
	while (t != a) {
		t *= a;
		t %= 10;
		roundTime++;
	}
	roundTime--;
	int r = 1;
	while (c) {
		if (c & 1) {
			r = (i64)r * b % roundTime;
		}
		b = (i64)b * b % roundTime;
		c /= 2;
	}
	if (!r) r = roundTime;
	t = 1;
	while (r--) {
		t *= a;
		t %= 10;
	}
	std::cout << t << "\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
void solve() {
    long long N;
    cin >> N;
    long long ll = 1;
    long long rr = 10;
    int len = 1;
    long long answer = 0;
    while(ll <= N) {
        answer += (min(N + 1, rr) - ll) * ((len - 1) / 3);
        len++;
        ll *= 10;
        rr *= 10;
    }
    cout << answer << endl;
}
int main() {
    solve();
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define println(x) cout<<(x)<<'\n';
#define print(x) cout<<(x)<<' ';

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

    int n;
    cin >> n;

    set<int> a;
    for (int i = 2; i <= 10000; i++) {
        if (i == 6 || i == 10 || i == 15)
            continue;
        int cnt = 0;
        if (i % 2 == 0)
            cnt++;
        if (i % 3 == 0)
            cnt++;
        if (i % 5 == 0)
            cnt++;
        if (cnt >= 2) {
            a.insert(i);
        }
    }

    cout << "6 10 15 ";

    n -= 3;
    while (n--) {
        cout << (*a.begin()) << ' ';
        a.erase(a.begin());
    }

}