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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using LD = long double;

template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> void coutall(T v) { if(v.empty()){cout << endl; return;} for(auto i = v.begin(); i != --v.end(); i++){cout << *i << " ";} cout << *--v.end() << endl; }
template <typename T> void DEBUGall(T v) { if(v.empty()){cerr << endl; return;} for(auto i = v.begin(); i != --v.end(); i++){cerr << *i << " ";} cerr << *--v.end() << endl; }
inline void IN(void){ return; }
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){ cin >> first; IN(rest...); return; }
inline void OUT(void){ cout << "\n"; return; }
template <typename First, typename... Rest> void OUT(First first, Rest... rest){ cout << first << " "; OUT(rest...); return; }
inline void DEBUG(void){ cerr << "\n"; return; }
template <typename First, typename... Rest> void DEBUG(First first, Rest... rest){ cerr << first << " "; DEBUG(rest...); return; }

void yes(bool ok = true){ cout << (ok ? "yes" : "no") << endl; }
void Yes(bool ok = true){ cout << (ok ? "Yes" : "No") << endl; }
void YES(bool ok = true){ cout << (ok ? "YES" : "NO") << endl; }
ll myceil(ll a, ll b) { return a >= 0 ? (a+b-1)/b : -((-a)/b); }
ll myfloor(ll a, ll b) { return a >= 0 ? a/b : -myceil(-a, b); }

map<int, int> compress(vi a){
    int n = a.size();
    map<int, int> cnt;
    rep(i, n) cnt[a[i]] = 1;
    int now = 0;
    for(auto [k, v] : cnt){
        cnt[k] = now;
        now++;
    }
    return cnt;
}

void Main(){
    int n, m; IN(n, m);
    vi x(m), y(m);
    rep(i, m) IN(x[i], y[i]);
    map<int, int> c = compress(x);
    int sz = c.size();
    vvi black(sz);
    rep(i, m) {
        black[c[x[i]]].pb(y[i]);
    }

    set<int> st;
    st.insert(n);

    for(auto b : black){
        vi stadd, stdel;
        for(auto pos : b){
            if(st.find(pos-1) != st.end() || st.find(pos+1) != st.end()) stadd.pb(pos);
            if(st.find(pos-1) == st.end() && st.find(pos+1) == st.end()) stdel.pb(pos);
        }
        for(auto aa : stadd) st.insert(aa);
        for(auto bb : stdel) {
            auto it = st.find(bb);
            if(it != st.end()) st.erase(it);
        }
    }
    OUT(st.size());
    return;
}

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

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

int main(){
	ll n,m;cin>>n>>m;
	vector<ll> g(n);
	while(m--){
		ll a,b;cin>>a>>b;a--;b--;
		g[a]|=(1<<b);
		g[b]|=(1<<a);
	}
	vector<ll> d(1<<n,INF);
	d[0]=1;
	for(ll i=0;i<n;i++)for(ll j=0;j<(1<<n);j++)if(d[j]==1 && (g[i]&j)==j)d[j|(1<<i)]=1;
	for(ll i=1;i<(1<<n);i++)for(ll j=i;j;j--,j&=i)d[i]=min(d[i],d[i^j]+d[j]);
	cout<<d[(1<<n)-1]<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LL long long int
vector<pair<LL,LL> > adj[100001];
vector <LL> djikstra(LL src,LL N)
{
    vector <LL> dis(N,INT_MAX);
    priority_queue< pair<LL,LL> ,vector< pair <LL,LL> >, greater< pair<LL,LL> > > pq;
    for(auto it:adj[src])
    {
    	pq.push(it);
    	dis[it.second]=it.first;
    }
    while(!pq.empty())
    {
        pair <LL,LL> temp=pq.top();
        pq.pop();
        LL s=temp.second;
        for(auto it:adj[s])
        {
            if( dis[it.second]  > dis[s] + it.first )
            {
                dis[it.second]= dis[s] + it.first;
                pq.push({dis[s] + it.first,it.second});
            }
        }
    }
    return dis;
}
int main()
{
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	LL  N,M;
	cin >> N >> M;
	map< pair<LL,LL> ,LL > hash;
	map<LL,LL> Self;
	for(LL i=0;i<N;i++)
	{
		Self[i]=INT_MAX;
	}
	for(LL i=0;i<M;i++)
	{
		LL x,y,z;
		cin>>x>>y>>z;
		x--;
		y--;
		if(x==y)
		{
			Self[x]=min(Self[x],z);
		}
		if( hash.find( {x,y} )==hash.end())
		{
			hash[{x,y}]=z;
		}
		else
		{
			hash[{x,y}]=min(hash[{x,y}],z);
		}
	}
	for(auto it:hash)
	{
		adj[it.first.first].push_back({it.second,it.first.second});
	}
	for(LL i=0;i<N;i++)
	{
		vector<LL> arr= djikstra(i,N);
		if(arr[i]==INT_MAX)
        {
          	if(Self[i]==INT_MAX)
			cout<<-1<<endl;
          else
            cout<<Self[i]<<endl;
        }
		else
			cout<<arr[i]<<endl;
	}

}

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


//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m; cin>>n>>m;
    char arr[n+10][m+10];
    for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) cin>>arr[i][j];
    ll dp[n+10][m+10];
    memset(dp,0,sizeof(dp));
    ll col[m+10]={0};
    dp[1][1]=1;
    col[1]=1;
    ll di[n+10][m+10];
    memset(di,0,sizeof(di));
    di[1][1]=1;
    ll sum=1;
    for(int i=2;i<=m;i++){
        if(arr[1][i]=='#') sum=0;
        dp[1][i]=sum;
        sum=(sum+dp[1][i]%mod);
        col[i]=dp[1][i];
        di[1][i]=dp[1][i];
    }
    sum=1;
    for(int i=2;i<=n;i++){
        if(arr[i][1]=='#') sum=0;
        dp[i][1]=sum;
        sum=(sum+dp[i][1]%mod);
        di[i][1]=dp[i][1];
    }
    for(int i=2;i<=n;i++){
        sum=dp[i][1];
        for(int j=2;j<=m;j++){
            if(arr[i][j]=='#') {
                sum=0;
                col[j]=0;
                di[i][j]=0;
                dp[i][j]=0;
            }
            else{
                ll val=sum;
                val=(val+col[j])%mod;
                val=(val+di[i-1][j-1]);
                dp[i][j]=val%mod;
                sum=(sum+val)%mod;
                col[j]=(val+col[j])%mod;
                di[i][j]=(val+di[i-1][j-1])%mod;
            }
        }
    }
    // for(int i=1;i<=n;i++) {
    //     for(int j=1;j<=m;j++) cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
    cout<<dp[n][m]%mod<<endl;
}

#include <bits/stdc++.h>

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
typedef long long LL;

const int MAXN = 55;
const int MOD = 1E9 + 7;
LL n, x, a[MAXN], g[MAXN], dp[MAXN][2];

template <class T>
void read(T& x) {
    x = 0;
    T f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') f = (ch == '-' ? -1 : 1), ch = getchar();
    while (ch >= '0' && ch <= '9') x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

template <class T, class... Args>
void read(T& x, Args&... args) {
    read(x), read(args...);
}

signed main() {
    read(n, x);
    for (int i = 1; i <= n; i++) read(a[i]);
    for (int i = n; i >= 1; i--) {
        if (!x) break;
        g[i] = x / a[i], x %= a[i];
    }
    for (int i = n - 1; i >= 1; i--) {
        LL lim = a[i + 1] / a[i];
        if (g[i] == 0) {
            dp[i][0] = dp[i + 1][0];
            dp[i][1] = dp[i + 1][1] + dp[i + 1][0] + 1;
        } else if (g[i] == lim - 1) {
            dp[i][0] = dp[i + 1][0] + dp[i + 1][1] + 1;
            dp[i][1] = dp[i + 1][1];
        } else {
            dp[i][1] = dp[i + 1][1] + dp[i + 1][0] + 1;
            dp[i][0] = dp[i + 1][0] + dp[i + 1][1] + 1;
        }
    }
    cout << dp[1][0] + 1;
    return 0;
}


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

#define  fl(i,a,b) for(long long i=a;i<b;i++)
#define  test long long t_c;cin>>t_c;for(long long ks=1;ks<=t_c;ks++)
#define pb push_back
#define vi vector<int>
#define all(x) x.begin(),x.end()
#define cy cout<<"YES\n";
#define cn cout<<"NO\n";
#define nl cout<<endl;
#define case(x) cout<<"Case "<<x<<": ";

typedef long long ll;
typedef long long int lli;
void sc(int &x){scanf("%d",&x);}
void sc(lli &x){scanf("%lld",&x);}
void sc(char *x){scanf("%s",x);}
void sc(double &x){scanf("%lf",&x);}

using namespace std;
int main()
{
      ios_base::sync_with_stdio(false);
      ll a,b,c,d;
      cin>>a>>b>>c>>d;
      if(c*d<=b)
      {
          cout<<-1<<endl;
      }
      else
      {
          ll x= ceil(a*1.0/(c*d-b)*1.0);
          cout<<x<<endl;
      }

}

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define speed ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define all(vec) vec.begin(),vec.end()
#define int long long int
using namespace std;
using namespace __gnu_pbds;

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

const int mod=1e9+7;

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

    if(b >= c*d ){
        cout<<-1;
        return;
    }

    int x=0;
    int cnt=0;
    while(a > d * x)
    {
        a += b;
        x += c;
        cnt++;
    }
    cout<<cnt;
}

signed main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("in.txt", "r", stdin);
    //     freopen("out.txt", "w", stdout);
    // #endif
    speed;
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    //cout << "\n\n"<<"Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
    return 0;
}


// Problem : B - Abbreviate Fox
// Contest : AtCoder - AtCoder Regular Contest 108
// URL : https://atcoder.jp/contests/arc108/tasks/arc108_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
    T f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

const int INF = 0x3f3f3f3f, N = 200003, M = N << 1;

int n;
char s[N], stk[N];
int tp;

