#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
using namespace std;
#define MAXN 100005
#define lowbit(x) (x&-x)
#define reg register
typedef long long LL;
typedef unsigned long long uLL;
typedef unsigned int uint;
typedef pair<int,int> pii;
const int INF=0x7f7f7f7f;
const int mo=998244353;
const double PI=acos(-1.0);
template<typename _T>
_T Fabs(_T x){return x<0?-x:x;}
template<typename _T>
void read(_T &x){
	_T f=1;x=0;char s=getchar();
	while(s>'9'||s<'0'){if(s=='-')f=-1;s=getchar();}
	while('0'<=s&&s<='9'){x=(x<<3)+(x<<1)+(s^48);s=getchar();}
	x*=f;
}
int a,b;LL dp[35][35],k;
char str[65];
signed main(){
	dp[0][0]=1;
	for(int i=0;i<=30;i++)
		for(int j=0;j<=30;j++){
			if(i)dp[i][j]+=dp[i-1][j];
			if(j)dp[i][j]+=dp[i][j-1];
		}
	read(a);read(b);read(k);int len=a+b;
	for(int i=1;i<=len;i++){
		if(a&&b){
			if(k>dp[a-1][b])k-=dp[a-1][b],str[i]='b',b--;
			else str[i]='a',a--;
		}
		else if(!a)str[i]='b',b--;
		else if(!b)str[i]='a',a--;
		//printf("%d %d %d:%d %d %d\n",a,b,k,dp[a][b],dp[a-1][b],dp[a][b-1]);
	}
	printf("%s\n",str+1);
	return 0;
}

#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()
#define BACK(x) x.rbegin(),x.rend()
#define MOD 1000000007
#define INF INT_MAX
#define FLOAT_ANS setprecision(30)
#define TORAD(x) (x*acos(-1)/180.0)
#define TODEG(x) (x*180/acos(-1))
#define elif else if

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

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

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

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

// MAIN PROGRAM -------------

int main(){
	string s;
	cin>>s;
	ll n=s.length();
	vector<char>t(n*2+100,'.');
	ll left=n+10,right=n+9;
	bool turn = false;
	for(auto c:s){
		if(c=='R'){
			turn=!turn;
			--n;
		}
		else{
			if(turn){
				--left;
				t[left]=c;
			}
			else{
				++right;
				t[right]=c;
			}
		}
	}

	stack<char>stk;
	rep(i,n){
		if(!stk.empty() && stk.top()==t[left+i]){
			stk.pop();
		}
		else{
			stk.push(t[left+i]);
		}
	}

	vector<char>ans;
	while(!stk.empty()){
		ans.push_back(stk.top());
		stk.pop();
	}

	if(turn){
		for(auto i:ans){
			cout<<i;
		}
	}
	else{
		for(ll i=ans.size()-1; i>=0; --i)cout<<ans[i];
	}
}

/*

*/


#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const int MAXV = 1000000;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int l, r;
    cin >> l >> r;
    int n = r - l + 1;
    int m = r;
    vector<int> a(n);
    iota(a.begin(), a.end(), l);

    vector<int> is_prime(m + 1, true);
    vector<int> num(m + 1, 0);
    vector<int> fs(m + 1, 1);
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i <= m; i++) {
        if (!is_prime[i]) continue;
        num[i]++;
        fs[i] *= i;
        for (int j = 2 * i; j <= m; j += i) {
            is_prime[j] = false;
            num[j]++;
            fs[j] *= i;
        }
    }

    vector<int> cnt(m + 1, 0);
    for (int i = 0; i < n; i++) {
        if (a[i] <= m && fs[a[i]] == a[i]) cnt[a[i]]++;
        for (int j = 2; j * j <= a[i]; j++) {
            if (a[i] % j != 0) continue;
            if (j <= m && fs[j] == j) cnt[j]++;
            if (j * j == a[i]) continue;
            int k = a[i] / j;
            if (k <= m && fs[k] == k) cnt[k]++;
        }
    }

    vector<int> ans(m + 1, 0);
    for (int i = 2; i <= m; i++) {
        if (fs[i] != i) continue;
        for (int j = i; j <= m; j += i) {
            if (num[i] % 2 == 0) ans[j] -= cnt[i];
            else ans[j] += cnt[i];
        }
    }

    ll total_ans = 0;
    for (int i = l; i <= r; i++) {
        if (i == 1) continue;
        total_ans += ans[i] - 2 * (r / i - (l - 1) / i) + 1;
    }
    cout << total_ans << "\n";
    return 0;
}

#include <iostream>

using namespace std;

const int N = 1000010;

typedef long long LL;

LL f[N];
LL ans = 0;

int main() {
    int l, r;
    cin >> l >> r;
    for (int i = r; i >= 2; i --) {
        LL tem = r / i - (l - 1) / i;
        f[i] = tem * tem;
        for (int j = i * 2; j <= r; j += i)
            f[i] -= f[j];
        ans += f[i];
        //cout << i << ' ' << f[i] << endl;
    }

    for (int i = max(l, 2); i <= r; i ++) {
        LL tem = 0;
        for (int j = i; j <= r; j += i) {
            tem ++;
        }
        ans -= tem * 2 - 1;
    }
    cout << ans;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const ll mod=1e9+7;
string t="atcoder";
void solve(){
	string s;cin >> s;
	int ans=1e9;
	int cur=0;
	bool totok=true;
	for(int i=0; i<7 ;i++){
		for(int j=0; j<s.size() ;j++){
			if(s[j]>t[i]) ans=min(ans,cur+j);
		}
		bool ok=false;
		for(int j=0; j<s.size() ;j++){
			if(s[j]==t[i]){
				s.erase(j,1);
				cur+=j;
				ok=true;
				break;
			}
		}
		if(!ok){
			totok=false;
			break;
		}
	}
	if(s.size()>0 && totok) ans=min(ans,cur);
	if(ans>1e8) cout << "-1\n";
	else cout << ans << '\n';
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	int t;cin >> t;while(t--) solve();
}

#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")

using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)

#define ynmes(a) (a) ? mes("Yes") : mes("No")
#define YNmes(a) (a) ? mes("YES") : mes("NO")
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

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

