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

inline int read(){
    int s=0,w=1;
    char ch=getchar();
    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;
}

inline bool read(int& a){
    int s=0,w=1;
    char ch=getchar();
    if(ch==EOF){
        return false;
    }
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    a=s*w;
    return true;
}

inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

inline void writeln(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
    puts("");
}

signed main(){
    char c[10];

    for(int i=1;i<=3;i++)
        c[i]=getchar();

    if(c[1]==c[2]&&c[2]==c[3])
        puts("Won");
    else
        puts("Lost");

    return 0;
}

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

int main() {
	int n;
	scanf("%d", &n);
	vector<int> a(n), b(n);
	for(int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for(int i = 0; i < n; i++)
		scanf("%d", &b[i]);
	int ans = 0;
	for(int i = 0; i < n; i++) {
		ans += (a[i] * b[i]);
	}
	if(ans == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << "Line " << __LINE__ << ": " <<  #x << " = " << (x) << "\n";
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;

template<typename T> using V = vector<T>;
template<typename T> using P = pair<T, T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

template <class T> void UNIQUE(vector<T> &x) {sort(ALL(x));x.erase(unique(ALL(x)), x.end());}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<"\n";}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<"\n";};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

int main(){

    ll R, X, Y;
    cin >> R >> X >> Y;
    ll D = X*X + Y*Y;
    ll E = R * R;

    if(D == E){
        cout << 1 << endl;
        return 0;
    }

    if(D < E){
        cout << 2 << endl;
        return 0;
    }

    ll P = (D+E-1)/E;

    ll k = (ll)sqrt(P) - 2;

    while(1){
        if(k*k >= P) break;
        k++;
    }

    cout << k << endl;

    return 0;
}

//Template Made By: Ojassvi Kumar
#include<bits/stdc++.h>
using namespace std;

#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define fo(i,a,b) for(long long int i=a; i<b; i++)
#define endl "\n"
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define min3(a,b,c) min(min((a),(b)),(c))
#define min4(a,b,c,d) min(min((a),(b)),min((c),(d)))
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(V) V.begin(),V.end()
#define itv vector<long long int>::iterator
#define pll pair<long long int,long long int>
#define mp make_pair
#define itp vector<pair<long long int,long long int>>::iterator
#define sll set<long long int,greater<long long int>>
#define its set<long long int,greater<long long int>>::iterator
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

//const long double pi = 3.14159265358979323846264338;
//const long long int MOD=1000000007;
//Template Ends

int main(){
	ios

		ll Tests=1;
//        cin>>Tests;
		while(Tests--){
			ll A,B,C;
			cin>>A>>B>>C;
			map<ll,ll> MA;
			MA[1]=6;
			MA[2]=5;
			MA[3]=4;
			MA[4]=3;
			MA[5]=2;
			MA[6]=1;
			ll ans=MA[A]+MA[B]+MA[C];
			cout<<ans<<endl;
		}
}


#include<iostream>
#include<string>

using namespace std;

int main() {

	long int n, x;
	string s;
	cin>>n>>x;
	cin>>s;
	for(int i = 0; i < s.size(); i++) {

		if(s[i] == 'x' && x != 0)
			x--;
		else if(s[i] == 'o')
			x++;
	}
	cout<<x<<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,x;

    cin>>n>>x;

    string s;
    cin>>s;

    for(int i = 0; i < n; i++)
    {
        if(s[i] == 'x')
        {
            x = max(0LL,x-1);
        }
        else
        {
            x = max(0LL,x+1);
        }
    }

    cout<<x;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n;
main()
{
cin>>n;
cout<<(n+99)/100<<endl;
}

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long N;
    long ans = 1000;

    for(int i = 1; i <= 4; i++)
    {
        scanf("%ld",&N);
        ans = (ans>N)? N:ans;
    }

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


#include<bits/stdc++.h>
//=====================START-MACRO=====================
namespace gengar
{
	#pragma GCC optimize("Ofast")
	using namespace std;
	namespace TypeDef
	{
		#define int long long
		#define itn int
		#define uint unsigned long long
		using Int=int64_t;
		using uInt=uint64_t;
		#define ld long double
		#define P pair<int,int>
		#define vt(tp) vector<tp>
		#define vvt(nm,tp,h,w,n) vector<vector<tp>>nm((h),vector<tp>(w,n))
		#define vvp vector<vector<P>>
		#define hmap unordered_map
		#define hset unordered_set
		#define PQ priority_queue
	};
	namespace OthDef
	{
		#define all(x) x.begin(),x.end()
		#define nsort(x) sort(all(x))
		#define rsort(x) nsort(x);reverse(all(x))
		#define unq(v) v.erase(unique(all(v)),v.end())
		#define l_b(c,x) distance(c.begin(),lower_bound(all(c),(x)))
		#define u_b(c,x) distance(c.begin(),upper_bound(all(c),(x)))
		#define fi first
		#define se second
		#define mp make_pair
		#define pb push_back
		#define eb emplace_back
		#define spc ' '
		#define pass
		void CIN(){}
		template<typename Car,typename... Cdr>
		void CIN(Car&&car,Cdr&&...cdr){cin>>car;CIN(forward<Cdr>(cdr)...);}
		template<class T>void drop(T x){cout<<(x)<<endl;exit(0);}
		void dYes(){puts("Yes");exit(0);}
		void dNo(){puts("No");exit(0);}
		#define Bit(n) (1LL<<(n))
		#define Bitall(n,i) for(int bit=0;bit<(1<<(int)(n));bit++)for(int i=0;i<(int)(n);i++)
		#define Bitif(i) if(bit&(1<<i))
	};
	namespace RepDef
	{
		#define _overload3(_1,_2,_3,name,...) name
		#define _rep(i,n) repi(i,0,n)
		#define repi(i,a,b) for(int i=(a),__SIZE##_=(b);i<__SIZE##_;i++)
		#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
		#define rrep(i,n) for(int i=1,__SIZE##_=(n);i<__SIZE##_;i++)
		#define repp(i,n) for(int i=0,__SIZE##_=(n);i<=__SIZE##_;i++)
		#define per(i,n) for(int i=(n)-1;i>=0;i--)
		#define pper(i,n) for(int i=(n)-1;i>=1;i--)
		#define perr(i,n) for(int i=(n);i>=0;i--)
	};
	namespace MathDef
	{
		const int inf=Bit(60);
		const int pi=acos(-1);
		const int mod=1000000007;//998244353
		#define myceil(a,b) ((a)+((b)-1))/(b)
		#define scale(n) cout<<fixed<<setprecision(n)
		int gcd(int a,int b){return b?gcd(b,a%b):a;}
		int lcm(int a,int b){return a/gcd(a,b)*b;}
		int fact(int n){int f=n;pper(i,n){f*=i;f%=mod;}return f;}
		template<class T>int chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
		template<class T>int chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
	};
	namespace AllDef
	{
		using namespace TypeDef;
		using namespace OthDef;
		using namespace RepDef;
		using namespace MathDef;
	};
	using namespace AllDef;
};
using namespace gengar;

//=======================END-MACRO=======================

namespace AHC001
{

//=====================START-AHC001======================

double dst(double a,double b,double c,double d)
{
	double ret=sqrt(pow(double(c)-double(a),2)+pow(double(d)-double(b),2));
	return ret/2/sqrt(2);
}

void solve()
{
	int n;cin>>n;
	vector<double>a(n),b(n),r(n);
	rep(i,n)cin>>a[i]>>b[i]>>r[i];
	double dist[200];
	rep(i,200)dist[i]=inf;
	//ここまで入力とか
	//dist計算
	rep(i,n)for(int j=0;j<n;j++)
	{
		if(j==i)continue;
		chmin(dist[i],dst(a[i],b[i],a[j],b[j]));
	}

	rep(i,n)
	{
		double lpdist=dist[i];
		if(dist[i]*dist[i]>r[i]/4)lpdist=(sqrt(r[i]))/2;
		cout<<(int)(max(a[i]-lpdist+0.5,0.0))<<spc;
		cout<<(int)(max(b[i]-lpdist+0.5,0.0))<<spc;
		cout<<(int)(min(a[i]+lpdist+0.5,10000.0))<<spc;
		cout<<(int)(min(b[i]+lpdist+0.5,10000.0))<<endl;
	}
	exit(0);
}

//=====================END-AHC001======================
};

using namespace AHC001;

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

#include <bits/stdc++.h>
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

namespace IO {
  char buf[1000000], *p1 = buf, *p2 = buf;
  inline char gc() {
    if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
    return p1 == p2 ? EOF : *(p1++);
  }
  template <class T> inline void read(T &n) {
    n = 0; RI ch = gc(), f;
    while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
    f = (ch == '-' ? ch = gc(), -1 : 1);
    while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
    n *= f;
  }
  char Of[105], *O1 = Of, *O2 = Of;
  template <class T> inline void print(T n, char ch = '\n') {
    if (n < 0) putchar('-'), n = -n;
    if (n == 0) putchar('0');
    while (n) *(O1++) = (n % 10) ^ 48, n /= 10;
    while (O1 != O2) putchar(*(--O1));
    putchar(ch);
  }
}

using IO :: read;
using IO :: print;

int const mod = 1e9 + 7;
int f[1005];

int main() {

#ifdef LOCAL
  FILEIO("a");
#endif

  int n; cin >> n;
  char AA; cin >> AA;
  char AB; cin >> AB;
  char BA; cin >> BA;
  char BB; cin >> BB;
  f[n - 2] = 1;
  for (RI i = n - 2; i; --i) {
    if (AB == 'A') {
      if (AA == 'B') {
        if (i - 2 >= 0)
          f[i - 2] = (f[i - 2] + f[i]) % mod;
        if (BA == 'B')
          for (RI j = i - 3; j >= 0; --j)
            f[j] = (f[j] + f[i]) % mod;
      }
      f[i - 1] = (f[i - 1] + f[i]) % mod;
    }
    else {
      if (BB == 'A') {
        if (i - 2 >= 0)
          f[i - 2] = (f[i - 2] + f[i]) % mod;
        if (BA == 'A')
          for (RI j = i - 3; j >= 0; --j)
            f[j] = (f[j] + f[i]) % mod;
      }
      f[i - 1] = (f[i - 1] + f[i]) % mod;
    }
  }
  cout << f[0] << endl;

  return 0;
}

// created by Daniel yuan
/*
     ________
    /        \
   / /      \ \
  / /        \ \
  \            /
   \  ______  /
    \________/
*/


#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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T> using indexed_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
template <typename T> using indexed_multiset = tree<T, null_type,less_equal<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define mii map<int,int>
#define rep(i, begin, end) for (int i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define pb push_back
#define mp make_pair
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define endl "\n"
#define ff first
#define ss second
#define PI 3.14159265358979323846
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define bit(x,j) ((x>>j)&1)
#define sz(a) (int)((a).size())
#define PRINT(v) for(auto t:v) cout<<t<<" ";cout<<endl;
#define PRINTDP(v) for(auto t:v){for(auto u:t){ cout<<u<<" ";} cout<<endl;}
#define PRINTM(mpp) for(auto t:mpp) cout<<t.ff<<" "<<t.ss<<endl;
#define read(v,n) vector<int> v(n); rep(i,0,n) cin>>v[i];
const int MOD=1e9+7 ;
const int MOD2=998244353;
const int INF=1e18+5;
int nCr(int n, int k) { if(k>n) return 0; double res = 1; for (int i = 1; i <= k; ++i) res = res * (n - k + i) / i; return (int)(res + 0.01); }
int gcd(int a,int b){ return b? gcd(b,a%b):a; }
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}
template<typename T,typename T1>T add_self(T &a,T1 b,T m=MOD){return a=((a%m+b%m)%m);}
const int N= 1e6+5;
int mob[N+2];
vector<int> primes;
int lp[N+1];
void linear_sieve(){
    for(int i=2;i<=N;i++){
        if(lp[i]==0){
            lp[i]=i;
            primes.push_back(i);
        }

        for(int j=0;j<sz(primes) && primes[j]<=lp[i] && i*primes[j]<=N;j++)
            lp[i * primes[j]] = primes[j];
    }
}

void precompute(){
    mob[1]=1;
    rep(i,2,N+1){
       mob[i] = [](int x){
            int cnt=0;
            while(x>1){
                int p=lp[x];
                int k=0;
                while(x%p==0){
                    x/=p;
                    k++;
                }
                if(k>1) return 0;
                ++cnt;
            }
            if(cnt & 1)
                return -1;
            else
                return 1;
       }(i);
    }
}

void solve(){
    int l,r;
    cin>>l>>r;
    if(l==1) l++;
    int ans=0;

    rep(g,2,N){
        int cnt= r/g - (l-1)/g; // Coprime pairs in [l,r]
        ans -= mob[g]*cnt*cnt;
    }

    // Removing pairs such as (x,kx) and (kx,x)

    rep(i,l,r+1){
        for(int j=i;j<=r;j+=i){
            ans--;
            if(i!=j)
                ans--;
        }
    }

    cout<<ans<<endl;

}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(17);
    int t=1;
    linear_sieve();
    precompute();
    // cin>>t;
    while(t--)
    solve();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define fi first
#define se second
#define UP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define UU(a,b,c) for(ll (a)=(b);(a)<=(c);(a)++)
#define DN(a,b,c) for(ll (a)=(b);(a)>(c);(a)--)
#define DU(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)

ll n, k, c[18], u, v, m;
vector<int> edge[100005];
int bitOf[100005];
ll DP[(1LL << 17)][18];

void reset()
{
	UP(i, 0, 1LL << 17)
	{
		UP(j, 0, 17)
		{
			DP[i][j] = -1;
		}
	}
}

void input()
{
	cin >> n >> m;
	UU(i, 1, m)
	{
		cin >> u >> v;
		edge[u].pb(v);
		edge[v].pb(u);
	}
	cin >> k;
	UP(i, 0, k)
	{
		cin >> u;
		c[i] = u;
		bitOf[u] = (1LL << i);
	}
}

class Compare
{
public:
    bool operator() (pair<int, pii> a, pair<int, pii> b)
    {
    	if(a.fi == b.fi)
    	{
    		return __builtin_popcount(a.se.se) < __builtin_popcount(b.se.se);
    	}
    	return a.fi > b.fi;
    }
};

bool vis[100005] = {0};
ll dist[20][20];

ll bfs(int now, int target)
{
	bool vis[100005] = {0};
	queue<int> q;
	q.push(now);
	for(int step = 0 ; !q.empty() ; step++)
	{
		int csz = q.size();
		while(csz--)
		{
			int now = q.front();
			q.pop();
			vis[now] = true;
			if(now == target)
			{
				return step;
			}
			UP(i, 0, edge[now].size())
			{
				if(vis[edge[now][i]] == false)
				{
					q.push(edge[now][i]);
					vis[edge[now][i]] = true;
				}
			}
		}
	}
	return INT_MAX;
}

ll dp(int now, int bit)
{
	if(__builtin_popcount(bit) == k)
	{
		return 1;
	}
	else if(DP[bit][now] != -1) return DP[bit][now];
	else
	{
		ll cost = INT_MAX;

		UP(i, 0, k)
		{
			if(bit & (1LL << i)){}
			else
			{
				cost = min(cost, dist[now][i] + dp(i, (bit | (1LL << i))));
			}
		}
		cost = min(cost, (ll)INT_MAX);
		return DP[bit][now] = cost;
	}
}

void solve()
{
	UU(j, 0, k)
	{
		UU(i, 0, k) dist[i][j] = INT_MAX;
	}

	UP(j, 0, k)
	{
		UP(i, j + 1, k)
		{
			dist[j][i] = dist[i][j] = bfs(c[i], c[j]);
		}
	}

	ll ans = INT_MAX;
	UP(i, 0, k)
	{
		ans = min(ans, dp(i, (1LL << i)));
	}
	if(ans == INT_MAX) ans = -1;
	cout << ans << endl;
}

void LetsRock()
{
	solve();
}

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

		reset();
		input();
		LetsRock();
	return 0;
}