int main()
{
    //File("");
    n = gi <int> ();
    scanf("%s", s + 1);
    for (int i = 1; i <= n; i+=1)
    {
    	stk[++tp] = s[i];
    	if (tp >= 3 && stk[tp] == 'x' && stk[tp - 1] == 'o' && stk[tp - 2] == 'f')
    		tp -= 3;
    }
    printf("%d\n", tp);
    return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

using vint = vector<int>;
using vll = vector<ll>;
using vld = vector<ld>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define x first
#define y second
#define all(v) v.begin(),v.end()

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  vector<char> v;
  for(char c : s) {
    v.push_back(c);
    if(v.size() >= 3 && v[int(v.size()) - 3] == 'f' && v[int(v.size()) - 2] == 'o'
      && v.back() == 'x') {
        v.pop_back(); v.pop_back(); v.pop_back();
      }
  }

  cout << v.size() << '\n';

  return 0;
}


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

typedef long long LL;
typedef pair<int, int> PII;
const int N = 510 + 10;
#define gcd __gcd
const int mod = 200;
const int inf = 0x3f3f3f3f;
#define x first
#define y second

int a[N];

void solve() {
	int n;
	scanf("%d", &n);
	printf("%d\n", n / 100 + (n % 100 != 0));
}

int main() {
	// freopen("in.txt", "r", stdin);
	solve();
	return 0;
}

// Problem C

#include <stdio.h>
#include <iostream>
#include <vector>
#include <string.h>
#include <cassert>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <queue>
#include <stack>

#define MAXN 1000
#define pb push_back
#define mp make_pair

using namespace std;

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

int c[3];

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

  int ncifre = 0;

  while (n!=0) {
    c[(n%10)%3]++;
    n = n/10;
    ncifre++;
  }

  if ((c[1] + 2*c[2] )%3 == 0)
    cout << "0\n";
  else if ((c[1] + 2*c[2]) % 3 == 1) {
    if (c[1] >= 1 && ncifre >= 2) cout << "1\n";
    else if (c[2] >= 2 && ncifre >= 3) cout << "2\n";
    else cout << "-1\n";
  }
  else {
    if (c[2] >= 1 && ncifre >= 2) cout << "1\n";
    else if (c[1] >= 2 && ncifre >= 3) cout << "2\n";
    else cout << "-1\n";
  }

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MOD 998244353
#define ll long long
int main(){
	ll a=0,b=0,c=0;
	cin>>a>>b>>c;
	ll moda = a*(a+1)/2, modb = b*(b+1)/2, modc = c*(c+1)/2;
	ll modx = ((moda % MOD)*(modb % MOD))%MOD;
	ll mody = ((modx % MOD)*(modc % MOD)% MOD);
	cout<<mody<<endl;

}

#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n, long long modvalue) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2, modvalue);
        return t * t % modvalue;
    } else {
        return modpow(m, n - 1, modvalue) * m % modvalue;
    }
}

long long moddiv(long long a, long long b, ll modvalue) { return (a * modpow(b, mod - 2, modvalue)) % modvalue; }

const ll INF = 1LL << 60 + 2;

string change_binary(long long a) {
    string ret;
    for (int i = 31; i >= 0; i--) {
        ret += (a >> i & 1) + '0';
    }
    return ret;
}

ll nCkmod(ll n, ll k, ll modvalue) {
    ll numera = 1;
    for (int i = n; i > n - k; i--) {
        numera *= i;
        numera %= modvalue;
    }
    ll denomi = 1;
    REP(i, k) {
        denomi *= (i + 1);
        denomi %= modvalue;
    }
    return moddiv(numera, denomi, modvalue);
}

map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
vector<ll> dijkstra(vector<vector<P>> graph, ll s) {
    vector<ll> ans(graph.size(), -1);
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push({0, s});
    while (pq.size() > 0) {
        ll cur1 = 0;
        ll cur2 = 0;
        if (ans[pq.top().second] != -1) {
            pq.pop();
        } else {
            cur1 = pq.top().first;
            cur2 = pq.top().second;
            pq.pop();
            ans[cur2] = cur1;
            for (ll i = 0; i < graph[cur2].size(); i++) {
                pq.push({cur1 + graph[cur2][i].first, graph[cur2][i].second});
            }
        }
    }
    return ans;
}
vector<string> maze;
ll h, w;
bool check(ll y, ll x) {
    if (x < 0 || x >= w || y < 0 || y >= h || maze[y][x] == '#') {
        return false;
    }
    return true;
}
vector<vector<ll>> graph;
vector<vector<ll>> visited;
void dfs(ll curx, ll cury) {
    if (-1 < curx && curx < h && -1 < cury && cury < w && visited[curx][cury] == 0) {
        if (graph[curx][cury] == 1) {
            // cout << curx << " " << cury << endl;
            // cout << visited[curx][cury] << endl;
            visited[curx][cury]++;
            dfs(curx + 1, cury);
            dfs(curx, cury + 1);
            dfs(curx + 1, cury + 1);
            dfs(curx + 1, cury - 1);
            dfs(curx, cury - 1);
            dfs(curx - 1, cury + 1);
            dfs(curx - 1, cury);
            dfs(curx - 1, cury - 1);
        }
    }
}
int main() {
    ll A, B, C;
    cin >> A >> B >> C;
    ll x = ((A * (A + 1)) / 2) % 998244353;
    ll y = ((B * (B + 1)) / 2) % 998244353;
    ll z = ((C * (C + 1)) / 2) % 998244353;
    cout << ((((x * y) % 998244353) * z) % 998244353) << endl;
}


#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <iomanip>
#include <cmath>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include<cstring>
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
void solve()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll cyan=a;
    ll red=0;
    ll ans=0;
    if(c*d-b==0||c*d-b<0)
    {
        cout<<-1;
        return;
    }

    while (cyan>d*red)
    {
        cyan+=b;
        red+=c;
        ans++;
    }

    cout<<ans;
}
int main()
 {
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while (t--)
	{
		solve();
	}
 }

#include <bits/stdc++.h>

using namespace std;

#define int long long int
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define mk make_pair
#define vi vector<int>
#define pii pair<int, int>
#define mod 1000000007
#define set_pre(x, y) fixed << setprecision(y) << x
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)

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

void solve() {
    int a, b, c, d, n = 0, k = 0, cnt = 0, ans = 0;
    cin >> a >> b >> c >> d;

    if (b >= c * d) {
        cout << -1;
        return;
    }

    cout << ceil((a * 1.0) / (c * d - b));
}

int32_t main() {
    clock_t begin = clock();
    init();
    // Write your code here....

    solve();

    // code end.....

#ifndef ONLINE_JUDGE
    clock_t end = clock();
    std::cout << "\n\nExecuted In: " << double(end - begin) / CLOCKS_PER_SEC * 1000 << " ms";
#endif
    return 0;
}


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

template <class Tp, class Comp = std::less<Tp>>
bool chle(Tp &x, const Tp &y, Comp comp = Comp()) {
  return comp(y, x) ? x = y, true : false;
}

template <class Tp, class Comp = std::less<Tp>>
bool chge(Tp &x, const Tp &y, Comp comp = Comp()) {
  return comp(x, y) ? x = y, true : false;
}

void solve() {
  i64 n;
  cin >> n;
  while (~n & 1) {
    n >>= 1;
  }
  i64 ans = 0;
  for (i64 d = 1; d * d <= n; ++d) {
    if (n % d) {
      continue;
    }
    ans++;
    if (d < n / d) {
      ++ans;
    }
  }
  ans += ans;
  cout << ans << "\n";
}

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

  solve();
}

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

typedef long long ll;

int main()
{
    ll n;
    scanf("%lld", &n);

    ll cnt = 0;
    for(ll i = 1; i * i <= n; i++)
    {
        if(n % i == 0)
        {
            if(i % 2 == 1 )
                cnt++;
            if(i != n / i && (n / i) % 2 == 1)
                cnt++;
        }
    }
    printf("%lld\n", cnt * 2);

    return 0;
}


#include <bits/stdc++.h>

#define ln                 '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