ll nlcm(vector<ll> numbers) {
    ll res;
    res = numbers[0];
    for (ll i = 1; i < (ll)numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}

uintmax_t ncr(unsigned int n, unsigned int r) {
    if ( r * 2 > n ) r = n - r;
    uintmax_t dividend = 1;
    uintmax_t divisor  = 1;
    for ( unsigned int i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

signed main() {
    ll t;
    cin >> t;

    rep(i, t) {
        string s;
        cin >> s;
        ll len = (ll)s.size();

        if ("atcoder" < s) {
            mes(0);
            continue;
        }

        ll tmp = 0;
        rep(j, len) {

            if (s[j] == 'a') {
                tmp++;

                if (tmp == len) {
                    mes(-1);
                    break;
                }

            } else {
                if (s[j] > 't') {
                    mes(tmp-1);
                } else {
                    mes(tmp);
                }
                break;
            }

        }

    }

}


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

int main(){

  int n,w;
  cin >> n >> w;

  vector<int> s(n),t(n),p(n);
  for(int i=0; i<n; ++i)
    cin >> s[i] >> t[i] >> p[i];

  vector<ll> oyu(*max_element(t.begin(), t.end()),0);

  for(int i=0; i<n; ++i) {
    oyu[s[i]] += p[i];
    oyu[t[i]] -= p[i];
  }

  for(int i=1; i<oyu.size(); ++i)
    oyu[i] += oyu[i-1];

  cout << (*max_element(oyu.begin(), oyu.end())>w ? "No" : "Yes") << endl;

}

// Pratiyush Mishra

#include <bits/stdc++.h>
#define ull unsigned long long int
#define ll long long int
#define LL_MAX 9223372036854775807
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define vl vector<ll>
#define bs(v, x) binary_search(v.begin(), v.end(), x)
#define mem1(a) memset(a, -1, sizeof(a))
#define popf pop_front
#define p() cout << '\n'
#define p0(x) cout << x << " "
#define p1(x) cout << x << '\n'
#define p2(x, y) cout << x << " " << y << '\n'
#define p3(x, y, z) cout << x << " " << y << " " << z << '\n'
#define printv(v)                   \
  for (ll i = 0; i < v.size(); ++i) \
    cout << v[i] << " ";            \
  cout << '\n'
#define pr1(x) cout << fixed << setprecision(15) << x << '\n'
#define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
#define mod 1000000007
#define mod1 998244353
#define fio                         \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)
#define get(n) \
  ll n;        \
  cin >> n
#define getvec(v, n)         \
  vector<ll> v(n);           \
  for (ll i = 0; i < n; i++) \
    cin >> v[i];
#define getstr(s) \
  string s;       \
  cin >> s
#define all(x) x.begin(), x.end()
#define countBits(x) __builtin_popcount(x)
using namespace std;

const ll M = 2e5;

void mainSolve()
{
  get(n);
  get(w);
  vl v(M + 1, 0);
  for (int i = 0; i < n; i++)
  {
    ll p, s, e;
    cin >> s >> e >> p;
    v[s] += p;
    v[e] -= p;
  }
  for (int i = 1; i <= M; i++)
    v[i] += v[i - 1];
  for (ll x : v)
  {
    if (x > w)
    {
      p1("No");
      return;
    }
  }
  p1("Yes");
}

int main()
{
  fio;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  //get(t);
  ll t = 1;
  while (t--)
  {
    mainSolve();
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;
  #define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
  #define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)

int32_t main()
{

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

    set<string> ss,sss;

    int n;
    cin >> n;

    while(n--)
    {
        string s;
        cin >> s;

        if(s[0] == '!')
        {
            string str;
            for(int i = 1; i< s.size(); i++)
            {
                str.push_back(s[i]);
            }
            sss.insert(str);
        }
        else
        {
            ss.insert(s);
        }

    }

    for(auto &i : ss)
    {
        if(sss.count(i))
        {
            cout << i ;
            return 0;
        }
    }

    cout << "satisfiable";
    return 0;
}


//Badwaper gg
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define pb push_back
#define re register int
#define fr first
#define sd second
#define FOR(i,a,b) for(re i=a;i<=b;i++)
#define REP(i,a,b) for(re i=a;i>=b;i--)
#define lowbit(x) x&(-x)
#define Z(x) (x>=mod?x-mod:x)
#define pa pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
ll n;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();
	ll l=0,r=2e9,ans=0;
	while(l<=r)
	{
		ll mid=(l+r)>>1;
		if(mid*(mid+1)/2<=n+1)ans=mid,l=mid+1;
		else r=mid-1;
	}
	//cout<<"WTF:"<<ans<<" "<<ans*(ans+1)/2;
	printf("%lld\n",n-ans+1);
	return 0;
}

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

//solution:
#define int int64_t
#define span(a) begin(a), end(a)

struct segtree {
  int n;
  static inline int size = 1;
  vector<int> t, lazy;
  segtree() = default;
  segtree(int n): n(n) {
    while(size < n) size <<= 1;
    t.assign(size << 1, 0);
    lazy.assign(size << 1, 0);
  }
  void push(int x, int l, int r) {
    //a[l, r] += x ---> delta = (r - l) * lazy;
    int m = l + r >> 1;
    t[2 * x + 1] += lazy[x] * (m - l);
    t[2 * x + 2] += lazy[x] * (r - m);
    lazy[2 * x + 1] += lazy[x];
    lazy[2 * x + 2] += lazy[x];
    lazy[x] = 0;
  }
  int query(int lo, int hi, int x = 0, int l = 0, int r = size) {
    if(lo >= r || l >= hi) return 0;
    if(lo <= l and r <= hi) return t[x];
    push(x, l, r);
    int m = l + r >> 1;
    return query(lo, hi, 2 * x + 1, l, m) + query(lo, hi, 2 * x + 2, m, r);
  }
  void update(int lo, int hi, int v, int x = 0, int l = 0, int r = size) {
    if(lo >= r || l >= hi) return;
    if(lo <= l and r <= hi) {
      t[x] += v * (r - l), lazy[x] += v; //remember how t[x] is updated here!
      return;
    }
    push(x, l, r);
    int m = l + r >> 1;
    update(lo, hi, v, 2 * x + 1, l, m);
    update(lo, hi, v, 2 * x + 2, m, r);
    t[x] = t[2 * x + 1] + t[2 * x + 2];
  }
};

void hike() {
  int n; cin >> n;
  vector<int> a(n);
  segtree s(n), t(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = n - 1; ~i; --i) {
    s.update(a[i], a[i] + 1, t.query(0, a[i]));
    t.update(a[i], a[i] + 1, 1);
  }
  for(int i = 0; i < n; ++i) {
    cout << s.query(0, n) << "\n";
    s.update(a[i] + 1, n, 1);
    s.update(0, a[i], -1);
  }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr); cout.tie(nullptr);
  int t = 1; //cin >> t;
  while(t--) hike();
  return 0;
} //farewell, until we meet again..


#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))
#define P 1000000007
long powP (long a, long b) {
  if (b == 1) return a;
  else if (b == 0) return 1;
  else if (b < 0) return powP(a, P - 1 + b);
  else {
    long b2 = powP(a, b/2);
    b2*=b2;
    b2%=P;
    return (b2 * powP(a, b%2)) % P;
  }
}

template <typename T>
using vec = vector<T>;

template <typename T>
using vvec = vector<vector<T>>;

#define INF INT_MAX
#define pii pair<int, int>

int main() {
  long n;
  cin>>n;
  vec<long> fib(2,1);
  do {
    fib.push_back(*(fib.end()-1)+*(fib.end()-2));
  } while (fib.back()<pow(10,18));
  int m = fib.size();
  vec<int> fibs(m);
  int o = (upper_bound(ALL(fib), n)-fib.begin()-1);
  while (n!=0) {
    int i = (upper_bound(ALL(fib), n)-fib.begin()-1);
    fibs[i]++;
    n-=fib[i];
  }

  int flag = o%2;
  vec<int> exe(0);
  for (int i = o; i >= 0; i--) {
    exe.push_back(3+flag);

    for (int j = 0; j < fibs[i]; j++) {
      exe.push_back(1+flag);
    }

    flag=1-flag;
  }

  cout<<exe.size()<<endl;
  for (int i = 0; i < exe.size(); i++) {
    cout<<exe[i]<<endl;
  }
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
#define pp pair<ll,ll>
ll MOD=1000000007;
ll mod=998244353;
int inf=2000001000;
ll INF=1e18+5;

int main() {
    ll n;
    cin >> n;
    vector<ll> a;
    a.push_back(1);
    a.push_back(1);
    int u=0;
    while(true){
        if (a[u]+a[u+1]>n) break;
        a.push_back(a[u]+a[u+1]);
        u++;
    }
    u=a.size();
    n-=a[u-1];
    vector<int> c(u);
    rep(i,a.size()){
        while(true){
            if (n<a[u-i-1]) break;
            c[u-i-1]++;
            n-=a[u-i-1];
        }
    }
    if (n==1){
        cout << 1 << endl;
        cout << 1 << endl;
        return 0;
    }
    vector<int> ans;
    int st;
    // cout << u << endl;
    // rep(i,u) cout << a[i] << endl;
    // cout << endl;
    if (u%2==1){
        st=0;
        ans.push_back(1);
    }
    else {
        st=1;
        ans.push_back(2);
    }
    rep(i,a.size()-1){
        rep(j,c[u-1-i]){
            if (st==0) ans.push_back(1);
            else ans.push_back(2);
        }
        if (st==0) ans.push_back(4);
        else ans.push_back(3);
        st=1-st;
    }
    cout << ans.size() << endl;
    rep(i,ans.size()){
        cout << ans[i] << endl;
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, bool> pib;

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;

typedef vector<double> vf;

typedef long double ld;

#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

#define printItr(A) for(auto itr = A.begin(); itr != A.end(); ++itr){cout << * itr << ", ";}cout << endl;

const double PI = 3.141592653589793;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

bool isOK(vi& a, ll k, ll index) {
	return a[index] < k * (index + 1);
}

ll binary_search(vi& a, ll k) {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = (ll)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;

		if (isOK(a, k, mid))
			right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}

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

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

bool eq(vi P, vi Q) {
	rep(i, P.size()) {
		if (P[i] != Q[i]) {
			return false;
		}
	}
	return true;
}

ll gcd(ll a, ll b)
{
	if (a%b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a%b));
	}
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}

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

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

	ll s = 0;
	rep(i, N - 1) {
		ll a;
		cin >> a;
		s += a;
	}

	ll ans = N * M - s;
	if (ans < 0) {
		ans = 0;
	}

	if (ans > K) {
		ans = -1;
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
    int n,k,m,a;
    cin >>n>>k>>m;
    int sum=0;
    rep(i,n-1){
        cin>>a;
        sum+=a;
    }
    rep(i,k+1){
        if((sum+i)>=m*n){
            cout << i <<endl;
            return 0;
        }
    }
    cout << -1 <<endl;
}


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

#define F first
#define S second

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 	ll n; cin >> n;
 	vector<ll> r, g, b;
 	for(int i = 0; i < 2*n; i++){
 		ll x; cin >> x;
 		char c; cin >> c;
 		if(c == 'R') r.push_back(x);
 		else if(c == 'G') g.push_back(x);
 		else b.push_back(x);
 	}
 	sort(r.begin(), r.end());
 	sort(g.begin(), g.end());
 	sort(b.begin(), b.end());
 	ll x = 0, y = 0, z = 0, ans = LLONG_MAX;
 	x = y = z = ans;
 	if(r.size() & 1){
 		if(b.size() & 1) swap(g, b);
 	} else if(g.size() & 1){
 		swap(r, b);
 	} else {
 		ans = 0;
 	}
 	for(auto &i: r){
 		auto p = lower_bound(g.begin(), g.end(), i);
 		if(p != g.end()) x = min(x, abs(i - *p));
 		if(p != g.begin()) x = min(x, abs(i - *prev(p)));
 	}
 	for(auto &i: g){
 		auto p = lower_bound(b.begin(), b.end(), i);
 		if(p != b.end()) y = min(y, abs(i - *p));
 		if(p != b.begin()) y = min(y, abs(i - *prev(p)));
 	}
 	for(auto &i: r){
 		auto p = lower_bound(b.begin(), b.end(), i);
 		if(p != b.end()) z = min(z, abs(i - *p));
 		if(p != b.begin()) z = min(z, abs(i - *prev(p)));
 	}
 	ans = min(ans, x);
 	if(y != LLONG_MAX && z != LLONG_MAX) ans = min(ans, y + z);
 	cout << ans << '\n';
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vc = vector<T>;
template<class T> using vvc = vc<vc<T>>;
template<class T> using vvvc = vc<vvc<T>>;
template<class T> using vvvvc = vvc<vvc<T>>;
template<class T> using PQ = priority_queue<T>;
template<class T> using invPQ = priority_queue<T, vector<T>, greater<T>>;
using IP = pair<int, int>;
using LP = pair<ll, ll>;
#define all(x) begin(x), end(x)
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
#define rep3(i, m, n) for (int i = (m); (i) < (int)(n); i++)
#define repr(i, n) for (int i = (n) - 1; (i) >= 0; i--)
#define rep3r(i, m, n) for (int i = (n) - 1; (i) >= (int)(m); i--)
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr long long LINF = 4611686015206162431;

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

    int N;
    cin >> N;
    ll a[2*N];
    vc<int> c(2*N);
    vvc<ll> dogs(3);
    rep (i, N*2) {
        cin >> a[i];
        char col;
        cin >> col;
        if (col == 'G') c[i] = 1;
        else if (col == 'B') c[i] = 2;
        dogs[c[i]].emplace_back(a[i]);
    }
    rep (i, 3) {
        sort(all(dogs[i]));
    }

    int oddcnt = dogs[0].size() % 2 + dogs[1].size() % 2 + dogs[2].size() % 2;
    ll ans = LINF;
    if (oddcnt == 0) ans = 0;
    else {
        int even = 0;
        rep (i, 3) if (dogs[i].size() % 2 == 0) even = i;
        int odd1 = (even + 1) % 3, odd2 = (even + 2) % 3;

        rep (i, dogs[odd1].size()) {
            int pos = lower_bound(all(dogs[odd2]), dogs[odd1][i]) - dogs[odd2].begin();
            if (pos < dogs[odd2].size()) chmin(ans, abs(dogs[odd2][pos] - dogs[odd1][i]));
            if (pos > 0) {
                chmin(ans, abs(dogs[odd2][pos-1] - dogs[odd1][i]));
            }
        }

        ll tmp1 = LINF, tmp2 = LINF;
        rep (i, dogs[odd1].size()) {
            int pos1 = lower_bound(all(dogs[even]), dogs[odd1][i]) - dogs[even].begin();
            if (pos1 < dogs[even].size()) chmin(tmp1, abs(dogs[even][pos1] - dogs[odd1][i]));
            if (pos1 > 0) chmin(tmp1, abs(dogs[even][pos1-1] - dogs[odd1][i]));
        }
        rep (i, dogs[odd2].size()) {
            int pos2 = lower_bound(all(dogs[even]), dogs[odd2][i]) - dogs[even].begin();
            if (pos2 < dogs[even].size()) chmin(tmp2, abs(dogs[even][pos2] - dogs[odd2][i]));
            if (pos2 > 0) chmin(tmp2, abs(dogs[even][pos2-1] - dogs[odd2][i]));
        }
        chmin(ans, tmp1 + tmp2);
    }

    cout << ans << endl;
}


#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

ll a[300009];
ll tree[900099];
int c;

void seg(ll node,ll b,ll e)
{
    if(b==e)
    {

        //cout<<node<<" "<<a[b]<<endl;
        tree[node]=a[b];

        //cout<<tree[node].value<<endl;
        return;
    }

    ll left=node*2;
    ll right=(node*2)+1;

    ll mid=(b+e)/2;

    seg(left,b,mid);
    seg(right,mid+1,e);

    tree[node]=tree[left]^tree[right];

}

ll query(int node,int b,int e,int i,int j)
{
    if(i>e || j<b)
        return 0;

    if(i<=b && e<=j)
        return tree[node];

    ll left=node*2;
    ll right=(node*2)+1;

    ll mid=(b+e)/2;

    ll x=query(left,b,mid,i,j);
    ll y=query(right,mid+1,e,i,j);

    return x^y;
}

void update(ll node,ll b,ll e,ll i,ll value)
{
    if(i>e || i<b)
        return;

    if(i<=b && e<=i)
    {
        tree[node]^=value;

        return;
    }

    ll left=node*2;
    ll right=(node*2)+1;

    ll mid=(b+e)/2;

    update(left,b,mid,i,value);
    update(right,mid+1,e,i,value);

    tree[node]=tree[left]^tree[right];

}

int main()
{
    faster

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

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

    seg(1,1,n);

    /*for(int i=1; i<=3*n; i++)
        cout<<tree[i].value<<" ";
    cout<<endl;*/

    ll t,l,r;
    while(q--)
    {
        cin>>t>>l>>r;

        if(t==1)
        {
            update(1,1,n,l,r);

        }
        else
        {
            cout<<query(1,1,n,l,r)<<endl;
        }
    }

    return 0;
}

#include<ctime>
#include<cstdio>
#include<cctype>
#define le(p) ((p)<<1)
#define ri(p) ((p)<<1|1)
using namespace std;
const int N=1.2e6+7;
int read(){
	char c;
	int x=0,f=1;
	while(!isdigit(c=getchar()))
		f-=2*(c=='-');
	while(isdigit(c)){
		x=x*10+f*(c-48);
		c=getchar();
	}
	return x;
}
int n,q,t,x,y,a[N];
int L[N],R[N],X[N];
void up(int p){
	X[p]=X[le(p)]^X[ri(p)];
}
void build(int p,int l,int r){
	L[p]=l;
	R[p]=r;
	if(l==r){
		X[p]=a[l];
		return;
	}
	int m=(l+r)>>1;
	build(le(p),l,m);
	build(ri(p),m+1,r);
	up(p);
}
void upd(int p,int x,int k){
	if(L[p]==R[p]){
		X[p]^=k;
		return;
	}
	int m=(L[p]+R[p])>>1;
	if(x<=m)
		upd(le(p),x,k);
	else
		upd(ri(p),x,k);
	up(p);
}
int ask(int p,int l,int r){
	if(l<=L[p]&&R[p]<=r)
		return X[p];
	int m=(L[p]+R[p])>>1;
	int res=0;
	if(l<=m)
		res^=ask(le(p),l,r);
	if(r>m)
		res^=ask(ri(p),l,r);
	return res;
}
int main(){
	#ifndef ONLINE_JUDGE
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
	#endif
	clock_t t1=clock();
	//--------
	n=read();
	q=read();
	for(int i=1;i<=n;++i)
		a[i]=read();
	build(1,1,n);
	for(int i=1;i<=q;++i){
		t=read();
		x=read();
		y=read();
		if(t==1)
			upd(1,x,y);
		else
			printf("%d\n",ask(1,x,y));
	}
	//--------
	fprintf(stderr,"%0.3lfs",1.0*(clock()-t1)/CLOCKS_PER_SEC);
	return 0;
}


#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
#define sz(x) (ll)x.size()
#define lnt(s) (ll)s.length()
#define mt(cnt) cnt.empty()
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> osSet;

using pll = pair<ll, ll>;
using pl = pair<ll, pll>;
using tll = tuple<ll, ll, ll>;

const ll maxN = 1e5;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

ll func(ll x){
	return (x*(x+1))/2;
}

ll _pow(ll b, ll p){
	if(p == 0) return 1;
	if(p == 1) return b;
	ll exB = b*b;
	if(p&1) return b*_pow(exB, p/2);
	return _pow(exB, p/2);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n, m;
	cin >> n >> m;
	ll ar[m];
	for(ll i=0; i<m; i++)
		cin >> ar[i];
	sort(ar, ar+m);
	vector<ll> v;
	ll low = 0;
	for(ll i=0; i<m; i++){
		if(i == m-1 and ar[i] != n){
			v.emplace_back(n-ar[i]);
		}
		v.emplace_back(ar[i]-low-1);
		low = ar[i];
	}
	if(!(n-m))
		cout << "0";
	else if(!m)
		cout << "1";
	else{
		ll mn = INF, ans = 0;
		for(ll i=0; i<v.size(); i++){
			if(v[i] != 0)
	        	mn = min(mn, v[i]);
        }
		for(ll i=0; i<v.size(); i++)
			ans += v[i]/mn + (v[i]%mn != 0 ? 1 : 0);
		cout << ans;
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
template <class T>
bool chmax(T& a, const T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define FOR(i, l, r) for (int i = (l); i < (r); ++i)
#define RFOR(i, l, r) for (int i = (r)-1; (l) <= i; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define CIN(c) cin >> (c)
#define COUT(c) cout << (c) << '\n'
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<ll, ll>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
static const double EPS = 1e-10;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;
// static const ll MOD = 998244353;
static const int INF = (1 << 30) - 1; // 1073741824 - 1
// static const ll INF = (1LL << 60) - 1;  // 4611686018427387904 - 1

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

    ll N, M;
    cin >> N >> M;
    if (M == 0) {
        COUT(1);
        return 0;
    }

    VLL A(M);
    REP(i, M) {
        CIN(A[i]);
    }
    SORT(A);

    ll minVal = INF;
    ll bef = 1;
    VI between;
    A.push_back(N + 1);
    // A.push_back(N);
    REP(i, M + 1) {
        ll p = A[i] - bef;
        bef = A[i] + 1;
        if (p <= 0) continue;
        chmin(minVal, p);
        between.push_back(p);
    }

    ll ans = 0;
    for (auto v : between) {
        ans += ceil(v / (double)minVal);
    }
    COUT(ans);
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main(void) {
	long long N, K;
	cin >> N >> K;

	for (int i = 0; i < K; i++) {
		if (N % 200 == 0) {
			N /= 200;
		}
		else {
			N *= 1000;
			N += 200;
		}
	}

	cout << N << endl;
	return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)

#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF (int)1e9
#define LLINF (ll)1e12
#define MOD (int)1e9+7
#define PB push_back
#define endl "\n"

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

void solve() {
    ll n,k;
    cin >> n >> k;
    REP(i,k){
      if(n%200==0){
        n /= 200;
      }else{
        n = n*1000+200;
      }
    }
    cout << n << endl;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(v) (v.begin(),v.end())
#define sz(v) ((int)((v).size()))
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define endl '\n'

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair< ll, ll> pll;
typedef vector<pll> vll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ull> vul;
typedef vector<pii> vii;
typedef vector<vi> vvi;

void fast() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inputf.txt", "r", stdin);
	freopen("outputf.txt", "w", stdout);
#endif
}
void solve()
{

}
bool have_7(int num)
{
	while (num)
	{
		int d = num % 10;
		num /= 10;
		if (d == 7) return true;
	}
	return false;
}
int decimaltooctal(int decimalNum)
{
	int octalNum = 0, placeValue = 1;
	int dNo = decimalNum;
	while (decimalNum != 0) {
		octalNum += (decimalNum % 8) * placeValue;
		decimalNum /= 8;
		placeValue *= 10;
	}
	return octalNum;
}
int to_int(string s)
{
	stringstream k(s);
	int x = 0;
	k >> x;
	return x;
}
int main() {
	fast();
	int n;
	cin >> n;
	int res = n;
	for (int i = 1; i <= n; i++)
	{
		if (have_7(decimaltooctal(i)) || have_7(i))
			res--;
	}
	cout << res << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    int m = n / 2;
    ll a[n], b[n];
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, n) {
        cin >> b[i];
    }
    ll ans = 0;
    vector<ll> even, odd;
    rep(i, n) {
        ll c = a[i] - b[i];
        if (i % 2 == 0) {
            even.emplace_back(c);
        } else {
            odd.emplace_back(c);
        }
        ans += max(a[i], b[i]);
    }
    sort(ALL(even));
    sort(ALL(odd));
    rep(i, m) {
        if (even[i] * odd[i] < 0) {
            ans -= min(abs(even[i]), abs(odd[i]));
        }
    }
    cout << ans << endl;
    return 0;
}


#include<stdio.h>

int main()
{
    double Sx,Sy,Gx,Gy;
    scanf("%lf%lf%lf%lf",&Sx,&Sy,&Gx,&Gy);
    double ans;
    ans=Gx+Gy*(Sx-Gx)/(Gy+Sy);
    printf("%.10lf\n",ans);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define inf 1000000005 /*10^9+5*/
#define mod 1000000007 /*10^9+7*/
#define eps 1e-10
#define rep(i,n) for(int i = 0; i < (n); ++i) /*0からn-1までのrepeat*/
#define rrep(i,n) for(int i = 1; i <= (n); ++i) /*1からnまでのrepeat*/
#define drep(i,n) for(int i = (n)-1; i >= 0; --i) /*n-1から0までのrepeat*/
#define srep(i,s,t) for (int i = s; i < t; ++i) /*sからt-1までのrepeat*/
#define isin(x,l,r) ((l) <= (x) && (x) < (r)) /*l以上r未満のx*/
#define each(a,b) for(auto& (a): (b)) /*よくわかんない☆*/
#define pct __builtin_popcountll /*1bitの数*/
#define all(a) a.begin(),a.end() /*ぜーんぶ*/
#define sz(v) (int)(v).size() /*大きさ*/
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end()) /*重複削除*/
#define cmx(x,y) x=max(x,y) /*最大*/
#define cmn(x,y) x=min(x,y) /*最小*/
#define rev(v) reverse((v).begin(),(v).end()); /*逆順*/
#define so(v) sort((v).begin(), (v).end()); /*ソート*/
#define yn {puts("Yes");}else{puts("No");} /*はいかいいえか*/
#define YN {puts("YES");}else{puts("NO");} /*大文字-はいかいいえか*/
#define dame { puts("-1"); return 0;}/*だめ*/
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define vipls vector<int> pls; /*@_vipls*/

using ll = long long;
using unit = unsigned;
using ull = unsigned long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vp = vector<P>;
using vt = vector<T>;
using vs = vector<string>;
using vc = vector<char>;

int main() {
    double a, b, c, d;
    cin >> a >> b >> c >> d;

    cout <<setprecision(15)<<c-((d*(c-a))/(d+b)) <<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=998244353;
constexpr ll INF=1e18;

int main(){
    ll n, k; cin >> n >> k;
    VI a(n), b(n), c(n);
    REP(i,n) cin >> a[i] >> b[i] >> c[i], b[i]++;
    set<int> t;
    REP(i,n){
        t.insert(a[i]);
        t.insert(b[i]);
    }
    map<int,int> mp;
    int tm=0;
    VI tt;
    for(auto x:t) tt.push_back(x);
    REP(i,tt.size()){
        mp[tt[i]]=tm;
        tm++;
    }
    VI im(tt.size(),0);
    REP(i,n){
        im[mp[a[i]]]+=c[i];
        im[mp[b[i]]]-=c[i];
    }
    ll ans=0, now=0;
    REP(i,tt.size()-1){
        now+=im[i];
        if(k<now)
            ans+=(tt[i+1]-tt[i])*k;
        else
            ans+=(tt[i+1]-tt[i])*now;
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long
#define pb push_back
#define all(v) begin(v), end(v)
#define sz(v) (int)v.size()
#define ff first
#define ss second
const int inf = 4e18;
const int N = 2e5 + 10;

int n, m;
int dp[1 << 20];
vector<pair<int, int>> q[20];

int rec(int pos, int mask) {
	int &ans = dp[mask];
	if (pos == n) return 1;
	if (ans != -1) return ans;

	ans = 0;
	for (int i = 0; i < n; i++) {
		if (!(mask & (1 << i))) {
			int nMask = mask | (1 << i);
			bool can = 1;
			for (auto &p : q[pos]) {
				int got = ((1 << p.ff) - 1) & nMask;
				can &= (__builtin_popcountll(got) <= p.ss);
			}

			if (can) ans += rec(pos + 1, nMask);
		}
	}

	return ans;
}

void testCase() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y, z; cin >> x >> y >> z; x--;
		q[x].pb({y, z});
	}

	memset(dp, -1, sizeof(dp));
	cout << rec(0, 0);
}

int32_t main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int t_c = 1;
	// cin >> t_c;
	while (t_c--) testCase();
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define int                 		long long
#define double              		long double
#define endl                		"\n"
#define pb                  		push_back
#define PI                  		3.1415926535897932384626433832795l
#define F                   		first
#define S                   		second
#define mp                  		make_pair
#define f(i,n)              		for(int i=0;i<n;++i)
#define loop(i,a,b)         		for (int i=a ; i<b ;++i)
#define fastio              		ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)              		(v).begin(),(v).end()
#define rall(v)             		(v).rbegin(),(v).rend()
#define gcd(a,b)            		__gcd((a),(b))
#define fill(a,value)       		memset(a,value,sizeof(a));
#define minn(v)             		*min_element(v.begin(), v.end());
#define maxx(v)             		*max_element(v.begin(), v.end());
#define print(x)            		cout<<(x)<<endl;
typedef pair<int, int>      		pii;
typedef vector<int>         		vi;
const int mod = 1e9 + 7;
const int MOD = 998244353;

int power(int x, int y, int p)
{
	int res = 1;

	x = x % p;

	while (y > 0) {
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}
int modInverse(int n, int p)
{
	return power(n, p - 2, p);
}

// Returns nCr % p using Fermat's little
// theorem.
int nCr(int n,  int r, int p)
{
	// Base case
	if (r == 0)
		return 1;
	int fac[n + 1];
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = (fac[i - 1] * i) % p;

	return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;
}

void solve()
{
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < 9;)
	{
		if (s[i] == 'Z' and s[i + 1] == 'O' and s[i + 2] == 'N' and s[i + 3] == 'e')
		{
			ans++;
			i += 3;
		}
		else
		{
			i++;
		}

	}
	print(ans)
}

signed main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;
	cout << fixed << setprecision(12);
	int T = 1;
	//cin >> T;
	f(tc, T)
	{
		//cout << "Case #" << tc + 1 << ": ";
		solve();
	}
	return 0;
}

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define boostIO                   \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repn(i, n) for (int i = 1; i <= n; i++)
#define rrep(i, b, a) for (int i = b; i >= a; i--)
#define sz(v) (int)(v.size())
#define all(v) v.begin(), v.end()
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define trav(a, x) for (auto &a : x)
#define popcount(x) __builtin_popcountll(x)
#define pb push_back
#define fi first
#define se second
#define mod 1000000007
#define int long long
typedef pair<int, int> pii;
const long long INF = 1e18;
const int N = 1e5 + 5;

signed main() {
    boostIO;
    char c1, c2, c3;
    cin >> c1 >> c2 >> c3;
    if (c1 == c2 && c2 == c3) {
        cout << "Won\n";
    } else {
        cout << "Lost\n";
    }
    return 0;
}
// XD


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

#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define bit(n)      (1ll<<(li)(n))
#define INF bit(60)

#define MOD 998244353

int main() {
    li a,b;
    cin>>a>>b;
    cout<<(a-b)*100.0/a<<endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define REP(i, n) for (int i=1; i<=(int)(n); i++)
#define FOR(i, n, m) for (int i=(n); i<=(int)(m); i++)
#define ll long long
const ll INF=1LL<<60;
const double pi=3.1415926535;

int main() {
    vector<vector<int>> dp(900, vector<int>(900));
    vector<int> vec_output;

    rep(i, 1000) {

        //入力
        vector<int> input(4);
        rep(j, 4) cin >> input.at(j);

        //通った道
        vector<int> usei(0), usej(0);
        usei.push_back(input.at(0));
        usej.push_back(input.at(1));

        int x = input.at(1);
        int y = input.at(0);
        int xplus = 0;
        int yplus = 0;
        if (x < input.at(3)) xplus = 1;
        if (x > input.at(3)) xplus = -1;
        if (y < input.at(2)) yplus = 1;
        if (y > input.at(2)) yplus = -1;
        bool X = false;

        //経路探索
        while (x != input.at(3)) {
            //ｘの残りをうめる
            if (y == input.at(2)) {
                while (x != input.at(3)) {
                    x += xplus;
                    usei.push_back(y);
                    usej.push_back(x);
                    cout << (xplus == 1 ? "R" : "L") << flush;
                }
                break;
            }

            //探索済みか近いかを調べる
            if (dp.at(y*30 + x).at(y*30 + x+xplus) == 0 && dp.at(y*30 + x).at((y+yplus)*30 + x) == 0) {
                X = !X;
            } else if (dp.at(y*30 + x).at(y*30 + x+xplus) == 0) {
                X = true;
            } else if (dp.at(y*30 + x).at((y+yplus)*30 + x) == 0) {
                X = false;
            } else if (dp.at(y*30 + x).at(y*30 + x+xplus) < dp.at(y*30 + x).at((y+yplus)*30 + x)) {
                X = true;
            } else if (dp.at(y*30 + x).at(y*30 + x+xplus) > dp.at(y*30 + x).at((y+yplus)*30 + x)) {
                X = false;
            } else {
                X = !X;
            }

            if (X) {
                x += xplus;
                usei.push_back(y);
                usej.push_back(x);
                cout << (xplus == 1 ? "R" : "L") << flush;
            } else {
                y += yplus;
                usei.push_back(y);
                usej.push_back(x);
                cout << (yplus == 1 ? "D" : "U") << flush;
            }
        }

        //yの残りをうめる
        while (y != input.at(2)) {
            y += yplus;
            usei.push_back(y);
            usej.push_back(x);
            cout << (yplus == 1 ? "D" : "U") << flush;
        }
        cout << endl;

        //入力
        ll output;
        cin >> output;

        //点数の平均を計算
        vec_output.push_back(output);
        ll sum = 0;
        for (ll a : vec_output) {
            sum += a;
        }
        ll ave = sum / vec_output.size();
        output -= ave;
        output *= 60;
        int size = usei.size();

        rep(j, usei.size()-1) {
            int a = usei.at(j);
            int b = usej.at(j);
            int c = usei.at(j+1);
            int d = usej.at(j+1);
            //cout << a*30+b << " " << c*30+d << endl;
            dp.at(a*30+b).at(c*30+d) += output / size;
            dp.at(c*30+d).at(a*30+b) += output / size;
        }

        /*rep(j, 29) {
            rep(k, 29) {
                cout << " " << dp.at(j*30+k).at(j*30+k+1);
            }
            cout << endl;
            rep(k, 30) {
                cout << dp.at(j*30+k).at((j+1)*30+k) << " ";
            }
            cout << endl;
        }*/
    }
}


#include<bits/stdc++.h>
#define rep(i,a,b) for (register int i=(a);i<=(b);++i)
#define req(i,a,b) for (register int i=(a);i>=(b);--i)
using namespace std;
int a,b;
int main()
{
    cin>>a>>b;
    cout<<(a+b>>1)<<' '<<(a-b>>1)<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
  	int a,b;
  	cin>>a>>b;
  	ll x=(a+b)/2,y=(a-b)/2;
  	cout<<x<<" "<<y;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a)
#define dumparr(a,n)
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

pll operator+(pll a,pll b){
  return pll(a.first+b.first,a.second+b.second);
}
pll operator-(pll a,pll b){
  return pll(a.first-b.first,a.second-b.second);
}
pll operator*(ll a,pll b){
  return pll(b.first*a,b.second*a);
}
const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const long long MOD = 998244353;

void solve(long long A, long long B, long long C){
  auto f = [](ll x){return x*(x+1)/2%MOD;};
  cout<< f(C)*f(A)%MOD*f(B)%MOD<<endl;
}

int main(){
  cout<<setprecision(1000);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);
int gcd(int a, int b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}

int lcm(int a, int b) { return abs(a) / gcd(a, b) * abs(b); }
int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll sa = (a * (a + 1) / 2) % 998244353;
  ll sb = (b * (b + 1) / 2) % 998244353;
  ll sc = (c * (c + 1) / 2) % 998244353;

  ll ans = (((sa * sb) % 998244353) * sc) % 998244353;
  cout << ans << endl;
}


#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;

#define REP(i,b,e) for(int i=b; i<e; i++)
#define PRINT(vec) {printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");}
#define fi first
#define se second

const int MOD = 1e9+7;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	std::string s;
	std::cin >> s;

	std::deque<char> deq;
	bool flip = false;
	for(char c: s){
		if(c=='R') flip = !flip;
		else{
			if(flip){
				if(deq.size() && deq.front()==c) deq.pop_front();
				else deq.push_front(c);
			}else{
				if(deq.size() && deq.back()==c) deq.pop_back();
				else deq.push_back(c);
			}
		}
	}

	if(flip){
		REP(i, 0, deq.size()) printf("%c", deq[deq.size()-1-i]); puts("");
	}else{
		REP(i, 0, deq.size()) printf("%c", deq[i]); puts("");
	}
	return 0;
}

#define MOD_TYPE 1

#pragma region Macros

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

#if 0
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using Int = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
#endif
#if 1
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9 + 10;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-7;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

struct io_init
{
  io_init()
  {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(30) << setiosflags(ios::fixed);
  };
} io_init;
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr istream &operator>>(istream &is, pair<T, U> &p) noexcept
{
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

// --------------------------------------

void solve()
{
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll Max = -1;
  ll sum = 0, wsum = 0;
  rep(i, n)
  {
    chmax(Max, a[i]);
    sum += a[i];
    wsum += sum;
    ll ans = wsum + (i + 1) * Max;
    cout << ans << "\n";
  }
}

int main()
{
  solve();
}


#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

ll N,M,H,W,Q,K,A,B;
string S;
using P = pair<ll, ll>;
const ll INF = (1LL<<60);

template<class T> bool chmin(T &a, const T b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T b){
    if(a < b) {a = b; return true;}
    else return false;
}
template<class T> void my_printv(std::vector<T> v,bool endline = true){
    if(!v.empty()){
        for(std::size_t i{}; i<v.size()-1; ++i) std::cout<<v[i]<<" ";
        std::cout<<v.back();
    }
    if(endline) std::cout<<std::endl;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin>>S;
    N = S.size();
    vec num(26, 0);
    ++num[S.back() - 'a'];
    ll res = 0;
    Rreps(i, N - 1, 1){
        if(S[i-1] == S[i]){
            res += N - 1 - i - num[S[i] - 'a'];
            rep(j, 26) num[j] = 0;
            num[S[i] - 'a'] = N - i;
        }else{
            ++num[S[i] - 'a'];
        }
    }
    cout<<res<<endl;
}

/**
 * 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;
}();

using ld=long double;
const ld PI = acos((ld)-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) ld 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<ld, ld>;
using vd= vector<ld>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

/* from first pair of chars we can change the whole
 * string, but only that positions with are not
 * allready that char.
 *
 * Then note that we can do that for the rightmost char-pair,
 * then for the second rightmost...etc.
 *
 * Note also that we apply operatios from right to
 * left, so after applying the operation until the
 * end of the string, the whole string is same char up to the end.
 */
void solve() {
    cins(s);
    vvi cnt(26, vi(s.size()+1));
    const int n=s.size();

    for(size_t i=0; i<s.size(); i++) {
        for(int j=0; j<26; j++)
            cnt[j][i+1]=cnt[j][i];
        cnt[s[i]-'a'][i+1]++;
    }

    char prev=' ';
    stack<pair<int,char>> pos;
    for(int i=1; i+1<s.size(); i++) {
        if(s[i]==s[i-1] && s[i]!=prev) {
            pos.push({i+1,s[i]-'a'});
            prev=s[i];
        }
    }

    int ans=0;
    int pp=s.size();
    while(pos.size()) {
        /* each pair contributes nuber of chars until end of string
         * minus number of same char up to next double char position.
         */
        auto [p,c]=pos.top();
        pos.pop();
        ans+=n-p-( cnt[c][pp]-cnt[c][p]);
        pp=p;
    }
    cout<<ans<<endl;
}

signed main() {
    solve();
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#include <complex>
#define rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define reps(x, s) for(llint (x) = 0; (x) < (llint)(s).size(); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define sz(x) ((ll)(x).size())
#define ceil(x, y) (((x)+(y)-1) / (y))
#define all(x) (x).begin(),(x).end()
#define outl(...) dump_func(__VA_ARGS__)
#define inf 1e18

using namespace std;

typedef long long llint;
typedef long long ll;
typedef pair<ll, ll> P;
bool exceed(ll x, ll y, ll m){return x >= m / y + 1;}

struct edge{
	ll to, cost;
	edge(){}
	edge(ll a, ll b){
		to = a, cost = b;
	}
};

template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for(int i = 0; i<vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}
template<typename T, typename U>
ostream& operator << (ostream& os, pair<T, U>& pair_var) {
	os << "(" << pair_var.first << ", " << pair_var.second << ")";
	return os;
}
template<typename T, typename U>
ostream& operator << (ostream& os, map<T, U>& map_var) {
	for(typename map<T, U>::iterator itr = map_var.begin(); itr != map_var.end(); itr++) {
		os << "(" << itr->first << ", " << itr->second << ")";
		itr++;
		if(itr != map_var.end()) os << ",";
		itr--;
	}
	return os;
}
template<typename T>
ostream& operator << (ostream& os, set<T>& set_var) {
	for(typename set<T>::iterator itr = set_var.begin(); itr != set_var.end(); itr++) {
		os << *itr;
		++itr;
		if(itr != set_var.end()) os << " ";
		itr--;
	}
	return os;
}
void dump_func() {cout << endl;}
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
    cout << head;
    if(sizeof...(Tail) > 0) cout << " ";
    dump_func(std::move(tail)...);
}

ll n;
string s, x;
ll dp[200005][7];

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

	cin >> n >> s >> x;
	s = "#" + s, x = "#" + x;

	dp[n][0] = 1;
	rep(i, 1, 6) dp[n][i] = -1;

	for(int i = n-1; i >= 0; i--){
		rep(j, 0, 6){
			if(x[i+1] == 'T') dp[i][j] = max(dp[i+1][j*10%7], dp[i+1][(j*10+s[i+1]-'0')%7]);
			if(x[i+1] == 'A') dp[i][j] = min(dp[i+1][j*10%7], dp[i+1][(j*10+s[i+1]-'0')%7]);
		}
	}

	if(dp[0][0] > 0) outl("Takahashi");
	if(dp[0][0] < 0) outl("Aoki");

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int N;
string digit, turn;
int dp[100001][7];
bool calc(int index, int rem) {
    if (index == N) {
        return rem == 0;
    }
    int &retVal = dp[index][rem];
    if (retVal != -1)
        return retVal;
    if (turn[index]) {
        retVal = calc(index + 1, (10 * rem) % 7);
        retVal |= calc(index + 1, (10 * rem + digit[index]) % 7);
    }
    else {
        retVal = calc(index + 1, (10 * rem) % 7);
        retVal &= calc(index + 1, (10 * rem + digit[index]) % 7);
    }
    return retVal;
}

int main() {
    memset(dp, -1, sizeof(dp));
    cin >> N;
    cin >> digit >> turn;
    for (int x = 0; x < N; x++)
    {
        digit[x] -= '0';
        turn[x] = turn[x] == 'T';
    }
    cout << (calc(0, 0) ? "Takahashi" : "Aoki");

}


#include "bits/stdc++.h"

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

void debug(map<int,pii> a) {
  for (auto p : a) {
    cout << p.first << ": " << "(" << p.second.first << "," << p.second.second << ")\n";
  }
}

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

  int N,L;
  cin >> N >> L;

  auto read = [](int N, int L) {
    vector<int> v{0};
    for (int i = 1; i <= N+1; i++) {
      int ai = L+1;
      if (i <= N)
        cin >> ai;
      v.push_back(ai-i);
    }
    map<int,pii> interval;
    for (int i = 0; i < v.size(); i++) {
      if (i==0 || v[i] != v[i-1])
        interval[v[i]].first = i;
      interval[v[i]].second = i;
    }
    return interval;
  };
  auto A = read(N,L);
  auto B = read(N,L);
  ll ans = 0;
  for (auto p : B) {
    int val = p.first;
    if (!A.count(val)) {
      cout << -1 << '\n';
      return 0;
    }
    ans += max(A[val].first-B[val].first,0) + max(B[val].second-A[val].second,0);
  }
  cout << ans << '\n';
}

#include <bits/stdc++.h>
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

const int N = 1e5;
int n, L, a[N + 5], b[N + 5];

int main() {
	scanf("%d%d", &n, &L);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", &b[i]);
	}
	a[n + 1] = b[n + 1] = L + 1;
	for (int i = n + 1; i >= 1; i--) {
		a[i] -= a[i - 1] + 1;
		b[i] -= b[i - 1] + 1;
	}
	int64 ans = 0;
	for (int j = 1, i = 1; i <= n + 1; i++) {
		if (b[i] > 0) {
			for (; a[j] == 0; j++);
			ans += std::max(0, i - j);
			int sum = 0;
			for (; j <= n + 1 && sum < b[i]; sum += a[j++]);
			if (sum != b[i]) {
				printf("-1\n");
				return 0;
			}
			ans += std::max(0, j - 1 - i);
		}
	}
	printf("%lld\n", ans);
	return 0;
}


#include<bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
const int INF = 1e9+1;
using namespace std;
using ll = long long;
using p = pair<int, int>;

int main() {
  string S;
  string Z = "ZONe";
  cin >> S;
  int i = 0;
  int j = 0;
  int ans = 0;
  while (true) {
    while (S[i+j] == Z[j]) {
      j++;
      if (j >= 4) {
        j--;
        ans++;
        break;
      }
    }
    i += max(1, j-1);
    if (i >= 11) break;
    j = 0;
  }
  cout << ans << endl;
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
        string s;
        cin>>s;
int count=0;
        for(int i=0;i<12;i++)
        {
        	if(s[i] == 'Z' && s[i+1] == 'O' && s[i+2] == 'N' && s[i+3]=='e')
        		{count++;}
        }
       cout<<count<<endl;
       return 0;
}


#define _USE_MATH_DEFINES

#include <algorithm>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <queue>

#define	INF   1010101010LL
#define INFLL 1010101010101010101LL

using namespace std;
using Complex = complex<double>;

const int mod = 1000000007;
//const int mod = 998244353;

int main()
{
	int n;
	string s, t;
	cin >> n >> s >> t;
	long long ans = 0;
	queue<int> q;
	for (int i = 0; i < n; i++) {
		if (s[i] != t[i]) {
			q.push(i);
			i++;
			while (i < n) {
				if (s[i] == '1') {
					s[i] = '0';
					ans += i - q.front();
					q.pop();
				}
				if (s[i] != t[i]) {
					q.push(i);
				}
				if (q.empty()) {
					break;
				} else {
					i++;
				}
			}
			if (!q.empty()) {
				cout << -1 << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
#define ll long long
#define ld long double
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rnd(time(0));

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

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

const int mod=998244353;

signed main()
{

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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
        freopen("INPUT.txt","r",stdin);
        freopen("OUTPUT.txt","w",stdout);
    }
#endif

    int n,m,k;
    cin>>n>>m>>k;
    int ans=0;
    if(n==1&&m==1)
    {
        cout<<k;
        return 0;
    }
    else if(n==1||m==1)
    {
        cout<<powm(k,n+m-1,mod);
        return 0;
    }

    for(int i=1;i<=k;i++)
    {
        int z=(powm(i,n,mod))-powm(i-1,n,mod)+mod;
        z%=mod;
        z*=(powm(k-i+1,m,mod));
        z%=mod;
        ans+=z;
        ans%=mod;
    }
    cout<<ans;

}


#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(register int i=(a);i>=(b);--i)
//#define int long long
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define mod 998244353
struct modint{
    int x;
    modint(int o=0){x=o;}
    modint &operator = (int o){return x=o,*this;}
    modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
    modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
    modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
    modint &operator ^=(int b){
        modint a=*this,c=1;
        for(;b;b>>=1,a*=a)if(b&1)c*=a;
        return x=c.x,*this;
    }
    modint &operator /=(modint o){return *this *=o^=mod-2;}
    modint &operator +=(int o){return x=x+o>=mod?x+o-mod:x+o,*this;}
    modint &operator -=(int o){return x=x-o<0?x-o+mod:x-o,*this;}
    modint &operator *=(int o){return x=1ll*x*o%mod,*this;}
    modint &operator /=(int o){return *this *= ((modint(o))^=mod-2);}
    template<class I>friend modint operator +(modint a,I b){return a+=b;}
    template<class I>friend modint operator -(modint a,I b){return a-=b;}
    template<class I>friend modint operator *(modint a,I b){return a*=b;}
    template<class I>friend modint operator /(modint a,I b){return a/=b;}
    friend modint operator ^(modint a,int b){return a^=b;}
    friend bool operator ==(modint a,int b){return a.x==b;}
    friend bool operator !=(modint a,int b){return a.x!=b;}
    bool operator ! () {return !x;}
    modint operator - () {return x?mod-x:0;}
};

#define maxn 200005
int n,a[maxn],b[maxn],cnt;
map<int,int>mp,mp2,id;
inline int ID(int x){
	if(!id.count(x))return id[x]=++cnt;
	return id[x];
}
inline int ABS(int x){
	return x<0?-x:x;
}
vector<int>va[maxn],vb[maxn];
int pa[maxn],pb[maxn],p[maxn],tmp[maxn];
long long tot;
int t[maxn];
void msort(int l,int r)
{
    if(l==r)return;
    int m=(l+r)/2;
    msort(l,m);
    msort(m+1,r);
    int p=l,i=l,j=m+1;
    while(i<=m&&j<=r)
    {
        if(a[i]>a[j])
        {
            tot+=m-i+1;
            t[p++]=a[j++];
        }
        else t[p++]=a[i++];
    }
    while(i<=m)t[p++]=a[i++];
    while(j<=r)t[p++]=a[j++];
    for(i=l;i<=r;i++)a[i]=t[i];
}
signed main()
{
	n=read();
	For(i,1,n)a[i]=read()+i,mp[a[i]]++,ID(a[i]);
	For(i,1,n)b[i]=read()+i,mp2[b[i]]++;
	for(auto it:mp)
		if(mp2[it.fi]!=it.se){
			puts("-1");
			return 0;
		}
	For(i,1,n)va[ID(a[i])].pb(i);
	For(i,1,n)vb[ID(b[i])].pb(i);
	long long res=0,now=0;
	For(i,1,cnt){
		int sz=va[i].size();
		For(j,0,sz-1){
			int u=++now;
			pa[va[i][j]]=u;
			pb[vb[i][j]]=u;
		}
	}
	For(i,1,n)tmp[pb[i]]=i;
	For(i,1,n)pa[i]=tmp[pa[i]],a[i]=pa[i];
	msort(1,n);
	cout<<tot;
	return 0;
}

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

// 0-indexed
template <class T>
struct BIT {
  int treesize;
  vector<T> lst;
  // constructor
  BIT(int newn = 0) : treesize(newn), lst(newn + 1, 0) {}
  // a_place += num
  void add(int place, T num) {
    ++place;
    while (place <= treesize) {
      lst[place] += num;
      place += place & -place;
    }
  }
  // sum between [0,place)
  T sum(int place) {
    T res = 0;
    while (place > 0) {
      res += lst[place];
      place -= place & -place;
    }
    return res;
  }
  // sum [l,r)
  T sum(int left, int right) { return sum(right) - sum(left); }
};

int n;
vector<int> a, b;

long long solve();

int main() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i] += i;
  }
  b.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
    b[i] += i;
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  {
    vector<int> va = a, vb = b;
    sort(va.begin(), va.end());
    sort(vb.begin(), vb.end());
    for (int i = 0; i < n; ++i)
      if (va[i] != vb[i]) return -1;
    map<int, vector<int>> mp;
    for (int i = 0; i < n; ++i) mp[b[i]].push_back(i);
    for (int i = n - 1; i >= 0; --i) {
      long long now = a[i];
      a[i] = mp[now].back();
      mp[now].pop_back();
    }
  }
  long long res = 0;
  BIT<long long> bit(n);
  for (int i = 0; i < n; ++i) {
    res += bit.sum(a[i], n);
    bit.add(a[i], 1);
  }
  return res;
}


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

vector<ll>ans(MAX*MAX,-1);
vector<vector<ll> >G(MAX);
vector<vector<ll> >idx(MAX,vector<ll>(MAX));
vector<vector<ll> >re(MAX,vector<ll>(MAX,0));
vector<ll>used(MAX,0);
void dfs(ll v,ll p){
    if(p>=0&&ans[idx[p][v]]==-1){
        ans[idx[p][v]]=re[p][v];
    }
    if(used[v])return;
    used[v]=1;
    for(auto e:G[v]){
        if(e==p)continue;
        dfs(e,v);
    }
}

signed main(){
    ll n,m;cin>>n>>m;
    vector<ll>a(m),b(m),c(n);
    rep(i,m)cin>>a[i]>>b[i];
    rep(i,n)cin>>c[i];
    rep(i,m){
        a[i]--;b[i]--;
        re[b[i]][a[i]]=1;
        idx[a[i]][b[i]]=i;
        idx[b[i]][a[i]]=i;
        if(c[a[i]]>c[b[i]])ans[i]=0;
        else if(c[a[i]]<c[b[i]])ans[i]=1;
        else{
            G[a[i]].pb(b[i]);
            G[b[i]].pb(a[i]);
        }
    }
    rep(i,n){
        if(G[i].size()==0)continue;
        if(used[i])continue;
        dfs(i,-1);
    }
    rep(i,m){
        cout<<(ans[i]?"<-":"->")<<endl;
    }
}

#line 2 "/home/defineprogram/Desktop/Library/template/template.cpp"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,n) for(ll i=1;i<n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<ll,ll>
#define len(s) (ll)s.size()

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr ll inf = 3e18;
#line 3 "/home/defineprogram/Desktop/Library/structure/UnionFind.cpp"

class UnionFind{
	using size_type=int32_t;
	size_type N;
	vector<size_type>par,siz;
public:
	size_type find(size_type x){
		assert(x<N);
		return (par[x]==x?x:par[x]=find(par[x]));
	}
	void merge(size_type x,size_type y){
		assert(x<N&&y<N);
		x=find(x);y=find(y);
		if(x==y)return;
		if(siz[x]>siz[y])swap(x,y);
		par[x]=y;siz[y]+=siz[x];
	}
	bool same(size_type x,size_type y){
		return find(x)==find(y);
	}
	size_type size(size_type x){
		return siz[find(x)];
	}
	UnionFind(size_type N):N(N),siz(N,1),par(N){
		iota(all(par),0);
	}
};

/*
@brief Union Find
@docs docs/UnionFind.md
*/
#line 3 "main.cpp"

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll N,M;cin>>N>>M;
    if(N<=2){
        if(M==0){
            rep(i,N)cout<<i*2+1<<" "<<i*2+2<<endl;
        }else {
            cout<<"-1\n";
        }
    }else {
        if(M<0||M>N-2)cout<<"-1\n";
        else {
            cout<<1<<" "<<10000000<<endl;
            rep(i,M+1)cout<<2+i*2<<" "<<3+i*2<<endl;
            rep(i,N-M-2)cout<<100000000+i*2<<" "<<100000000+i*2+1<<endl;
        }
    }
}


#pragma region templates
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using PQR = priority_queue<T,vector<T>,greater<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const ld PI = acos((ld)-1);
constexpr ll dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
inline void Yes() { cout << "Yes" << ENDL; }
inline void No() { cout << "No" << ENDL; }
inline void YES() { cout << "YES" << ENDL; }
inline void NO() { cout << "NO" << ENDL; }

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <typename T>
vector<T> finddivisor(T x) {  //整数xの約数(xを含む)
  vector<T> divisor;
  for(T i = 1; (i * i) <= x; i++) {
    if(x % i == 0) {
      divisor.push_back(i);
      if(i * i != x) { divisor.push_back(x / i);}
    }
  }
  sort(divisor.begin(), divisor.end());
  return divisor;
}

template <typename T> V<T> prefix_sum(const V<T>& v) {
  int n = v.size();
  V<T> ret(n + 1);
  rep(i, 0, n) ret[i + 1] = ret[i] + v[i];
  return ret;
}

template<typename T>
T rand(T l,T r){
  static random_device rd;
  static mt19937 g(rd());
  return uniform_int_distribution<T>(l,r)(g);
}//[]

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(auto&& x: vec) is >> x;
  return is;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
  return os<<"{"<<p.fs<<","<<p.sc<<"}";
}

template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
  os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}