#include<bits/stdc++.h>
using namespace std ;
const long long INF =1001001001 ;
//巡回セールスマン問題
//要解き直し

int main(){
    int N , M ;
    cin >> N >> M ;
    vector<vector<int > > to(N) ;
    for(int i = 0 ; i < M ; i++){
      int a , b ;
      cin >> a >> b ;
      a-- ;
      b-- ;
      to.at(a).push_back(b) ;
      to.at(b).push_back(a) ;
    }

    int K ;
    cin >> K ;
    vector<int > C(K) ;
    for(int i = 0 ; i < K ; i ++){
        cin >> C.at(i) ;
        C.at(i)-- ;
    }

    vector<vector<int > > dist(K , vector<int >(K)) ; //dist.at(i).at(j) = distance of i - j

    auto bfs = [&](int sv){
      vector<int > dist(N , INF) ;
      queue<int > q ;
      dist.at(sv) = 0 ;
      q.push(sv) ;
      while(!q.empty()){
        int v = q.front() ;
        q.pop() ;

        for(int u : to.at(v)){
          if(dist.at(u) != INF) continue ;
          dist.at(u) = dist.at(v) + 1 ;
          q.push(u) ;
        }
      }
      return dist ;
    } ;

    for(int i = 0 ; i < K ; i++){
      vector<int> d = bfs(C.at(i)) ;
      for(int j = 0 ; j < K ; j++){
        dist.at(i).at(j) = d.at(C.at(j)) ;
      }
    }

    int k2 = 1<<K ;
    vector<vector<int > > dp(k2 , vector<int > (K,INF));

    for(int i = 0 ; i < K ; i++){
      dp.at(1<<i).at(i) = 1 ;
    }

    for(int s = 0 ; s < k2 ; s++){
      for(int i = 0 ; i < K ; i++){
        if(!(s>>i&1)) continue ;
        for(int j = 0 ; j < K ; j++){
          if(s>>j&1) continue ;
          dp.at(s|1<<j).at(j) = min(dp.at(s|1<<j).at(j) , dp.at(s).at(i) + dist.at(i).at(j)) ;
        }
      }
    }

    int ans = INF ;
    for(int i = 0 ; i < K ; i++){
      ans = min(ans , dp.at(k2-1).at(i)) ;
    }

    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;

}


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

int x,y;

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

  int low=min(x,y);
  int high=max(x,y);

  low+=3;
  if(low<=high)
    cout<<"No";
  else
    cout<<"Yes";

}

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

      solve();

 return 0;
}

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

signed main()
{
  int a,b,x,y; cin >> a >> b;
  x = (a+b)/2;
  y = a-x;
  cout << x << " " << y;
}


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

#define int         long long
#define ull         unsigned long long
#define ll          long long
#define M           998244353
#define pb          push_back
#define p_q         priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp          make_pair
#define lb          lower_bound
#define ub          upper_bound
#define F           first
#define S           second
#define rep(i, begin, end) for (int i=begin;i<end;i++)
#define repd(i, begin, end) for (int i=end-1;i>=begin;i--)
#define ini(a,n,b)  for(ll int i=0;i<n;i++) a[i]=0;
#define cset(a)     __builtin_popcountll(a)
#define hell        1000000007
#define re          resize
const int INF=1e18;
const int N=3e5+5;