template<int mod> struct modulo {
	typedef modulo T;
	int w;
	operator int() const { return w; }

	modulo() {}
	modulo(int w) { this->w = w; fix(); }
	template<class A> modulo(A w) { this->w = w % mod; fix(); }
	inline void fix() { if (w >= mod || w < -mod) w %= mod; if (w < 0) w += mod; }

	inline T  operator -  () const { return mod - w; }
	inline T& operator += (const T &b) { if ((w += b.w) >= mod) w -= mod; return *this; }
	inline T& operator -= (const T &b) { if ((w -= b.w) < 0) w += mod; return *this; }
	inline T& operator *= (const T &b) { w = (unsigned long long) w * b.w % mod; return *this; }
	inline T& operator /= (const T &b) { return *this *= b.inv(); }
	#define make_operation(P)\
	friend inline T operator P (const T &a, const T &b) { return T(a) P##= b; }\
	template<class U> friend inline T operator P (const T &a, const U &b) { return T(a) P##= b; }\
	template<class U> friend inline T operator P (const U &a, const T &b) { return T(a) P##= b; }
	make_operation(+) make_operation(-) make_operation(*) make_operation(/)
	#undef make_operation

	inline T inv() const {
		int a = w, m = mod, u = 0, v = 1, t;
		for (; a != 0; t = m / a, m -= t * a, swap(a, m), u -= t * v, swap(u, v));
		return u;
	}

	friend inline T pow(const T &w, num p) {
		T a = w, r = 1; for (; p > 0; a *= a, p >>= 1) if (p & 1) r *= a; return r;
	}
};
const int mod = 998244353;
typedef modulo<mod> rem;

const int nsz = 5e2;
char s[nsz + 5][nsz + 5];
int n, m, d[2 * nsz + 5];
rem ans = 1;

int main() {
	scanf("%d%d", &n, &m);
	cont (i, n) scanf("%s", s[i] + 1);
	cont (i, n + m - 1) d[i] = -2;
	cont (i, n) cont (j, m) if (s[i][j] != '.') {
		int id = i + j - 1, c = s[i][j] == 'R' ? 0 : 1;
		if (d[id] == -2) d[id] = c;
		else if (d[id] != c) d[id] = -1;
	}
	cont (i, n + m - 1) {
		if (d[i] == -1) ans = 0;
		else if (d[i] == -2) ans *= 2;
	}
	printf("%d\n", ans.w);
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}
#ifdef LOCAL
void _debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void _debug_out(Head H, Tail... T) { cerr << " " << to_string(H); _debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", _debug_out(__VA_ARGS__)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...) 42
#define eprintf(...) 42
#endif

bool chikai(ll a,ll b,ll c,ll d) {
  return abs(a-c)+abs(b-d) <= 3;
}

ll r1, c1, r2, c2;

ll solve() {
  if(r1==r2 && c1==c2)  return 0;

  {
    ll tasu1 = r1+c1;
    ll tasu2 = r2+c2;
    ll hiku1 = r1-c1;
    ll hiku2 = r2-c2;

    if(chikai(r1,c1,r2,c2)) return 1;
    if(tasu1==tasu2) return 1;
    if(hiku1==hiku2) return 1;

    if((tasu1 %2) == (tasu2%2)) return 2;
    if((hiku1 %2) == (hiku2%2)) return 2;
  }

  rep(x,-3,4) rep(y,-3,4) {
    if(abs(x)+abs(y)>3) continue;
    ll rr1 = r1+x;
    ll cc1 = c1+y;

    ll tasu1 = rr1+cc1;
    ll tasu2 = r2+c2;
    ll hiku1 = rr1-cc1;
    ll hiku2 = r2-c2;

    if(chikai(rr1,cc1,r2,c2)) return 2;
    if(tasu1==tasu2) return 2;
    if(hiku1==hiku2) return 2;
  }
  rep(x,-3,4) rep(y,-3,4) {
    if(abs(x)+abs(y)>3) continue;
    if(x+y>3) continue;
    ll rr2 = r2+x;
    ll cc2 = c2+y;

    ll tasu1 = r1+c1;
    ll tasu2 = rr2+cc2;
    ll hiku1 = r1-c1;
    ll hiku2 = rr2-cc2;

    if(chikai(r1,c1,rr2,cc2)) return 2;
    if(tasu1==tasu2) return 2;
    if(hiku1==hiku2) return 2;
  }

  return 3;
}

int main() {
  cin >>  r1 >> c1 >> r2 >> c2;
  cout << solve() <<endl;
}


#include <bits/stdc++.h>

#define ln                 '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 5e5;
char s[nsz + 5], t[nsz + 5];
int n, ans;

int main() {
	scanf("%d", &n);
	scanf("%s", s);
	scanf("%s", t);
	int c0 = 0, c1 = 0;
	loop (i, n) {
		c0 += s[i] == '0';
		c1 += t[i] == '0';
	}
	if (c0 != c1) {
		printf("-1\n");
		return 0;
	}
	for (int i0 = 0, j0 = 0, i1 = 0, j1 = 0; i0 < n && i1 < n; i0 = j0 + 1, i1 = j1 + 1) {
		for (j0 = i0; j0 < n && s[j0] == '1'; ++j0);
		for (j1 = i1; j1 < n && t[j1] == '1'; ++j1);
		ans += j0 != j1;
	}
	printf("%d\n", ans);
}

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define ud unsigned int
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x3f
#define MAX_INF_VAL 0x3f3f3f3f
#define MAX_INF_VAL_LL 0x3f3f3f3f3f3f3f3f
//#define pi 3.141592653589
#define eps 1e-9
#define F(x) ((x)/3+((x)%3==1?0:tb))
#define G(x) ((x)<tb?(x)*3+1:((x)-tb)*3+2)
//#define p 2173412051LL
//#define sz 2

using namespace std;

template< typename T > void read( T &x ) {
	x = 0;
	char ch = getchar();
	ll f = 1;
	while( !isdigit( ch ) ) {
		if( ch == '-' )
		f *= -1;
		ch = getchar();
	}
	while( isdigit( ch ) ) {
		x = x * 10 + ch - 48;
		ch = getchar();
	}
	x *= f;
}

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

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

char s[ 500010 ], t[ 500010 ];
vector< int > a, b;

int main() {
	ios::sync_with_stdio( false );
	cin.tie( 0 ), cout.tie( 0 );
	int n;
	cin >> n;
	cin >> s + 1 >> t + 1;
	for( int i = 1; i <= n; ++i ) {
		if( s[ i ] == '0' )
			a.push_back( i );
		if( t[ i ] == '0' )
			b.push_back( i );
	}
	if( a.size() != b.size() ) {
		cout << "-1";
		return 0;
	}
	int ans = 0;
	for( int i = 0; i < a.size(); ++i ) {
		if( a[ i ] != b[ i ] )
			++ans;
	}
	cout << ans;
	return 0;
}


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

#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
#define vvvll vector<vector<vector<ll>>>
#define vvll vector<vector<ll>>
#define vll vector<ll>

constexpr ll INF = (1ll << 60);
constexpr ll mod = 1000000007;
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll V;
ll G[20][20];
ll dp[200000][20];
int main() {
    ll x[20],y[20],z[20];
    cin >> V;
    rep(i, V) {
        cin>>x[i]>>y[i]>>z[i];
    }
    rep(i,V){
        rep(j,V){
            G[i][j]=abs(x[i]-x[j])+abs(y[i]-y[j])+max(0ll,z[j]-z[i]);
        }
    }
    rep(i, 1 << V) {
        rep(j, 20) { dp[i][j] = INF; }
    }
    dp[0][0] = 0;
    rep(S, 1 << V) {
        rep(v, V) {
            rep(u, V) {
                if (S != 0 && !(S & (1 << u))) continue; // u を含まない場合を除く
                if ((S & (1 << v)) == 0) {
                    if (v != u) chmin(dp[S | (1 << v)][v], dp[S][u] + G[u][v]);
                }
            }
        }
    }
    if (dp[(1 << V) - 1][0] != INF) {
        cout << dp[(1 << V) - 1][0] << endl;
    }
    return 0;
}

#include <cstdio>
#include <iostream>
#define N 300005

using namespace std;

long long val[N];

inline long long read()
{
	long long f(1),x(0);char a=getchar();
	while(a!='-'&&(a<'0')||a>'9')a=getchar();
	a=='-'?f=-1:x=a-'0';a=getchar();
	while(a>='0'&&a<='9')x=(x<<3)+(x<<1)+a-'0',a=getchar();
	return x*f;
}

struct node
{
	long long val,lazy,l,r;
}tree[N<<2];

void build(long long root,long long l,long long r)
{
	tree[root].l=l;tree[root].r=r;
	if(l==r)
	{
		tree[root].val=val[r];
		return;
	}
	long long mid=(l+r)/2;
	build((root<<1),l,mid);build((root<<1)+1,mid+1,r);
	tree[root].val=tree[(root<<1)].val ^ tree[(root<<1)+1].val;
}

void pushdown(long long root)
{
	if(tree[root].lazy)
	{
		tree[(root<<1)  ].lazy^=tree[root].lazy;
		tree[(root<<1)+1].lazy^=tree[root].lazy;
		tree[(root<<1)  ].val^=tree[root].lazy*(tree[(root<<1)  ].r-tree[(root<<1)  ].l+1);
		tree[(root<<1)+1].val^=tree[root].lazy*(tree[(root<<1)+1].r-tree[(root<<1)+1].l+1);
		tree[root].lazy=0;
	}
}

void update(long long root,long long l,long long r,long long val)
{
	if(tree[root].l>r||tree[root].r<l)return;
	if(tree[root].r<=r&&tree[root].l>=l)
	{
		tree[root].lazy^=val;
		tree[root].val^=val*(tree[root].r-tree[root].l+1);
		return;
	}
	pushdown(root);
	update((root<<1),l,r,val);update((root<<1)+1,l,r,val);
	tree[root].val=tree[(root<<1)].val^tree[(root<<1)+1].val;
}

long long queryval(long long root,long long l,long long r)
{
	if(tree[root].l>r||tree[root].r<l)return 0;
	if(tree[root].r<=r&&tree[root].l>=l)return tree[root].val;
	pushdown(root);
	return queryval((root<<1),l,r)^queryval((root<<1)+1,l,r);
}

int main()
{
	long long n,m;
	n=read();m=read();
	for(int i=1;i<=n;i++)val[i]=read();
	build(1,1,n);
	while(m--)
	{
		long long opt=read();
		if(opt==1)
		{
			long long x=read(),k=read();
			update(1,x,x,k);
		}
		else
		{
			long long x=read(),y=read();
			printf("%lld\n",queryval(1,x,y));
		}
	}
	return 0;
}


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

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

// auto mod int
// depends on Template

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

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    mint ans = 1;
    ll s = 0;
    rep(i,n)s+=a[i];
    for(ll i = m+n;i>m-s;i--){
        ans *= i;
    }
    for(ll i = s+n;i>=1;i--){
        ans /= i;
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int N = 1005;

int n, x;
void solve(int Case) {
    scanf("%d %d", &n, &x);
    x *= 100;

    int ans = -1;
    int v, p, y = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &v, &p);
        y += v * p;
        if (ans == -1 && y > x) ans = i + 1;
    }

    printf("%d\n", ans);
}

int main () {
    int T = 1;
    // scanf("%d", &T);
    for (int t = 1; t <= T; ++t) solve(t);
    return 0;
}


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

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

#define mp make_pair
#define fr first
#define sc second

// full credit ecnerwala
template <int& MOD_>
struct modint {
    static constexpr int& MOD = MOD_;
    // static_assert(MOD_ > 0, "MOD must be positive");

   private:
    using ll = long long;

    int v;

    static int minv(int a, int m) {
        a %= m;
        assert(a);
        return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
    }

   public:
    modint() : v(0) {}
    modint(ll v_) : v(int(v_ % MOD)) {
        if (v < 0) v += MOD;
    }
    explicit operator int() const { return v; }
    friend std::ostream& operator<<(std::ostream& out, const modint& n) {
        return out << int(n);
    }
    friend std::istream& operator>>(std::istream& in, modint& n) {
        ll v_;
        in >> v_;
        n = modint(v_);
        return in;
    }

    friend bool operator==(const modint& a, const modint& b) {
        return a.v == b.v;
    }
    friend bool operator!=(const modint& a, const modint& b) {
        return a.v != b.v;
    }

    modint inv() const {
        modint res;
        res.v = minv(v, MOD);
        return res;
    }
    friend modint inv(const modint& m) { return m.inv(); }
    modint neg() const {
        modint res;
        res.v = v ? MOD - v : 0;
        return res;
    }
    friend modint neg(const modint& m) { return m.neg(); }

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

    modint& operator++() {
        v++;
        if (v == MOD) v = 0;
        return *this;
    }
    modint& operator--() {
        if (v == 0) v = MOD;
        v--;
        return *this;
    }
    modint& operator+=(const modint& o) {
        v -= MOD - o.v;
        v = (v < 0) ? v + MOD : v;
        return *this;
    }
    modint& operator-=(const modint& o) {
        v -= o.v;
        v = (v < 0) ? v + MOD : v;
        return *this;
    }
    modint& operator*=(const modint& o) {
        v = int(ll(v) * ll(o.v) % MOD);
        return *this;
    }
    modint& operator/=(const modint& o) { return *this *= o.inv(); }

    friend modint operator++(modint& a, int) {
        modint r = a;
        ++a;
        return r;
    }
    friend modint operator--(modint& a, int) {
        modint r = a;
        --a;
        return r;
    }
    friend modint operator+(const modint& a, const modint& b) {
        return modint(a) += b;
    }
    friend modint operator-(const modint& a, const modint& b) {
        return modint(a) -= b;
    }
    friend modint operator*(const modint& a, const modint& b) {
        return modint(a) *= b;
    }
    friend modint operator/(const modint& a, const modint& b) {
        return modint(a) /= b;
    }
    modint qpow(ll pow) const {
        modint ans = 1, base = v;
        while (pow) {
            if (pow & 1) ans *= base;
            base *= base;
            pow >>= 1;
        }
        return ans;
    }
    friend modint qpow(const modint& a, ll pow) { return a.qpow(pow); }
};

int MOD;

void solve() {
    ll N;
    int M;
    cin >> N >> M;
    MOD = M * M;
    using mint = modint<MOD>;
    cout << (int)qpow(mint(10), N) / M % M << '\n';
}

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

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

    return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct edge {
  ll to, cost;
};

int main() {
  ll n; cin >> n;
  ll N = n + 1;
  ll res = 0; ll i = 1;
  while(N > res) {
    res += i;
    if(N < res) break;
    ++i;
  }
  if(n == 2) cout << 1 << endl;
  else cout << n - (i - 1) + 1 << endl;
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
int n,x;
cin>>n>>x;
vector<int> vec;
int c;
for(int i=1;i<=n;i++)
{
cin>>c;
vec.push_back(c);
}
auto it=find(vec.begin(),vec.end(),x);
while(it!=vec.end())
{
vec.erase(it);
it=find(vec.begin(),vec.end(),x);
}
for(auto i:vec)cout<<i<<" ";
return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define ff first
#define ss second
#define hell 1000000007

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009

ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll n;cin>>n;
	vector<pair<ll,string>> v;
	rep(iu,0,n) {
		string x;
		ll y;
		cin>>x>>y;
		v.pb({y,x});
	}
	sort(all(v));
	reverse(all(v));
	cout << v[1].ss << endl;
}


#include <bits/stdc++.h>
#ifdef LOCAL
#include "debuger.hpp"
#else
#define DUMP(...) 1145141919810
#define CHECK(...) (__VA_ARGS__)
#endif

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    printf("%d %d\n", 2 * i % n + 1, (2 * i + 1) % n + 1);
  }
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (ll i=(ll)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const ll INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(ll x=pow(10,7)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { ll d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll modpow(ll x, ll p) { ll result = 1, now = 1, pm = x; while (now<=p) { if (p&now) { result = result * pm % MOD; } now*=2; pm = pm*pm % MOD; } return result; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

int main() {
  ll N; cin >> N;
  rep(i,N) {
    ll a = i*2, b = i*2+1;
    ll tca = 0; while ((1<<tca)<=a) tca++;
    while (a>=N) { if (a&(1<<tca)) a ^= (1<<tca); tca--; }
    ll tcb = 0; while ((1<<tcb)<=b) tcb++;
    while (b>=N) { if (b&(1<<tcb)) b ^= (1<<tcb); tcb--; }
    a++; b++;
    cout << a << " " << b << endl;
  }
  return 0;
}


#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll=int;
using ld=long double;
using pll=pair<ll, ll>;
//using mint = modint1000000007;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo 2e18
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
//priority_queue<ll, vector<ll>, greater<ll>> Q;
/*
01234でタイルの方向管理？
*/
#define TIMEOVER_M 15000
#define TIMEOVER 1980000
#define DIV 500

ll T[50][50];
bool B[50][50];
ll P[50][50];
ll D[50][50];
char *ans;
char *W;
ll score=0;
ll high=0;
ll dx[]={0, 1, 0, -1};
ll dy[]={-1, 0, 1, 0};
char dc[]={'U', 'R', 'D', 'L'};
bool all_fin;
bool fin;
clock_t start;
clock_t start_m;
ll loop;
ll node=0;

void steped(ll y, ll x, bool b){
  ll d=D[y][x];
  if (d){
    --d;
    ll ny=y+dy[d];
    ll nx=x+dx[d];
    B[ny][nx]=b;
  }
  B[y][x] = b;
}

// 行き止まりになったら、その時点でのstringを出力
void dfs(ll y, ll x, ll c){// {y, x, 歩数}
  bool used[4]={};
  rep(i, 4){
    clock_t now = clock();

    if(now-start_m>TIMEOVER_M) fin=true;
    if(now-start>TIMEOVER) all_fin=true;
    ll r=(node++/DIV)%4;
    while(used[r]) (r+=1)%=4;
    used[r]=true;
    ll ny=y+dy[r];
    ll nx=x+dx[r];
//    cout << "time:" << now-start << endl;
    if(ny<0 || nx<0 || ny>49 || nx>49 || B[ny][nx] || fin || all_fin){
      if(chmax(high, score)){
        if(ans) free(ans);
        ans=strdup(W);
      }
    }
    else{
      //反映
      score+=P[ny][nx];
      W[c]=dc[r];
      steped(ny, nx, true);

      dfs(ny, nx, c+1);
      //復元
      score-=P[ny][nx];
      W[c]='\0';
      steped(ny, nx, false);
    }
  }

}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  W=(char*)calloc(2000, 1);
  start = clock();
  ll si, sj;
  cin >> si >> sj;
  rep(i, 50) rep(j, 50) cin >> T[i][j];
  rep(i, 50) rep(j, 50) cin >> P[i][j];
  // タイルの方向D
  rep(i, 50) rep(j, 50){
    rep(k, 4){
      ll ny=i+dy[k];
      ll nx=j+dx[k];
      if(ny<0 || nx<0 || ny>49 || nx>49) continue;
      if(T[i][j]==T[ny][nx]) D[i][j]=k+1;
    }
  }
  while(!all_fin){
    loop++;
    fin=false;
    start_m = clock();
    score = P[si][sj];
    chmax(high, score);
    rep(y, 50) rep(x, 50) B[y][x]=false;
    rep(i, 2000) W[i]='\0';
    steped(si, sj, true);
    dfs(si, sj, 0);
  }
//  cout << high << " " << loop << " " << node << endl;
  printf("%s\n", ans);
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    int N;
    string T;
    cin >> N >> T;
    string s = "";
    rep(i, 4 * N) { s += "110"; }

    lint len = 3;
    lint sum = 1;
    rep(i, 10) {
        len *= 10;
        sum *= 10;
    }

    if (s.substr(0, N) != T and s.substr(1, N) != T and s.substr(2, N) != T) {
        cout << 0 << endl;
        return 0;
    }

    if (T == "11") {
        cout << sum << endl;
    } else if (T == "10") {
        cout << sum << endl;
    } else if (T == "01") {
        cout << sum - 1 << endl;
    } else if (T == "0") {
        cout << sum << endl;
    } else if (T == "1") {
        cout << sum * 2 << endl;
    } else {
        // 必ず0がいる
        lint from, to;
        if (T[0] == '0') {
            from = 2;
        } else if (T.substr(0, 2) == "11") {
            from = 0;
        } else if (T.substr(0, 2) == "10") {
            from = 1;
        }

        if (T.back() == '0') {
            to = len;
        } else if (T.substr(N - 2, 2) == "11") {
            to = len - 1;
        } else if (T.substr(N - 2, 2) == "01") {
            to = len - 2;
        }
        cout << ((to - from) - N) / 3 + 1 << endl;
    }

    // d(sum);
    // d(len);
    // dump(s);
    return 0;
}


#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int a, b, c = 0, d = 0;
  cin >> a >> b;
  while(a) {
    c += a % 10;
    a /= 10;
  }
  while(b) {
    d += b % 10;
    b /= 10;
  }
  cout << max(c,d) << endl;

  return 0;
}

/*
* Author      : Arman Sykot
* Date & time : 02.01.2021 18:00:36 +06
*/

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define I_am_the_one_who_KNOCKS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

const double EPS = 1e-9;

int main() {
#ifndef ONLINE_JUDGE
	freopen ("in.txt", "r", stdin);
	freopen ("out.txt", "w", stdout);
#endif
	I_am_the_one_who_KNOCKS;

	int a, b;
	cin >> a >> b;

	int suma = 0, sumb = 0;
	while (a) {
		int rem = a % 10;
		a /= 10;
		suma += rem;
	}

	while (b) {
		int rem = b % 10;
		b /= 10;
		sumb += rem;
	}

	if (suma > sumb)
		cout << suma << "\n";
	else
		cout << sumb << "\n";
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(void){

    int a;
    double b;
    cin>>a>>b;

    cout<<a*b/100.0<<endl;
}

#line 1 "main.cpp"
#include <bits/stdc++.h>
using namespace std;

// template {{{
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

#define  range(i, l, r) for (i64 i = (i64)(l); i < (i64)(r); (i) += 1)
#define rrange(i, l, r) for (i64 i = (i64)(r) - 1; i >= (i64)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(i32 x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != (int)v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solve() {
  int n = input();
  vector< i64 > as(n);
  cin >> as;

  for (auto &a : as) a *= 2;
  whole(sort, as);

  i64 x = as[(n-1)/2] / 2;
  i64 ans = x * n + whole(accumulate, as, 0ll);
  for (auto &a : as) {
    ans -= min(a, 2 * x);
  }

  cout << (long double)ans / n / 2 << endl;
}

signed main() {
  solve();
}


// C++(GCC 9.2.1)
// 解き直し.
// https://atcoder.jp/contests/arc108/editorial/348
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int, int>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define a first
#define b second

int main(){

    // 1. 入力情報.
    int N, M;
    scanf("%d %d", &N, &M);
    vvi G(N);
    map<P, int> m; // グラフの辺情報(最大一つ)を保存.
    rep(i, M){
        int u, v, c;
        scanf("%d %d %d", &u, &v, &c);
        u--, v--;
        G[u].pb(v);
        G[v].pb(u);
        m[{u, v}] = c;
        m[{v, u}] = c;
    }

    // 2. 頂点 1 から 各頂点までの距離を計算.
    // https://ja.wikipedia.org/wiki/幅優先探索
    function<void(vvi&, int, int*)> bfs = [&](vvi &G, int s, int* d){
        // 2-1. 空のキュー.
        queue<int> q;

        // 2-2. 探索地点 s をキュー q に追加.
        q.push(s);
        while(!q.empty()){
            // 2-3. キューから取り出す.
            int u = q.front();
            q.pop();

            // 2-4. 取り出した要素を処理.
            for(auto &e : G[u]){
                // 2-5. 訪問済であれば, 処理をスキップ.
                if(d[e])            continue;
                if(!d[e] && e != s) d[e] = d[u] + 1, q.push(e);
            }
        }
        return;
    };
    int d[N];
    memset(d, 0, sizeof(d));
    bfs(G, 0, d);
    // rep(i, N) printf("d[%d]=%d\n", i, d[i]);

    // 3. 頂点 1 から 近い順 に並び替え.
    // -> {距離, 頂点番号}
    priority_queue<P, vector<P>, greater<P>> pq;
    rep(i, N) pq.push({d[i], i});

    // 4. 各頂点に, 整数を書き込む.
    int ans[N];
    memset(ans, 0, sizeof(ans));
    ans[0] = 1; //  頂点 1 に 1 を書き込む.
    while(!pq.empty()){
        // 4-1. 頂点 v を一つ取り出す.
        P p = pq.top();
        pq.pop();

        // 4-2. 頂点 v の 頂点番号は？
        int v = p.b;

        // 4-3. 頂点 v を 根とする部分木 について, 整数を書き込む.
        for(auto &u : G[v]){
            // 4-4. 頂点 v に 書き込まれた整数.
            int nv = ans[v];

            // 4-5. 頂点 v の 子供 に 相当する頂点 u を 選択し, 書き込み.
            if(d[u] > d[v] && !ans[u]){
                // 4-6. 辺のラベル.
                int ne = m[{v, u}];

                // 4-7. 辺のラベルと比較して, 書き込む整数を選択.
                if(nv == ne) ans[u] = (nv == 1) ? N : 1;
                else         ans[u] = ne;

            }
        }
    }

    // 5. 出力.
    rep(i, N) printf("%d\n", ans[i]);
    return 0;

}

// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int ll
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define ll long long
#define pi pair<int,int>
#define pii pair<pi,int>
#define vi vector<int>
#define pb push_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,x;
	cin>>n>>x;
	vi v(n);
	rep(i,n){
		cin>>v[i];
	}
	map<int,int> mp;
	mp[x] = 1;
	rep(i,n-1){
		map<int,int> newmp;
		for(auto x:mp){
			// x.fi ke sabse pass vaale 2 numbers which
			// are divisible by v[i+1] (might be 1)
			int num = x.fi;
			int r = num%v[i+1];
			if(r == 0){
				newmp[num] += x.sec;
			}
			else{
				newmp[num-r] += x.sec;
				newmp[num+v[i+1]-r] += x.sec;
			}
		}
		mp = newmp;
	}
	int ans = 0;
	for(auto x:mp){
		ans += x.sec;
	}
	cout<<ans;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 321123;

int n, k, ans, black[N], white[N];
vector<int> g[N];

void dfs(int v, int p, int x) {
	black[v] = N;
	white[v] = 0;
	for (auto u : g[v]) {
		if (u == p) continue;
		dfs(u, v, x);
		if (black[v] + 1 + white[u] <= x)
			white[u] = -1;
		if (black[u] + 1 + white[v] <= x)
			white[v] = -1;
		if (white[u] != -1)
			white[v] = max(white[v], white[u] + 1);
		black[v] = min(black[v], black[u] + 1);
	}
	if (white[v] == x || (white[v] != -1 && v == 1)) {
		ans++;
		white[v] = -1;
		black[v] = 0;
	}
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < n - 1; i++) {
		int a, b; cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int l = 1, r = n - 1;
	while (l < r) {
		int m = (l + r) / 2;
		ans = 0;
		dfs(1, 0, m);
		if (ans <= k)
			r = m;
		else
			l = m + 1;
	}
	cout << l << "\n";
	return 0;
}

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

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

int to[400001], ne[400001], he[200001];
int Q[200001], pl[200001], dl[200001];

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}

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

	int N = getint(), K = getint();
	int k = 1;
	rep(i, N - 1) {
		int u = getint(), v = getint();
		to[k] = v;
		ne[k] = he[u];
		he[u] = k++;
		to[k] = u;
		ne[k] = he[v];
		he[v] = k++;
	}

	int q = 0, p = 0;
	Q[q++] = 1;
	while (p < N) {
		int u = Q[p++];
		int tmp = 0;
		int ind = he[u];
		he[u] = 0;
		while (ind) {
			int v = to[ind];
			tmp = ne[ind];
			if (he[v] > 0) {
				Q[q++] = v;
				ne[ind] = he[u];
				he[u] = -ind;
			}
			ind = tmp;
		}
	}

	int are = 1000000, pd0 = are;
	int L = 0, R = (N + K - 1) / K;
	while (L + 1 < R) {
		int wj = (L + R) / 2;

		int num = 0;

		for (int i = N - 1; i >= 0; i--) {
			int po = pd0 - 1;
			int dd = pd0;
			int u = Q[i];
			for (int ind = -he[u]; ind; ind = -ne[ind]) {
				int v = to[ind];
				if (po < pl[v]) po = pl[v];
				if (dd < dl[v]) dd = dl[v];
			}
			if (po >= dd) dd = 0;
			if (dd >= pd0 + wj) {
				num++;
				po = pd0 + wj;
				dd = 0;
			}
			pl[u] = po - 1;
			dl[u] = dd + 1;
			if (num > K) break;
		}

		int are = num + (dl[1] > pd0);
		if (are > K) L = wj;
		else R = wj;

		pd0 += are;
	}

	printf("%d", R);

	Would you please return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve() {
  string s;
  cin >> s;
  ll m;
  cin >> m;

  ll maxi = 0LL;
  for (char c : s) {
    maxi = max(maxi, (ll)c - '0');
  }
  maxi += 1;
  if (s.size() == 1) {
    cout << (m >= stoll(s) ? 1 : 0) << '\n';
    return;
  }
  ll n = (int)s.size();
  auto check = [&](ll x) {
    if((n + 1) > m * logl(x)) return false;
    ll cp = 0, res = 1LL;
    for (ll i = n - 1LL; i >= 0LL; i--) {
      cp += (ll)(s[i] - '0') * res;
      if (res > m or cp > m) return false;
      res *= x;
    }
    if (cp <= m) return true;
    return false;
  };

  if(!check(maxi)) return void(cout << 0 << "\n");
  ll l = maxi, r = maxi, ans;
  while(check(r)) r <<= 1;
  while (l <= r) {
    ll mid = l + (r - l) / 2LL;
    if (check(mid)) {
      ans = mid;
      l = mid + 1LL;
    } else {
      r = mid - 1LL;
    }
  }
  cout << max(0LL, ans - maxi + 1) << '\n';
}

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

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cstdint>

bool IsFeasible(const std::vector<int>& digits, std::int64_t base, std::int64_t M) {
  std::int64_t X = 0;
  for (const auto digit : digits) {
    if (X > M / base) {
      return false;
    }
    X = X * base + digit;
  }
  return X <= M;
}

int main() {
  std::string X;
  std::int64_t M;
  std::cin >> X >> M;
  const int D = X.size();
  if (D < 2) {
    std::cout << (std::stoi(X) <= M) << std::endl;
    return 0;
  }
  std::vector<int> digits(D);
  for (int i = 0; i < D; ++i) {
    digits[i] = X[i] - '0';
  }
  const std::int64_t d = *std::max_element(digits.begin(), digits.end());
  std::int64_t feasible = d;
  for (std::int64_t b = static_cast<std::int64_t>(1) << 60; b; b >>= 1) {
    const auto base = feasible + b;
    if (IsFeasible(digits, base, M)) {
      feasible = base;
    }
  }
  std::cout << (feasible - d) << std::endl;
  return 0;
}


#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <bitset>
#include <complex>
using namespace std;

//typedef long long ll;
//typedef pair<ll, ll> P;
//const ll INF   = 1000000000000000000;
//const ll MOD   = 1000000000 + 7;

//typedef pair<int, int> P;
//const int INF  = 1000000001;
//const int MOD  = 1000000000 + 7;

//const int MAX_N = 100000 + 10;
//int a[MAX_N];

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

  int N, K;
  cin >> N >> K;

  int ans = 0;
  for(int n = 1; n <= N; n++) {
    for (int k = 1; k <= K; k++) {
      int tmp = 100*n + k;
      ans += tmp;
    }
  }

  cout << ans << endl;

  return 0;
}

#include<iostream>
using namespace std;
int main()
{
  int A,B=0;
  int maxFollow=0;

  cin >> A;
  cin >> B;

  maxFollow = 2*A + 100;

  int diff = maxFollow - B;

  cout << diff << endl;
}


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

using namespace std;

#define ll long long

vector<ll> vec;

void solve(){
    for(char i = '1';i<='9';i++){
        string temp = "";
        temp += i;
        temp += temp;
        vec.push_back(stoll(temp));
    }
    for(char i = '1';i<='9';i++){
        for(char j = '0';j<='9';j++){
            string temp = "";
            temp += i;
            temp += j;
            temp += temp;
            vec.push_back(stoll(temp));
        }
    }
    for(char i = '1';i<='9';i++){
        for(char j = '0';j<='9';j++){
            for(char k = '0';k<='9';k++){
                string temp = "";
                temp += i;
                temp += j;
                temp += k;
                temp += temp;
                vec.push_back(stoll(temp));
            }
        }
    }
    for(char i = '1';i<='9';i++){
        for(char j = '0';j<='9';j++){
            for(char k = '0';k<='9';k++){
                for(char l = '0';l<='9';l++){
                    string temp = "";
                    temp += i;
                    temp += j;
                    temp += k;
                    temp += l;
                    temp += temp;
                    vec.push_back(stoll(temp));
                }
            }
        }
    }
    for(char i = '1';i<='9';i++){
        for(char j = '0';j<='9';j++){
            for(char k = '0';k<='9';k++){
                for(char l = '0';l<='9';l++){
                    for(char m = '0';m<='9';m++){
                        string temp = "";
                        temp += i;
                        temp += j;
                        temp += k;
                        temp += l;
                        temp += m;
                        temp += temp;
                        vec.push_back(stoll(temp));
                    }
                }
            }
        }
    }
    for(char i = '1';i<='9';i++){
        for(char j = '0';j<='9';j++){
            for(char k = '0';k<='9';k++){
                for(char l = '0';l<='9';l++){
                    for(char m = '0';m<='9';m++){
                        for(char n = '0';n<='9';n++){
                            string temp = "";
                            temp += i;
                            temp += j;
                            temp += k;
                            temp += l;
                            temp += m;
                            temp += n;
                            temp += temp;
                            vec.push_back(stoll(temp));
                        }
                    }
                }
            }
        }
    }
    sort(vec.begin(),vec.end());
    ll n;
    cin>>n;
    int c = 0;
    for(int i = 0;i<vec.size();i++){
        if(vec[i] > n)break;
        c++;
    }
    cout<<c;
}

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

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    #define int int64_t
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        string s = to_string(i);
        int num = stoll(s+s);
        //cout<<num<<endl;
        if(num>n){
            break;
        }
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef long int li;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test ll t; cin >> t; while(t--)
#define print_tc(t, c) cout << "Case #" << t << ": " << c << "\n";
const long long int dx[4] = {0, 0, -1, 1}, dy[4] = {1, -1, 0, 0};
const long long int cons = 100005, ncr_cons = 100005;
const long long int MOD = 1000000007; // const long long int MOD = 998244353;
const long long int const_INT_MAX = 1000000000000000000, const_INT_MIN = -1 * 1000000000000000000;
using namespace std;
bool sortinrev(const pair<ll,ll> &a, const pair<ll,ll> &b){return (a.first > b.first);}
bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b){return (a.second < b.second);}
bool sortbysecinrev(const pair<ll,ll> &a, const pair<ll,ll> &b){return (a.second > b.second);}
ll gcd(ll x, ll y){return (ll)(__gcd(x, y));}
ll lcm(ll x, ll y){return (ll)((x * y) / gcd(x, y));}
ll mod_expo(ll x, ll y, ll p){
    if((x + p) % p == 0) return 0;
    ll res = 1; x = (x + p) % p;
    while (y > 0){
        if(y & 1) res = (res*x + p) % p;
        y = y>>1; x = (x*x + p) % p;
    }
    return res;
}
void usaco(string str = ""){
    fastio;
    if(str.size()){
        freopen((str + ".in").c_str(), "r", stdin);
        freopen((str + ".out").c_str(), "w", stdout);
    }
}
int main(){
    usaco();
    ll x, y, z; cin >> x >> y >> z; cout << (y * z - 1) / x << "\n";
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}

#pragma GCC optimize("Ofast")
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <cctype>
#include <sstream>
#include <stack>
#include <deque>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Po = pair<double, double>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=ll(a);i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define PB push_back
#define MP make_pair
#define SZ(x) ll(x.size())
#define ALL(x) x.begin(),x.end()
#define NIL -1
#define INF 1ll<<63-1
//#define MOD 1000000007
#define PI 3.14159265358979323846
#define endl "\n"
#define EPS 1e-9
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl

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

bool YN(bool b) {
	if (b)Yes;
	else No;
	return true;
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template <unsigned int MOD>
struct ModInt {
    using uint = unsigned int;
    using ull = unsigned long long;
    using M = ModInt;

    uint v;

    ModInt(ll _v = 0) { set_norm(_v % MOD + MOD); }
    M& set_norm(uint _v) {  //[0, MOD * 2)->[0, MOD)
        v = (_v < MOD) ? _v : _v - MOD;
        return *this;
    }

    explicit operator bool() const { return v != 0; }
    M operator+(const M& a) const { return M().set_norm(v + a.v); }
    M operator-(const M& a) const { return M().set_norm(v + MOD - a.v); }
    M operator*(const M& a) const { return M().set_norm(ull(v) * a.v % MOD); }
    M operator/(const M& a) const { return *this * a.inv(); }
    M& operator+=(const M& a) { return *this = *this + a; }
    M& operator-=(const M& a) { return *this = *this - a; }
    M& operator*=(const M& a) { return *this = *this * a; }
    M& operator/=(const M& a) { return *this = *this / a; }
    M operator-() const { return M() - *this; }
    M& operator++(int) { return *this = *this + 1; }
    M& operator--(int) { return *this = *this - 1; }

    M pow(ll n) const {
        if (n < 0) return inv().pow(-n);
        M x = *this, res = 1;
        while (n) {
            if (n & 1) res *= x;
            x *= x;
            n >>= 1;
        }
        return res;
    }

    M inv() const {
        ll a = v, b = MOD, p = 1, q = 0, t;
        while (b != 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(p -= t * q, q);
        }
        return M(p);
    }

    bool operator==(const M& a) const { return v == a.v; }
    bool operator!=(const M& a) const { return v != a.v; }
    friend ostream& operator<<(ostream& os, const M& a) { return os << a.v; }
    static uint get_mod() { return MOD; }
};

using Mint = ModInt<998244353>;

V<ll> divisor(ll n) {
    V<ll> ret;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ALL(ret));
    return (ret);
}

signed main() {
    cout << fixed << setprecision(15);
    ll x, y, a, b; cin >> x >> y >> a >> b;
    ll cnt = 0;
    while (double(x)<=double(x+b)/double(a)&&double(x)<double(y)/double(a)) {
        x *= a;
        cnt++;
    }
    cnt += (y - x-1) / b;
    cout << cnt << endl;
}


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

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

int main() {
    ll n;
    cin >> n;
    ll ans = LLONG_MAX;
    ll b = 0;
    while (bit(b) <= n) {
        ll a = n / bit(b);
        ll c = n % bit(b);
        chmin(ans, a + b + c);
        b++;
    }
    cout << ans << endl;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <cmath>
#include <set>
#include <map>
#include <stdio.h>
#include <stdlib.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
#define INF64 9223372036854775807
#define INF32 2147483647
#define F first
#define S second
typedef long long ll;
using namespace std;
using ull = unsigned long long;
using ll = long long;
using vi = vector<int>;
using vl = vector<long>;
using vll = vector<long long>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvll = vector<vll>;
using vs = vector<string>;
using pii = pair<int, int>;
using vd = vector<double>;
const int mod = 1000000007;
ll myceil(ll a, ll b) { return (a + (b - 1)) / b; }
ll myfloor(ll a, ll b) { return a / b; }
template<class T>void chmin(T& a, T b) {
    if (a > b)a = b;
}
ll gcd(ll a, ll b) {
    if (b == 0)return a;
    return gcd(b, a%b);
}

int main() {
    ll n; cin >> n;
    string s = to_string(n);
    if (s.size() % 2 == 0) {
        string s1 = s.substr(0, s.size() / 2);
        string s2 = s.substr(s.size() / 2, s.size());
        int pre = stoi(s1); int lat = stoi(s2);
        if (pre <= lat)cout << pre << endl;
        else
            cout << pre - 1 << endl;
    }
    else {
        int key = s.size() / 2;
        cout << pow(10, key) - 1 << endl;
    }
}


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

#define rep(i,n) for (int i = 0;i < (int)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;

ll comb[61][61];

int main() {

    ll A, B, K;
    cin >> A >> B >> K;

    comb[0][0] = 1;
    rep(i, 60) {
        rep(j, i + 1) {
            comb[i + 1][j] += comb[i][j];
            comb[i + 1][j + 1] += comb[i][j];
        }
    }

    string ans = "";
    while(A + B > 0) {
        if(A == 0) {
            ans += 'b';
            B--;
            continue;
        }

        ll x = comb[A + B - 1][A - 1];
        if(x < K) {
            K -= x;
            ans += 'b';
            B--;
        } else {
            ans += 'a';
            A--;
        }
    }

    cout << ans << endl;
}

#include <iostream>

using namespace std;

__uint128_t T = 1;
long long MOD = (1LL << 61) - 1;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

void solve(int a, int b, long long k) {
  if (a + b == 1) {
    cout << (a == 1 ? 'a' : 'b') << endl;
    return;
  }
  long long t = T;
  if ((a + b) * k > a * t) {
    cout << 'b';
    T *= b;
    T /= a + b;
    solve(a, b - 1, k - (a * t) / (a + b));
  } else {
    cout << 'a';
    T *= a;
    T /= a + b;
    solve(a - 1, b, k);
  }
}

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

  for (int i = max(A, B) + 1; i <= A + B; i++) {
    T *= i;
    T %= MOD;
  }
  for (int i = 2; i <= min(A, B); i++) {
    T *= modinv(i, MOD);
    T %= MOD;
  }

  solve(A, B, K);
}


    //For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second

    using namespace std;

    // Disjoint Set DataStructure
    int parent[151];         // reserve space for map if n > 10000
    int urank[151];
    int maxi[151],mini[151];

    void create(ll x, ll y)
    {
        parent[x] = x ;
        urank[x] = 1 ;         // rank = no. of nodes in its subtree
        maxi[x]=y;
        mini[x]=y;
    }

    ll find(ll x)
    {
        if( parent[x] != x )    //path compression
        {
            parent[x] = find(parent[x]) ;
        }
        return parent[x];
    }

    void merge(ll x, ll y)
    {
        ll xroot = find(x);
        ll yroot = find(y);
        if(xroot==yroot)
            return;

        if( urank[xroot] <= urank[yroot] )    // Union by rank
        {
            parent[xroot] = yroot ;
            urank[yroot] = urank[yroot] + urank[xroot] ;
            maxi[yroot] = max(maxi[yroot],maxi[xroot]);
            mini[yroot] = min(mini[yroot],mini[xroot]);
        }
        else
        {
            parent[yroot] = xroot;
            urank[xroot] = urank[xroot] + urank[yroot] ;
            maxi[xroot] = max(maxi[yroot],maxi[xroot]);
            mini[xroot] = min(mini[yroot],mini[xroot]);
        }
    }

    int n;
    pii ar[101];

    bool intersect(ll x1,ll y1,ll x2,ll y2,ld r)
    {
        if(4*r*r > (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2))
            return true;
        return false;
    }

    bool func(ld r)
    {
        int i,j,x;
        for(i=1;i<=n;++i)
        {
            create(i,ar[i].s);
        }
        for(i=1;i<=n;++i)
        {
            for(j=i+1;j<=n;++j)
            {
                if(intersect(ar[i].f,ar[i].s,ar[j].f,ar[j].s,r))
                {
                    // cout<<i<<"..."<<j<<" "<<r<<endl;
                    merge(i,j);
                }
            }
        }
        for(i=1;i<=n;++i)
        {
            x=find(i);
            if(maxi[x]+2*r > 100 && mini[x]-2*r < -100)
            {
                // cout<<i<<" "<<x<<" "<<r<<endl;
                return false;
            }
        }
        return true;
    }

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int i,j;
            cin>>n;
            for(i=1;i<=n;++i)
            {
                cin>>ar[i].f>>ar[i].s;
            }
            ld l=0.0,r=200,mid,ans=0.0;;
            for(i=1;i<=100;++i)
            {
                mid=(l+r)/2;
                if(func(mid))
                {
                    ans=mid;
                    l=mid;
                }
                else
                {
                    r=mid;
                }
            }
            printf("%.9Lf\n",ans);
        }
        return 0;
    }

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const double eps = 1e-10;
const double INF = 1e9;