template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}
#pragma endregion templates

signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n;cin>>n;
  string s;cin>>s;
  V<ll> pac(26,0);
  rep(i,0,n)pac[s[i]-'a']++;

  sort(all(pac));
  if(s[0]!=s[n-1])cout<<1<<ENDL;
  else if(pac.back()>n/2)cout<<-1<<ENDL;
  else cout<<2<<ENDL;

}
//(・_・)(・_・)(・_・)(・_・)
//CHECK overflow,what to output?
//any other simpler approach?

// Problem: C - Max GCD 2
// Contest: AtCoder - Japanese Student Championship 2021
// URL: https://atcoder.jp/contests/jsc2021/tasks/jsc2021_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Parsed on: 17-04-2021 12:52:09 IST (UTC+05:30)
// Author: Kapil Choudhary
// ********************************************************************
// कर्मण्येवाधिकारस्ते मा फलेषु कदाचन |
// मा कर्मफलहेतुर्भूर्मा ते सङ्गोऽस्त्वकर्मणि || १.४७ ||
// ********************************************************************

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.1415926535897932384626
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int>	vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii>	vpii;
typedef vector<pll>	vpll;
typedef vector<vi> vvi;
typedef vector<vll>	vvll;
typedef vector<vull> vvull;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}

const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;