int powm(int a,int b,int c)
{
  int res=1;
  while(b)
  {
    if(b&1)
    res=(res*a)%c;
      a=(a*a)%c;
      b>>=1;
  }

  return res;
}
int pow(int a,int b)
{
  int res=1;
  while(b)
  {
    if(b&1)
    res=(res*a);
      a=(a*a);
      b>>=1;
  }

  return res;
}

signed main(void)
{ios
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);freopen("answer.txt", "w", stdout);
    #endif

    int n,m;
    cin>>n>>m;
    int p=powm(10,n,m*m);
    int ans=(p/m)%m;
    cout<<ans<<endl;

}

#include<bits/stdc++.h>
#define int long long
#define inf 999999999999
#define N 100000
using namespace std;
int n,dp[N+1],g[27];
string s;
signed main(){
//	freopen("optimize0.in","r",stdin);
//	freopen("optimize.out","w",stdout);
	cin>>n;
	cin>>s;
	for(int i=1;i<=n;i++)dp[i]=inf;
	for(int i=0;i<26;i++)g[i]=inf;
	for(int i=1;i<=n;i++){
	g[s[i-1]-'a']=min(g[s[i-1]-'a'],dp[i-1]);
		for(int j=0;j<26;j++){
			if(j!=s[i-1]-'a')dp[i]=min(dp[i],g[j]);
		}
		dp[i]++;
	}
	if(dp[n]<inf)cout<<dp[n]<<endl;
	else cout<<-1<<endl;
	return 0;
}
/*

*/


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

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(0);
	string s;
	cin >> s;

	int e = 0;
	for (int i = s.size()-1; i >= 0; --i) {
		if (s[i] != '0') {
			e = i;
			break;
		}
	}

	bool ans = true;
	for (int i = 0; i < (e+1)/2 && ans; ++i) {
		if (s[i] != s[e-i]) ans = false;
	}
	if (ans) cout << "Yes";
	else cout << "No";

    return 0;
}

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

using namespace std;
//using namespace atcoder;

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

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

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

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

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

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

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

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

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

// edit

void solve() {
    string s;
    cin >> s;
    if (s == "0") {
        cout << "Yes" << endl;
        return;
    }
    while (s.back() == '0') {
        s.pop_back();
    }
    string t = s;
    reverse(ALL(t));
    if (s == t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();

    return 0;
}


#include <bits/stdc++.h>
#define rep(i, f, n) for (ll i = (f); i < (ll)(n); i++)
#define repe(i, f, n) for (ll i = (f); i <= (ll)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

template <class T>
void chmin(T& a, T b) {
  if (a > b) a = b;
}

template <class T>
void chmax(T& a, T b) {
  if (a < b) a = b;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, 0, n) cin >> a[i];

  ll ans = 0;
  rep(l, 0, n) {
    int x = a[l];
    rep(r, l, n) {
      chmin(x, a[r]);
      chmax(ans, x * (r - l + 1));
    }
  }

  cout << ans << endl;

  return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
#include<unordered_set>
using namespace std;
long long hasht[26];
void toZ(){
    for(int i=0;i<26;i++)
        hasht[i]=0;
}
long long getC(char c){
    long long cnt=0;
    for(int i=0;i<26;i++){
        if('a'+i!=c)cnt+=hasht[i];
    }
    toZ();
    return cnt;
}
int main(){
   string s;
   long long cnt=0;
   cin>>s;
   reverse(s.begin(),s.end());
   int n=s.size();
   int last=-1;
   char cc='W';
   hasht[s[0]-'a']++;
   hasht[s[1]-'a']++;
   for(int i=2;i<n;i++){
       if(s[i]==s[i-1]&&s[i-1]!=s[i-2]){
           cnt+=getC(s[i]);
           if(cc!=s[i]){
             cnt+=last+1;
           }
         	last=i;
            cc=s[i];
       }else{
           hasht[s[i]-'a']++;
       }
   }
   cout<<cnt;
  	return 0;
}


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

#define int long long
#define mat vector<vector<int>>
#define vi vector<int>
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define pi pair<int, int>
#define inf 1000000000
#define mod 1000000007
//#define endl "\n"

const ll INF=1e18+5;

const int naxN=2e1+5;
int fact[naxN], inv_fact[naxN];

int power(int a, int n){
	int res=1;

	while(n){
		if(n%2) res=(res*a)%mod, n--;
		else a=(a*a)%mod, n/=2;
	}
	return res%mod;
}

void init(){
	fact[0]=inv_fact[0]=1;

	for(int i=1; i<naxN; i++){
		fact[i]=(i*fact[i-1])%mod;
		inv_fact[i]=power(fact[i], mod-2)%mod;
	}
}

int ncr(int a, int b){
	if(a<0 || b<0 || a<b) return 0;

	return (fact[a]%mod*inv_fact[b]%mod*inv_fact[a-b]%mod)%mod;
}

int dx[8]={-1, -1, -1, 0, 1, 1, 1, 0};
int dy[8]={-1, 0, 1, 1, 1, 0, -1, -1};

int par[30];
int R[30];

int find(int a){
	if(par[a]<0) return a;
	return par[a]=find(par[a]);
}

void merge(int a, int b){
	a=find(a);
	b=find(b);

	if(a==b) return;

	if(R[a]>=R[b]){
		par[b]=a;
		R[a]+=R[b];
	}
	else{
		par[a]=b;
		R[b]+=R[a];
	}
}

//****DO NOT TOUCH ABOVE THIS LINE****//
//#define kk

const int maxN=1e5+5;

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

	long double ans=(long double)(a-b)/a;
	ans*=100;

	cout<<ans<<endl;
}

//****DO NOT TOUCH BELOW THIS LINE****//

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

	cout<<fixed<<setprecision(18);

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

	//preprocess();

	int T=1;
	//cin>>T;

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

#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
using ll = long long;
#define pint pair<int, int>
#define pll pair<ll, ll>
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  ll a[n];
  rep(i, n) cin >> a[i];
  ll ans = 0;
  rep(left, n) {
    int right = left + 1;
    ll len = 1;
    ll m = a[left];
    while (right < n) {
      ans = max(ans, m * len);
      m = min(m, a[right]);
      right++;
      len++;
    }
    ans = max(ans, m * len);
  }

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


#include <bits/stdc++.h>
using namespace std;
int main() {
  int h,w,a,b,num=0,id1,id2;
  cin>>h>>w>>a>>b;
  int s=(h*(w-1))+(w*(h-1));

  for (int i=0;i<(1<<s);i++){
    set<int> m;
    bool e=false;
    int t_num=0;
    for (int j=0;j<s;j++){
      if(i&(1<<j))t_num++;
    }
    if (t_num!=a)continue;
    for (int j=0;j<s;j++){
      if(i&(1<<j)){
        if(j<(w*(h-1))){
          id1=j;
          id2=id1+w;
          if(m.count(id1)||m.count(id2)) e=true;
          else{
            m.insert(id1);
            m.insert(id2);
          }
        }
        else{
          id1=(j-w*(h-1))+(j-w*(h-1))/(w-1);
          id2=id1+1;
          if(m.count(id1)||m.count(id2)) e=true;
          else{
            m.insert(id1);
            m.insert(id2);
          }
        }
      }
    }
    if (!e) num++;
  }
  cout<<num<<endl;
}

// execute g++ main.cpp -std=c++14 -I C:\Users\naoya\Desktop\code\Atcoder
#include<bits/stdc++.h>
//#include<atcoder/all>
typedef long long ll;
typedef long double ld;
using namespace std;
//using namespace atcoder;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//ordered_set 重複不可
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// use set_function + find_by_order(select itr-num)

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
char Alpha[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};

int dx[2] = {1, 0};
int dy[2] = {0, 1};

//cout << std::fixed << std::setprecision(15) << y << endl; //小数表示

int h, w, a, b;

vector<vector<vector<Pii>>> gridmemo;
vector<vector<vector<Pii>>> gridmemo2;

void solve(vector<vector<Pii>> grid, int x, int  y, int count){
    if(x+1 == h && y+1 == w){
        if(count == a){
            gridmemo.pb(grid);
        }else{
            return;
        }
    }else if(x+1 == h){
        solve(grid, 0, y+1, count);
    }else{
        solve(grid, x+1, y, count);
    }
    REP(i,0,2){
        int nx = x + dx[i], ny = y+dy[i];
        if(nx >= 0 && nx < h && ny >= 0 && ny < w && grid[nx][ny] == Pii(-1, -1) && grid[x][y] == Pii(-1, -1)){
            grid[x][y] = Pii(nx, ny);
            grid[nx][ny] = Pii(x, y);
            if(x+1 == h && y+1 == w){
                if(count+1 == a){
                    gridmemo.pb(grid);
                }else{
                    return;
                }
            }else if(x+1 == h){
                solve(grid, 0, y+1, count+1);
            }else{
                solve(grid, x+1, y, count+1);
            }
            grid[x][y] = Pii(-1, -1);
            grid[nx][ny] = Pii(-1, -1);
        }
    }
}