class Union_Find{
  vector<int> par; vector<int> rank; vector<int> num;
public:
  Union_Find(int n) {
    par = vector<int>(n); rank = vector<int>(n,0); num = vector<int>(n,1);
    rep(i,n) par[i] = i;
  }
  int find(int x) {
    if(par[x] == x) return x;
    else  return par[x] = find(par[x]);
  }
  int number(int x) {
    return num[find(x)];
  }
  void unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) swap(x, y);
    if (rank[x] == rank[y]) rank[x]++;
    par[y] = x;
    num[x] += num[y];
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main(){
  int n;
  cin >> n;
  double x[n], y[n];
  rep(i,n) cin >> x[i] >> y[i];
  double l = 0, r = 100.0;
  while(r - l > eps) {
    double m = (l + r) / 2;
    Union_Find uf(n+2);
    rep(i,n) {
      if(y[i]+m > -m+100.0) uf.unite(n,i);
      if(y[i]-m < m-100.0) uf.unite(n+1,i);
    }
    rep(i,n) rep(j,n) if((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]) < 4.0*m*m) uf.unite(i,j);
    if(uf.find(n) == uf.find(n+1)) r = m;
    else l = m;
  }
  printf("%.12lf\n",l);
  return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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;
}
map<pair<ll,ll>,ll> mp;
ll calc(ll a,ll k){
    if(a==0)return 0;
    if(k==0)return a;
    if(mp.find(MP(a,k))!=mp.end())return mp[MP(a,k)];
    ll K = (1LL<<k);
    return mp[MP(a,k)] = min(a/K + calc(a-K*(a/K),k-1), a/K+1 + calc((K)*(a/K + 1)-a,k-1));
}
int main(){
    ll x,y;
    cin >> x >> y;
    ll mi = (1LL<<62);
    for(int i=0;i<=62;i++){
        ll X = x;
        bool ng = 0;
        rep(j,i){
            X *= 2;
            if(X >=4000000000000000000LL){
                ng = 1;
                break;
            }
        }
        if(ng)break;
        ll p = abs(X-y);
        // cerr << i << " " << p << endl;
        ll res = 0;
        res = calc(p,i);
        // for(int j=i;j>=0;j--){
        //     ll K = (1LL<<j);
        //     res += (p/K);

        //     p -= K * (p/K);
        //     ll s = __builtin_popcount(p);
        //     ll q = abs(p-K);
        //     ll t = __builtin_popcount(q);
        //     if(s>t){
        //         p = q;
        //         res++;
        //     }else{

        //     }
        // }
        chmin(mi,res+i);
    }
    cout << mi << endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long x, y;
	cin >> x >> y;
	map<long long, long long> dp;
	auto sol = [&](auto &&self, long long val){
		if(dp[val]) return dp[val];
		if(x >= val){
			return x - val;
		}
		long long rv = val - x;
		if(val % 2){
			rv = min(rv, self(self, (val - 1) / 2) + 2);
			rv = min(rv, self(self, (val + 1) / 2) + 2);
		}
		else{
			rv = min(rv, self(self, val / 2) + 1);
		}
		dp[val] = rv;
		return rv;
	};
	cout << sol(sol, y);
	return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma")
using namespace std;
using ll = long long int;
#define F first
#define S second
#define pb push_back
#define fast_io ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int N=2e5+10,LN=20,SQ=550,M=1e5+10;
const ll INF=1e18;
const int MOD=1000000007 /*998244353*/;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using pll=pair<ll,ll>;
using pii=pair<int,int>;
#define ordered_set tree<pair<pll,ll>, null_type,less<pair<pll,ll>>, rb_tree_tag,tree_order_statistics_node_update>
ll pow(ll x, ll y, ll mod){
    ll ans=1;
    while (y != 0) {
        if (y & 1) ans = ans * x % mod;
        y >>= 1;
        x = x * x % mod;
    }
    return ans;
}
ll n,m;
pll s[N];
int main(){
    fast_io;
    cin >> n >> m;
    if(n==1 && m==0) return cout << 1 << ' ' << 2 << '\n', 0;
    if(m>n-2 || m<0) return cout << -1 << '\n', 0;
    cout << 1 << ' ' << 2*m+4 << '\n';
    for(ll i=1; i<=m+1; i++){
        cout << i*2 << ' ' << i*2+1 << '\n';
    }
    for(ll i=m+2; i<n; i++) cout << 2*i+1 << ' ' << 2*i+2 << '\n';
    return 0;
}

//#include<cstdio>
//#include<cassert>
//#include<iostream>
//#include<cstring>
//#include<algorithm>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((int)1e8 + 5)
#define MAXP ((int)2e5)
#define MAXL ((ll)1e18 + 5)
#define MAX_X ((ll)1e5 + 2)
#define pi acos(-1)
#define M ((int)1e6 + 7)
#define MOD ((int)1e9 + 7)
#define MOD1 ((int)998244353 + 0)
#define BAS ((int)1e6 + 3)
#define BAS1 ((int)2e5 + 3)
#define NN ((int)1e5 + 5)
#define N ((int)2e5 + 5)
#define eps (1e-8)
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL)
#define logn 10
#define endl "\n"
#define mp make_pair
#define BUCK 105
#define LEF (idx<<1)
#define RIG ((idx<<1)|1)
//#define int ll

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;