int max_gcd(vi &v, int n) {
    int high = 0;
    for (int i = 0; i < n; i++)
        high = max(high, v[i]);

    int count[high + 1] = {0};
    for (int i = 0; i < n; i++)
        count[v[i]]++;

    int counter = 0;

    for (int i = high; i >= 1; i--)
    {
        int j = i;
        counter = 0;
        while (j <= high)
        {
           if(count[j] >=2)
              return j;

           else if (count[j] == 1)
                counter++;
           j += i;
           if (counter == 2)
              return i;
        }
    }
}

void solve()
{
  	int a, b; cin >> a >> b;
  	int n = b - a + 1;
  	vi v(n);

  	int x = a;
  	for(int i = 0; i < n; i++) v[i] = x++;

  	cout << max_gcd(v, n) << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

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

    int t = 1;
    // int test = 1;
    // cin >> t;
    while(t--) {
      // cout << "Case #" << test++ << ": ";
      solve();
    }

    return 0;
}


#pragma GCC optimize("-Ofast","-funroll-all-loops")
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
#include <bits/stdc++.h>
using namespace std;
//#define int long long
//#define ULL unsigned long long
#define fi first
#define se second
#define ls 2 * rt
#define rs 2 * rt + 1
#define PII pair<int,int>
#define PDD pair<double, double>
#define gcd(a,b) __gcd(a,b)
#define lowbit(x) (x & (-x))
typedef long long ll;
const int N = 1e5 + 5;
const int M = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
// const ll mod = 1e9 + 7;
// const ll inf = 0x3f3f3f3f3f3f3f3f;