int main(){
    cin >> h >> w >> a >> b;
    vector<vector<Pii> > grid(h, vector<Pii>(w, Pii(-1, -1)));
    int ans = 0;
    solve(grid, 0, 0, 0);
    /*
    REP(i, 0, gridmemo.size()){
        REP(x, 0,h){
            REP(y, 0, w){
                cout << gridmemo[i][x][y] << " ";
            }
            cout << endl;
        }
        cout << endl;
    }
    */
    REP(i,0,gridmemo.size()){
        int flag = 1;
        REP(l, 0, gridmemo2.size()){
            int f = 1;
            REP(x, 0, h){
                REP(y, 0, w){
                    if(gridmemo[i][x][y] != gridmemo2[l][x][y]){
                        f = 0; //OK
                    }
                }
            }
            if(f){
                flag = 0;
            }
        }
        if(flag){
            gridmemo2.pb(gridmemo[i]);
        }
        ans += flag;
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

ll d[1111][1111];

void init(ll n,ll m) {
  rep(i,n+1)rep(j,m) d[i][j+1]+=d[i][j];
  rep(j,m+1)rep(i,n) d[i+1][j]+=d[i][j];
}
ll calc(ll x1,ll y1,ll x2,ll y2) {return d[x2][y2]-d[x1][y2]-d[x2][y1]+d[x1][y1];}

void Main() {
  ll n,k;
  cin >> n >> k;
  ll a[n][n];
  rep(i,n)rep(j,n) R a[i][j];
  ll l=-1,r=MAX,e=k*k/2+1;
  while(l+1<r) {
    ll m=(l+r)/2;
    rep(i,n+1)rep(j,n+1) d[i][j]=0;
    rep(i,n) {
      rep(j,n) {
        if(a[i][j]>=m) d[i+1][j+1]++;
      }
    }
    init(n,n);
    ll f=1;
    rep(i,n-k+1) {
      rep(j,n-k+1) {
        ll c=calc(i,j,i+k,j+k);
        if(c<e) f=0;
      }
    }
    if(!f) r=m;
    else l=m;
  }
  pr(l);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}

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

int main(void)
{
    IOS
    int n, m;
    cin >> n >> m;
    vector<ll> h(n), w(m);
    REP(i,n) cin >> h[i];
    REP(i,m) cin >> w[i];
    sort(ALL(h));
    sort(ALL(w));
    vector<ll> h2(n);
    REP(i,n-1) h2[i] = h[i+1] - h[i];
    vector<ll> hsumf(n), hsumb(n);
    for(int i = 0; i < n; i += 2) hsumf[i+2] = hsumf[i] + h2[i];
    for(int i = n-1; i > 0; i -= 2) hsumb[i-2] = hsumb[i] + h2[i-1];
    ll ans = 1e18;
    for(int i = 0; i < n ; i += 2) {
        auto it = lower_bound(ALL(w),h[i]);
        ll hw = abs(*it - h[i]);
        if (it != w.begin()) {
            it--;
            hw = min(hw, abs(h[i]-*it));
        }
        ll tmp = hw + hsumf[i] + hsumb[i];
        ans = min(ans,tmp);
    }

    cout << ans << '\n';

    return 0;
}


#include <iostream>
using namespace std;

typedef long long ll;

#define min(x,y) ((x)<(y)?(x):(y))
#define max(x,y) ((x)<(y)?(y):(x))

ll comb(ll n, ll k){
    if (k == 0 || k == n) return 1;
    if (k == 1 || k == n-1) return n;
    return comb(n-1,k)+comb(n-1,k-1);
}

int main(){
    ll n,k;cin >> n >> k;--k;
    for(ll xyz=3;xyz<=3*n;++xyz){
        if(xyz <= n+1){
            ll xmin = 1;
            ll xmax = xyz-2;
            if (xmin <= xmax){
                ll s = ((xyz-1-xmax)+(xyz-1-xmin))*(xmax-xmin+1)/2;
                if(s <= k){
                    k -= s;
                }else{
                    for(ll x=xmin;x<=xmax;++x){
                        ll c = xyz-1-x;
                        if(c <= k){
                            k -= c;
                            continue;
                        }
                        ll y=1+k;
                        ll z=xyz-x-y;
                        cout << x << " " << y << " " << z << "\n";
                        return 0;
                    }
                }
            }
        }else if(xyz < 2*n+1){
            {
                ll xmin = 1;
                ll xmax = xyz-n-1;
                if(xmin <= xmax){
                    ll s = ((n-(xyz-n-xmax)+1)+(n-(xyz-n-xmin)+1))*(xmax-xmin+1)/2;
                    if(s <= k){
                        k -= s;
                    }else{
                        for(ll x=xmin;x<=xmax;++x){
                            ll c = n-(xyz-n-x)+1;
                            if(c <= k){
                                k -= c;
                                continue;
                            }
                            ll y=xyz-n-x+k;
                            ll z=xyz-x-y;
                            cout << x << " " << y << " " << z << "\n";
                            return 0;
                        }
                    }
                }
            }
            {
                ll xmin = xyz-n;
                ll xmax = n;
                if (xmin <= xmax){
                    ll s = ((xyz-1-xmax)+(xyz-1-xmin))*(xmax-xmin+1)/2;
                    if(s <= k){
                        k -= s;
                    }else{
                        for(ll x=xmin;x<=xmax;++x){
                            ll c = xyz-1-x;
                            if(c <= k){
                                k -= c;
                                continue;
                            }
                            ll y=1+k;
                            ll z=xyz-x-y;
                            cout << x << " " << y << " " << z << "\n";
                            return 0;
                        }
                    }
                }
            }
        }else{
            ll xmin = xyz-2*n;
            ll xmax = n;
            ll s = ((n-(xyz-n-xmax)+1)+(n-(xyz-n-xmin)+1))*(xmax-xmin+1)/2;
            if(s <= k){
                k -= s;
            }else{
                for(ll x=xmin;x<=xmax;++x){
                    ll c = n-(xyz-n-x)+1;
                    if(c <= k){
                        k -= c;
                        continue;
                    }
                    ll y=xyz-n-x+k;
                    ll z=xyz-x-y;
                    cout << x << " " << y << " " << z << "\n";
                    return 0;
                }
            }
        }
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define MOD(a, m) ((a % m + m) % m)
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; }
const ll MOD = 1e9+7;

ll N, K;

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

    vector<vector<ll>> X(4, vector<ll>(3*N+1));
    vector<vector<ll>> S(4, vector<ll>(3*N+1));
    X[0][0] = 1;
    REP(i,3){
        S[i][0] = X[i][0];
        REP(k,3*N){
            S[i][k+1] = X[i][k+1] + S[i][k];
        }

        REPi(k,1,3*N+1){
            //// X[][k] <= {X[][k-N] ... X[][k-1]}
            X[i+1][k] = S[i][k-1];
            if(k-N-1 >= 0)
                X[i+1][k] -= S[i][k-N-1];
        }
    }

    ll sum = 0;
    ll num = -1;
    REP(i,3*N+1){
        auto tmp = X[3][i];
        if(sum+tmp >= K){
            num = i;
            K -= sum;
            break;
        }
        sum += tmp;
    }

    //cout << sum << endl;
    //cout << num << endl;

    ll left, mid;
    bool valid = false;
    for(left = 1; left <= N; left++){
        ll rem = num - left;
        if(rem < 0 || 3*N < rem) continue;
        ll n = X[2][rem];
        if(K > n){
            K -= n;
        }
        else{
            for(mid = 1; mid <= N; mid++){
                ll rem2 = rem - mid;
                if(rem2 < 0 || 3*N < rem2) continue;
                ll n = X[1][rem2];
                K -= n;
                if(K == 0){
                    valid = true;
                    break;
                }
            }
        }

        if(valid)
            break;
    }

    printf("%lld %lld %lld\n", left, mid, num - (left + mid));

    return 0;
}


#include <stdio.h>
#include <algorithm>
#include <set>
#include <tuple>
#include <queue>
#include <vector>
using namespace std;
using ll = unsigned long long;
using pii = pair<int, int>;

int n, m, a[10000], b[10000], c[200], d[10000], v[200];
vector<pii> e[200];
void dfs(int x, int p) {
	if (v[x])
		return;
	v[x] = 1;

	for (pii ed : e[x]) {
		int y, id;
		tie(y, id) = ed;
		if (y == p)
			continue;
		if (d[id])
			continue;

		d[id] = (a[id] == x ? 2 : 3);
		dfs(y, x);
	}
}
int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++)
		scanf("%d %d", a + i, b + i);
	for (int i = 1; i <= n; i++)
		scanf("%d", c + i);

	for (int i = 0; i < m; i++) {
		if (c[a[i]] != c[b[i]])
			d[i] = ((c[a[i]] > c[b[i]]) ? 2 : 3);
		else {
			e[a[i]].emplace_back(b[i], i);
			e[b[i]].emplace_back(a[i], i);
		}
	}
	for (int i = 1; i <= n; i++)
		dfs(i, 0);

	for (int i = 0; i < m; i++)
		printf((d[i] ^ 2) ? "<-\n" : "->\n");
}

#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const int SIZE = 1e6+9;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;

map<pair<int,int>, int> e;
int ans[100009];
void f(int a,int b) {// a->b
    if(e.count({b,a}))ans[e[{b,a}]]=1;
}

vector<int> adj[100009];
bool vis[100009];
int c[100009];
int h[100009];

void dfs(int x, int p){
    //printf("D %d %d\n",x,p);
    for(int i:adj[x]){
        //printf("N %d\n",i);
        if(i==p||c[i]!=c[x])continue;
        if(!vis[i] || h[i]<h[x])f(x,i);
        if(!vis[i]){
            h[i]=h[x]+1;
            vis[i]=1;
            dfs(i,x);
        }
    }
}

