    #include <bits/stdc++.h>

    using namespace std;

     #define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
    #define   ipr         	pair<int, int>
    #define   pb            push_back
    #define   ff            first
    #define   ss            second
   // #define fill(a,b) memset(a, b, sizeof(a))
    #define   fr(i, j, k)   for (int i = j; i < k; i++)
    #define   rf(i, j, k)   for (int i = j; i >= k;i--)
    #define   int           long long int
    #define   ll 			unsigned long long
    #define   ld            long double
    #define   all(x)        x.begin(), x.end()
    #define   rall(x)       x.rbegin(),x.rend()
    #define   mp            make_pair
    #define L(x) ('a'<=x && x<='z')
    #define   inf           INT_MAX
    #define   read_file();	freopen("input.txt", "r", stdin);	freopen("output.txt", "w", stdout);
    #define   IOS           std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    const ld  pi   =  acos(-1);
    const int mod =  1000000007;
    const double epsilon = 1e-9;

    template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<" ";return out;}
    template<class T> ostream& operator <<(ostream &out,set<T> &A){for(auto x:A) out<<x<<" ";return out;}
    template<class T> ostream& operator <<(ostream &out,unordered_set<T> &A){for(auto x:A) out<<x<<" ";return out;}
    template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}

    int binpow(int a,int b) {
        a=a%mod;

        int res = 1;
    while (b > 0) {
            if (b & 1)res = (res * a)%mod;
            a = (a * a)%mod;
            b >>= 1;
    }
    return (res+mod)%mod;
    }

        const int  N = 10000025 ;
    int prime[N];
    int prime_cnt[N];

    void SieveOfEratosthenes()
    {
        fr(i,0,N)prime[i]=i;

        prime[0]=0;
        prime[1]=1;

        for (int p=2; p*p<=10000000; p++)
        {

            if (prime[p] == p)
            {
                for (int i=p; i<=10000000; i += p)
                   if(prime[i]==i) prime[i] = p;
            }
        }

    }

  int32_t main(){
        IOS;
      int t;
     // cin>>t;
      t=1;

     while(t--){

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

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

#define ll long long
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

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

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int A, B;
	cin >> A >> B;
	cout << (A + B) / 2 << " " << (A - B) / 2 << endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define dd long double
#define all(x) x.begin(),x.end()
template<ll MOD = 998244353>
struct mint{
    ll x;
    ll mod = MOD;
    mint(ll x=0):x(x%MOD){}
    mint& operator+=(const mint a){
        if((x+=a.x)>=MOD) x-=MOD;
        return *this;
    }
    mint& operator-=(const mint a){
        if((x += MOD-a.x)>=MOD) x-=MOD;
        return *this;
    }
    mint& operator*=(const mint a){
        (x*=a.x)%=MOD;
        return *this;
    }
    mint operator+(const mint a) const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const{
        mint res(*this);
        return res*=a;
    }
    mint power(ll t) const{
        if(!t) return 1;
        mint a = power(t>>1);
        a*=a;
        if(t&1) a*=*this;
        return a;
    }

    mint inv() const{
        return power(MOD-2);
    }
    mint& operator/=(const mint a){
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const{
        mint res(*this);
        return res/=a;
    }
};
template<ll mod>
ostream & operator << (ostream & output,const mint<mod> & a){
        output<<a.x;
        return output;
}
template<ll mod>
istream & operator >> (istream & input, mint<mod>& a){
        input>>a.x;
        return input;
}

using mll=mint<>;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v){
    os << "[";
    for (ll i=0; i < v.size(); ++i) {
        os << v[i];
        if (i != v.size() - 1)
            os << ", ";
    }
    os << "]";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v){
    os << "{";
    for (auto it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}";
    return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v){
    os<<"{";
    for (auto it : v){
        os << it.first << " : "
           << it.second ;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}";
    return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v){
    os << "(";
    os << v.first << ", "
       << v.second << ")";
    return os;
}
const ll N=4e5+10;
mll fact[N+1];
mll ifact[N+1];

void init(){
    fact[0]=fact[1]=1;
    FOR(i,2,N+1){
        fact[i]=fact[i-1]*i;
    }
    ifact[0]=1;
    ifact[1]=1;
    ifact[1]/=1;
    FOR(i,2,N+1){
        ifact[i]=1;
        ifact[i]/=i;
        ifact[i]*=ifact[i-1];
    }
}

mll pnc(ll n, ll r){
    mll a=fact[n];
    a*=ifact[r];
    a*=ifact[n-r];
    return a;
}

ll spf[N];

void spfe(){
    for(ll i=1;i<=N;i++){
        spf[i]=i;
    }
    for(ll i=4;i<=N;i+=2){
        spf[i]=2;
    }
    for(ll i=2;i*i<=N;i++){
        if(spf[i]==i){
            for(ll j=i*i;j<=N;j+=i){
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    init();
    spfe();
    ll n,m;
    cin>>n>>m;
    vector<ll> dp(N);
    for(ll i=1;i<N;i++){
        for(ll j=2*i;j<N;j+=i){
            dp[j]++;
        }
    }
    mll ans=0;
    for(ll i=1;i<=m;i++){
        ll nn=i;
        vector<ll> prods;
        while(nn!=1){
            ll x=spf[nn];
            ll temp=1;
            while(nn%x==0){
                nn/=x;
                temp*=x;
            }
            prods.pb(temp);
        }
        mll tempo=1;
        for(auto & x:prods){
            tempo*=pnc(dp[x]+n-1,n-1);
        }
        ans+=tempo;
    }
    cout<<ans<<endl;

}

#include <bits/stdc++.h>

using namespace std;

#define ll int64_t

const int mod = 998244353;
int inc(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }

vector<int> mult(vector<int> &a, vector<int> &b)
{
    vector<int> tmp(a.size());
    for (int i = 1; i < a.size(); i++)
    {
        for (int j = i; j < a.size(); j += i)
        {
            tmp[j] = inc(tmp[j], 1ll * a[i] * b[j / i] % mod);
        }
    }
    return tmp;
}
vector<int> qpow(vector<int> a, int x)
{
    vector<int> res(a.size());
    res[1] = 1;
    while (x)
    {
        if (x & 1)
            res = mult(res, a);
        a = mult(a, a);
        x >>= 1;
    }
    return res;
}
void solve()
{
    int n, m;
    cin >> n >> m;
    vector<int> dp(m + 1, 1);

    dp = qpow(dp, n);
    int ans = 0;
    for (int i = 1; i <= m; i++)
        ans = inc(ans, dp[i]);
    cout << ans << endl;
}

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

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


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

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const int INF = 1e9;
const double PI = acos(-1);
const int mod = 1000000007;

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

    int ans = 0;
    rep(i, h) {
        rep(j, w - 1) {
            if (s[i][j] == '.' && s[i][j + 1] == '.') {
                ans++;
            }
        }
    }
    rep(i, w) {
        rep(j, h - 1) {
            if (s[j][i] == '.' && s[j + 1][i] == '.') {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

//#define ll long long

int main() {
    ios::sync_with_stdio(false);

    int h, w, x, y;
    cin >> h >> w >> x >> y;
    x--; y--;

    vector<string> vec(h);

    int cnt = 0;
    for (int i = 0; i < h; i++) {
        cin >> vec[i];
    }

    for (int i = x - 1; i >= 0; i--) {
        if (vec[i][y] == '.') {
            cnt++;
        }else break;
    }

    for (int i = x; i < h; i++) {
        if (vec[i][y] == '.') {
            cnt++;
        }else break;
    }

    for (int i = y - 1; i >= 0; i--) {
        if (vec[x][i] == '.') {
            cnt++;
        }else break;
    }

    for (int i = y + 1; i < w; i++) {
        if (vec[x][i] == '.') {
            cnt++;
        }else break;
    }

    cout << cnt << endl;

    return 0;
}


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

int main() {
  string x;
  char a='.';
  cin>>x;
  int count =x.size();
  for(int i=0;i<count;i++){
    if(x.at(i)==a){
      break;
    }
    else{
    cout<<x.at(i);
    }

  }

}

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

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

  long long n;
  cin >> n;

  int d = to_string(n).length();
  long long ans = 0, mul = 1;
  for (int i = 1; i <= d - 1; i++) {
    ans += (i - 1) / 3 * 9 * mul;
    mul *= 10;
  }
  ans += (d - 1) / 3 * (n - mul + 1);

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


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,int>Q;
int main(){
	ll n;
	cin>>n;
	for(ll i=1,j=3;;i++){
		Q[j]=i;
		if(1e18/3<j)break;
		j*=3;
	}
	for(ll i=1,j=5;;i++,j*=5){
		if(j>n)break;
		ll k=n-j;
		if(Q[k]!=0){
			printf("%d %lld\n",Q[k],i);
			return 0;
		}
		if(1e18/5<j)break;
	}
	puts("-1");
	return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <unordered_map>
#include <cstdio>
#include <climits>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

ll n;

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> n;
	for (int i = 1; i <= 37; i++)for (int j = 1; j <= 25; j++) {
		ll p = 1, q = 1;
		for (int k = 0; k < i; k++)p *= 3;
		for (int k = 0; k < j; k++)q *= 5;
		if (p + q == n) {
			cout << i << " " << j << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}


#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define mod 1000000007
#define inf 1e18
#define N 1000043
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define loop(a,b) for(int i=a;i<b;i++)
#define test int t; cin >> t; while(t--)
#define pll pair<ll,ll>
#define int ll
using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string a;
    cin >> a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.length();i++){
        if(a[i]=='9')   a[i]='6';
        else if(a[i]=='6')   a[i]='9';
    }
    cout << a << endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ull maxprim = 1e9 + 7;
ull gcd (ull a, ull b) {
    return b ? gcd (b, a % b) : a;
}
int main()
{    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll tst,n,i,j,ite=0,flg,m,lim,k,l,r,q,res,i1,j1,x;
    tst=1;//cin>>tst;
    while(tst--){
      string str;
      cin>>str;
      for(i = str.length() - 1;i>=0;i--){
        if(str[i]=='6')cout<<'9';
        else if(str[i]=='9')cout<<'6';
        else cout<<str[i];
      }
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

const long long MOD = 1000000007;

int main(){
  int n,a;
  int x=0;
  cin >> n;
  vector<bool> c(200001,true);

  rep(i,n){
    cin >> a;
    c.at(a)=false;
    while(!c.at(x)) x++;
    cout << x << endl;
  }

}

#include<iostream>
using namespace std;

int main()
{
    int64_t n;
    cin >> n;
    if(n % 2 == 0)
        cout << "White" << endl;
    else
        cout << "Black" << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#define mp make_pair
#define pb push_back
#define fp first
#define sp second
typedef long long int ll;
typedef pair<ll,ll> pp;
#define check(x, i) ((x>>i)&1LL)
#define set(x,i) (x|(1LL<<i))
#define unset(x,i) (x&~(1LL<<i))
#define INF LONG_MAX
#define MAX_N 20
#define MAX 200005
#define mod 1000000007
#define REP(i,n) for(i=0;i<n;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define len(i,s) for(i=0;s[i];i++)
#define T() ll t;cin>>t;while(t--)
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
ll gcd (ll a, ll b){return (a?gcd(b%a,a):b);}
ll pow1(ll a,ll b,ll MOD){ll ans=1;while(b!=0){if(b&1)ans=(ans*a)%MOD;a=(a*a)%MOD;b=b/2;}return ans;}
ll modInverse(ll a,ll p){return pow1(a,p-2,p);}
void ash(){
	boost
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

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

    ll p=1<<n;
    ll i;
     vector<pair<ll,ll>> m(p);
    REP(i,p)
    {
        ll x;
        cin>>x;
        m[i]={x,i+1};
    }
    vector<pair<ll,ll>> m1;
    while(p!=2)
    {
    for(i=0;i<p;i+=2)
    {
       // cout<<m[i].fp<<"a"<<m[i].sp<<" "<<m[i+1].fp<<"a"<<m[i+1].sp<<"\n";
     if(m[i].fp>m[i+1].fp)
    m1.pb({m[i].fp,m[i].sp});
    else
    m1.pb({m[i+1].fp,m[i+1].sp});
    }
    //cout<<"\n";
    m.clear();
    m=m1;
    m1.clear();
    p/=2;
}
if(m[0].fp<m[1].fp)
    cout<<m[0].sp;
else
    cout<<m[1].sp;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>  using oset =
    tree<T, null_type, less<T>,
    rb_tree_tag, tree_order_statistics_node_update>;
#define odrkey order_of_key
#define fbodr find_by_order
#define ll long long
#define sq(a) ((a)*(a))
#define ull unsigned long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pi 3.1415926536
#define nwl cout <<"\n";
#define MAXN 100009
#define ff first
#define ss second
#define pb push_back
#define pf push_front
ll Pow(ll a, ll b) {
	if (a == 0) return 0LL;
	ll ans = 1;
	for (int i = 0; i < b; i++) {
		ans *= a;
	}
	return ans;
}
ll lcm(ll a, ll b) {
	return (a * b) / __gcd(a, b);
}
ll md = (ll) 1e9 + 7;
ll bigmod(ll a, ll b, ll m) {
	if (b == 0) return 1LL;
	ll tm = bigmod(a, b / 2, m);
	tm = (tm * tm) % m;
	if (b % 2) tm = (tm * a) % m;
	return tm;
}
ll ncr(ll n, ll r) {
	if (r > n - r) r = n - r;
	ll up = 1;
	ll down = 1;
	for (ll i = 0; i < r; i++) {
		up = (up * (n - i)) % md; /* md== mod */
		down = (down * (r - i)) % md;
	}
	return (up * bigmod(down, md - 2, md)) % md;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n ;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		if (x > 10) {
			x -= 10;
			ans += x;
		}
	}
	cout << ans << endl;
}


#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=2000000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 1000000007
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

namespace My_Math{
    #define N 2000000

    int fac[N+100],invfac[N+100];

    int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
    int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
    int mul(int x,int y) {return 1ll*x*y%maxd;}
    ll qpow(ll x,int y)
    {
        ll ans=1;
        while (y)
        {
            if (y&1) ans=mul(ans,x);
            x=mul(x,x);y>>=1;
        }
        return ans;
    }
    int getinv(int x) {return qpow(x,maxd-2);}

    int C(int n,int m)
    {
        if ((n<m) || (n<0) || (m<0)) return 0;
        return mul(mul(fac[n],invfac[m]),invfac[n-m]);
    }

    void math_init()
    {
        fac[0]=invfac[0]=1;
        rep(i,1,N) fac[i]=mul(fac[i-1],i);
        invfac[N]=getinv(fac[N]);
        per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
    }
    #undef N
}
using namespace My_Math;

int main()
{
    int n=read(),m=read(),k=read();
    if (n>m+k) {puts("0");return 0;}
    math_init();
    int ans=dec(C(n+m,m),C(n+m,m+k+1));
    printf("%d",ans);
    return 0;
}

// Problem: E - White and Black Balls
// Contest: AtCoder - AtCoder Beginner Contest 205
// URL: https://atcoder.jp/contests/abc205/tasks/abc205_e
// Memory Limit: 1024 MB
// Time Limit: 2000 ms

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

typedef long long ll;
const int MOD = 1e9 + 7;

// C(n + m, n) - C(n + m, n - k - 1)
// (m, n) -> (n - k - 1, m + k + 1), y = x + k + 1
ll x, y;
void ex_gcd(ll a, ll b) {
	if (b == 0) {
		x = 1, y = 0;
		return;
	}
	ex_gcd(b, a % b);
	ll t = x;
	x = y;
	y = t - a / b * y;
	return;
}
ll inv(int p) {
	ex_gcd(p, MOD);
	return (x % MOD + MOD) % MOD;
}
ll C(int n, int m) {
	if (m < 0) return 0;
	ll res = 1;
	for (int i = 1; i <= m; ++i) {
		res = res * (n - i + 1) % MOD;
		res = res * inv(i) % MOD;
	}
	return res;
}
int main() {
	int n, m, k;
	cin >> n >> m >> k;
	if (n > m + k) {
		cout << 0;
		return 0;
	}
	ll p = C(n + m, n), q = C(n + m, n - k - 1);
	cout << (p - q + MOD) % MOD;
	return 0;
}


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

template <typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag,
tree_order_statistics_node_update>;
template <typename T>
using omultiset = tree<T, null_type, less_equal<T>, rb_tree_tag,
tree_order_statistics_node_update>;

#define ll long long
#define pb push_back
#define mp make_pair
#define umap unordered_map
#define fr(i,a,b) for(int i=a;i<b;i++)
const int mx=1e7+5;
const int mod=1e9+7;
#define deb(x) cout<<x<<endl;
#define debl(x) cout<<x<<" ";
#define spair(p) cout<<"("<<p.first<<","<<p.second<<")"<<endl;
int gcdExtended(int a, int b, int* x, int* y)
{
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    int x1, y1; // To store results of recursive call
    int gcd = gcdExtended(b % a, a, &x1, &y1);
    *x = y1 - (b / a) * x1;
    *y = x1;

    return gcd;
}

ll modInverse(ll a, ll m)
{
    int x, y;
    int g = gcdExtended(a, m, &x, &y);
    if (g != 1)
        return 0;
    else
    {
        // m is added to handle negative x
        ll res = (x % m + m) % m;
        return res;
    }
}

ll nCr(int n, int r,int m){
    if(r>n){
        return 0;
    }
    if(r>n-r){
        r = n-r;
    }
    ll ans = 1;
    for(int i = 1; i<=r ; i++){
        ans *= (n-i+1);
        ans%= m;
        ans *= modInverse(i, m);
        ans %= m;
    }
    return ans;
}
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
long long binpow(long long a, long long b, long long m)
{
    a %= m;
    long long res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
template<typename u,typename v>
auto min(u a,v b)
{
    return a>b ? b:a;
}
template<typename u,typename v>
auto max(u a,v b)
{
    return a<b?b:a;
}

void solve()
{

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int val;
    set<int> a,b;
    for(int i=0;i<n;i++)
    {
        cin>>val;
        a.insert(val);
    }
    for(int i=0;i<n;i++)
    {
        cin>>val;
        b.insert(val);
    }
    int max=*(b.begin());
    int min=*a.rbegin();
    if(min > max)
    {
        deb(0);
        return 0;
    }
    deb(max - min + 1);
}

/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vvb= vector<vb>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

/* We need to find foreach bulb the leftnearsest and rightnearest blocks.
 * But what about overcount?
 *
 * We count to N and W up to next bulb or block.
 * We count to S and E only if the next block is more near than the next bulb.
 *
 * fu.. This does not work, consider horizontal illuminated fields
 * and vertical ones. They intersect!
 *
 * Can we maintain segment trees and do range updates?
 *
 * -> Consider all four direction separate.
 */
void solve() {
    cini(h);
    cini(w);
    cini(n);
    cini(m);

    vvb bu(h, vb(w));
    vvb bl(h, vb(w));
    for(int i=0; i<n; i++)  {
        cini(r); r--;
        cini(c); c--;
        bu[r][c]=true;
    }
    for(int i=0; i<m; i++)  {
        cini(r); r--;
        cini(c); c--;
        bl[r][c]=true;
    }

    vvb ans(h, vb(w));
        /* dir E */
    for(int i=0; i<h; i++) {
        int on=false;
        for(int j=0; j<w; j++) {
            if(bu[i][j])
                on=true;
            else if(bl[i][j])
                on=false;

            if(on)
                ans[i][j]=true;
        }
    }
        /* dir W */
    for(int i=0; i<h; i++) {
        int on=false;
        for(int j=w-1; j>=0; j--) {
            if(bu[i][j])
                on=true;
            else if(bl[i][j])
                on=false;

            if(on)
                ans[i][j]=true;
        }
    }

        /* dir S */
    for(int j=0; j<w; j++) {
        int on=false;
        for(int i=0; i<h; i++) {
            if(bu[i][j])
                on=true;
            else if(bl[i][j])
                on=false;

            if(on)
                ans[i][j]=true;
        }
    }

        /* dir N */
    for(int j=0; j<w; j++) {
        int on=false;
        for(int i=h-1; i>=0; i--) {
            if(bu[i][j])
                on=true;
            else if(bl[i][j])
                on=false;

            if(on)
                ans[i][j]=true;
        }
    }

    int ansv=0;
    for(int i=0; i<h; i++)
        for(int j=0; j<w; j++)  {
            if(ans[i][j])
                ansv++;
        }

    cout<<ansv<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;}
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    int a,b;
    cin >> a >> b;
    int aa=0,bb=0;
    while(a){
        aa+=a%10;
        a/=10;
    }
    while(b){
        bb+=b%10;
        b/=10;
    }
    if(aa<bb) aa=bb;

    cout << aa << endl;

    return 0;
}

#include <iostream>
#include <vector>

int main() {
    int N, M;
    std::cin >> N >> M;
    std::vector<std::pair<int, int>> conditions(M);
    for (auto& [A, B] : conditions) {
        std::cin >> A >> B;
        A--;
        B--;
    }
    int K;
    std::cin >> K;
    std::vector<std::pair<int, int>> choices(K);
    for (auto& [C, D] : choices) {
        std::cin >> C >> D;
        C--;
        D--;
    }

    int ans = 0;
    for (int i = 0; i < 1 << K; i++) {
        std::vector<bool> dishes(N);
        for (int j = 0; j < K; j++) {
            const auto& [C, D] = choices[j];
            if (i & (1 << j)) {
                dishes[C] = 1;
            }
            else {
                dishes[D] = 1;
            }
        }
        int cnt = 0;
        for (auto& [A, B] : conditions)
            if (dishes[A] && dishes[B]) cnt++;

        if (ans < cnt) ans = cnt;
    }
    std::cout << ans << std::endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ll long long

int main(){
	ll n;
	cin >> n;
	ll ans = 0;
	for(ll i=0;i<n;i++){
		ll a;
		cin >> a;
		if(a > 10){
			ans += a-10;
		}
	}
	cout << ans << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T1, class T2> inline bool chmax(T1 &a, const T2 &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T1, class T2> inline bool chmin(T1 &a, const T2 &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);cerr<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T> void verr(const set<T> &st) { repa(a, st) cerr << a << " "; cerr << endl; }
template <class S, class T> void verr(const map<S, T> &mp) { repa(a, mp) cerr << "{" << a.first << ", " << a.second << "} "; cerr << endl; }
template <class S, class T, class N> void verr(const vector<pair<S,T>>& a, const N& n) { rep(i, n) cerr << "{" << a[i].first << ", " << a[i].second << "} "; cerr << endl; }
template <class T, class N> void verr(const vector<T>& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << endl; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << endl; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

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

    ll ans = 0;
    rep(i, N) ans += max(0ll, A[i] - 10);
    cout << ans << endl;
}


#include <iostream>
#include <cstdio>

using namespace std;
using ll = long long;

int main() {
    ll n, m; cin >> n >> m;
    ll array[n], cnt[n] = {0}, ans = n;
    for (ll i = 0; i < n; i++) {
        cin >> array[i];
    }
    for (ll i = 0; i < m; i++) {
        cnt[array[i]]++;
    }
    for (ll i = 0; i < n; i++) {
        if (cnt[i] == 0) {
            ans = i;
            break;
        }
    }
    for (ll i = m; i < n; i++) {
        ll a = array[i];
        ll b = array[i-m];
        cnt[a]++;
        cnt[b]--;
        if (b < ans && cnt[b] == 0) {
            ans = b;
        }
    }
    cout << ans << endl;
    return 0;
}

/*
ID: Trump
TASK:
LANG: C++
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include <iostream>
#include <fstream>
#include <cstring>
#include <algorithm>
#include <cmath>
#define sll(n) scanf("%lld",&n);
#define sll2(a,b) scanf("%lld",&n);
#define sll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c);
#define slb(n) scanf("%Lf",&n);
#define pll(n) printf("%lld",n);
#define pln printf("\n");
#define plb(n) printf("%Lf",n);
#define plb2(n) printf("%.2Lf",n);
#define plb3(n) printf("%.3Lf",n);
#define plb4(n) printf("%.4Lf",n);
#define plb5(n) printf("%.5Lf",n);
#define plb6(n) printf("%.6Lf",n);
using namespace std;
typedef long long ll;
typedef long double lb;
typedef double db;
typedef int it;
typedef bool bl;
//#define MARK
const ll losn=1e6+5;
const ll maxn=1e5+5;
const ll minn=1e3+5;
const ll tiny=1e2+5;
const ll inf=1e9;
const ll binf=1e18;
const ll mod=1e9+7;
const ll lmod=998244353;
const ll hashmod=4698571;
const lb pi=3.1415926;
const ll myn=0;
void gk(){cout<<"---------------"<<endl;}
void ck(){cout<<1<<endl;}
void ck(ll a){cout<<a<<endl;}
void ck(ll a[minn][minn],ll n,ll m){for(ll i=1;i<=n;i++){for(ll j=1;j<=m;j++){cout<<a[i][j]<<" ";}cout<<endl;}}
ll n,m,k,T,u,v,len;

ll arr[losn*2];
struct node{
	ll s,nums,as;
};
node tree[losn*2<<4];

void pushup(ll rt){
	if(tree[rt<<1].s<tree[rt<<1|1].s){
		tree[rt]=tree[rt<<1];
	}else{
		tree[rt]=tree[rt<<1|1];
	}
}

void build(ll l,ll r,ll rt){
	ll mid=(l+r)>>1;
	if(l==r){
		tree[rt].s=l;
		tree[rt].nums=0;
		tree[rt].as=0;
		return;
	}
	if(l<r){
		build(l,mid,rt<<1);
		build(mid+1,r,rt<<1|1);
	}
	pushup(rt);
}

void update(ll x,ll c,ll l,ll r,ll rt){
	ll mid=(l+r)>>1;
	if(l==r){
		tree[rt].nums+=c;
		if(tree[rt].nums==0){
			tree[rt].s=l;
		}else{
			tree[rt].s=binf;
		}
		return ;
	}
	if(x<=mid){
		update(x,c,l,mid,rt<<1);
	}
	if(x>mid){
		update(x,c,mid+1,r,rt<<1|1);
	}
	pushup(rt);
}

int main(){
//#ifdef MARK
//    freopen("input.in", "r", stdin);
//    freopen("ouput.out", "w", stdout);
//    freopen("ouput.out", "r", stdin);
//    freopen("input.in", "w", stdout);
//#endif
	cin>>n>>m;
	for(ll i=1;i<=n;i++){
		cin>>arr[i];
		arr[i]+=1;
	}
	build(1,m,1);
	for(ll i=1;i<=m;i++){
		if(arr[i]>=m+1){

		}else{
			update(arr[i],1,1,m,1);
		}
	}
	ll l=1,r=m;
	ll ans=binf;
	while(r<=n){
		node q=tree[1];
//		cout<<q.s<<endl;
		if(q.s==binf){
			ans=min(ans,m);
		}else{
			ans=min(ans,q.s-1);
		}
		r++;
		if(arr[r]<=m){
			update(arr[r],1,1,m,1);
		}
		if(arr[l]<=m){
			update(arr[l],-1,1,m,1);
		}
		l++;
		if(r==n+1){
			break;
		}
	}
	ck(ans);
	return 0;
}
/*
0 1 2

2

*/


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

using namespace std;

#define ll long long int
#define ld long double
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007

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

    ll n;
    cin>>n;
    ll a[n] , b[n] , c[n];
    map<ll , ll> mp1 , mp2;
    for(int i = 0; i < n; i++){
        cin>>a[i];
        mp1[a[i]]++;
    }
    for(int i = 0; i < n; i++){
        cin>>b[i];
    }
    for(int i = 0; i < n; i++){
        cin>>c[i];
        mp2[b[c[i] - 1]]++;
    }
    ll ans = 0;
    for(auto it : mp1){
        ans += (it.second * mp2[it.first]);
    }
    cout<<ans;
    return 0;
}

//wtrl,everybody hangbeat me
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,pii> piiii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef queue<char> qc;
typedef queue<string> qs;
typedef vector<char> vc;
typedef vector<string> vs;
typedef map<char,int> mpci;
typedef map<int,int> mpii;
typedef map<string,int> mpsi;
typedef set<int> sei;
typedef set<char> sec;
typedef set<string> ses;
typedef stack<ll> si;
typedef stack<char> sc;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pll> vpll;
typedef vector<pdd> vdd;
typedef unsigned int uint;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vii> vvii;
/*=====================================================================*/
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define sz(a) (int)(a.size())
#define len(a) (int)(a.length())
#define all(s) (s).begin(),(s).end()
#define fi first
#define se second
#define be begin
#define en end
#define m_p make_pair
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define forn(i,p,n) for(int i=p;i<=n;i++)
#define ford(i,p,n) for(int i=n;i>=p;i--)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();++i)
#define zero(a) memset(a,0,sizeof(a))
#define number(a,num) memeset(a,num,sizeof(a))
#define INF 1e9
#define PI acos(-1)

/*=====================================================================*/

string int_to_string(ll n)
{
	string s="";
	while(n)
	{
		ll now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
ll string_to_int(string s)
{
	ll n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
/*======================================================================*/
ll lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}
bool prime(int n)
{
	if(n==0||n==1)
	  return false;
	for(int i=2;i*i<=n;i++)
	  if(n%i==0)
	    return false;
	return true;
}
string turn(int n,int k)
{
	string s="";
	while(n)
	{
		s+=(char)(n%k+'0');
		n/=k;
	}
	reverse(s.begin(),s.end());
	return s;
}
const string turn16(int n)
{
	string s="";
	while(n!=0)
	{
		if(n%16>9)
		  s+=(char)('A'+n%16-10);
		else
		  s+=(char)('0'+n%16);
		n/=16;
	}
	reverse(s.begin(),s.end());
	return s;
}
/*======================================================================*/
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
const int month[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};
int a[10010];
/*======================================================================*/
int main()
{
    std::ios::sync_with_stdio(false);
  /*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
  */
  /*====================================================================*/
  int n;
  cin>>n;
  rep(i,n)
  {
  	cin>>a[i];
  }
  int ans=0,maxn;
  rep(i,n)
  {
  	maxn=a[i];
  	ans=max(ans,maxn);
  	forn(j,i+1,n-1)
  	{
  		maxn=min(maxn,a[j]);
  		ans=max(ans,maxn*(j-i+1));
	}
  }
  cout<<ans<<endl;
  return 0;
}


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

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

int P[100001];
int sei[100001], fu[100001], kisuu[100001], ind[100001], kazu[100001], kazu2[100001];

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

	int N;
	cin >> N;
	rep1(i, N - 1) {
		cin >> P[i + 1];
		kazu[P[i + 1]]++;
	}
	rep(i, N) kazu2[i + 1] = (kazu[i + 1] += kazu[i]);

	for (int i = N; i >= 2; i--) {
		int ret = sei[i] - 1;

		auto ki = kisuu + kazu[i - 1];
		int sz = kazu2[i - 1] - kazu[i - 1];
		sort(ki, ki + sz);

		if (sz & 1) {
			ret -= fu[i];
			rep(j, sz) {
				if (j & 1) ret -= ki[j];
				else ret += ki[j];
			}
		}
		else {
			ret += fu[i];
			rep(j, sz) {
				if (j & 1) ret += ki[j];
				else ret -= ki[j];
			}
		}

		if (ret & 1) {
			kisuu[kazu2[P[i] - 1]++] = ret;
		}
		else {
			if (ret >= 0) sei[P[i]] += ret;
			else fu[P[i]] += ret;
		}
	}

	int ret = sei[1] - 1;

	auto ki = kisuu + kazu[0];
	int sz = kazu2[0] - kazu[0];
	sort(ki, ki + sz);

	if (sz & 1) {
		ret -= fu[1];
		rep(j, sz) {
			if (j & 1) ret -= ki[j];
			else ret += ki[j];
		}
	}
	else {
		ret += fu[1];
		rep(j, sz) {
			if (j & 1) ret += ki[j];
			else ret -= ki[j];
		}
	}

	co((N - ret) / 2);

	Would you please return 0;
}

// Problem: C - DFS Game
// Contest: AtCoder - AtCoder Regular Contest 112
// URL: https://atcoder.jp/contests/arc112/tasks/arc112_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <cstdio>
#include <set>

const int maxn = 1e5 + 19;

struct Edge{
	int to, next;
}edge[maxn];

int head[maxn], cnt;

inline void add(int from, int to){
	edge[++cnt].to = to;
	edge[cnt].next = head[from];
	head[from] = cnt;
}

int n, dp[maxn][2], size[maxn];

std::multiset<int> s;
void dfs(int node){
	int odd = 0;
	size[node] = 1;
	for(int i = head[node]; i; i = edge[i].next)
		dfs(edge[i].to), size[node] += size[edge[i].to], odd += size[edge[i].to] & 1;
	for(int now = 0; now < 2; ++now){
		s.clear();
		dp[node][now] = now & 1;
		for(int i = head[node]; i; i = edge[i].next)
			if(size[edge[i].to] & 1){
				dp[node][now] += dp[edge[i].to][now];
				s.insert(dp[edge[i].to][now ^ 1] - dp[edge[i].to][now]);
			}
			else{
				if((dp[edge[i].to][now] < dp[edge[i].to][now ^ 1]) == (now & 1)) dp[node][now] += dp[edge[i].to][now];
				else if(odd & 1) dp[node][now] += dp[edge[i].to][now ^ 1];
				else dp[node][now] += dp[edge[i].to][now];
			}
		int sz = s.size();
		if(!(now & 1))
			for(int i = 1; i <= sz; ++i)
				if(i & 1) s.erase(s.find(*s.begin()));
				else dp[node][now] += *s.begin(), s.erase(s.find(*s.begin()));
		else
			for(int i = 1; i <= sz; ++i)
				if(i & 1) s.erase(s.find(*--s.end()));
				else dp[node][now] += *--s.end(), s.erase(s.find(*--s.end()));
	}
}

int main(){
	scanf("%d", &n);
	for(int i = 2, p; i <= n; ++i){
		scanf("%d", &p);
		add(p, i);
	}
	dfs(1); printf("%d\n", dp[1][1]);
}


#include <bits/stdc++.h>

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second

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

    ll n,x;
    string s;

    cin >> n >> x >> s;
    for(int i=0; i<n; i++)
    {
        if (s[i]=='x')
        {
            if (x) x--;
        }
        else
            x++;
    }

    cout << x << '\n';

    return 0;
}

#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
//Required Headers
using namespace std;

#define PI 3.1415926535897932384626
#define sp(x,y)                     fixed<<setprecision(y)<<x
#define mk(arr,n,type)              type *arr=new type[n]; // dynamic allocation of memory
#define del(arr)                    delete []arr;           // deletion of allocated memory
const int mod = 1'000'000'007;
const int inf = 1e9 + 5;

//for loops

#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define fo2(i, n,t) for(i=0; i<n; i+=t)

//essentials

#define tc(t)               ll t;ll i; cin>>t; fo(i,t)
#define ll long long

//STL

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define vbe(x) x.begin(), x.end()
#define sortvbe(x) sort(vbe(x))
#define setit(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef map<int,int>    mii;
typedef map<ll,ll>      mll;
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
typedef set<int>        si;
typedef set<ll>         sl;

//inputs

#define ci(x)     cin>>x;
#define ci2(x,y)    cin>>x>>y;

//template<typename... T>
//void read(T&... args) {
//  ((cin >> args), ...);
//}

//outputs

#define pi(x)     cout<<x;
#define pinl(x)     cout<<x<<endl;

//template<typename... T>
//void write(T&&... args) { //rvalue reference is new to C++
//  ((cout << args << " "), ...);
//}
ll m=1000000007;
//some imp func

inline int gcd(int a,int b) {if (a==0) return b; else return gcd(b%a,a);}
inline void take_input(int A[],int n){for(int i=0;i<n;i++){ cin>>A[i];}}
inline void show(int *A,int n){for(int i=0;i<n;i++){cout<<A[i]<<" ";}cout<<endl;}
inline bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) { return (a.second < b.second); }
inline bool sortbysecdesc(const pair<int,int> &a, const pair<int,int> &b) { return (a.second > b.second); }
inline void swap(int &a,int &b){int temp=a;a=b;b=temp;}
inline void initialise(int A[],int n,int k){for(int i=0;i<n;i++){A[i]=k;}}
inline void vect_input(vector<int>&v,int n){for(int i=0;i<n;i++){int input;cin>>input;v.pb(input);}}
inline int modulo(int a,int b){return (b+(a%b))%b;}
inline int getascii(char ch){return (int)ch;}
inline ll expo_mod(ll e,ll p){if(p==0)return (1);ll ans=expo_mod(e,p/2);ans=((ans%m)*(ans%m))%m;if(p%2!=0)ans=((e%m)*(ans%m))%m;return ans%m;}
inline ll expo(ll e,ll p){if(p==0)return (1);ll ans=expo(e,p/2);ans=(ans)*(ans);if(p%2!=0)ans=(e)*(ans);return ans;}
inline ll com_wd_m(ll n,ll r,ll m){ll p=1,d=1;if(r==0 or r==n )return(1);if(r==1 )return (n%m);r=min(r,n-r);for(ll i=0;i<r;i++){p=((p%m)*((n%m)-(i%m))%m)%m;p=((p%m)*(expo((i+1),m-2)%m))%m;}return (p%m);}

template<typename T>
void show_vect(vector<T> v){for(int i=0;i<v.size();i++){cout<<v[i]<<" ";}cout<<endl;}
template<typename T>
void vect_input(vector<T>&v,T n){for(int i=0;i<n;i++){cin>>v[i];}}
ll fact(ll n) { return (n==1 || n==0) ? 1: n * fact(n - 1);  }
ll fact_mod(ll n,ll x) {if(n==x) return 1; return (n==1 || n==0) ? 1: ((n%m) * (fact((n - 1)%m))%m)%m;  }

//debugging

#define deb(x) cout << #x << " = " << x << endl; //to check the values
#define deb2(x, y) cout << #x << " = " << x << "," << #y << " = " << y << endl;

void A_A()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.in", "r", stdin);
    freopen("output.in", "w", stdout);
    freopen("error.in","w",stderr);
    #endif
}
ll num;

void solve(){
  ll n,x;
  string s;
  cin>>n>>x;
  cin>>s;
  for(auto i:s){
    if(i=='o') x++;
    if(i=='x' && x-1>=0) x--;
  }
  cout<<x;
}

int main(){
   A_A();
  // tc(t){
    solve();
  // }
  return 0;
}
/*

*/


#include<bits/stdc++.h>
using namespace std;
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define MAX             INT_MAX
#define MIN             INT_MIN
#define F               first
#define S               second
#define pbmax           priority_queue<int>//max heap
#define pbmin           priority_queue<int, vector<int>, greater<int>>//min heap priority_queue
#define lpi(i,a,b)      for(int i=0;i<b;i++)
#define lpd(i,a,b)      for(int i=a;i>=b;i--)
const double pi = 3.14159265359;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;
vector<int>G[N];
vector<int>vis(N, 0);
void dfs(int node, int &dist)
{
    vis[node] = 1;
    dist++;
    for (auto x : G[node])
    {
        if (vis[x] == 0)
        {
            dfs(x, dist);
        }
    }
}
void task()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int l = 0, r = n - 1;
    vector<pair<int, int>>vp;
    set<int>S;
    while (l < r)
    {
        if (a[l] != a[r]) {
            vp.pb({a[l], a[r]});
            S.insert(a[l]);
            S.insert(a[r]);
        }
        l++;
        r--;
    }
    if (vp.size() == 0)
    {
        cout << 0 << '\n';
        return;
    }
    for (auto x : vp)
    {
        G[x.F].pb(x.S);
        G[x.S].pb(x.F);
    }
    int ans = 0;
    for (auto x : S)
    {
        if (vis[x] == 0)
        {
            int cnt = 0;
            dfs(x, cnt);
            ans += max((int)0, cnt - 1);
        }
    }
    cout << ans << '\n';

}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int test_cases = 1;
    //cin >> test_cases;
    while (test_cases--)
    {
        task();

    }
}

#include <bits/stdc++.h>

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

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

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

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

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

struct COMB{
    vl fact, fact_inv, inv;
    void init_nCk(long long SIZE) {
        fact.resize(SIZE + 5);
        fact_inv.resize(SIZE + 5);
        inv.resize(SIZE + 5);
        fact.at(0) = fact.at(1) = fact_inv.at(0) = fact_inv.at(1) = inv.at(1) = 1;
        for(long long i = 2; i < SIZE + 5; i++) {
            fact.at(i) = fact.at(i - 1)*i%MOD;
            inv.at(i) = MOD - inv.at(MOD%i)*(MOD/i)%MOD;
            fact_inv.at(i) = fact_inv.at(i - 1)*inv.at(i)%MOD;
        }
    }
    long long nCk (long long n, long long k) {
        assert(!(n < k));
        assert(!(n < 0 || k < 0));
        return fact.at(n)*(fact_inv.at(k)*fact_inv.at(n - k)%MOD)%MOD;
    }
};
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if(b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b*x;
    return d;
}

void Main() {
    CIN(K);
    ll res = 0;
    for(int a = 1; a*a*a <= K; a++) {
        int k = K/a;
        for(int b = a; b*b <= k; b++) {
            for(int c = b; b*c <= k; c++) {
                if(a*b*c <= K) {
                    if(a != b && b != c) {
                        res += 6;
                    } else if(a == b && b != c) {
                        res += 3;
                    } else if(a != b && b == c) {
                        res += 3;
                    } else {
                        res += 1;
                    }
                }
            }
        }
    }
    cout << res << endl;
}

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


#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main() {
#ifdef DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll K;
    cin >> K;
    ll ans1 = 0;
    ll ans2 = 0;
    ll ans3 = 0;
    for(ll A = 1; A <= K; A++){
        for(ll B = A; A*B <= K; B++){
            for(ll C = B; A*B*C <= K; C++){
                if(A != B && B != C && C != A){
                    ans1 ++;
                }else if(A == B && B == C){
                    ans3 ++;
                }else{
                    ans2 ++;
                }
            }
        }
    }
    ll ans = ans1 * 2 * 3 + ans2 * 3 + ans3;
    cout << ans << endl;
    return 0;
}

//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word
//Incase of close mle change language to c++17 or c++14
/**#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops”)**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007ll //998244353ll
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int k, ans=0;
    cin>>k;
    for(int i=1;i<=k;i++)
    {
        for(int j=1;i*j<=k;j++)
        {
            for(int z=1;i*j*z<=k;z++)
            ans++;
        }
    }
    cout<<ans;
}


#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define ll              long long int
#define vi              vector<int>
#define vll             vector<ll>
#define vvi             vector < vi >
#define pb              push_back
#define all(x)          (x).begin(),(x).end()
#define pii             pair<int,int>
#define vpl             vector<pair<ll,ll>>
#define pll             pair<long long, long long>
#define mod             1000000007
#define inf             1000000000000000001;
#define mp(x,y)         make_pair(x,y)
#define mem(a,val)      memset(a,val,sizeof(a))
#define eb              emplace_back
#define ff              first
#define ss              second
#define poss(flag)      cout << (flag ? "YES\n" : "NO\n")
#define rep(i,j,k)      for(ll i=j;i<=k;i++)
#define repr(i,j,k)     for(ll i=j;i>=k;i--)
#define ii              insert
using namespace std;

int pow(int x, unsigned int y, int p){
    int res=1;
    x=x%p;
    if (x==0) return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int _pow(int a, int b){
    if(!b)
        return 1;
    int temp = _pow(a, b / 2);
    temp = (temp * temp);
    if(b % 2)
        return (a * temp);
    return temp;
}

int invmod(int a,int m){
    return pow(a,m-2,m);
}
int cl(int a,int x){
    if(a%x==0)
        return a/x;
    else
        return a/x+1;
}

void yes(){
    cout<<"YES"<<"\n";
}
void no(){
    cout<<"NO"<<"\n";
}
set<ll>s;

void SieveOfEratosthenes(int n)
{
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));

    for (int p = 2; p * p <= n; p++)
    {

        if (prime[p] == true)
        {

            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }

    for (int p = 2; p <= n; p++){
        if (prime[p]){
            s.ii(p);
        }
    }

}

int main()
{
    string s;
    cin >> s;
    string ans = s.substr(0,s.find('.'));
    cout<<ans;

    #ifndef ONLINE_JUDGE
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    #endif
    return 0;

}

#include <bits/stdc++.h>
using namespace std;
int main(){
  string X;
  cin >> X;
  for(int i=0;i<(int)X.size();i++){
    if(X[i]=='.') return 0;
    else cout << X[i];
  }
}


#include <bits/stdc++.h>
using namespace std;
#define mp(a, b) make_pair(a, b)
typedef pair<int, int> pii;
const int maxn = 50 + 10;
int n, m, q;
pii a[maxn];
int x[maxn];
int main()
{
	scanf("%d%d%d", &n, &m, &q);
	for(int i = 1; i <= n; ++i) scanf("%d%d", &a[i].second, &a[i].first);
	sort(a + 1, a + n + 1, greater<pii>());
	for(int i = 1; i <= m; ++i) scanf("%d", &x[i]);
	while(q--)
	{
		int l, r;
		scanf("%d%d", &l, &r);
		multiset<int> s;
		for(int i = 1; i <= m; ++i)
			if(i < l || i > r)
				s.insert(x[i]);
		int ans = 0;
		for(int i = 1; i <= n; ++i)
		{
			auto it = s.lower_bound(a[i].second);
			if(it == s.end()) continue;
			ans += a[i].first;
			s.erase(it);
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

typedef long long int ll;
const ll INF = 1e17 + 11;

pair<ll, ll> pll[100];
vector<ll> vpl;
ll dp[100][100];

bool cmp(pair<ll,ll> a, pair<ll,ll> b){
	return a.first*b.second < a.second*b.first;
}

ll recur(ll i, ll j, ll n, ll m){
  if(i == n or j == m)
    return 0;
  if(dp[i][j] != -1)
    return dp[i][j];
  ll ans = 0;
  if(pll[i].first <= vpl[j])
    ans = max(ans, pll[i].second+recur(i+1,j+1,n,m));
  ans = max(ans,max(recur(i+1,j,n,m), recur(i,j+1,n,m)));
  return dp[i][j] = ans;
}

void init(){
  for(ll i=0; i<100; i++)
    for(ll j=0; j<100; j++)
      dp[i][j] = -1;
}

int main(){
  cin.sync_with_stdio(false);
  cin.tie(0);
  ll n, m, q;
  cin >> n >> m >> q;
  for(ll i=0; i<n; i++){
  	cin >> pll[i].first >> pll[i].second;
  }
  sort(pll, pll+n);
  ll A[m];
  for(ll i=0; i<m; i++)
    cin >> A[i];
  while(q--){
    init();
    ll x, y;
  	cin >> x >> y;
    for(ll i=0; i<x-1; i++)
      vpl.emplace_back(A[i]);
    for(ll i=y; i<m; i++)
      vpl.emplace_back(A[i]);
    sort(begin(vpl), end(vpl));
    ll ans = recur(0,0,n, vpl.size());
    cout << ans << "\n";
    vpl.clear();
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

//#define ONLINE_JUDGE
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define repe(z, x, y) for(int z=x;z<y;++z)
#define repd(z, x, y) for(int z=x;z>=y;--z)
#define repde(z, x, y) for(int z=x;z>y;--z)
#define int long long

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

const int INF = 0x3f3f3f3f;
const double eps = 1e-9;
const int mod = 1e9 + 7;

void solve()
{
    int n, x;
    cin >> n >> x;
    rep(i, 1, n)
    {
        int tmp;
        cin >> tmp;
        if(tmp != x)
            cout << tmp << ' ';
    }

    cout << endl;
}

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

    IOS;
    int t;
    solve();
}


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

using namespace std;

int main(void){

    string  n;
    int     k;
    cin >> n >> k;

    for (int i = 0; i < k; i++) {
        vector<int>  g1, g2;
        int          keta = n.size();
        for (int j = 0; j < keta; j++) {
            g1.push_back(n[j] - '0');
            g2.push_back(n[j] - '0');
        }
        sort(g1.begin(), g1.end(), greater<int>());
        sort(g2.begin(), g2.end());

        //g1, g2を数字に変換
        long long  num_g1 = 0, num_g2 = 0;
        long long  f;
        for (int j = 0; j < keta; j++) {
            num_g1 += g1[j] * pow(10, keta - j - 1);
            num_g2 += g2[j] * pow(10, keta - j - 1);
        }
        f = num_g1 - num_g2;
        /*
        cout << "n[" << i << "] = " << n << endl;
        cout << "g1[" << i << "] = " << num_g1;
        cout << " g2[" << i << "] = " << num_g2 << endl;
        cout << "f[" << i << "] = " << f << endl;
        */
        n = to_string(f);
    }

    cout << n << endl;

    return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         cout<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define endl            "\n"
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

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

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

char myHeap[200 * 1024 * 1024];
int sz = 0;
void assert_tle(bool q) { while (!q); }
void* operator new  ( std::size_t count ) {
    sz += count;
    assert_tle(sz <= 200 * 1024 * 1024);
    return myHeap + sz - count;
}

void operator delete (void *ptr) { }

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

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

    while(k--)
    {
        string g1=to_string(n);
        string g2=to_string(n);

        sort(g1.begin(),g1.end(),greater<int>());
        sort(g2.begin(),g2.end());

        n=stoi(g1)-stoi(g2);
    }

    cout<<n;
}

int32_t main()
{
    fastIO();
    //w(t)
    {
        solve();
        cout<<endl;
    }
    return 0;
}


/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

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

	int cnt = 0;
	for(int i=9999;i>=0;i--) {
		string snum = to_string(i);
		int pad_len = 4 - snum.length();
		if(pad_len > 0) {
			string pad = string(pad_len, '0');
			snum = pad + snum;
		}
		//~chk(snum);

		bool possible = true;
		int f[10] = {0};
		for(int j=0;j<snum.length();j++) {
			f[snum[j]-'0']++;
		}

		for(int j=0;j<s.length();j++) {
			if(s[j] == 'o' && f[j] == 0) {possible = false; break;}
			if(s[j] == 'x' && f[j] > 0) {possible = false; break;}
		}

		if(possible) cnt++;
	}

	cout<<cnt<<en;
}

int main() {
	int t = 1;

	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define testcases \
    int t;        \
    cin >> t;     \
    while (t--)
#define rep(i, j, k) for (int i = j; i <= k; i++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define pi 3.14159265358979323846
#define mod 1000000007

int32_t main()
{
    boost;
    string s;
    cin >> s;
    set<int> x_count, o_count, q_count;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '?')
            q_count.insert(i);
        else if (s[i] == 'o')
            o_count.insert(i);
        else
            x_count.insert(i);
    }
    string pin = "....";
    int ans = 0;
    for (int i = 0; i <= 9; i++)
    {
        for (int j = 0; j <= 9; j++)
        {
            for (int k = 0; k <= 9; k++)
            {
                for (int l = 0; l <= 9; l++)
                {
                    set<int> vals;
                    bool flag = false;
                    pin[0] = '0' + i;
                    pin[1] = '0' + j;
                    pin[2] = '0' + k;
                    pin[3] = '0' + l;
                    for (int u = 0; u < 4; u++)
                    {
                        vals.insert(pin[u] - '0');
                    }
                    for (auto u : vals)
                    {
                        if (o_count.find(u) == o_count.end() && q_count.find(u) == q_count.end())
                        {
                            flag = true;
                            break;
                        }
                    }
                    for (auto u : o_count)
                    {
                        if (vals.find(u) == vals.end())
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (flag == false)
                        ans++;
                }
            }
        }
    }
    cout << ans;
}


#include<iostream>
#include<vector>
#include<iomanip>
#include<set>
#include<algorithm>
#include<unordered_map>
#define ll long long
#define io {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define rt int t;cin>>t;while(t--)
#define r1 int t=1;while(t--)
#define mp make_pair
#define endl '\n'
using namespace std;
unordered_map<int,int>m[200010];
int f[200010];
int find(int x) {
	return x==f[x]?x:f[x]=find(f[x]);
}
void merge(int a,int b) {
	int lx=find(a);
	int rx=find(b);
	if(lx!=rx) {
		if(m[lx].size()>m[rx].size()) {
			f[rx]=lx;
			for(auto i:m[rx]) {
				m[lx][i.first]+=i.second;
			}
		} else {
			f[lx]=rx;
			for(auto i:m[lx]) {
				m[rx][i.first]+=i.second;
			}
		}
	}
}
int main() {
	io;
	r1 {
		int n,q;
		cin>>n>>q;
		for(int i=1; i<=n; i++) {
			int x;
			cin>>x;
			m[i][x]++;
			f[i]=i;
		}
		while(q--) {
			int opt;
			cin>>opt;
			if(opt==1) {
				int a,b;
				cin>>a>>b;
				merge(a,b);
			} else if(opt==2) {
				int x,y;
				cin>>x>>y;
				int k=find(x);
				cout<<m[k][y]<<endl;
			}
		}
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,num = 0;cin>>n>>x;
  vector<int>vec(n);
  for(int i = 0; i < n; i++){
    cin >> vec.at(i);
    if(vec.at(i) == x){
      num++;
    }
  }
  int j = 0;
  for(int i = 0; i < n; i++){
    if(vec.at(i) != x){
      cout << vec.at(i) << " ";
    }
  }
  return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<list>
#define ll long long
#define str string
#define ld long double
#define vec vector
#define vll vec<ll>
#define vvll vec<vll>
#define vbo vec<bool>
#define vvbo vec<vbo>
#define vin(a) rep(i,0,a.size())cin>>a[i];
#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,b,a) for(ll i=(b);i>=(a);i--)
#define repset(itr,a) for(auto itr=a.begin();itr!=a.end();itr++)
#define repnck(bit,n,k) for(ll bit=(1ll<<(k))-1;bit<(1ll<<(n));bit=(bit==0?(1ll<<(n)):nec(bit)))
#define bi1(bit,i) ((bit)&1ll<<(i)?true:false)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define kai "\n"
#define prque priority_queue
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mie min_element
#define mae max_element
#define tos to_string
#define sep setprecision
#define lob lower_bound
#define upb upper_bound
#define bis binary_search
#define nep next_permutation
#define MOD 1000000007ll
#define MAX 2147483647ll
#define MIN 0.0000000001l
#define equal(a,b) (abs((a)-(b))<MIN)
using namespace std;
void solve();
struct ll2{ll x,y;bool operator<(const ll2 &l)const{return x!=l.x?x<l.x:y<l.y;};};
struct ll3{ll x,y,z;bool operator<(const ll3 &l)const{if(x!=l.x)return x<l.x;if(y!=l.y)return y<l.y;return z<l.z;};};

class ufset{
public:
	ufset(ll n) {rank.resize(n,0);rep(i,0,n)p.pub(i);}
	bool same(ll i,ll j){return find(i)==find(j);}
	void unite(ll i,ll j){link(find(i),find(j));}
	ll find(ll i){if(i!=p[i])p[i]=find(p[i]);return p[i];}
private:
  vll p,rank;
	void link(ll i,ll j){if(rank[i]>rank[j])p[j]=i;else{p[i]=j;if(rank[i]==rank[j])rank[j]++;}}
};

class nck{
public:
	nck(ll maxn,ll mod=MOD){
		NUM=maxn+1;p=mod;
		fac.resize(NUM);finv.resize(NUM);inv.resize(NUM);
		fac[0]=fac[1]=finv[0]=finv[1]=inv[1]=1;
		rep(i,2,NUM){fac[i]=fac[i-1]*i%p;inv[i]=p-inv[p%i]*(p/i)%p;finv[i]=finv[i-1]*inv[i]%p;}
	}
	ll c(ll n,ll k){return fac[n]*(finv[k]*finv[n-k]%p)%p;}
private:
  ll NUM,p;
	vll fac,finv,inv;
};

ll gcd(vector<ll> a){rep(i,1,a.size()){ll k=a[i-1]%a[i];while(k!=0){a[i-1]=a[i];a[i]=k;k=a[i-1]%a[i];}}return a.back();}
ll lcm(vector<ll> a){ll n;rep(i,1,a.size()){n=a[i-1]*a[i];ll k=a[i-1]%a[i];while(k!=0){a[i-1]=a[i];a[i]=k;k=a[i-1]%a[i];}n/=a[i];a[i]=n;}return n;}
ll pow2(ll a,ll b,ll p=MOD){if(b==-1)return pow2(a,p-2,p);ll res=1;if(b>0){res=pow2(a,b/2,p);if(b%2==0)res=res*res%p;else res=res*res%p*a%p;}return res;}
ll nec(ll bit){ll x=bit&-bit,y=bit+x;return (((bit&~y)/x)>>1)|y;}
ll bisz(ll bit){ll size=0;while(bit>0){bit/=2;size++;}return size;}
ll ransu(){static unsigned int TX=123456789, TY=362436069, TZ=521288629, TW=88675123;unsigned int tt=(TX^(TX<<11));TX=TY;TY=TZ;TZ=TW;return (TW=(TW^(TW>>19))^(tt^(tt>>8)));}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed;
	solve();
}
void solve(){
	ll a,b,c,d;cin>>a>>b>>c>>d;
	if(a==c&&b==d){cout<<0<<kai;return;}
		if(a+b==c+d||a-b==c-d||abs(a-c)+abs(b-d)<=3){
			cout<<1<<kai;return;
		}else if((c+d-a-b)%2==0){
			cout<<2<<kai;return;
		}
	rep(i,-3,4)rep(j,-3,4){
		if(abs(i)+abs(j)<=3){
			if(a+b==c+d+i+j||a-b==c+i-d-j||abs(a-c-i)+abs(b-d-j)<=3){
				cout<<2<<kai;return;
			}
		}
	}
	cout<<3<<kai;
}

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

int ri(){
  int n;cin>>n;
  return n;
}

int main(){
  ll r1=ri(),c1=ri(),r2=ri(),c2=ri();
  int ans;
  if(r1==r2 && c1==c2) ans=0;
  else if(r1+c1==r2+c2 || r1-c1 == r2-c2 || abs(r1-r2)+abs(c1-c2)<=3){
    ans=1;
  }
  else if(abs(r1-r2)+abs(c1-c2)<=6 || (r1+c1)%2==(r2+c2)%2 || abs(c1-c2+r1-r2)<=3
          || abs(c1-c2-r1+r2)<=3){
    ans=2;
  }
  else ans=3;
  cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
//#define ll long long
#define int long long
//#define ull unsigned long long
#define PI pair<int,int>
//#define PI pair<ll,int>
const int maxm=2e5+5;
int d[1<<20];
int e[20];//e[i]为点i的边集
int n,m;
signed main(){
    ios::sync_with_stdio(0);
    cin>>n>>m;
    for(int i=0;i<n;i++)e[i]|=(1<<i);
    for(int i=1;i<=m;i++){
        int a,b;cin>>a>>b;
        a--,b--;
        e[a]|=(1<<b);
        e[b]|=(1<<a);
    }
    //init
    for(int i=0;i<(1<<n);i++){
        d[i]=1e9;
    }
    d[0]=0;
    //dp
    for(int i=1;i<(1<<n);i++){
        //判断集合是否本身是一个完全图
        int ok=1;
        for(int j=0;j<n;j++){
            if(i>>j&1){
                if((e[j]&i)!=i){
                    ok=0;
                }
            }
        }
        if(ok)d[i]=1;
        //枚举当前集合是从何组合的
        for(int j=i;j;j=((j-1)&i)){//枚举子集
            d[i]=min(d[i],d[i-j]+d[j]);//d[i]由(i-j)和j组成.
        }
    }
    cout<<d[(1<<n)-1]<<endl;
    return 0;
}
/*
n<=18,考虑状压dp:
令d[i]表示点集为i时,满足题目条件的最小连通块数量.

*/

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <ios>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <utility>

using namespace std;

using i64 = int64_t;
using u64 = uint64_t;
using i32 = int32_t;
using pi64 = pair<i64, i64>;

constexpr i64 MAXN = 3*100*1000LL+5LL;
constexpr i64 MOD = 1000000007LL;
constexpr i64 INF64 = MOD * MOD;
#define vec vector
#define let const
#define DRi64(x) i64 x; cin >> x;
#define DRS(x) string x; cin >> x;
#define DRVi64(v, n) vec<i64> v(n); { for (i64 i = 0; i < n; ++i) { cin >> v[i]; }}

#ifdef DEBUG
#define P(x) cerr << x << "\n"
#else
#define P(x)
#endif

int
main()
{
    ios_base::sync_with_stdio(false);
    const unsigned seed =
        chrono::system_clock::now().time_since_epoch().count();
    mt19937 gen(seed);

    DRi64(N); DRi64(M);
    vec<vec<i64>> adj(N);
    for (i64 i = 0; i < M; ++i)
    {
        DRi64(A); DRi64(B);
        A--, B--;
        adj[A].push_back(B);
        adj[B].push_back(A);
    }

    vec<bool> is_valid(1LL << N, false);
    // look at all possible cliques and see whether each one is valid
    for (i64 mask = 0; mask < (1LL << N); ++mask)
    {
        vec<i64> clique;
        for (i64 i = 0, mask2 = mask; mask2; ++i, mask2 >>= 1)
        {
            if (mask2 & 1)
            {
                clique.push_back(i);
            }
        }
        bool ok = true;
        for (let i64 v : clique)
        {
            for (let i64 v2 : clique)
            {
                if (v2 == v)
                {
                    continue;
                }
                ok &= find(adj[v].begin(), adj[v].end(), v2) != adj[v].end();
            }
        }
        is_valid[mask] = ok;
        P(mask << ": " << (is_valid[mask] ? "OK" : "bad"));
    }

    vec<i64> min_clique_counts(1LL << N, MOD);
    min_clique_counts[0] = 0;
    for (i64 mask = 1; mask < (1LL << N); ++mask)
    {
        for (i64 submask = mask; submask; submask = (submask - 1) & mask)
        {
            P("mask: " << mask << " sub: " << submask);
            if (is_valid[submask])
            {
                P("mask & ~submask: " << (mask & ~submask));
                min_clique_counts[mask] = min(min_clique_counts[mask], 1 + min_clique_counts[mask & ~submask]);
            }
            else
            {
                min_clique_counts[mask] = min(min_clique_counts[mask], min_clique_counts[submask] + min_clique_counts[mask & ~submask]);
            }
        }
        P(bitset<18>(mask) << ": " << min_clique_counts[mask]);
    }
    cout << min_clique_counts[(1LL << N) - 1] << "\n";

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long double ld;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define ms memset
#define pb push_back
#define F first
#define S second
ll MOD = 1000000007;
ll INF = 1000000000;

ll power(ll base, ll n){
	if (n == 0) return 1;
	if (n == 1) return base;
	ll halfn = power(base, n/2);
	if (n % 2 == 0) return (halfn * halfn) % MOD;
	return (((halfn * halfn) % MOD) * base) % MOD;
}

ll inverse(ll n){
	return power(n, MOD-2);
}

ll add(ll a, ll b){
	return (a+b) % MOD;
}

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

ll gcd(ll a, ll b){
	if (a == 0) return b;
	if (a == 1) return 1;
	return gcd(b%a, a);
}

int main(){
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    FOR(i, 0, n){
    	cin >> a[i];
    	if (i % 2 == 1){
    		a[i] = 0 - a[i];
		}
	}
	vector<ll> A(n+1);
	map<ll, ll> mp;
	mp[0] = 1;
	ll ans = 0;
	FOR(i, 1, n+1){
		A[i] = A[i-1] + a[i-1];
		ans += mp[A[i]];
		mp[A[i]]++;
	}
	cout << ans << '\n';
	return 0;
}

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

int main() {
    using ll = long long;
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    vector<ll> sums(n + 1);
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            sums[i + 1] = sums[i] + a[i];
        } else {
            sums[i + 1] = sums[i] - a[i];
        }
    }

    map<ll, ll> mp;
    for (int i = 0; i <= n; i++) mp[sums[i]]++;

    ll ans = 0;

    for (auto m: mp) ans += (m.second - 1) * m.second / 2;

    cout << ans << endl;
}


#include <bits/stdc++.h>

using namespace std;

vector<int> son[100010];
int n, pv, f[100010];
bool g[100010];

bool cmp(pair<int, bool> x, pair<int, bool> y) {
  if (x.second == y.second) return x.first < y.first;
  if (x.second == 0) return x.first < 0;
  return y.first >= 0;
}

void dfs(int rt) {
  f[rt] = g[rt] = 1;
  if (son[rt].empty()) return;
  vector<pair<int, bool>> tmp;
  for (int i : son[rt]) {
    dfs(i);
    tmp.push_back({f[i], g[i]});
    g[rt] ^= g[i];
  }
  sort(tmp.begin(), tmp.end(), cmp);
  bool flag = 1;
  for (pair<int, int> i : tmp) {
    if (flag)
      f[rt] += i.first; else
      f[rt] -= i.first;
    if (i.second) flag = !flag;
  }
}

int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; ++i) {
    scanf("%d", &pv);
    son[pv].push_back(i);
  }
  dfs(1);
  printf("%d\n", (n + f[1]) / 2);
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
#define m(a) memset(a,0,sizeof(a))
const int N=2e5+5;
int n,m;
int f[N],w[N],T;
vector<int>g[N],b[N];
void work(int k){
	int z=g[k].size();
	int i,er=0;
	w[k]=1;
	for(int i=0;i<z;i++){
		int y=g[k][i];
		work(y);
		w[k]+=w[y];
		if(w[y]%2==0){
			if(f[y]>0)f[k]+=f[y];
			else er+=f[y];
		}
		else b[k].push_back(f[y]);
	}
	f[k]+=er*(w[k]%2*2)-er;
	sort(b[k].begin(),b[k].end());
	for(int i=0;i<b[k].size();i++){
		f[k]+=b[k][i]*(1-(b[k].size()-1-i)%2*2);
	}
	f[k]--;
}
int main(){
	int n;cin>>n;
	for(int i=2;i<=n;i++){
		int x;cin>>x;
		g[x].push_back(i);
	}
	work(1);
	int maxs=0;
	for(int i=1;i<=n;i++){
		maxs=max(maxs,f[i]);
	}
	cout<<(n-f[1])/2;
}


#include <bits/stdc++.h>

using namespace std;

#define ar array
#define ll long long
#define tc(t) int t; cin >> t;while(t--)
#define lp(i, x, y) for(ll i = x; i <= y; i++)
#define lpr(i, x, y) for(ll i = x; i >= y; i--)
#define in1(x) ll x; cin >> x
#define in2(x, y) ll x, y; cin >> x >> y
#define in3(x, y, z) ll x, y, z; cin >> x >> y >> z
#define mem(x, y) memset(x, (y), sizeof(x))
#define ite(it, l) for (auto it = l.begin(); it != l.end(); it++)

const int MAX = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;

int main()
{
    // cin.tie(0); cout.tie(0); freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    string a;
    cin >> a;
    int n = a.size();
    lpr(i, n-1, 0)
    {
        if(a[i] == '6')
            cout << "9";
        else if(a[i] == '9')
            cout << "6";
        else
            cout << a[i];
    }
    cout << endl;
}

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> Pair;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

struct SieveEratosthenes{
    vector<int> min_fact;

    SieveEratosthenes(int N){
        _build(N);
    }

    void _build(int N){
        min_fact.resize(N+1);
        for(int i=0; i<=N; i++) min_fact[i] = i;
        min_fact[0] = min_fact[1] = -1;

        for(int i=2; i*i<=N; i++){
            for(int j=i*i; j<=N; j+=i){
                if(i < min_fact[j])
                    min_fact[j] = i;
            }
        }
    }

    bool is_prime(int x){
        return min_fact[x] == x;
    }

    vector<pair<int,int>> factorize(int x){
        vector<pair<int,int>> ret;
        while(x>1){
            if(ret.empty() || ret.back().first != min_fact[x])
                ret.emplace_back(min_fact[x], 1);
            else
                ret.back().second++;

            x /= min_fact[x];
        }

        return ret;
    }
};

void Main(){
    ll N; cin >> N;
    set<ll> s;
    for(ll x=2; x<sqrt(N)+10; x++){
        for(ll y=x*x; y<=N; y*=x){
            s.insert(y);
        }
    }
    ll ans = N - s.size();
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define inrange(a, x, b) (a <= x && x <= b)
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using vcvc = vector<vc>;
using pll = pair<ll, ll>;
template<class T> void print(T x,bool cl=1){cout<<(cl?"\x1b[36m":"")<<x<<(cl?"\x1b[39m":"")<<'\n';}
template<class T> void print1d(T x,ll n=-1,bool cl=true){if(n==-1)n=x.size();rep(i,0,n){cout<<(cl?"\x1b[36m":"")<<x[i]<<(i==n-1?'\n':' ');}cout<<(cl?"\x1b[39m":"");}
template<class T> void print2d(T x,ll r=-1,ll c=-1,bool cl=1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c,cl);}
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; }
ll modc(ll a, char op, ll b, ll _mod=mod)
{
        a %= _mod; b %= _mod; ll res = 1;
        switch (op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break;
        }
        if (res < 0) { res += _mod; } return res;
}

int main()
{
        ll N, A, B;
        cin >> N >> A >> B;
        N -= A;
        N += B;
        cout << N << endl;
}

#include <bits/stdc++.h>
#define PB push_back
#define ST first
#define ND second
#define _ ios_base::sync_with_stdio(0); cin.tie(0);
//mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

using namespace std;

using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;

int n,a,b;

int main() {_
	cin >> n >> a >> b;
	cout << n - a + b;

}


#include <bits/stdc++.h>

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

    std::vector< long long > B(K);
    std::vector< std::pair< long long, long long > > B_zan_i(K);
    long long total = 0;
    for(int i=0; i<K; i++){
        B[i] = A[i] * M / N;
        total += B[i];
        B_zan_i[i].first = (A[i] * M) % N;
        B_zan_i[i].second = i;
    }

    std::sort(B_zan_i.begin(), B_zan_i.end());
    for(int i=0; i<M-total; i++){
        B[B_zan_i[K - i - 1].second]++;
    }

    for(int i=0; i<K; i++){
        if(i == K-1){
            std::cout << B[i] << std::endl;
        }else{
            std::cout << B[i] << " ";
        }
    }

    return 0;
}


#include <iostream>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>

using namespace std;
const int INF = 1 * (1 << 30);
const int mINF = -1 * (1 << 30);

int main()
{
  double n;
  cin >> n;
  n *= 1.08;
  int tmp = (int)n;
  if (tmp < 206)
  {
    cout << "Yay!" << endl;
  }
  else if (tmp == 206)
  {
    cout << "so-so" << endl;
  }
  else
  {
    cout << ":(" << endl;
  }
  return 0;
}

# define _GLIBCXX_DEBUG
# define rep(i, n) for (int i=0; i<(int)(n); i++)
# define FOR(i,a,b) for(int i=(a);i<=(b);++i)
# define ALL(a) (a).begin(), (a).end()
# define COUT(x) cout << (x) << endl;
# define KAI() cout << endl;
# define INF 10000000000000000LL
typedef long long ll;
# include <iostream>
# include <string>
# include <cmath>
# include <algorithm>
# include <vector>
# include <set>
# include <bitset>
using namespace std;

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

    double ans;

    ans = floor(1.08*n);

    // int ans=0;
    if (ans < 206) COUT("Yay!")
    else if (ans == 206) COUT("so-so")
    else COUT(":(")
}


#pragma region Macros
#include <bits/stdc++.h>
#if defined(LOCAL) || defined(ONLINE_JUDGE) || defined(_DEBUG)
#include <atcoder/all>
#endif
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>using vec = vector<T>;
template<class T, class U>using umap = unordered_map<T, U>;
template<class T>using uset = unordered_set<T>;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vl = vec<ll>;
#define fi first
#define se second
#define el endl
constexpr ll INF = numeric_limits<ll>::max()/2-1;
#pragma endregion

#pragma region IOMacros
template<class T>
istream &operator>>(istream &stream, vec<T>& o){REP(i, o.size())stream >> o[i];return stream;}
template<class T>
ostream &operator<<(ostream &stream, vec<T>& objs){REP(i, objs.size())stream << objs[i] << " ";stream << el;return stream;}

#define I(T, ...) ;T __VA_ARGS__;__i(__VA_ARGS__);
void __i() {}
template<class T, class... Ts> void __i(T&& o, Ts&&... args){cin >> o;__i(forward<Ts>(args)...);}

void O() {cout << el;}
template<class T, class... Ts> void O(T&& o, Ts&&... args){cerr << o << " ";O(forward<Ts>(args)...);}
#pragma endregion

void Main();

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

void Main(){
    I(ll, T);
    REP(i, T){
        I(ll, A);
        if(A&1){
            cout << "Odd" << el;continue;
        }
        A/=2;
        if(A&1){
            cout << "Same" << el;
        }else{
            cout << "Even" << el;
        }
    }
}

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

int main() {
    int T;
    cin >> T;
    while (T--) {
        long long N;
        cin >> N;
        if(N%4 == 2) {
            cout << "Same" << endl;
        }
        else if(N%4 == 0) {
            cout << "Even" << endl;
        }
        else {
            cout << "Odd" << endl;
        }
    }
}


//Problem link :
//done by sanath kumar
#include<bits/stdc++.h>
#include <cstdlib>
using namespace std;
#define ll      			long long int
#define ld      			long double
#define mod     			1000000007
#define inf     			1e9
#define endl    			"\n"
#define pb      			push_back
#define vi 					vector<ll>
#define vs					vector<string>
#define pii 				pair<ll,ll>
#define ump 				unordered_map
#define mp 					make_pair
#define pq_max  			priority_queue<ll>
#define pq_min				priority_queue<ll,vector<ll>,greater<ll>>
#define all(v)				v.begin(),v.end()
#define ff 					first
#define ss					second
#define mid(l,r)    		(l+(r-l))/2
#define bitc(x)				__builtin_popcount(x)
#define loop(i,a,b)			for(int i=(a);i<=(b);i++)
#define looprev(i,a,b) 		for(int i=(a);i>=(b);i--)
#define iter(c,it)			for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define log(args...)		{string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);err(_it,args);}
#define logarr(arr,a,b)		for(int z=(a);z<=(b);z++) cout<<(arr[z])<<" ";cout<<endl;
template<typename T> T gcd(T a,T b) {if(b==0) return a; return gcd(b,a%b);}
template<typename T> T lcm(T a,T b) {return a*(b/gcd(a,b));}

void err(istream_iterator<string> it){}
template<typename T,typename... Args>
void err(istream_iterator<string> it,T a,Args... args){
	cout<<*it<<" = "<<a<<endl;
	err(++it,args...);
}
void file_i_o(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}
ll *getfactorial(){
	int m=1e6;
	ll *fact=new ll[m+1];
	fact[0]=1;
	loop(i,1,m){
		fact[i]=(fact[i-1]*i)%mod;
	}
	// time complexity O(n)
	return fact;
}
vi *getfactors(){
	int n=2e5;
	vi *factors=new vi[n+5];
	loop(i,1,n){
		for(int j=i;j<=n;j+=i){
			factors[j].pb(i);
		}
	}
	// time complexity O(nlogn)
	return factors;
}
ll power(ll a,ll b,ll m=mod){
	if(b==0) return 1;
	ll smallans=power(a,b/2,m);
	ll ans=(smallans*smallans)%m;
	if(b%2==1){
		ans=(ans*a)%m;
	}
	return ans;
	// time complexity O(logb)
}
bool *isprime(){
	int m=1e6;
	bool *p=new bool[m];
	loop(i,0,m) p[i]=true;
	p[0]=false;
	p[1]=false;
	loop(i,2,sqrt(m)){
		for(int j=2*i;j<=m;j+=i){
			p[j]=false;
		}
	}
	// time complexity O(nloglogn)
	return p;
}
ll nCr(ll n,ll r,int m=mod){
	if(n<r) return 0;
	ll dp[2][r+5];
	memset(dp,0,sizeof(dp));
	int i=1;
	loop(k,0,n) dp[k][0]=1;
	loop(k,1,n){
		loop(j,1,r){
			dp[i][j]=dp[i^1][j]+dp[i^1][j-1];
		}
		i=i^1;
	}
	// time complexity O(n*r) ,in worst case O(n^2)
	return dp[i^1][r];
}

//==================START==================
vi val[3];
ll twopoi(int x,int y){
	ll i=0,j=0,ans=1e15;
	while(i<val[x].size() and j<val[y].size()){
		ll p=val[y][j]-val[x][i];
		if(ans>abs(p)) ans=abs(p);
		if(p==0) break;
		if(p>0) i++;
		else j++;
	}
	return ans;
}
int main(){
	file_i_o();
	clock_t begin=clock();
	int n;
	cin>>n;

	loop(i,1,2*n){
		ll x;
		char c;
		cin>>x>>c;
		if(c=='R') val[0].pb(x);
		else if(c=='G') val[1].pb(x);
		else if(c=='B') val[2].pb(x);
	}
	loop(i,0,2){
		if(val[i].size()!=0) sort(all(val[i]));
	}
	int r=val[0].size();
	int g=val[1].size();
	int b=val[2].size();
	if(r%2==0 and b%2==0 and g%2==0) cout<<0<<endl;
	else{
		ll ans=-1;
		if(r%2==0){
			ans=twopoi(1,2);
			if(val[0].size()!=0) ans=min(ans,twopoi(0,1)+twopoi(0,2));
		}
		else if(g%2==0){
			ans=twopoi(0,2);
			if(val[1].size()!=0) ans=min(ans,twopoi(1,0)+twopoi(1,2));
		}
		else{
			ans=twopoi(0,1);
			if(val[2].size()!=0) ans=min(ans,twopoi(2,1)+twopoi(0,2));
		}
		cout<<ans<<endl;
	}
	#ifndef ONLINE_JUDGE
		clock_t end=clock();
		cout<<"\n\n\nExecuted in :"<<double(end-begin)/CLOCKS_PER_SEC*1000<<" ms"<<endl;
	#endif
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define ll long long
#define F(type, i, a, b, incr) for (type i = a; i <= (type)(b); i += (type)(incr))
#define RF(type, i, a, b, decr) for (type i = a; i >= (type)(b); i -= (type)(decr))
#define sz(a) sizeof(a)
#define deb(a) cerr << " [" << #a << "->" << a << "] "
#define next_line cerr << '\n'
#define all(a) a.begin(), a.end()
#define iter(it, s) for (auto it = s.begin(); it != s.end(); it++)
#define setbits(x) __builtin_popcountll(x)
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int INF = 1e18;

int Get(char color){
    if(color == 'R')
        return 0;
    if(color == 'G')
        return 1;
    return 2;
}

void solve()
{
    int n;
    cin >> n;
    n *= 2LL;
    // R, G, B
    vector<vector<int> > dogs(3);
    F(int, i, 0, n - 1, 1){
        int a;
        char c;
        cin >> a >> c;
        dogs[Get(c)].push_back(a);
    }
    F(int, i, 0, 2, 1){
        dogs[i].push_back(-INF);
        dogs[i].push_back(INF);
        sort(all(dogs[i]));
    }
    sort(all(dogs), [](vector<int> &a, vector<int> &b){
        return ((int)(a.size()) & 1) < ((int)(b.size()) & 1);
    });
    // 1->even
    if((((int)(dogs[1].size()) & 1)) == 0){
        cout << "0\n";
        return;
    }
    int min_1_2 = INF;
    vector<pii> min_0_1;
    vector<pii> min_0_2;
    for(int v: dogs[1]){
        if((v == (-INF)) || (v == (INF)))
            continue;
        auto p1 = lower_bound(all(dogs[2]), v);
        auto p2 = upper_bound(all(dogs[2]), v);
        p2 --;
        min_1_2 = min({min_1_2, (*p1) - v, v - (*p2)});
    }
    // deb(min_1_2);
    int z_s = dogs[0].size();
    F(int, i, 0, z_s - 1, 1){
        int v = dogs[0][i];
        if((v == (-INF)) || (v == (INF)))
            continue;
        auto p1 = lower_bound(all(dogs[1]), v);
        auto p2 = upper_bound(all(dogs[1]), v);
        p2 --;
        min_0_1.push_back(pii(min((*p1) - v, v - (*p2)), i));

        auto p3 = lower_bound(all(dogs[2]), v);
        auto p4 = upper_bound(all(dogs[2]), v);
        p4 --;
        min_0_2.push_back(pii(min((*p3) - v, v - (*p4)), i));
    }
    int oth_poss = INF;
    if(!min_0_1.empty()){
        sort(all(min_0_1));
        sort(all(min_0_2));
        if(min_0_1[0].second == min_0_2[0].second){
            oth_poss = min(oth_poss, min_0_1[0].first + min_0_2[1].first);
            oth_poss = min(oth_poss, min_0_2[0].first + min_0_1[1].first);
        }else{
            oth_poss = min(oth_poss, min_0_1[0].first + min_0_2[0].first);
        }
    }
    // deb(oth_poss);
    int ans = min(min_1_2, oth_poss);
    cout << ans << '\n';
}

signed 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);
        // freopen("Debug.txt", "w", stderr);
    #else
    #endif
    // cout << fixed << setprecision(10);
    int _t = 1;
    // cin>>_t;
    F(int, i, 1, _t, 1){
        // cout << "Case #" << i << ": ";
        solve();
    }
}


#include <iostream>
#include <string>

using namespace std;

int main() {
    string c;
    cin >> c;
    cout << (c[0] == c[1] && c[1] == c[2] ? "Won" : "Lost") << endl;
}

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

int main() {
unsigned long N,M,a,b,answer;
int count = 1;
answer = 0;
cin >> N;
M = N;
while (M>9){
 M = M / 10;
 count++;
}
  if (count % 2 != 0)
{
 if (count == 1){
cout << 0 << endl;
  return (0);}
  if (count == 3){
cout << 9 << endl;
  return (0);}
  if (count == 5){
cout << 99 << endl;
  return (0);}
  if (count == 7){
cout << 999 << endl;
  return (0);}
  if (count == 9){
cout << 9999 << endl;
  return (0);}
  if (count == 11){
cout << 99999 << endl;
  return (0);}
}
int x = pow(10, count/2);
a = N / x;
b = N % x;
if (a > b)
  answer = a-1;
else
  answer = a;
cout << answer << endl;
  return (0);
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define rep1(i,n) for(int i = 1 ; i < n ; i++)
#define rrep(i,n) for(int i = n - 1 ; i >= 0 ; i--)
#define rrep1(i,n) for(int i = n ; i > 0 ; i--)
#define INF 1001001001
#define MOD 1000000007
using ll = int64_t;
using P = pair<int, int>;

int main(){
    int n, m, k;
    cin >> n >> m;
    vector<int> a(m,0);
    vector<int> b(m,0);
    rep(i,m)cin >> a[i] >> b[i];
    cin >> k;
    vector<int> c(k,0);
    vector<int> d(k,0);
    rep(i,k)cin >> c[i] >> d[i];

    int ans = -INF;
    rep(bit, 1<<k){//O(2^k)
        set<int> field;

        rep(i,k){//O(k)
        if(bit>>i&1)field.insert(c[i]);
        else field.insert(d[i]);
        }

        int ten_ans = 0;
        rep(i, m){
            if(field.count(a[i]) && field.count(b[i]))ten_ans++;
        }
        ans = max(ans, ten_ans);
    }
    cout << ans << endl;
}

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

const int N = 1e5 + 100;

int main() {
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    #endif
    int n, l;
    cin >> n >> l;
    vector<int> a(N), b(N);
    a[n + 1] = b[n + 1] = l + 1;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) {
        cin >> b[i];
    }
    n = n + 2;
    for (int i = 0; i < n; ++i) {
        a[i] -= i;
        b[i] -= i;
    }

    unordered_map<int, pair<int, int>> mp1, mp2;

    for (int i = 0; i < n; ++i) {
        if (mp1.count(a[i]) == 0) {
            mp1[a[i]] = make_pair(i, i);
        } else {
            mp1[a[i]].second = i;
        }
    }

    for (int i = 0; i < n; ++i) {
        if (mp1.count(b[i]) == 0) {
            cout << -1 << endl;
            return 0;
        }
        if (mp2.count(b[i]) == 0) {
            mp2[b[i]] = make_pair(i, i);
        } else {
            mp2[b[i]].second = i;
        }
    }

    long long ans = 0;
    for (auto it : mp2) {
        auto A = mp1[it.first];
        auto B = mp2[it.first];
        ans += max(0, A.first - B.first) + max(0, B.second - A.second);
    }

    cout << ans << endl;
}