int n, m;
int k;
int dist[20][100010];
int c[20];
int dp[18][1 << 18];
int vis[100010];
vector<int> path[100010];

void bfs(int u){
    for(int i = 1; i <= n; i++){
        dist[u][i] = inf;
    }
    memset(vis, 0, sizeof vis);
    dist[u][c[u]] = 0;
    queue<int> q;
    q.push(c[u]);
    vis[c[u]] = 1;
    while(!q.empty()){
        int f = q.front();
        q.pop();
        for(auto v : path[f]){
            if(!vis[v]){
                vis[v] = 1;
                dist[u][v] = dist[u][f] + 1;
                q.push(v);
            }
        }
    }

}

int solve(int i, int zt){
    if(zt == (1 << k) - 1){
        return 0;
    }
    if(dp[i][zt] != -1){
        return dp[i][zt];
    }
    int res = inf;
    for(int j = 0; j < k; j++){
        if(((1 << j)&zt)){
            continue;
        }
        res = min(res, solve(j, zt | (1 << j)) + dist[j][c[i]] );
    }
    return dp[i][zt] = res;
}

void solve(){
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int a, b;
        cin >> a >> b;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    cin >> k;
    for(int i = 0; i < k; i++){
        cin >> c[i];
        bfs(i);
    }
    int ok = 1;
    for(int i = 0; i < k; i++){
        if(dist[i][c[0]] >= inf){
            ok = 0;
            break;
        }
    }
    if(!ok){
        cout << "-1" << "\n";
        return ;
    }
    memset(dp, -1, sizeof dp);
    int ans = inf;
    for(int i = 0; i < k; i++){
        ans = min(ans, 1 + solve(i, 1 << i));
    }
    cout << ans << "\n";
    return ;
}