int main(){
    DRII(n,m);
    REP(i,m){
        DRII(a,b);a--;b--;
        e[MP(a,b)]=i;
        adj[a].PB(b);
        adj[b].PB(a);
    }
    REP(i,n)RI(c[i]);
    for(auto v:e){
        if(c[v.F.F]==c[v.F.S])continue;
        if(c[v.F.F]>c[v.F.S])f(v.F.F,v.F.S);
        else f(v.F.S,v.F.F);
    }
    REP(i,n){
        if(vis[i])continue;
        vis[i]=1;
        dfs(i,-1);
    }
    REP(i,m){
        if(ans[i])puts("<-");
        else puts("->");
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int, int> >
#define vpll vector <pair <long long, long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define vb vector <bool>
#define vvb vector <vb>
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MANX MAXN
#define itn int
#define dbg(x); {cout << #x << "=" << x << ", ";}
#define in(x); { for (auto &to : x) cin >> to;}
#define out(x); { for (auto &to : x) cout << to << " "; cout << '\n'; }

const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const int mod1 = 1e9+7;
const int mod2 = 1e9+21;
int a,b;

void solve()
{
    cin>>a>>b;
    int x=a+b;
    if (x>=15&&b>=8)
        cout<<1;
    else if (x>=10&&b>=3)
        cout<<2;
    else if (x>=3)
        cout<<3;
    else
        cout<<4;
}

int main() {
    #ifdef Mip182
    freopen("a.in", "r", stdin);
    #else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #endif
    int _t;
    _t=1;
//    cin>>_t;
    while (_t--)
        solve();
    #ifdef Mip182
    cout<<'\n'<<"Time : "<<(double)(clock())/CLOCKS_PER_SEC<<'\n';
    #endif
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

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

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const int N = 101010;
int n, m;
int ed[N][2];
vector<int> g[N];
int c[N];
int ans[N];
bool used[N];

int getOther(int id, int v) {
	return ed[id][0] ^ ed[id][1] ^ v;
}

void dfs(int v) {
	used[v] = 1;
	for (int id : g[v]) {
		int u = getOther(id, v);
		if (used[u]) {
			if (ans[id] == -1)
				ans[id] = (int)(ed[id][1] == v);
		} else {
			ans[id] = (int)(ed[id][1] == v);
			dfs(u);
		}
	}
}

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		ans[i] = -1;
		for (int j = 0; j < 2; j++) {
			scanf("%d", &ed[i][j]);
			ed[i][j]--;
		}
	}
	for (int i = 0; i < n; i++)
		scanf("%d", &c[i]);
	for (int i = 0; i < m; i++) {
		int v = ed[i][0], u = ed[i][1];
		if (c[v] != c[u]) {
			if (c[v] > c[u])
				ans[i] = 0;
			else
				ans[i] = 1;
		} else {
			g[v].push_back(i);
			g[u].push_back(i);
		}
	}
	for (int i = 0; i < n; i++) {
		if (used[i]) continue;
		dfs(i);
	}
	for (int i = 0; i < m; i++) {
		if (ans[i] == 0)
			printf("->\n");
		else
			printf("<-\n");
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define forinc(a,b,c) for(int a=b, _c=c; a<=_c; ++a)
#define fordec(a,b,c) for(int a=b, _c=c; a>=_c; --a)
#define forv(a,b) for(auto &a:b)
#define func function
#define fasty ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define fi first
#define se second
#define pb push_back
#define all(a) begin(a),end(a)
#define reset(f,x) memset(f,x,sizeof(f))
#define bit(x,i) (x>>(i-1)&1ll)
#define on(x,i) (x|(1ll<<(i)))
#define off(x,i) (x&~(1ll<<(i-1)))
using ii=pair<int,int>;
using ll=long long;
using ull=unsigned long long;

const int N=5005;
int n;
string s;
int a[N],b[N],c[N],d[N];

int32_t main(){
   fasty;

   cin>>n>>s; s=' '+s;
   forinc(i,1,n){
      a[i]=a[i-1]+(s[i]=='A');
      b[i]=b[i-1]+(s[i]=='T');
      c[i]=c[i-1]+(s[i]=='G');
      d[i]=d[i-1]+(s[i]=='C');
   }
   int ans=0;
   forinc(i,1,n) forinc(j,i,n){
      if(a[j]-a[i-1]==b[j]-b[i-1] && c[j]-c[i-1]==d[j]-d[i-1]) ans++;
   }
   cout<<ans<<'\n';
}

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

int main()
{
    int N;
    string s;
	cin >> N >> s;
	int cnt = 0, ans = 0;
	for(int i = 0; i<N; i++){
		int a = 0, b = 0;
		for(int j = i; j<N; j++){
			if(s[j] == 'A'){
				a++;
			}
			else if(s[j] == 'T'){
				a--;
			}
			else if(s[j] == 'C'){
				b++;
			}
			else{
				b--;
			}
			if(a==0 && b==0){
				ans++;
			}
		}
	}
	cout << ans;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define pll pair<long long,long long>
#define vl vector<long long>
#define vll vector<pll>
#define vi vector<int>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAXN = 1000002;
const int MOD2 = 998244353;
const int MOD = 1000000007;
const int INF = 1e8;
const ld EPS = 1e-7;
// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define trav(a, x) for(auto& a : x)
#define fill(x,y) memset(x,y,sizeof(x))
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
ll mul(ll x, ll y)
{
    return (x * 1ll * y) % MOD2;
}

ll fastpow(ll x, ll y)
{
    ll z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}
ll modinv(ll n,ll p)
{
	return fastpow(n,p-2) ;
}
struct Comp {
  bool operator()(const std::pair<int, int> &a, const std::pair<int, int> &b) {
    if (a.first != b.first) {
      return a.first > b.first;
    }
    return a.second >b.second;
  }
};
int main(int argc, char** argv)
{   sws ;
cout<<setprecision(10);
   //tcase
    {
    ll a,b ;
    cin>>a>>b ;
    cout<<(a+b)/2<<" "<<(a-b)/2<<"\n" ;
    }

return 0 ;
}

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define FOR(i, m, n) for (ll i(m); i < n; i++)
#define DWN(i, m, n) for (ll i(m); i >= n; i--)
#define REP(i, n) FOR(i, 0, n)
#define DW(i, n) DWN(i, n, 0)
#define F(n) REP(i, n)
#define FF(n) REP(j, n)
#define D(n) DW(i, n)
#define DD(n) DW(j, n)
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using tll = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using vtll = vector<tll>;
using gr = vector<vll>;
using wgr = vector<vpll>;
void add_edge(gr&g,ll x, ll y){ g[x].pb(y);g[y].pb(x); }
void add_edge(wgr&g,ll x, ll y, ll z){ g[x].eb(y,z);g[y].eb(x,z); }
struct d_ {
    template<typename T> d_& operator,(const T& x) {
        cerr << ' ' <<  x; return *this;}
    template<typename T,typename U> d_& operator,(const pair<T,U>& x) {
        cerr << ' ' <<  x.x << ',' << x.y; return *this;}
    template<typename T> d_& operator,(const vector<T>& x) {
        for(auto x: x) cerr << ' ' <<  x; return *this;}
} d_t;
#define dbg(args ...) { d_t,"|",__LINE__,"|",":",args,"\n"; }
#define deb(X ...) dbg(#X, "=", X);
#define EPS (1e-10)
#define INF (1LL<<61)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(void) {
    ios_base::sync_with_stdio(false);
    ll a,b; cin >> a >> b;
    ll x = (a+b)/2;
    ll y = a-x;
    cout << x << ' ' << y << endl;
    return 0;
}


#include<bits/stdc++.h>
#define lli unsigned long long int
#define endl "\n"
#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
using namespace std;
lli min(lli a,lli b)
{
    if (a<b)
    {
        return a;
    }
    else
    {
        return b;
    }
}
lli max(lli a,lli b)
{
    if (a>b)
    {
        return a;
    }
    else
    {
        return b;
    }
}

void solve()
{
    lli x,y,a,b;
    cin>>x>>y>>a>>b;
    lli cnt=0;
    while((__int128)x*a<y && x*a<=x+b )
    {
        x*=a;
        cnt++;
    }

    cnt+=(y-x-1)/b;

    cout<<cnt<<endl;

}

int main(){

    fastio;
    cout<<fixed;
    cout<<setprecision(10);
    lli t=1;
//    cin>>t;
    for(lli i=1;i<=t;i++)
    {
        solve();
    }
    return 0;
}

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<complex>
#include<cstdio>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 100005
#define mid(l,r) l+(r-l)/2
#define removeduplicates(vec) vec.erase( unique( vec.begin(), vec.end() ), vec.end() )
#define memset1(v) memset(v,-1,sizeof(v))
#define memset0(v) memset(v,0,sizeof(v))
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}

void solve(){
	ll x,y,a,b;
	ll c=0;
	cin>>x>>y>>a>>b;
	ll maxi=0;
	while(1){
		ll rem=y-x;
		maxi=max(maxi,c+rem/b+(rem%b!=0));
		c++;
		if(x>=y/a)break;
		x*=a;
	}
	maxi=max(maxi,c);
	cout<<maxi-1;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e3 + 5;
typedef long long LL;
LL const mod = 1e9 + 7;
LL n, dp[N][2];

LL qmi(LL a, LL k, LL p) {
    LL res = 1 % p;  // res记录答案, 模上p是为了防止k为0，p为1的特殊情况
    while (k) {  // 只要还有剩下位数
        if (k & 1)
            res =
                (LL)res * a % p;  // 判断最后一位是否为1，如果为1就乘上a，模上p,
                                  // 乘法时可能爆int，所以变成long long
        k >>= 1;  // 右移一位
        a = (LL)a * a %
            p;  // 当前a等于上一次的a平方，取模，平方时可能爆int，所以变成long
                // long
    }
    return res;
}

int main() {
    cin >> n;
    char caa, cab, cba, cbb;
    cin >> caa >> cab >> cba >> cbb;
    if (n <= 3)
        cout << 1 << endl;
    else if (cab == 'A') {
        if (caa == 'A') {
            cout << 1 << endl;
            return 0;
        }
        if (cba == 'A') {
            dp[0][0] = 1;
            dp[0][1] = 0;
            for (int i = 1; i <= n - 2; i++) {
                dp[i][0] = (dp[i - 1][0] + dp[i - 1][1]) % mod;
                dp[i][1] = dp[i - 1][0];
            }
            cout << (dp[n - 2][0]) % mod << endl;
            return 0;
        } else {
            cout << qmi(2, n - 3, mod) << endl;
            return 0;
        }
    } else if (cab == 'B') {
        if (cbb == 'B') {
            cout << 1 << endl;
            return 0;
        }
        if (cba == 'B') {
            dp[0][0] = 1;
            dp[0][1] = 0;
            for (int i = 1; i <= n - 2; i++) {
                dp[i][0] = (dp[i - 1][0] + dp[i - 1][1]) % mod;
                dp[i][1] = dp[i - 1][0];
            }
            cout << (dp[n - 2][0]) % mod << endl;
            return 0;
        } else {
            cout << qmi(2, n - 3, mod) << endl;
            return 0;
        }
    }
    return 0;
}

/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-12-05 16:43:07
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , m , A[MAXN] , s;

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

	cin >> n >> m; m += n;
	for(int i = 0 ; i < n ; i++){
		cin >> A[i];
		s += A[i] + 1;
	}
	ll ans = 1 , x = 1;
	// cout << s << sep << m << endl;
	for(int i = 1 ; i <= s ; i++){
		ans = ans * (m - i + 1) % MOD;
		x = x * i % MOD;
	}
	cout << ans * poww(x , MOD - 2 , MOD) % MOD << endl;

    return 0;
}
/*

*/


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

using ull = unsigned long long;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const double pi = acos(-1.0);
const int inf = INT_MAX;
const int N = 50 + 5;

int n;
ll x, a[N], lim[N], dp[N][2], num_x[N];

ll recurse(int i, int c) {
	if (dp[i][c] != -1) {
		return dp[i][c];
	}
	if (i == n - 1) {
		return 1;
	}
	if (c) {
		if (1 + num_x[i] == lim[i]) {
			dp[i][c] = recurse(i + 1, 1);
		} else {
			dp[i][c] = recurse(i + 1, 0) + recurse(i + 1, 1);
		}
	} else {
		if (num_x[i]) {
			dp[i][c] = recurse(i + 1, 0) + recurse(i + 1, 1);
		} else {
			dp[i][c] = recurse(i + 1, 0);
		}
	}
	return dp[i][c];
}

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

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

	for (int i = 0; i < n - 1; i++) {
		lim[i] = a[i + 1] / a[i];
	}
	lim[n - 1] = LLONG_MAX;

	ll temp = x;
	for (int i = 0; i < n; i++) {
		num_x[i] = temp % lim[i];
		temp /= lim[i];
//		cout << num_x[i] << ' ';
	}
//	cout << '\n';

	memset(dp, -1, sizeof(dp));
	cout << recurse(0, 0) << '\n';
	return 0;
}

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

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	ll X; cin >> X;
	vector<ll> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	vector<ll> x(n);
	for(int i=n-1;i>=0;i--){
		x[i]=X/a[i];
		X%=a[i];
	}
	vector<ll> t(n);
	for(int i=0;i+1<n;i++){
		t[i]=a[i+1]/a[i];
	}
	t.back()=1e18;
	vector<ll> dp(2);
	dp[0]=1;
	for(int i=0;i<n;i++){
		vector<ll> pre(2);
		swap(dp,pre);
		for(int j=0;j<2;j++){
			for(int k=0;k<2;k++){
				{// Yが0
					ll z=t[i]*k-x[i]-j;
					if(0<=z and z<t[i]){
						dp[k]+=pre[j];
					}
				}
				{// お釣りが0
					ll y=x[i]+j-t[i]*k;
					if(0<y and y<t[i]){
						dp[k]+=pre[j];
					}
				}
			}
		}
	}
	cout << dp[0] << endl;
}


// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const long double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

const int MOD=3;
const int M=400100;
vi fact,rev;
bool do_init=false;
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
void init(){
	do_init=true;
	fact=rev=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
	rep(i,M)rev[i]=fact[i];
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!do_init)init();
	if(n<0||r<0||n<r)return 0; // 0 or 1
	ll out=fact[n]*rev[r]%m*rev[n-r]%m;
	return out;
}
ll nCr_l(ll n,ll r,ll m){
	ll out=1;
	while(n>0){
		(out*=nCr(n%m,r%m,m))%=m;
		n/=m;r/=m;
	}
	return out;
}

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

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

	int out=0;
	rep(i,n){
		int a;
		if(s[i]=='W')a=0;
		if(s[i]=='R')a=1;
		if(s[i]=='B')a=2;
		int t=nCr_l(n-1,i,3);
		(out+=t*a)%=MOD;
	}
	if(n%2==0)out=(3-out)%3;
	if(out==0)cout<<"W"<<endl;
	if(out==1)cout<<"R"<<endl;
	if(out==2)cout<<"B"<<endl;
}

#pragma region Macros
#include <bits/stdc++.h>
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define ALL(v) (v).begin(), (v).end()
#define LLA(v) (v).rbegin(), (v).rend()
#define SZ(v) (int)(v).size()
#define INT(...)                                                               \
    int __VA_ARGS__;                                                           \
    read(__VA_ARGS__)
#define LL(...)                                                                \
    ll __VA_ARGS__;                                                            \
    read(__VA_ARGS__)
#define DOUBLE(...)                                                            \
    double __VA_ARGS__;                                                        \
    read(__VA_ARGS__)
#define CHAR(...)                                                              \
    char __VA_ARGS__;                                                          \
    read(__VA_ARGS__)
#define STRING(...)                                                            \
    string __VA_ARGS__;                                                        \
    read(__VA_ARGS__)
#define VEC(type, name, size)                                                  \
    vector<type> name(size);                                                   \
    read(name)
#define VEC2(type, name, height, width)                                        \
    vector<vector<type>> name(height, vector<type>(width));                    \
    read(name)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
template <typename T> struct edge {
    int from, to;
    T cost;
    edge(int f, int t, T c) : from(f), to(t), cost(c) {}
};
template <typename T> using WGraph = vector<vector<edge<T>>>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;
const char newl = '\n';
template <class T> inline vector<T> make_vec(size_t a, T val) {
    return vector<T>(a, val);
}
template <class... Ts> inline auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec(ts...))>(a, make_vec(ts...));
}
void read() {}
template <class T> inline void read(T &a) { cin >> a; }
template <class T, class S> inline void read(pair<T, S> &p) {
    read(p.first), read(p.second);
}
template <class T> inline void read(vector<T> &v) {
    for(auto &&a : v)
        read(a);
}
template <class Head, class... Tail>
inline void read(Head &head, Tail &...tail) {
    read(head), read(tail...);
}
template <class T> void write(const T &a) { cout << a << '\n'; }
template <class T> void write(const vector<T> &a) {
    for(int i = 0; i < a.size(); i++)
        cout << a[i] << (i + 1 == a.size() ? '\n' : ' ');
}
template <class Head, class... Tail>
void write(const Head &head, const Tail &...tail) {
    cout << head << ' ';
    write(tail...);
}
template <class T> void writel(const T &a) { cout << a << '\n'; }
template <class T> void writel(const vector<T> &a) {
    for(int i = 0; i < a.size(); i++)
        cout << a[i] << '\n';
}
template <class Head, class... Tail>
void writel(const Head &head, const Tail &...tail) {
    cout << head << '\n';
    write(tail...);
}
template <class T> auto sum(const vector<T> &a) {
    return accumulate(ALL(a), T(0));
}
template <class T> auto min(const vector<T> &a) { return *min_element(ALL(a)); }
template <class T> auto max(const vector<T> &a) { return *max_element(ALL(a)); }
template <class T> inline void chmax(T &a, T b) { (a < b ? a = b : a); }
template <class T> inline void chmin(T &a, T b) { (a > b ? a = b : a); }
struct IO {
    IO() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        cout << fixed << setprecision(10);
    }
} io;
#pragma endregion

int main() {
    INT(n);
    write(n == 1 ? 0 : n - 1);
}


#include <iostream>
#include <algorithm>
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
using namespace std;

int main() {
  int a, b, x, y; cin >> a >> b >> x >> y;
  --a, --b;
  int res = x+y*abs(b-a);
  if(a>0) chmin(res, x+y*abs(b-(a-1)));
  if(a>b) chmin(res, x*((a-b)*2-1));
  else chmin(res, x*((b-a)*2+1));
  cout << res << endl;
  return 0;
}

#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
template<typename T> using V = std::vector<T>;
template<typename T> void fill(V<T>&v) { for(T&e:v) std::cin >> e; }
/*-*/

int main() {
	int a,b,x,y;
	std::cin >> a >> b >> x >> y;
	V<V<int> > dp(100,V<int>(2,-1));
	V<V<int> > dp2(100,V<int>(2,-1));
	dp[0][1]=x;
	dp[0][0]=0;
	dp2[0][1]=x;
	dp2[0][0]=0;
	rep(i,100) {
		if(i==0) continue;
		dp[i][0]=std::min(dp[i-1][0]+y,dp[i-1][1]+x);
		dp[i][1]=dp[i-1][1]+y;
		rep(j,2) dp[i][j]=std::min(dp[i][j],dp[i][j^1]+x);
	}
	rep(i,100) {
		if(i==0) continue;
		dp2[i][1]=std::min(dp2[i-1][1]+y,dp2[i-1][0]+x);
		dp2[i][0]=dp2[i-1][0]+y;
		rep(j,2) dp2[i][j]=std::min(dp2[i][j],dp2[i][j^1]+x);
	}
	if(b>a) print(dp[std::abs(b-a)][1]);
	else print(dp2[std::abs(b-a)][1]);
}


// Author: wlzhouzhuan
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fir first
#define sec second
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, t) memset(s, t, sizeof(s))
#define mcpy(s, t) memcpy(s, t, sizeof(t))
template<typename T1, typename T2> void ckmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> void ckmax(T1 &a, T2 b) { if (a < b) a = b; }
int read() {
  int x = 0, f = 0; char ch = getchar();
  while (!isdigit(ch)) f |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = 10 * x + ch - '0', ch = getchar();
  return f ? -x : x;
}
template<typename T> void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
template<typename T> void print(T x, char let) {
  print(x), putchar(let);
}