/*fast io
ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/

typedef tree < int,  null_type,  less < int >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;
typedef tree < pair < int, int >,  null_type,  less < pair < int, int > >,  rb_tree_tag,  tree_order_statistics_node_update > o_setp;
/// o_set s;
/// s.order_of_key(k) : Number of items strictly smaller than k .
/// *(s.find_by_order(k)) : K-th element in a set (counting from zero).

void ses()
{
    cout<<"-1\n";
    exit(0);
}

int main()
{
    fastio;
    int n , m;
    cin>>n>>m;
    if(m < 0 || m == n || (m == n-1 && n > 1) ) ses();
    else if(m == 0){
        for(int i = 1 ; i<=n ; i++) cout<<i+i-1<<" "<<i+i<<endl;
    }
    else{
        int rem = n - m-1 , from = 1 , too = MAX;
        while(rem--){
            cout<<from++<<" "<<too--<<endl;
        }
        rem = m+1;
        while(rem--){
            cout<<from<<" "<<1+from<<endl;
            from += 2;
        }
    }
    return 0;
}


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

using VI = vector<int>;

int g(VI a, int i, int d);

int f(VI const& v) {
    int i = find(cbegin(v), cend(v), 0) - cbegin(v);
    return i < v.size() ? g(v, i, 0) + g(v, i, 1) : 1;
}

int w;

int g(VI v, int i, int d) {
    int j = i + (d ? w : 1);
    if (j >= v.size() || !(d || j % w) || v[j]) {
        return 0;
    }
    v[i] = v[j] = 1;
    return f(v);
}

int main() {
    int h, a, b;
    scanf("%d%d%d%d", &h, &w, &a, &b);
    VI v(2 * a);
    v.insert(end(v), b, 1);
    int r = 0;

    do r += f(v);
    while (next_permutation(begin(v), end(v)));

    printf("%d\n", r);
    return 0;
}

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

int ans0[4] = { 0,0,0,0 };
int ans1[4] = { 1,1,1,1 };
int ans2[4] = { 6,2,4,8 };
int ans3[4] = { 1,3,1,3 };
int ans4[4] = { 6,4,6,4 };
int ans5[4] = { 5,5,5,5 };
int ans6[4] = { 6,6,6,6 };
int ans7[4] = { 1,7,9,3 };
int ans8[4] = { 6,8,4,2 };
int ans9[4] = { 1,9,1,9 };

int main()
{
	ll a, b, c;
	cin >> a >> b >> c;
	int mod = 4;
	//コーナーケース
	if (b % mod == 2)
	{
		if (c == 1) b = 2;
		else b = 0;
	}
	else
	{
		//cが偶数なら2乗、奇数なら1乗（なにもしない）
		if (c % 2 == 0) b *= b;

		b %= mod;
	}
	a %= 10;
	int ans = 0;
	if (a == 0) ans = ans0[b];
	if (a == 1) ans = ans1[b];
	if (a == 2) ans = ans2[b];
	if (a == 3) ans = ans3[b];
	if (a == 4) ans = ans4[b];
	if (a == 5) ans = ans5[b];
	if (a == 6) ans = ans6[b];
	if (a == 7) ans = ans7[b];
	if (a == 8) ans = ans8[b];
	if (a == 9) ans = ans9[b];

	cout << ans << endl;
}


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

// input
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); // __VA_ARGS__可変引数マクロ
template<typename T> void MACRO_VAR_Scan(T& t) { std::cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest& ...rest) { std::cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define MAT(type, c, m, n) std::vector<std::vector<type>> c(m, std::vector<type>(n));for(auto& R:c)for(auto& w:R)std::cin>>w;
// output
template<typename T>void MACRO_OUT(const T t) { std::cout << t; }
template<typename First, typename...Rest>void MACRO_OUT(const First first, const Rest...rest) { std::cout << first << " "; MACRO_OUT(rest...); }
#define OUT(...) MACRO_OUT(__VA_ARGS__);
#define FOUT(n, dist) std::cout<<std::fixed<<std::setprecision(n)<<(dist); // std::fixed 浮動小数点の書式 / setprecision 浮動小数点数を出力する精度を設定する。
#define SP std::cout<<" ";
#define TAB std::cout<<"\t";
#define BR std::cout<<"\n";
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define ENDL std::cout<<std::endl;
#define FLUSH std::cout<<std::flush;
// utility
#define ALL(a) (a).begin(),(a).end()
#define FOR(w, a, n) for(int w=(a);w<(n);++w)
#define REP(w, n) for(int w=0;w<int(n);++w)
#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T& a, const T b) { return a = (a > b) ? b : a; }
template<class T> using V = std::vector<T>;
template<class T> using VV = V<V<T>>;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using PAIR = std::pair<int, int>;
using PAIRLL = std::pair<ll, ll>;
constexpr int INFINT = (1 << 30) - 1;                    // 1.07x10^ 9
constexpr int INFINT_LIM = (1LL << 31) - 1;              // 2.15x10^ 9
constexpr ll INFLL = 1LL << 60;                          // 1.15x10^18
constexpr ll INFLL_LIM = (1LL << 62) - 1 + (1LL << 62);  // 9.22x10^18
constexpr double eps = 1e-7;
constexpr int MOD = 1000000007;
constexpr double PI = 3.141592653589793238462643383279;
template<class T, size_t N> void FILL(T(&a)[N], const T & val) { for (auto& x : a) x = val; }   //  int a[5] = {1,2,3,4,5};	FILL(a,10);
template<class ARY, size_t N, size_t M, class T> void FILL(ARY(&a)[N][M], const T & val) { for (auto& b : a) FILL(b, val); }  // ２次元配列でもそのまま使える
template<class T> void FILL(std::vector<T> & a, const T & val) { for (auto& x : a) x = val; }   //	使い方 vector<int> a(3);	FILL(a,10);
template<class ARY, class T> void FILL(std::vector<std::vector<ARY>> & a, const T & val) { for (auto& b : a) FILL(b, val); }  // ２次元配列でもそのまま使える
// ------------>8------------------------------------->8------------

int main() {
INIT;

VAR(ll,n)
V<PAIRLL> p(n);
ll a,b;
__int128_t a_sum =0;
REP(i,n){
    cin >> a >> b;
    p[i] = {2*a+b,b};
    a_sum += a;
}

sort(p.rbegin(),p.rend());

ll i =0;
__int128_t t_sum =0;
while(1){
    t_sum += (p[i].first - p[i].second) /2 + p[i].second ;
    a_sum -= (p[i].first - p[i].second) /2 ;
    i++;
    if(t_sum > a_sum)
        break;
}
OUT(i)

return 0;
}

#define ll long long
#define dd long double
#define pb push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define fo(i ,a, n) for(ll i =a ; i < n ; i++)
//#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)//traverse through a dataset
//#define sortx(x) sort(all(x))
#define maxpq priority_queue<ll>
#define minpq priority_queue<ll,vector<ll>,greater<ll>>
#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<bitset>
ll fact[200001] ;
ll inf=1e18;
ll z=1e9+7;
ll gdp(ll a , ll b){return (a - (a%b)) ;}
ll ld(ll a , ll b){if(a < 0) return -1*gdp(abs(a) , b) ; if(a%b == 0) return a ; return (a + (b - a%b)) ;} // least number >=a divisible by b
ll gd(ll a , ll b){if(a < 0) return(-1 * ld(abs(a) , b)) ;    return (a - (a%b)) ;} // greatest number <= a divisible by b
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll e_gcd(ll a , ll b , ll &x , ll &y){ if(b > a) return e_gcd(b , a , y , x) ; if(b == 0){x = 1 ; y = 0 ; return a ;}
ll x1 , y1 ; e_gcd(b , a%b , x1 , y1) ; x = y1 ; y = (x1 - ((a/b) * y1)) ; return e_gcd(b , a%b , x1 , y1) ;}
ll power(ll a ,ll b , ll p){if(b == 0) return 1 ; ll c = power(a , b/2 , p) ; if(b%2 == 0) return ((c*c)%p) ; else return ((((c*c)%p)*a)%p) ;}
ll inverse(ll a ,ll n){return power(a , n-2 , n) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
ll min(ll a , ll b){if(a < b) return a ; return b ;}
ll left(ll i){return ((2*i)+1) ;}
ll right(ll i){return ((2*i) + 2) ;}
ll ncr(ll n , ll r){if(n < r|| (n < 0) || (r < 0)) return 0 ; return ((((fact[n] * inverse(fact[r] , z)) % z) * inverse(fact[n-r] , z)) % z);}
void swap(ll&a , ll&b){ll c = a ; a = b ; b = c ; return ;}
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define ub(v,x) upper_bound(v.begin(),v.end(),x);
#define lb(v,x) lower_bound(v.begin(),v.end(),x);
dd pi = acos(-1) ;
ll pow(ll a ,ll b ){if(b == 0) return 1 ; ll c = pow(a , b/2) ; if(b%2 == 0) return (c*c) ; else return ((c*c)*a);}

using namespace std ;
const int N = 2e5+7;
const int M=1e6+7;
//vector<ll>adj[N];
//int mat[N][N];
//vector<bool>used(N,false);
//vector<ll>d(N,-1);
//vector<ll>p(N,-1);

bool cmp(ll a,ll b){
   return a>b;
}

struct S
{
    int m_n1;
    int m_n2;
    int m_n3;

    S(int n1, int n2, int n3) : m_n1(n1), m_n2(n2), m_n3(n3)
    {
    }

    bool operator<(const struct S& other) const
    {
        if(m_n1!=other.m_n1)
        return m_n1 < other.m_n1;
        else
        return m_n2 > other.m_n2;
    }
};

void solve(){
  ll n;
  cin>>n;
  ll votes[n][2];
  ll s[2]={0};
  vector<pair<ll,pair<ll,ll>>>v;
  fo(i,0,n){
    ll x,y;
    cin>>x>>y;
    votes[i][0]=x;
    votes[i][1]=y;
    s[1]+=x;
    v.pb({y+2*x,{x,y}});
  }
ll cnt=0;
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
 fo(i,0,n){
    if(s[0]>s[1]){
       break;
    }
    else{
      s[0]+=(v[i].S.F+v[i].S.S);
      s[1]-=v[i].S.F;

      cnt++;
    }
 }

 cout<<cnt<<endl;
}

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

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


#include <map>
#include <stack>
#include <stdio.h>
#include <stdlib.h>

#define ll long long
#define DEBUG pritnf("Passing [%s] in Line %d\n" , __FUNCTION__ , __LINE__) ;

const int MAX_N = 2e5 + 10 ;

std::map<int , int> bh ;
std::stack<int> st[MAX_N] ;

int n , tot , b[MAX_N] , BIT[MAX_N] ;

inline int lowbit(int x) {return x & (-x) ;}

int getsum(int x) {
	if (!x) return 0 ;

	int s = 0 ;
	for (; x ; x -= lowbit(x)) s += BIT[x] ;

	return s ;
}

void add(int x) {
	if (!x) return ;

	for (; x <= n ; x += lowbit(x)) ++BIT[x] ;
}

int main() {
	scanf("%d" , &n) ;
	for (int i = 1 ; i <= n ; ++i) {
		int a , p ;
		scanf("%d" , &a) ; a += i ;

		if (!bh.count(a)) bh[a] = ++tot ;
		p = bh[a] ; st[p].push(i) ;
	}
	for (int i = 1 ; i <= n ; ++i) scanf("%d" , &b[i]) ;

	///

	ll ans = 0 ;
	for (int i = n ; i ; --i) {
		int ned = b[i] + i , p = bh.count(ned) ? bh[ned] : 0 ;
		if (st[p].empty()) {ans = -1 ; break ;}

		int nw = st[p].top() ; st[p].pop() ;
		add(nw + 1) ; nw -= getsum(nw) ; ans += i - nw ;
	}

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

	return 0 ;
}

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,tune=native")
#include<bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define pb push_back
#define X first
#define Y second
#define mp make_pair

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

const int N = (int)1e5 + 5;

int A[N], B[N];
int n;

void solve(){
    cin >> n;
    ll sum = 0;
    for(int i = 0; i < n; i++){
        cin >> A[i];
        sum += A[i];
    }
    for(int i = 0; i < n; i++)
        cin >> B[i];
    vector<int> d1, d2;
    for(int i = 0; i < n; i++)
        if(i&1)d2.pb(B[i] - A[i]);
        else d1.pb(B[i] - A[i]);
    sort(all(d1));
    sort(all(d2));
    ll ans = sum;
    for(int pos = n/2-1; pos >= 0; pos--){
        sum += d1[pos] + d2[pos];
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

signed main(){
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    while(T--)
        solve();
    return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> vs;
    for(int i = 0; i < h; i++){
        string s;
        cin >> s;
        vs.push_back(s);
    }
    /*
        i,j   i+1,j
        i,j+1 i+1,j+1
    */
    int res = 0;
    for(int i = 0; i < h - 1; i++){
        for(int j = 0; j < w - 1; j++){
            int sharp = 0;
            if(vs[i][j] == '#') ++sharp;
            if(vs[i + 1][j] == '#') ++sharp;
            if(vs[i][j + 1] == '#') ++sharp;
            if(vs[i+1][j+1] == '#') ++sharp;
            if(sharp == 1 || sharp == 3) ++res;
        }
    }
    cout << res;
}

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

string S;

int main(){
  cin>>S;
  reverse(S.begin(),S.end());
  int right_block=0;
  char right_c='$';
  LL ans=0;
  stack<char> buf;
  for(char c:S){
    if(buf.size()!=0) if(buf.top()==c){
      int tmp=2; buf.pop();
      while(buf.size()!=0){ if(buf.top()!=c){ ans++; } tmp++; buf.pop(); }
      if(c!=right_c) ans+=right_block;
      right_c=c;
      right_block+=tmp;
      continue;
    }
    buf.push(c);
  }
  cout<<ans<<endl;
  return 0;
}