int main(){
    solve();

#ifndef ONLINE_JUDGE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif

    return 0;
}

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

#define REP(i,a,b) for(int i=a;i<=b;i++)
using LL = long long;

const int Nmax=1e5+9,INF=987'654'321;
int N,M,a,b,dist[19][19],K,C[19],D[Nmax],Nt;
int visited[Nmax],q,dp[19][(1<<19)],ans=INF;
vector <int> adj[Nmax];

int F(int s, int e) {
    fill(D+1,D+N+1,INF);
    fill(visited+1,visited+N+1,0);
    queue <int> Q;
    D[s]=0;     visited[s]=1;   Q.push(s);
    while (!Q.empty()) {
        q=Q.front();    Q.pop();
        for (auto u : adj[q]) {
            if (visited[u]) continue;
            D[u]=D[q]+1;    visited[u]=1;   Q.push(u);
        }
    }
    return D[e];
}

int DFS(int place, int visited) {
    if (dp[place][visited]<INF) return dp[place][visited];
    if (visited==(1<<K)-1) return 0;
    REP(k,1,K) {
        if (((visited>>(k-1))&1)==0)
            dp[place][visited]=min(dp[place][visited],dist[place][k]+DFS(k,visited|(1<<(k-1))));
    }
    // cout<<place<<" "<<visited<<" "<<dp[place][visited]<<"\n";
    return dp[place][visited];
}