int main() {
  int n,k;cin>>n>>k;
  int ans=0;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=k;j++){
      ans+=100*i+j;
    }
  }
  printf("%d\n",ans);
}

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll=long long;
using ld=long double;
using pll=pair<ll, ll>;
//using mint = modint1000000007;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo 2e18
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
//priority_queue<ll, vector<ll>, greater<ll>> Q;
// LMAX = 18446744073709551615 (1.8*10^19)
// IMAX = 2147483647 (2.1*10^9)
/*
400*8*2
*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  rep(i, 20){
    string S;
    rep(j, 20){
      S += 'A' + rand()%8;
    }
    cout << S << endl;
  }
}


#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h, w;
    cin >> h >> w;
    vector<int> a(h * w);
    int mi = INT_MAX;
    for (int i = 0; i < h * w; i++) {
        cin >> a[i];
        mi = min(mi, a[i]);
    }
    int ans = 0;
    for (int i = 0; i < h * w; i++) {
        ans += a[i] - mi;
    }
    cout << ans << "\n";
    return 0;
}

//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include <bits/stdc++.h>
// #include <atcoder/all>

using namespace std;
// using namespace atcoder;

typedef long long ll;
using vint = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vbool = vector<bool>;
template <class T> using arr = vector<vector<T>>;

//マクロ
// forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
// FORAは範囲for文(使いにくかったら消す)
#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 = b - 1; i >= ll(a); i--)
#define FORA(i, I) for (const auto &i : I)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000 // 10^12:∞
#define MOD 1000000007 // 10^9+7:合同式の法
#define MAXR 100000 // 10^5:配列の最大のrange

// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

template <class T> void pl(T x) { cout << x << " "; }

template <class T> void pr(T x) { cout << x << endl; }

template <class T> void prvec(const vector<T> &a) {
  REP(i, a.size() - 1) { cout << a[i] << " "; }
  pr(a[a.size() - 1]);
}

template <class T> void prarr(const arr<T> &a) {
  REP(i, a.size())
  if (a[i].empty())
    pr("");
  else
    prvec(a[i]);
}

using P = pair<ll, ll>;
void prp(const P &p) { cout << p.first << " " << p.second << endl; }

struct Constants {
  ll H, W;
  Constants() { cin >> H >> W; }
} C;

struct Args {
  arr<ll> a;
  Args() : a(C.H, vll(C.W, 0)) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    REP(i, C.H) {
      REP(j, C.W) { cin >> a.at(i).at(j); }
    }
  }
} args;

struct Solver {
  ll ans;
  Solver() : ans(0) {}
  //
  void solve() {
    map<ll, ll> counts;
    REP(i, C.H) {
      REP(j, C.W) {
        counts[args.a.at(i).at(j)]++;
      }
    }
    //
    ll minb = -INF;
    FORA(p, counts) {
      if (minb == -INF)  {
        minb = p.first;
        continue;
      }
      ans += (p.first - minb) * p.second;
    }
  }

  void output() { pr(ans); }
} s;

int main() {
  s.solve();
  s.output();
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int N, vis[10005];
int main () {
#ifndef ONLINE_JUDGE
    freopen("cpp.in", "r", stdin);
#endif
	cin >> N;
	if (N == 3) return puts("6 10 15") & 0;
	for (int i = 6; i <= 10000; i += 6) vis[i] = 1;
	for (int i = 10; i <= 10000; i += 10) vis[i] = 1;
	for (int i = 15; i <= 10000; i += 15) vis[i] = 1;
	for (int i = 1; i <= 10000 && N; i++)
		if (vis[i]) printf("%d ", i), N--;
	putchar('\n');
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const char mc[4]={'U','L','D','R'};
const int max_e = 9000;
const int inf = 1000000000;
int mh[29][29],mv[29][29];

int dijkstra(vector<vector<int> > &m, pair<int, int> s){
    priority_queue<pair<int,pair<int,int> >, vector<pair<int,pair<int,int> > >, greater<pair<int,pair<int,int> > > > next;
    next.push(make_pair(0,s));
    while (!next.empty()) {
        int x = next.top().second.first,y = next.top().second.second;
        int p = next.top().first;
        next.pop();
        if(x > 0){
            if(chmin(m[x - 1][y], p + mv[x - 1][y])){
                next.push(make_pair(p + mv[x - 1][y], make_pair(x - 1, y)));
            }
        }
        if(x < 29){
            if(chmin(m[x + 1][y], p + mv[x][y])){
                next.push(make_pair(p + mv[x][y], make_pair(x + 1, y)));
            }
        }
        if(y > 0){
            if(chmin(m[x][y - 1], p + mv[x][y - 1])){
                next.push(make_pair(p + mv[x][y - 1], make_pair(x, y - 1)));
            }
        }
        if(y < 29){
            if(chmin(m[x][y + 1], p + mv[x][y])){
                next.push(make_pair(p + mv[x][y], make_pair(x, y + 1)));
            }
        }
    }
    return 0;
}

string restore(vector<vector<int> > &m, int x, int y){
    string root = "";
    int s = 0;
    while (m[x][y] != 0) {
        ++s;
        int next_x = x,next_y = y,p = m[x][y];
        rep0(i, 4)if(chmin(p, m[min(max(0,x + dx[i]),29)][min(max(0,y + dy[i]),29)])){
            next_x = x + dx[i];
            next_y = y + dy[i];
            if(s != root.size())root.push_back(mc[i]);
            else root[s - 1] = mc[i];
        }
        x = next_x;
        y = next_y;
    }
    reverse(all(root));
    return root;
}

int update(string s, int p, int x, int y){
    rep0(i, s.size()){
        if(s[i] == 'U'){
            mv[x - 1][y] = (mv[x - 1][y] + p + 1) / 2;
            x--;
        }else if(s[i] == 'D'){
            mv[x][y] = (mv[x][y] + p + 1) / 2;
            x++;
        }else if(s[i] == 'R'){
            mh[x][y] = (mh[x][y] + p + 1) / 2;
            y++;
        }else{
            mh[x][y - 1] = (mh[x][y - 1] + p + 1) / 2;
            y--;
        }
    }
    return 0;
}

//modを確認すること
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    rep0(i, 30)rep0(j, 30){
        //mh[i][j] = max_e;
        //mv[i][j] = max_e;
        mh[i][j] = rand() % 8000 + 1000;
        mv[i][j] = rand() % 8000 + 1000;
    }

    rep0(i, 1000){
        vector<vector<int> > m(30,vector<int>(30,inf));
        int sx,sy,gx,gy,p;
        string s = "";
        cin >> sx >> sy >> gx >> gy;
        m[sx][sy] = 0;

        dijkstra(m, make_pair(sx, sy));
        string ans = restore(m, gx, gy);

        pf(ans);

        cin >> p;
        update(ans, int((p + ans.size() - 1) / ans.size()), sx, sy);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0;i<(int)(n);i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int,int>;
struct UnionFind {
    vector<int> par, size;
    UnionFind(int x) {
        par.resize(x);
        size.resize(x, 1);
        for(int i = 0; i < x; i++) {
            par[i] = i;
        }
    }
    int find(int x) {
        if (par[x] == x)
            return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int consize(int x) {
        return size[find(x)];
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (size[x] < size[y]) {
            par[x] = y;
            size[y] += size[x];
        }
        else {
            par[y] = x;
            size[x] += size[y];
        }
    }
};
signed main() {
    int n,m;cin >> n >> m;
    // vector<vector<int>> G(n);
    UnionFind uf(n);
    vector<int> a(n),b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    vector<int> v(n);
    rep(i, n) v[i]=b[i]-a[i];
    rep(i, m) {
        int a,b;cin >> a >> b;
        a--;b--;
        uf.unite(a,b);
    }
    map<int,int> mp;
    rep(i, n) {
        mp[uf.find(i)]+=v[i];
    }
    for(auto p:mp) {
        if(p.second) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

// Problem : B - Values
// Contest : AtCoder - AtCoder Regular Contest 106
// URL : https://atcoder.jp/contests/arc106/tasks/arc106_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

int N, M;
int dsu[200005];
long long val1[200005], val2[200005];

int getrt(int n){
	return dsu[n] = (dsu[n] == n ? n : getrt(dsu[n]));
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N >> M;
	for(int i= 1; i<=N; i++){
		dsu[i] = i;
		cin >> val1[i];
	}
	for(int i = 1; i<=N; i++){
		cin >> val2[i];
	}
	while(M--){
		int a, b;
		cin >> a >> b;
		if(getrt(a) != getrt(b)){
			val1[getrt(a)] += val1[getrt(b)];
			val2[getrt(a)] += val2[getrt(b)];
			dsu[getrt(b)] = getrt(a);
		}
	}
	for(int i = 1; i<=N; i++){
		if(getrt(i) == i){
			if(val1[i] != val2[i]){
				cout << "No\n";
				return 0;
			}
		}
	}
	cout << "Yes";
}


#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define drep(i,j,n) for(int i=0;i<(int)(n-1);i++)for(int j=i+1;j<(int)(n);j++)
#define trep(i,j,k,n) for(int i=0;i<(int)(n-2);i++)for(int j=i+1;j<(int)(n-1);j++)for(int k=j+1;k<(int)(n);k++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yes(ans) if(ans)printf("yes\n");else printf("no\n")
#define Yes(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YES(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define vector3d(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
const int MOD2=998244353;
const int INF=1<<30;
const ll INF2=(ll)1<<60;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T,class L>void scan(pair<T, L>& p){scan(p.first);scan(p.second);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T,class L>void print(const pair<T, L>& p){print(p.first);putchar(' ');print(p.second);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}
template<class T> void chmax(T &a,const T b){if(b>a)a=b;}
template<class T> void chmin(T &a,const T b){if(b<a)a=b;}

int main(){
    ll ans=0;
    LL(n);
    if(n<=999){
        out(0);
        return 0;
    }
    ll d=1000;
    while(d<=n){
        ans+=n-(d-1);
        d*=1000;
    }
    out(ans);
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
int a[105][105];
int s1[18];
int s2[18];
int v[105];
int main(){
	int n,m;
	cin >> n >> m;
	int x,y;
	for(int i = 0; i < m; i++){
		cin >> x >> y;
		a[x][y]+=1;
	}
	int t;
	cin >> t;
	for(int i = 0; i < t; i++){
		int sx,sy;
		cin >> sx >> sy;
		s1[i] = sx;
		s2[i] = sy;
	}
	int sum = 0;
	for(int i = 0; i < pow(2,t); i++){
		int p = i;
		ll ans = 0;
		memset(v,0,sizeof(v));
		int j = t;
		while(j--){//取t次
			if(p & 1){
				v[s1[t-j-1]] = 1;
				//cout << s1[t-j-1]<<' ';
			}
			else {
				v[s2[t-j-1]] = 1;
				//cout << s2[t-j-1] << ' ';
			}
			p>>=1;
			//cout << p;
		}
		//cout << ' ';
		//for(int i = 1; i <= n; i++){
		//	if(v[i] == 1)cout << i<<' ';
		//}
		//cout << endl;
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				if(a[i][j]&&v[i]&&v[j])ans+=a[i][j];
			}
		}
		if(ans>sum)sum = ans;
	}
	cout << sum << endl;
}


#pragma GCC optimize("Ofast")
//#pragma GCC target ("sse4")

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<array>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acosl(-1.0);

ll mod_pow(ll x, ll n, ll m = mod) {
	if (n < 0) {
		ll res = mod_pow(x, -n, m);
		return mod_pow(res, m - 2, m);
	}
	if (abs(x) >= m)x %= m;
	if (x < 0)x += m;
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, ll n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
modint operator/=(modint& a, modint b) { a = a / b; return a; }
const int max_n = 1 << 10;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
modint combP(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[a - b];
}

bool exi[18][18];
void solve() {
	int n; cin >> n;
	int m; cin >> m;
	rep(i, m) {
		int a, b; cin >> a >> b; a--; b--;
		exi[a][b] = exi[b][a] = true;
	}
	vector<bool> can(1 << n);
	rep(i, 1<<n) {
		can[i] = true;
		rep(j, n) {
			if (i & (1 << j)) {
				Rep(k, j + 1, n) {
					if (i & (1 << k)) {
						if (!exi[j][k])can[i] = false;
					}
				}
			}
		}
	}
	vector<int> dp(1 << n, mod);
	dp[0] = 0;
	rep(i, (1 << n)) {
		for (int s = i;; s = (s - 1) & i) {
			if (can[s]) {
				dp[i] = min(dp[i], dp[i ^ s] + 1);
			}
			if (s == 0)break;
		}
	}
	cout << dp[(1 << n) - 1] << "\n";
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(15);
	//init_f();
	//init();
	//expr();
	//int t; cin >> t; rep(i, t)
	solve();
	return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define next Cry_For_theMoon
using namespace std;
const int MAXN=25,LIM=1<<19;
int n,m,g[MAXN][MAXN];
int f[LIM],d[LIM],ans,vis[MAXN];
inline int Min(int a,int b){
	return (a<b)?a:b;
}
int main(){
	scanf("%d%d",&n,&m);
	ans=n;
	for(int i=1;i<=n;i++){
		g[i][i]=1;
	}
	for(int i=1,u,v;i<=m;i++){
		scanf("%d%d",&u,&v);
		g[u][v]=g[v][u]=1;
	}
	for(int i=0;i<n;i++){
		f[1<<i]=1;
	}
	for(int i=1;i<(1<<n);i++){
		if(f[i])continue;
		memset(vis,0,sizeof vis);
		f[i]=1;
		for(int j=0;j<n;j++){
			if(i&(1<<j)){
				vis[j+1]=1;
			}
		}
		for(int j=1;j<=n;j++){
			if(!vis[j])continue;
			for(int k=j+1;k<=n;k++){
				if(!vis[k])continue;
				if(!g[j][k]){
					f[i]=0;
					break;
				}
			}
			if(!f[i])break;
		}
	}
	for(int i=1;i<(1<<n);i++){
		d[i]=100;
		for(int j=i;j;j=(j-1)&i){
			if(!f[j])continue;
			d[i]=Min(d[i],1+d[j xor i]);
		}
	}
	printf("%d",d[(1<<n)-1]);
	return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define chmin(x,y) x = min((x),(y))
#define chmax(x,y) x = max((x),(y))
#define popcount(x) __builtin_popcount(x)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
const int INF = 1e9;
const long long LINF = 1e17;
const int MOD = 1000000007;
//const int MOD = 998244353;
const double PI = 3.14159265358979323846;

int main(){
    int n;
    cin >> n;
    vector<ll> x(n),c(n);
    rep(i,n){
        cin >> x[i] >> c[i];
    }
    vector<ll> dp(2,0);
    vector<vector<ll>> G(n+2);
    G[0].push_back(0);
    G[n+1].push_back(0);
    rep(i,n){
        G[c[i]].push_back(x[i]);
    }
    rep(i,n+1){
        sort(G[i].begin(),G[i].end());
        //rep(j,(ll)G[i].size()) cout << G[i][j] << " ";
        //cout << endl;
    }

    int before = 0;
    for(int i=1;i<=n+1;i++){
        if((int)G[i].size() == 0) continue;
        vector<ll> dp_new(2,LINF);
        ll l = G[before][0];
        ll r = G[before].back();
        if(l < G[i][0]){
            dp_new[0] = dp[0] + G[i].back() - l + G[i].back() - G[i][0];
            dp_new[1] = dp[0] + G[i].back() - l;
        }else if(l < G[i].back()){
            dp_new[0] = dp[0] + G[i].back() - l + G[i].back() - G[i][0];
            dp_new[1] = dp[0] + l - G[i][0] + G[i].back() - G[i][0];
        }else{
            dp_new[0] = dp[0] + l - G[i][0];
            dp_new[1] = dp[0] + l - G[i][0] + G[i].back() - G[i][0];
        }

        if(r < G[i][0]){
            chmin(dp_new[0],dp[1] + G[i].back() - r + G[i].back() - G[i][0]);
            chmin(dp_new[1],dp[1] + G[i].back() - r);
        }else if(r < G[i].back()){
            chmin(dp_new[0],dp[1] + G[i].back() - r + G[i].back() - G[i][0]);
            chmin(dp_new[1],dp[1] + r - G[i][0] + G[i].back() - G[i][0]);
        }else{
            chmin(dp_new[0],dp[1] + r - G[i][0]);
            chmin(dp_new[1],dp[1] + r - G[i][0] + G[i].back() - G[i][0]);
        }

        before = i;
        swap(dp,dp_new);
        //cout << dp[0] << " " << dp[1] << endl;
    }
    cout << min(dp[0],dp[1]) << endl;

    return 0;
}


#include<iostream>
using namespace std;

int main(){
  int n,x=0;
  cin>>n>>x;
  char a[n+1];
  cin>>a;

  for(int i=0;i<n;i++){
    if(a[i]=='o'){
      x++;
    }else if(a[i]=='x' && x!=0){
      x--;
    }
  }

  cout<<x;
return 0;
}

#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
//#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long a, b, c;
    cin >> a >> b >> c;
    cout << 21 - (a + b + c);
    return 0;
}


//HAR HAR MAHADEV
//WHEN IT GETS HARDER REMEMBER WHY YOU STARTED💪
/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;

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

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

#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)
#define vt vector
#define bug(x) cout<<#x<<"="<<x<<endl;

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ins insert
//#define MOD 998244353

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T> using PR = pair<T, T>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii = 3.14159265359;
const int MOD = 1000000007;
const char cl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
constexpr int pct(int x) { return __builtin_popcount(x); } // # of bits set
void solve() {
        string s;
        cin >> s;
        vi cnt(26);
        ll ans = 0;
        rep(i, sz(s)) {
                int c = s[i] - 'a';
                cnt[c]++;
                if(i + 2 < sz(s)) {
                        if(s[i] == s[i + 1]) {
                                ans += sz(s) - i - cnt[c];
                                cnt.assign(26, 0);
                                cnt[s[i] - 'a'] = sz(s) - i;
                        }
                }
        }
        cout << ans;
}
int main() {
        ios_base::sync_with_stdio(0); cin.tie(0);
        int t = 1;
        clock_t clk = clock();
        //cin >> t;
        while (t--) {
                solve();
        }
        return 0;
}
/* stuff you should look for
        * jab answer dhoondhna ho to matlb binary search beta
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
        * DON'T GET STUCK ON ONE APPROACH
*/

#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) for(auto x:obj)cout<<x<<' ';cout<<endl;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> lp;
typedef pair<double, double> FP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

bool com(lp a, lp b){
    return a.first*2 + a.second > b.first*2 + b.second;
}

int main(){
    int n;
    cin >> n;
    vector<lp> vot(n);
    rep(i,n)cin >> vot[i].first >> vot[i].second;
    sort(all(vot), com);
    ll aoki_sum = 0;
    rep(i,n)aoki_sum += vot[i].first;
    ll tak_sum = 0;
    int pos = 0;
    while(tak_sum <= aoki_sum){
        tak_sum += vot[pos].first + vot[pos].second;
        aoki_sum -= vot[pos].first;
        ++pos;
    }
    cout << pos << endl;
    return 0;
}