int main() {
    ios_base::sync_with_stdio(0);    cin.tie(0);
    cin>>N>>M;
    REP(j,1,M) {
        cin>>a>>b;
        adj[a].push_back(b);        adj[b].push_back(a);
    }
    cin>>K;     Nt=(1<<K)-1;
    REP(k,1,K) cin>>C[k];
    REP(i,1,K-1) {
        REP(j,i+1,K) {
            dist[i][j]=dist[j][i]=F(C[i],C[j]);
            if (dist[i][j]==INF) ans=-1;
            // cout<<i<<" "<<j<<" "<<dist[i][j]<<endl;
        }
    }
    if (ans==-1) cout<<-1;
    else {
        REP(i,1,K) {
            REP(j,0,Nt) dp[i][j]=INF;
        }
        REP(i,1,K) {
            ans=min(ans,1+DFS(i,1<<(i-1)));
        }
        cout<<ans;
    }
    return 0;
}


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

using namespace std;

int main() {
  long long N, M; cin >> N >> M;
  vector<long long> H(N), W(M);
  for (long long i = 0; i < N; i++) cin >> H[i];
  for (long long i = 0; i < M; i++) cin >> W[i];
  sort(H.begin(), H.end());
  vector<long long> sum1((N + 1) / 2), sum2((N + 1) / 2);
  for(long long i = 0; i + 1 < N; i += 2) sum1[i / 2 + 1] = sum1[i / 2] + H[i + 1] - H[i];
  for(long long i = N - 2; i > 0; i -= 2) sum2[i / 2] = sum2[i / 2 + 1] + H[i + 1] - H[i];
  long long result = 1e18;
  for (long long i = 0; i < M; i++) {
    long long ind = lower_bound(H.begin(), H.end(), W[i]) - H.begin();
    if (ind % 2 == 1) ind--;
    long long tmp = sum1[ind/2]+sum2[ind/2]+abs(W[i]-H[ind]);
    result = result > tmp ? tmp : result;
  }
  cout << result << endl;
  return 0;
}

/*
मनस्वी म्रियते कामं कार्पण्यं न तु गच्छति ।
अपि निर्वाणमायाति नानलो याति शीतताम् ॥
*/

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

#define mod 1000000007
#define pb push_back
#define ll long long int
#define ull unsigned ll
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define p2d(v) for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v) for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v) for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse
#define itr iterator
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
#define test3(x,y,z) cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define test4(w,x,y,z) cout << #w " = " << w << " " << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

/*
const ll infinity = 9e18;

bool compare(ll a,ll b) {return a > b;}
bool compare1(ppl a,ppl b) {return a.ff > b.ff;}
bool compare2(ppl a,ppl b) {return a.ss < b.ss;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}

ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md = mod) {ll product = 1; while(b){if(b&1){product = (product*a)%md;}a = (a*a)%md;b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

int main()
{
    fast

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

    ll n,m;
    cin>>n>>m;

    vl a(n),b(m);

    forn(i,0,n)
    {
        cin>>a[i];
    }

    forn(i,0,m)
    {
        cin>>b[i];
    }

    sort(all(a));
    sort(all(b));

    ll mid = a[(n/2)];

    ll total = 0;

    vl c(n,0),d(n,0);

    for(int i = 1; i < n; i += 2)
    {
        c[i] = total + (a[i]-a[i-1]);
        if(i+1 < n) c[i+1] = c[i];
        total = c[i];
    }

    total = 0;

    for(int i = n-2; i >= 0; i -= 2)
    {
        d[i] = total + (a[i+1]-a[i]);
        if(i-1 >= 0) d[i-1] = d[i];
        total = d[i];
    }

    // p1d(c)
    // p1d(d)

    ll mini = inf;

    forn(i,0,m)
    {
        ll idx = upper_bound(all(a),b[i]) - a.begin();
        // test1(idx)

        ll x = idx-1 >= 0 ? c[idx-1] : 0;
        ll y = idx < n ? d[idx] : 0;

        if((idx&1))
        {
            // x = idx-1 >= 0 ? c[idx-1] : 0;
            // y = idx < n ? d[idx] : 0;
            // test1(a[idx-1])
            mini = min(mini,x + abs(b[i]-a[idx-1]) + y);
        }
        else
        {
            // test1(a[idx-1])
            mini = min(mini,x + abs(a[idx]-b[i]) + y);
        }

        // test3(x,y,x + abs(a[idx]-b[i]) + y)
    }

    cout<<mini;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define ee cout << "\n"
#define pb push_back
#define mkp make_pair
#define sall(v) sort(v.begin(), v.end())
#define fo(i, n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vll vector<pair<ll, ll>>
#define mpl map<ll, ll>
#define pr pair<ll, ll>
//Fast input output
void setIO(string s = "")
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin.exceptions(cin.failbit);
    if (s.size())
    {
        freopen((s + ".in").c_str(), "r", stdin);
        freopen((s + ".out").c_str(), "w", stdout);
    }
}
void solve()
{
    ll n;
    cin >> n;
    cout << (n + 99) / 100;
    ee;
}
int main()
{
    setIO();
    ll totalTestCase = 1;
    //  cin>>totalTestCase;
    for (ll testCase = 1; testCase <= totalTestCase; testCase++)
    {
        solve();
    }
    return 0;
}

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


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
  long N;
  cin >> N;
  vector<long> A(N);
  rep(i, N) cin >> A[i];
  long ans = 0;
  rep(i, N) {
    long C = 1000000;
    for(int j = i; j < N; j++) {
      C = min(C, A[j]);
      ans = max(ans, C*(j+1-i));

    }
  }
  cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pb push_back
#define mp make_pair
#define int long long
#define ff first
#define ss second
#define double long double
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define dbg(x) cout << "~~~~~" << #x << "--->" << x << endl;
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define sz(a) ((int)(a).size())
#define setbit(n) (__builtin_popcount(n))
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
const int inf = 1e10 + 7;
const double eb=1e-9;
const int mod = 1e9 + 7;
template <class T>
T add(T v1,T v2, int mo=mod)
{
    return (v1%mo + v2%mo)%mo;
}
template<class T>
T subtract(T v1,T v2,int mo=mod)
{
    return (v1%mo - v2%mo)%mo;
}
template<class T>
T mult(T v1, T v2,int mo=mod)
{
    return (v1%mo * v2%mo )%mo;
}
template<class T,class P>
void build_st(vector<T> &a,vector<P> &segT,int start,int end,int tidx)
{
    if(start==end)
    {
    	segT[tidx]=a[start];
    	return;
    }
    int mid=start+(end-start)/2;
    build_st(a,segT,start,mid,tidx*2);
    build_st(a,segT,mid+1,end,2*tidx+1);

    segT[tidx]=segT[tidx*2]+segT[tidx*2+1];
}
template<class T,class P>
void update_st(vector<T> &a,vector<T> &segT,int start,int end,int tidx,int idx,T val)
{
    if(start==end)
    {
    	segT[tidx]=a[idx]=val;
    	return;
    }
    int mid=start+(end-start)/2;
    if(idx>mid)
    	update_st(a,segT,mid+1,end,2*tidx+1,idx,val);
    else
    	update_st(a,segT,start,mid,2*tidx,idx,val);
    segT[tidx]=segT[2*tidx]+segT[2*tidx+1];
}
template<class T>
T query_st(vector<T> &segT,int start,int end,int tidx,int left,int right)
{
    if(start>right || end<left)
    	return 0;
    if(start>=left && end<=right)
    	return segT[tidx];
    int mid=start+(end-start)/2;
    T val1=query_st(segT,start,mid,2*tidx,left,right);
    T val2=query_st(segT,mid+1,end,2*tidx+1,left,right);
    return val1+val2;
}
template <class T>
void in(vector<T> &a, int n, int g = 0)
{
    for (int i = g; i < n + g; i++)
        cin >> a[i];
}
template <class T>
void pv(vector<T> &a)
{
    for (auto i : a)
        cout << i << " ";
    cout << endl;
}
template <class T>
void pvv(vector<vector<T>>&a)
{
	for(auto i:a)
	{
		for(auto j:i)
			cout<<j<<" ";
		cout<<endl;
	}
}
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

void solver()
{
    int n;cin>>n;
    vi a(n);
    in(a,n);
    int ans=0;
    for(int i=0;i<n;i++)
    {
    	int mn=inf;
    	for(int j=i;j<n;j++)
    	{
    		mn=min(mn,a[j]);
    		ans=max(ans,(j-i+1)*mn);
    		// dbg(mn);
    	}
    }
    cout<<ans;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed<<setprecision(15);

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


#include <iostream>
using namespace std;
const int maxn=2e5;
const int maxa=2e5+1;
int N;
int A[maxn];
int rt[maxa];
int fndrt(int a){
	return rt[a]=(a==rt[a])?a:fndrt(rt[a]);
}
int main() {
	while(cin>>N){
		//higha will minimize the amount of array being updated.
		int higha=1;
		for(int i=0;i<N;i++){
			cin>>A[i];
			higha=max(higha,A[i]);
		}
		//Set all numbers to represent themselves
		for(int i=0;i<higha;i++){
			rt[i]=i;
		}
		//P and Q are theh numbers that A[i] or A[j] represents
		//basically we changed all A[i] or A[j] to P or Q
		int P,Q;
		int operations=0;
		for(int i=0,j=N-1;i<j;i++,j--){
			P=fndrt(A[i]);
			Q=fndrt(A[j]);
			//If they are not the same number,
			//then change the first number to represent the second number
			if(P!=Q){
				//Add one more operation
				operations++;
				//Change the representation of the first number to the second number
				rt[P]=Q;
			}
		}
		cout<<operations<<'\n';
	}
}

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define fl(n) for(int i=0;i<n;i++)
#define flj(n) for(int j=0;j<n;j++)
#define flo(n) for(int i=1;i<=n;i++)
#define mii map<int,int>
#define mci map<char,int>
#define V vector<int>
#define vp vector<pair<int,int>>
#define pb push_back
#define pp pair<int,int>
#define ff first
#define ss second
#define S set<int>
#define all(v) v.begin(),v.end()
#define gr greater<int>()
#define show2(a, b) cout<<a<<' '<<b<<endl;
#define show3(a, b, c) cout<<a<<' '<<b<<' '<<c<<endl;
const long long mod=1000000007;
const int N=2e5+5;
const long double PI=3.14159265358;
vector<vector<int>> adj;
bool vis[N];

// main code;
int c;
map<int,vector<int>> mp;
map<int,bool> visited;
void dfs(int j){
	visited[j]=true;
	c++;
	for(auto u:mp[j]){
		if(!visited[u]) dfs(u);
	}
}
int32_t main(){
    int t=1;
    //cin>>t;
	while(t--){
    int n;
    cin>>n;
    int a[n];
    fl(n){
    	cin>>a[i];
    	visited[a[i]]=false;
	}
    for(int i=0;i<n/2;i++){
    	mp[a[i]].pb(a[n-i-1]);
    	mp[a[n-i-1]].pb(a[i]);
	}
    int ans=0;
    for(auto it:mp){
    	if(!visited[it.ff]){
    		c=0;
    		dfs(it.ff);
    		ans+=max(0ll,c-1);
		}
	}
	cout<<ans;

}
	return 0;
	}