#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <bitset>
#include <cassert>
#include <math.h>
using namespace std;
#define MOD 1000000007LL
#define ll long long

const int M = 300001;
int n, N[M];
ll k , l;

void solve() {
    cin >> n >> k >> l;
    ll t = 0;
    bool isFull = true;
    bool canBeO = true;
    for(int i = 0 ; i < n ; i++) cin >> N[i];
    for(int i = 0 ; i < n ; i++) {
        if (N[i] > l) {
            cout << "No\n";
            return;
        }
        if (N[i] <= l - k) {
            isFull = true;
            canBeO = true;
            continue;
        }

        ll a = l - N[i];
        ll b = 2LL * k - a;

        if (isFull) {
            canBeO = false;
            if (a == 0) t = a;
            else {
                t = b;
                canBeO = true;
            }
            isFull = false;
            continue;
        }
        assert((canBeO == (t >= k)));
        t = (t + 1) % (2*k);

        //cout << i << "->" << a << " " << b << " " << t << endl;
        if (t > a && t < b) {
            if (canBeO) {
                canBeO = false;
                if (a == 0) t = a;
                else {
                    t = b;
                    canBeO = true;
                }
            }
            else {
                cout << "No\n";
                return;
            }
        }
        canBeO = t >= b;
        isFull = false;
    }
    cout << "Yes\n";
}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int test = 1;
    cin >> test;
    while (test--)
    {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define len(v) ((int)((v).size()))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define chmax(x, v) x = max((x), (v))
#define chmin(x, v) x = min((x), (v))
using namespace std;
using pii = pair<int, int>;

struct EndSet {
	set<int> points;
	pii seg = {1, 0};

	int cbase = 0, cdir = 1;

	void setFree(int mx) {
		points.clear(), cbase = 0, cdir = 1;
		seg = {1, mx};
	}

	void setPush(int x) {
		setFree(0);
		points.insert(x);
	}

	void rotate(int balance) {
		cbase = balance - cbase;
		cdir = -cdir;
		seg = {balance - seg.second, balance - seg.first};
	}

	int tr(int x) {
		return cbase + cdir*x;
	}

	int anti(int x) {
		return cdir * (x - cbase);
	}

	bool in(int x) {
		if (points.count(anti(x)))
			return true;
		return (seg.first <= x && x <= seg.second);
	}

	void push(int x) {
		points.insert(anti(x));
	}

	void popBelow(int x) {
		seg.second = min(seg.second, x);
		auto nextIt = [&] {
			return (cdir == 1 ? prev(points.end()) : points.begin());
		};
		while (!points.empty() && tr(*nextIt()) > x)
			points.erase(nextIt());
	}

	bool empty() {
		return points.empty() && seg.first > seg.second;
	}
};

void solve() {
	int n; cin >> n;
	EndSet util;
	int curAns = 0;
	for (int i = 0; i < n; ++i) {
		int x; cin >> x;
		util.popBelow(x-1);
		if (x % 2 == 0 && util.in(x/2)) {
			curAns += 2;
			util.setPush(x/2);
		} else if (util.empty()) {
			if (x % 2 == 0)
				curAns += 1, util.setPush(x/2);
			else
				util.setFree(x-1);
		} else {
			curAns += 1;
			if (x % 2 == 0)
				util.push(x/2);
		}
		util.rotate(x);
	}
	cout << 2*n - curAns << "\n";
}

signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int nbTests;
	cin >> nbTests;
	for (int iTest = 0; iTest < nbTests; ++iTest) {
		solve();
	}
}


#include <iostream>
#include <queue>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <algorithm>
#include <sstream>
#include <vector>
#include <string>
#define ull unsigned long long
#define loop(x,n) for(int x = 0; x < n; x++)
using namespace std;
int main() {
	int n, m, a, b;
	cin >> n >> m;

	int res = 0;
	for (b = 0; m - b*b >= 0; b++) {
		a = m - b*b;
		if (a*a + b == n)
			/*printf("%d %d\n", a, b),*/res++;
	}
	cout << res;
	return 0;
}


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

int main() {
    int n,m;
    cin >> n >> m;
    if (n<m) {
        cout << -1 ;
        return 0;
    }

    int temp = m;
    n -=m;

    int count = (n/2)- (n/2)%m;
    temp += ((n/2)%m)*2 + n%2;
    if (temp > 2*m) count +=2*m;
    else if (temp >0) count += m;

    cout << count << endl;

 }


#include <stdio.h>
int n, i, j, h;
long long fir, sec, p, sum, deg;
long long res, res2, x, d;
long long a[3][3], m[3][3], zz[3][3];
int arr[1000010];
void mul(long long a[3][3], long long b[3][3])
{
	 for (i = 1; i <= 2; i++)
	 {
		 for (j = 1; j <= 2; j++)
		 {
			 zz[i][j] = 0;
			 for (h = 1; h <= 2; h++)
			 {
				 zz[i][j] = (zz[i][j] + a[i][h] * b[h][j]) % p;
			 }
		 }
	 }
}
long long doit(long long deg, long long x, long long mod)
{
	 long long res = 1;
	 while (deg > 0)
	 {
		 if (deg % 2 == 0)
		 {
			 deg = deg / 2; x = (x * x) % mod;
		 }
		 else
		 {
			 deg--; res = (res * x) % mod;
		 }
	 }
	 return res;
}
void find(long long tt)
{
	 /*if (p == 2)
	 {
		 res = doit(tt, 3, p);
		 sum = (sum * res + p - (d * n) % p) % p;
	 }
	 else if (p % 2 == 0)
	 {
		 res = doit(tt, 3, p);
		 //zz = p / 2;
		 //obr = (doit(tt, 3, zz) + zz - 1) % zz;
		 d = (d * (res - 1)) / 2;
		 d = d % p;
		 sum = (sum * res + p - d) % p;
	 }
	 else
	 {*/
		 res = doit(tt, 3, p);
		 res2 = doit(tt, 3, p * 2) - 1; res2 = res2 / 2;
		 sum = (sum * res + p - (d * res2) % p) % p;
	 //}
}
/*struct thing
{
	 long long d, x, y;
	 thing() {}
	 thing(long long dd, long long xx, long long yy)
	 {
		 d = dd; x = xx; y = yy;
	 }
};
thing nod(long long a, long long b)
{
	 if (b == 0)
	 {
		 return thing(a, 1, 0);
	 }
	 thing zz = nod(b, a % b);
	 return thing(zz.d, zz.y, (zz.x + p - (zz.y * (a / b)) % p) % p);
}*/
int main()
{
	 //freopen("input.txt", "r", stdin);
	 //freopen("output.txt", "w", stdout);
	 scanf("%d%I64d%I64d%I64d", &n, &fir, &sec, &p);
	 /*if (p % 2 == 1)
	 {
		 obr = (nod(p, 2).y) % p;
	 }*/
	 sum = 0;
	 for (i = 1; i <= n; i++)
	 {
		 scanf("%d", &arr[i]); sum = (sum + arr[i]) % p;
	 }
	 if (n == 1)
	 {
		 printf("%I64d", sum); return 0;
	 }

	 deg = fir / 2;
	 a[1][1] = 1; a[1][2] = 1;
	 a[2][1] = 1; a[2][2] = 2;
	 m[1][1] = 1; m[2][2] = 1;
	 while (deg > 0)
	 {
		 if (deg % 2 == 0)
		 {
			 deg = deg / 2;
			 mul(a, a);
			 for (i = 1; i <= 2; i++)
			 {
				 for (j = 1; j <= 2; j++) a[i][j] = zz[i][j];
			 }
		 }
		 else
		 {
			 deg--;
			 mul(a, m);
			 for (i = 1; i <= 2; i++)
			 {
				 for (j = 1; j <= 2; j++) m[i][j] = zz[i][j];
			 }
		 }
	 }
	 d = arr[1] + arr[n];
	 find(fir);
	 if (fir % 2 == 1)
	 {
		 d = (arr[1] + (m[1][1] + m[1][2]) * arr[n - 1] + (m[2][1] + m[2][2]) * arr[n]) % p;
	 }
	 else
	 {
		 d = (arr[1] + m[1][2] * arr[n - 1] + m[2][2] * arr[n]) % p;
	 }
	 find(sec);
	 printf("%I64d", sum);
	 return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int main() {
long long n, md;
cin >> n >> md;
vector <long long> f(n+1, 1);
for (long long i = 1; i <=n; i++)
f[i] = f[i-1] * i % md;
long long max = 0;
for (int i = 1; i <= n; ++i)
{
max += (n - i + 1) * (f[i] * f[n-i+1] % md);
if(n<md)
max%=md;
}
cout <<max;
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
	string abc;
	cin >> abc;
	int max = int(abc[0]);
	bool flag = true;
	if (abc[0] != 'a')
	{
		flag = false;
	}
	for (int i = 0; i < abc.length(); i++)
	{
		if (int(abc[i]) > (max + 1))
		{
			flag = false;
			break;
		}
		if (int(abc.at(i)) >= max)
			max = int(abc[i]);
		//cout << int(abc[i]) << endl;
	}
	if (flag)
		cout << "YES";
	else
		cout << "NO";

	//system("pause");
		return 0;
}


#include <iostream>
using namespace std;

int main() {
	int n, k, arr[101];
	cin>>n>>k;
	bool solvable = true;
	int solved=0;
	int lastSolve = 0;
	for(int i=0; i<n; i++) {
		cin>>arr[i];
		if(arr[i]<=k && solvable) {
			solved++;
			lastSolve=i;
		} else {
			solvable = false;
		}
	}
	if(solvable == false) {
		solvable = true;
		for(int i=n-1; i>lastSolve; i--) {
		if(arr[i]<=k && solvable) {
			solved++;
		} else {
			solvable = false;
			lastSolve=i;
		}
		}
	}
	cout<<solved<<endl;
	return 0;
}


#include<iostream>
#include<map>
using namespace std;
typedef long long ll;
int main(){
    int tmp;
    cin>>tmp;
    while(tmp--){
        int n;
        cin>>n;
        map<ll,bool>mp;
        for(ll i=1;i*i<=n;i++){
            mp[i*i]=true;
            if(i*i*i<=n){
                mp[i*i*i]=true;
            }
        }
        cout<<mp.size()<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 4e18L + 1;
const int IINF = 2e9 + 1;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

/* #define LOCAL */
#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) ;
#define cerr if(0)cout
#endif

typedef double R;
typedef complex<R> C;

typedef long long RL;
typedef complex<RL> CL;

#define x real()
#define y imag()

const R eps = 1e-14;

bool eq(R r1, R r2) { return abs(r1 - r2) < eps; }

bool eq(const C& c1,const C& c2) { return eq(c1.x, c2.x) and eq(c1.y, c2.y); }

R dot(const C& c1, const C& c2) { return c1.x * c2.x + c1.y * c2.y;}
R det(const C& c1, const C& c2) { return c1.x * c2.y - c1.y * c2.x;}

RL dot(const CL& c1, const CL& c2) { return c1.x * c2.x + c1.y * c2.y;}
RL det(const CL& c1, const CL& c2) { return c1.x * c2.y - c1.y * c2.x;}

C to_C(const CL& cl){ return C(cl.x, cl.y);}

struct line{
	CL nl;
    RL cl;
	C n, d;
    R c;
	/* line(C n1, R c1) */
	/* 	:n{n1 / abs(n1)}, c{c1} {} */
	/* line(C p1, C p2) */
	/* 	:n{((p2 - p1) / abs(p2 - p1)) * C(0, 1)}, c{dot(p1, n)} {} */
    line() = default;
    line(CL p1, CL p2)
        :nl{(p2 - p1) * CL(0, 1)}, cl{dot(p1, nl)}, n{to_C(nl) / abs(to_C(nl))}, d{n.y, -n.x}, c{dot(to_C(p1), n)} {}

   	bool operator <(const line& other) const {
        RL de = det(nl, other.nl);
        if(de == 0){
            return c > other.c;
        } else {
            return de > 0;
        }
    }

	C val(R t) const { return c * n + t * d;}

	R tis(const line& other) const {
		return (other.c - c * dot(n, other.n)) / dot(d, other.n);
	}
};

ostream& operator <<(ostream& o, const line& l){ return o << l.n << " " << l.c;}

C is(const line& a, const line& b) { return a.val(a.tis(b));}

namespace hplane{
    const int N = 200000;
    line lns[2 * N + 1];
    C poly[2 * N + 1];
    int jd1, jd2, ju1, ju2, ans_sz, poly_sz, n = 0;
    inline int cnt(){ return ju2 + jd2 - ju1 - jd1 + 2; }
    void add(const line& l){ lns[n++] = l;}
    void clear(){ n = 0;}

    bool empty_is(const line& l1, const line& l2) { return eq(dot(l1.n, l2.n), -1.0) and l1.c + eps > -l2.c;}

    bool wrong(const line& l_prev, const line& l_last, const line& l_new) {
        if(!eq(det(l_last.nl, l_new.nl), 0)) {
            return l_last.tis(l_new) < l_last.tis(l_prev) + eps;
        } else {
            return false;
        }
    }

    int cor(int j1, int j2){
        sort(lns + j1, lns + j2 + 1);
        j2 = unique(lns + j1, lns + j2 + 1, [](line& l1, line& l2){ return dot(l1.nl, l2.nl) > 0 and det(l1.nl, l2.nl) == 0;}) - lns - 1;
        int j = min(j1 + 1, j2);
        rep(i, j1 + 2, j2 + 1){
            j++;
            while(j >= j1 + 2 and wrong(lns[j - 2], lns[j - 1], lns[i])){
                j--;
            }
            lns[j] = lns[i];
        }
        return j;
    }

    void c_front(int& j1, int& j2, int& j3){
        while((j3 - j2) >= 1 and wrong(lns[j1], lns[j2], lns[j2 + 1])) j2++;
    }
    void c_back(int& j1, int& j2, int& j3){
        while((j2 - j1) >= 1 and wrong(lns[j2 - 1], lns[j2], lns[j3])) j2--;
    }
    void solve(){
        ju1 = partition(lns, lns + n, [](const line& l){ return det(CL(1, 0), l.nl) > 0 or (l.nl.y == 0 and l.nl.x < 0);}) - lns;
        ju2 = n - 1;
        jd1 = 0; jd2 = ju1 - 1;
        jd2 = cor(jd1, jd2); ju2 = cor(ju1, ju2);
        int chck = 0;
        while(chck != cnt() and (jd2 - jd1) >= 0 and (ju2 - ju1) >= 0 and ((jd2 - jd1) >= 1 or (ju2 - ju1) >= 1)){
            if(empty_is(lns[jd1], lns[ju2]) or empty_is(lns[ju1], lns[jd2])){
                ans_sz = 0; return;
            }
            chck = cnt();
            c_front(jd2, ju1, ju2);
            c_back(ju1, ju2, jd1);
            c_front(ju2, jd1, jd2);
            c_back(jd1, jd2, ju1);
        }
        rep(i, jd1, jd2 + 1){
            lns[i - jd1] = lns[i];
        }
        rep(i, ju1, ju2 + 1){
            lns[jd2 + 1 - jd1 + i - ju1] = lns[i];
        }
        ans_sz = cnt();
    }

    void get_poly(){
        if(ans_sz > 2){
            poly_sz = ans_sz;
            rep(i, 0, ans_sz){
                poly[i] = is(lns[i], lns[(i + 1) % ans_sz]);
            }
        } else {
            poly_sz = 0;
        }
    }
}

R triangle_area(C v1, C v2, C v3){ return fabs(det(v2 - v1, v2 - v3)) / 2.0; }

R poly_area(C* poly, int pn){
    R res = 0.0;
    rep(i, 1, pn - 1){
        res += triangle_area(poly[0], poly[i], poly[i + 1]);
    }
    return res;
}

const int N = 2e5;
CL pts[N + 1];
int n;
CL p0, cp;

R solve(){
    hplane::clear();
    hplane::add(line(CL(1e6, 1e6) - p0, CL(-1e6, 1e6) - p0));
    hplane::add(line(CL(-1e6, 1e6) - p0, CL(-1e6, -1e6) - p0));
    hplane::add(line(CL(-1e6, -1e6) - p0, CL(1e6, -1e6) - p0));
    hplane::add(line(CL(1e6, -1e6) - p0, CL(1e6, 1e6) - p0));
    sort(pts, pts + n, [](auto& p1, auto& p2){ return !(p1.y >= 0 and p2.y < 0) and ((p1.y < 0 and p2.y >= 0) or det(p1, p2) > 0);});
    int j = 0;
    rep(i, 0, n){
        while((j + 1) % n != i and det(pts[i], pts[(j + 1) % n]) >= 0){
            j = (j + 1) % n;
        }
        if(det(pts[i], pts[(i + 1) % n]) > 0){
            hplane::add(line(pts[i], pts[(i + 1) % n]));
        } else if(det(pts[i], pts[(i + 1) % n]) == 0){
            return 0;
        }
        if(det(pts[i], pts[j]) > 0){
            hplane::add(line(pts[i], pts[j]));
        } else if(i != j and det(pts[i], pts[j]) == 0){
            return 0;
        }
    }
    hplane::solve();
    hplane::get_poly();
    return poly_area(hplane::poly, hplane::poly_sz);
}

int main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int T; cin >> T;
    rep(_, 0, T){
        cin >> n; n--;
        R ix0, iy0; cin >> ix0 >> iy0;
        p0 = CL(ix0, iy0);
        rep(i, 0, n){
            R ix, iy; cin >> ix >> iy;
            pts[i] = CL(ix, iy);
            pts[i] -= p0;
        }
        cout << setprecision(15) << fixed << solve() << "\n";
    }
    return 0;
}


#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;

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

// arithmetic progressiong sum -> m + m+1 + ... + k-1 + k
LL range_sum(LL m, LL k) {
    LL n = k-m+1;
    return (n*(m+k))/2;
}

LL combine(LL m, LL k) {
    LL n = k-m+1;
    return range_sum(m, k) - n + 1;
}

LL result(LL n, LL k, LL m) {
    LL terms = k-m+1;
    LL sum = (terms*(m+k))/2 - terms + 1;
    if (sum >= n)
        return sum;
    sum--;
    LL dif = n - sum;
    if (dif >= m)
        return sum+1;
    assert(sum+dif == n);
    return sum+dif;
}

int main(int argc, char*argv[]) {
    ios_base::sync_with_stdio(false);
    LL n, k;
    cin >> n >> k;

    if (n == 1)
        cout << 0 << endl;
    else if (combine(2, k) < n)
        cout << -1 << endl;
    else if (combine(2, k) == n)
        cout << k-1 << endl;
    else if (combine(k, k) == n)
        cout << 1 << endl;
    else {
        LL lo=2, hi=k;

        while (lo <= hi) {
            LL mid = lo + (hi-lo)/2;
            LL res = result(n, k, mid);
            if (res == n) {
                cout << k-mid+2 << endl;
                break;
            } else if (res < n)
                hi = mid-1;
            else
                lo = mid+1;
        }
    }

    return EXIT_SUCCESS;
}


//ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef unsigned long long ull;
#define MX 1000000000
#define endl '\n'
#define startt ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr first
#define sc second
#define MOD 1000000007

int main()
{
    startt;
    int n, k;
    cin >> n >> k;
    int a[n+2];
    for(int i = 1 ; i <= n; i++)
    {
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 0; i <= n; i++)
    {
        if(k-i >= 1 && k+i <= n)
        {
            if(a[k-i] + a[k+i] == 2)
            {
                ans+=2-int(i == 0);
            }
        }
        else
        {
            if(k-i >= 1)
            {
                ans+=a[k-i];
            }
            if(k+i <= n)
            {
                ans+=a[k+i];
            }
        }
    }
    cout << ans << endl;
}


#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int MaxN = 410;
const int MOD = 10007;

char s[MaxN];
int n,m,N,cnt,a[MaxN][MaxN],b[MaxN][MaxN],c[MaxN][MaxN];
int f[MaxN][MaxN][MaxN];

inline void mul(int a[][MaxN],int b[][MaxN],int c[][MaxN]){
	static int d[MaxN][MaxN];
	memset(d,0,sizeof(d));
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			for(int k=i;k<=j;k++)
				d[i][j]=(d[i][j]+a[i][k]*b[k][j])%MOD;
	memcpy(c,d,sizeof(d));
}

inline void pow(int x){
	memset(c,0,sizeof(c));
	for(int i=0;i<N;i++) c[i][i]=1;
	for(;x;x>>=1,mul(a,a,a)) if(x&1) mul(c,a,c);
}

int F(int l,int r,int C){
	if(f[l][r][C]!=-1) return f[l][r][C];
	int &t=f[l][r][C];
	if(l==r) return t=!C;
	else if(s[l]==s[r]) return t=(l+1==r ? !C : F(l+1,r-1,C));
	else return t=C ? F(l,r-1,C-1)+F(l+1,r,C-1)%MOD : 0;
}
int main()
{
	scanf("%s%d",s,&n);
	m=strlen(s);n+=m;cnt=n+1>>1;
	int n1=m-1,n2=m+1>>1,n3=n2;
	N=n1+n2+n3;
	for(int i=0;i<n1;i++) a[i][i]=24,a[i][i+1]=1;
	for(int i=n1;i<n1+n2;i++) a[i][i]=25,a[i][i+n2]=1,i<n1+n2-1 ? a[i][i+1]=1 : 0;
	for(int i=n1+n2;i<N;i++) a[i][i]=26;
	memcpy(b,a,sizeof(a));
	pow(cnt-1);mul(c,b,a);
	memset(f,0xff,sizeof(f));
	long long res=0;
	for(int c1=0;c1<m;c1++){
		int c2=m-c1+1>>1,flag=~(m-c1)&1;
		int c3=cnt-c1-c2;
		if(c3<0) continue;
		int tot=F(0,m-1,c1);
		res+=1LL*tot*a[n1-c1][n1+n2+c2-1];
		if((n&1) && flag) res+=1LL*MOD*MOD-1LL*tot*c[n1-c1][n1+c2-1];
	}
	printf("%d\n",int(res%MOD));
	return 0;
}


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


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k;
int main() {
    int flag=0,sum=0;
    cin >> n >> k;
    ll s=sqrt(n);
    if(s*s==n) flag=1;
    for(int i=1;i<sqrt(n);i++) {
        if(n%i==0) sum++;
    }
    if(flag) sum=sum*2+1;
    else sum=sum*2;
    if(k>sum) {
        cout << "-1" << endl;
    }
    else {
        if(k*2-1==sum) {
            cout << s << endl;
            return 0;
        }
        int ss=0;
        for(int i=1;i<sqrt(n);i++) {
            if(n%i==0) ss++;
            if(ss==k) {
                cout << i << endl;
                break;
            }
            else if(sum-ss+1==k) {
                cout << n/i << endl;
                break;
            }
        }
    }
    return 0;
}//2020-10-14 23:53:24.571


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll w,m;
    while(cin>>w>>m){
        int flag=1;
        for(int i=1;i<=100;i++){
            ll tt=m%w;
            if(tt!=0&&tt!=1&&tt!=w-1)flag=0;
            if(tt==w-1)m++;
            m/=w;
        }
        puts(flag?"YES":"NO");
    }
    return 0;
}


#include<stdio.h>
#include<iostream>

using namespace std;

bool isLetter(char& x) {
    return (x >= 65 && x <= 90);
}

int main() {

    long long int probz = 1;
    int letterProb = 10;
    int so2al = 0;

    char s;
    bool letters[10] = { 0 };

    s=getchar();

    if (s == '?')
        probz *= 9;

    else if (isLetter(s)) {
        probz *= 9;
        letterProb -= 1;
        letters[s - 65] = 1;
    }

    while(s!='\n'){
        s = getchar();
        if (isLetter(s) && !letters[s - 65]) {
            probz *= (letterProb == 0) ? 1 : letterProb;
            letterProb -= (letterProb == 0) ? 0 : 1;
            letters[s - 65] = 1;
        }

        else if (s == '?') {
            so2al++;
        }
    }

    cout<<probz;
    while(so2al--) cout<<0;
    return 0;
}


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

const double pi = acos(-1.0);
const double eps = 1e-6;

double sqr(double x)
{
    return x * x;
}
double min(double x,double y)
{
    return x > y ? y : x;
}
double max(double x,double y)
{
    return x > y ? x : y;
}
double area(double x0,double y0,double x1,double y1,double x2,double y2)
{
    return (x1-x0)*(y2-y0) - (x2-x0)*(y1-y0);
}
int cross(double x0,double y0,double x1,double y1,double x2,double y2)
{
    double tmp = area(x0,y0,x1,y1,x2,y2);
    if(tmp > eps)return 1;
    if(tmp < -eps)return -1;
    return 0;
}
bool blockByWall(int xw1,int yw1,int xw2,int yw2,double x1,double y1,double x2,double y2)
{
    if(min(xw1,xw2) > max(x1,x2)+eps || min(yw1,yw2) > max(y1,y2)+eps || min(x1,x2) > max(xw1,xw2)+eps || min(y1,y2) > max(yw1,yw2)+eps)return 0;

    if(cross(x1,y1,x2,y2,xw1,yw1) * cross(x1,y1,x2,y2,xw2,yw2) > 0)return 0;
    if(cross(xw1,yw1,xw2,yw2,x1,y1) * cross(xw1,yw1,xw2,yw2,x2,y2) > 0)return 0;

    return 1;
}

bool blockByMirror(int xm1,int ym1,int xm2,int ym2,double x1,double y1,double x2,double y2)
{
    if(!blockByWall(xm1,ym1,xm2,ym2,x1,y1,x2,y2))return 0;
    if(cross(x1,y1,x2,y2,xm1,ym1) == 0 && cross(x1,y1,x2,y2,xm2,ym2) == 0)return 0;
    return 1;
}

void getReflection(int xm1,int ym1,int xm2,int ym2,double x,double y,double &xx,double &yy)
{
    double a = sqr(xm1-xm2) + sqr(ym1-ym2);
    double b = sqr(xm1-x) + sqr(ym1-y);
    double c = sqr(xm2-x) + sqr(ym2-y);

    double cosb = ((a+b-c)/2/sqrt(a*b));
    double cosc = ((a+c-b)/2/sqrt(a*c));

    double bb = sqrt(b)*cosb;
    double cc = sqrt(c)*cosc;
    /*
    if(alpha > pi/2)bb = -bb;
    if(beta > pi/2)cc = -cc;
    */
    xx = (xm1*cc + xm2*bb) / (bb+cc);
    yy = (ym1*cc + ym2*bb) / (bb+cc);

    xx = xx + xx - x;
    yy = yy + yy - y;
}
void getIntersection(double x1,double y1,double x2,double y2,double xx1,double yy1,double xx2,double yy2,double &x,double &y)
{
    double s1 = area(x1,y1,x2,y2,xx1,yy1);
    double s2 = area(x1,y1,xx2,yy2,x2,y2);
    double ss = s1 + s2;

    x = (xx1 * s2 + xx2 * s1) / (s1 + s2);
    y = (yy1 * s2 + yy2 * s1) / (s1 + s2);
}
int main()
{
    int x1,y1,x2,y2;
    int xw1,xw2,yw1,yw2;
    int xm1,xm2,ym1,ym2;

    cin >> x1 >> y1;
    cin >> x2 >> y2;
    cin >> xw1 >> yw1 >> xw2 >> yw2;
    cin >> xm1 >> ym1 >> xm2 >> ym2;

    if(!blockByWall(xw1,yw1,xw2,yw2,x1,y1,x2,y2) && !blockByMirror(xm1,ym1,xm2,ym2,x1,y1,x2,y2))
        cout << "YES" << endl;
    else if(cross(xm1,ym1,xm2,ym2,x1,y1) * cross(xm1,ym1,xm2,ym2,x2,y2) < 0)
        cout << "NO" << endl;
    else if(cross(xm1,ym1,xm2,ym2,x1,y1) != 0 || cross(xm1,ym1,xm2,ym2,x2,y2) !=0)
    {
        double xx2,yy2;
        getReflection(xm1,ym1,xm2,ym2,x2,y2,xx2,yy2);

        if(!blockByMirror(xm1,ym1,xm2,ym2,x1,y1,xx2,yy2))
            cout << "NO" << endl;
        else{
            double xx,yy;
            getIntersection(xm1,ym1,xm2,ym2,x1,y1,xx2,yy2,xx,yy);
            if(blockByWall(xw1,yw1,xw2,yw2,x1,y1,xx,yy) || blockByWall(xw1,yw1,xw2,yw2,x2,y2,xx,yy))
                cout << "NO" << endl;
            else
                cout << "YES" << endl;
        }
    }else cout << "NO" << endl;
//  system("pause");
}


#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <memory>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <map>
#include <numeric>
#include <time.h>
#include <numeric>
#include <cstdlib>
#include <bitset>
#include <set>

typedef long long int LLint;
using namespace std;

vector<LLint> canonicalGroups(LLint x) {
  vector<LLint> results;

  LLint rghtBorder = 0;

  results.push_back(1);
  for (LLint i = 2; i < sqrt(x); i++) {
    LLint tmp = 1;
    while (x % i == 0) {
      x /= i;
      tmp *= i;
    }
    if(tmp != 1)
      results.push_back(tmp);
  }

  if (x != 1) {
    results.push_back(x);
  }
  return results;
}

int main() {

  LLint x;
  cin >> x;

  auto groups = canonicalGroups(x);

  LLint finRes1 = LLONG_MAX;
  LLint finRes2 = LLONG_MAX;

  LLint n = groups.size();

  for (int i = 0; i < (1 << n); i++) {
    LLint localRes = 1;
    for (int j = 0; j < n; j++) {
      if (i & (1 << j))
        localRes *= groups[j];
    }
    if (max(localRes, x / localRes) < max(finRes1,finRes2)) {
      finRes1 = localRes;
      finRes2 = x / localRes;
    }
  }

  cout << finRes1 << " " << finRes2 << endl;
  return 0;
}


//writen by @libra9z
//please don't hack me ! if you do this , please leave a message to me ! I'm looking forward to hearing from you !
#define __NOT_USE_CPLUSPLUS
//#define LOCAL_TIME
//#define FILE_JUDGE
#pragma comment(linker, "/stack:20000000")
#pragma warning(disable:4146)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
//"C"
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <complex.h>
#include <fenv.h>
#include <inttypes.h>
#include <stdalign.h>
#include <stdbool.h>
#include <stdint.h>
#include <tgmath.h>
#include <wchar.h>
#include <wctype.h>
//"C++"
#ifndef __NOT_USE_CPLUSPLUS
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <typeinfo>
#include <valarray>
#include <vector>
//"C++11"
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif //"C++11"
using namespace std;
#endif //"C++"
unsigned long long rdtsc(){unsigned long long ret=0;asm volatile("rdtsc" : "=A" (ret) : :);return ret;}
typedef char i8;
typedef unsigned char u8;
typedef short i16;
typedef unsigned short u16;
typedef int i32;
typedef unsigned int u32;
typedef long i32p;
typedef unsigned long u32p;
typedef long long i64;
typedef unsigned long long u64;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for (int i=0;i<(n);i++)
#define Rep(i,a,b) for (int i=(a);i<=(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rRep(i,a,b) for (int i=(a);i>=b;i--)
#define repit(it,a) for (__typeof(a.begin()) it=a.begin();it!=a.end();++it)
#define X first
#define Y second
#define sqr(x) ((x)*(x))
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define reunique(v) v.erase(unique(all(v)),v.end())
#define prl cerr << "called: " << __LINE__ << endl
#define eaq(n,x) __typeof(x) n=x;
#define RET(p,x) return p<<x<<endl,0;
#define Error(p,x) p<<x;__builtin_abort();
#define Debug(x) cerr<<#x<<" = "<<x<<endl
#define Debug22(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<endl
#define Debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")\n"
#define Debug_arr(v,n) for(int i=0;i<n;++i) cerr<<#v<<"["<<i<<"]"<<" = "<<v[i]<<endl
const bool multitests=false,alotoftests=false;
const int inf=1e9;
const long long infl=1e18;
const long long h1=239017;
const long long h2=731604233;
const long long mod=1000000007;
const long long mod2=1000000009;
const int dx[]={1,0,-1,0,1,0,-1,0};
const int dy[]={0,1,0,-1,1,0,-1,0};
const double pi=3.1415926535897932384626f;
//****************����������****************THE*HACHERS*PLEASE*BEGIN*HACK*AT*THIS*LINE*****************************
i64 inv(i64 a,i64 b)
{
	return a-1?b-inv(b%a,a)*b/a:1;
}
i64 p=1,q=1,n;
bool solve(const int &__test)
{
	scanf("%lld",&n);
	for (i64 i=1;i<=n+1;++i)
	{
		p=p*(n+1+i)%mod;
		q=q*i%mod;
	}
	printf("%I64d",p*inv(q,mod)%mod-1);
	return false;
}
//****************����������****************THE*HACHERS*PLEASE*END*HACK*AT*THIS*LINE*******************************
signed main()
{
	rdtsc();
	#ifdef FILE_JUDGE
	freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	#endif
	int __tests,__test=1;
	(multitests==true)?((alotoftests==false)?__builtin_scanf("%d",&__tests):__tests=inf):__tests=1;
	for (;(alotoftests==true && multitests==true)?(!solve(__test)):(__test<=__tests);++__test)
		{if(!(multitests==true && alotoftests==true)){solve(__test);}}
	#ifdef LOCAL_TIME
	__builtin_fprintf(stderr,"\n\nSystem Time : %.3f seconds.\n",(double)clock()*1.0/1000);
	#endif
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<fstream>
#include<map>
#include<ctime>
#include<set>
#include<queue>
#include<cmath>
#include<vector>
#include<bitset>
#include<functional>
#define x first
#define y second
#define mp make_pair
#define pb push_back
using namespace std;

typedef long long LL;
typedef double ld;

const LL Mod=1000000007;
const LL MAX=150+10;

LL n,m;

LL f[MAX][MAX][MAX][4],g[MAX][MAX][MAX][4];//可以变大 不可以变大
LL sum[MAX][MAX][4];

void add(LL& a,LL b)
{
	a+=b;
	while(a<0)a+=Mod;
	a%=Mod;
}

LL ask(LL l,LL a,LL b)
{
	return sum[a][b][l];
}

LL get(LL l,LL a,LL b,LL c,LL d)
{
	return ((LL)ask(l,b,d)-ask(l,b,c-1)-ask(l,a-1,d)+ask(l,a-1,c-1)+2*Mod)%Mod;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#endif
	int i,j,k,l;
	cin>>n>>m;
	for(j=1;j<=m;++j)
		for(k=j;k<=m;++k)
			f[1][j][k][3]=1;
	for(i=2;i<=n;++i)
	{
		memset(sum,0,sizeof sum);
		for(j=1;j<=m;++j)
			for(k=1;k<=m;++k)
				for(l=0;l<4;++l)
					sum[j][k][l]=(f[i-1][j][k][l]+sum[j-1][k][l]+sum[j][k-1][l]-sum[j-1][k-1][l]+Mod)%Mod;
		for(j=1;j<=m;++j)
			for(k=j;k<=m;++k)
			{
				//1 1
				add(f[i][j][k][3],get(3,j,m,1,k));
				//1 0
				add(f[i][j][k][2],get(2,j,k,k,m));
				if(k+1<=m)add(f[i][j][k][2],get(3,j,k,k+1,m));
				//0 1
				add(f[i][j][k][1],get(1,1,j,j,k));
				if(j-1>0)add(f[i][j][k][1],get(3,1,j-1,j,k));
				//0 0
				if(j-1>0 && k+1<=m)
					add(f[i][j][k][0],get(3,1,j-1,k+1,m));
				if(j-1>0)
					add(f[i][j][k][0],get(2,1,j-1,k,m));
				if(k+1<=m)
					add(f[i][j][k][0],get(1,1,j,k+1,m));
				add(f[i][j][k][0],get(0,1,j,k,m));
			}
	}
	/*
	   111
	    11
	   */
	LL ans=0;
	for(i=1;i<=n;++i)
		for(j=1;j<=m;++j)
			for(k=j;k<=m;++k)
				for(l=0;l<4;++l)
				{
					LL c=f[i][j][k][l];
					add(ans,c*(n-i+1));
				}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int d,l,v1,v2;
    cin>>d>>l>>v1>>v2;
    int space=l-d;
    double ans =(space*1.0)/(v1+v2);
    cout<<fixed<<setprecision(20)<<ans;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

bool func(float x1,float y1,float x2,float y2,float x3,float y3,float x4,float y4,float a,float b)
{
	bool p,q;
	float m1,m2,m3,m4;
	float c1,c2,c3,c4;
	m1=(y2-y1)/(x2-x1);m2=(y4-y3)/(x4-x3);m3=(y3-y2)/(x3-x2);m4=(y1-y4)/(x1-x4);
	c1=y1-m1*x1;c2=y3-m2*x3;c3=y2-m3*x2;c4=y4-m4*x4;
	if((b-m1*a-c1)*(b-m2*a-c2)<=0)
		p=1;
	else
		p=0;
	if((b-m3*a-c3)*(b-m4*a-c4)<=0)
		q=1;
	else
		q=0;
	return p&q;
}
int main()
{
	float ax1,ax2,ax3,ax4,ay1,ay2,ay3,ay4;
	float bx1,bx2,bx3,bx4,by1,by2,by3,by4;
	cin>>ax1>>ay1>>ax2>>ay2>>ax3>>ay3>>ax4>>ay4;
	cin>>bx1>>by1>>bx2>>by2>>bx3>>by3>>bx4>>by4;
	float lx1,rx1,dy1,uy1;
	lx1=min(ax1,min(ax2,min(ax3,ax4)));
	rx1=max(ax1,max(ax2,max(ax3,ax4)));
	dy1=min(ay1,min(ay2,min(ay3,ay4)));
	uy1=max(ay1,max(ay2,max(ay3,ay4)));
	for(float i=lx1;i<=rx1;i++)
	{
		for(float j=dy1;j<=uy1;j++)
		{
			if(func(bx1,by1,bx2,by2,bx3,by3,bx4,by4,i,j))
			{
				cout<<"YES"<<endl;
				exit(0);
			}
		}
	}
	cout<<"NO"<<endl;
	return 0;
}


//lxrtxdy!
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <bitset>
#include <algorithm>
#include <iomanip>

using namespace std;

#define forn(i,n) for (int i = 0; i < int(n); i++)
#define ford(i,n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i,l,r) for (int i = int(l); i <= int(r); i++)
#define all(a) a.begin(), a.end()
#define sz(a) int(a.size())
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define x first
#define y second

template<typename X> inline X abs(const X& a) { return a < 0 ? -a : a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

typedef long long li;
typedef long double ld;
typedef pair<ld, ld> pt;

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9;
const ld PI = acosl(ld(-1));

const int N = 100 * 1000 + 15;
int w, h;
int n;
pair<pt, pt> a[N];

inline void readPt (pt& p)
{
	int x, y;
	assert(scanf ("%d%d", &x, &y) == 2);

	p = mp(ld(x), ld(y));
}

inline bool read()
{
	if (scanf ("%d%d%d", &w, &h, &n) != 3)
		return false;

	forn (i, n)
	{
		readPt(a[i].ft);
		readPt(a[i].sc);
	}

	return true;
}

inline bool operator < (const pt& a, const pt& b)
{
	if (abs(a.x - b.x) < EPS)
		return a.y < b.y;

	return a.x < b.x;
}

inline bool in (const ld& a, const ld& b, const ld& p)
{
	return min(a, b) <= p + EPS && p <= max(a, b) + EPS;
}

inline bool in (const pt& a, const pt& b, const pt& p)
{
	return in(a.x, b.x, p.x) && in(a.y, b.y, p.y);
}

inline ld det (const ld& a, const ld& b, const ld& c, const ld& d)
{
	return a * d - b * c;
}

inline bool intersect (const pt& a, const pt& b, const pt& c, const pt& d, pt& p)
{
	ld A1 = a.y - b.y, B1 = b.x - a.x;
	ld C1 = -(A1 * a.x + B1 * a.y);

	ld A2 = c.y - d.y, B2 = d.x - c.x;
	ld C2 = -(A2 * c.x + B2 * c.y);

	ld D = det(A1, B1, A2, B2);

	if (abs(D) < EPS)
		return false;

	p.x = -det(C1, B1, C2, B2) / D;
	p.y = -det(A1, C1, A2, C2) / D;

	return in(a, b, p) && in(c, d, p);
}

inline bool merge (pt& a, pt& b, pt c, pt d)
{
	ld A = a.y - b.y, B = b.x - a.x;
	ld C = -(A * a.x + B * a.y);

	if (abs(A * c.x + B * c.y + C) > EPS)
		return false;
	if (abs(A * d.x + B * d.y + C) > EPS)
		return false;

	if (!in(a, b, c) && !in(a, b, d) && !in(c, d, a) && !in(c, d, b))
		return false;

	if (a > b)
		swap(a, b);
	if (c > d)
		swap(c, d);

	a = min(a, c), b = max(b, d);

	return true;
}

inline bool cmpEq (const pt& a, const pt& b)
{
	return abs(a.x - b.x) < EPS && abs(a.y - b.y) < EPS;
}

int sze;
pt e[N];
vector<pt> p[N];
vector<int> g[N], used[N];

int cntG;
vector<int> gran[N];
ld area[N];
int id[N];

pt pole;

inline bool cmpAng (const int& a, const int& b)
{
	return atan2(e[a].y - pole.y, e[a].x - pole.x) < atan2(e[b].y - pole.y, e[b].x - pole.x);
}

inline ld getArea (const vector<int>& a)
{
	ld ans = 0;
	forn (i, sz(a))
	{
		int ni = (i + 1) % sz(a);

		ans += (e[ a[ni] ].x - e[ a[i] ].x) * (e[ a[ni] ].y + e[ a[i] ].y);
	}

	return ans / ld(2);
}

int col[N];
int cntCol = 0;

void dfs (int v)
{
	if (col[v] != -1)
		return;

	col[v] = cntCol;

	forn (i, sz(g[v]))
	{
		int to = g[v][i];

		dfs(to);
	}
}

inline bool onSeg (const pt& a, const pt& b, const pt& p)
{
	ld A = a.y - b.y, B = b.x - a.x;
	ld C = -(A * a.x + B * a.y);

	if (abs(A * p.x + B * p.y + C) > EPS)
		return false;

	return in(a, b, p);
}

inline bool onPoly (const vector<int>& a, const pt& p)
{
	pt p2 = mp(p.x + 28657, p.y + 33461);

	int cnt = 0;
	forn (i, sz(a))
	{
		int ni = (i + 1) % sz(a);

		if (onSeg(e[ a[i] ], e[ a[ni] ], p))
			return true;

		pt pp;
		cnt += intersect(e[ a[i] ], e[ a[ni] ], p, p2, pp);
	}

	return cnt & 1;
}

string colOut[N];
string colIn[N];

void colorBorder (int cid, const string& s);

set<int> gused, cused;

vector<int> par;
vector< vector<int> > gg;

void colorGran (int gid, const string& s)
{
	if (gused.count(gid))
		return;

	gused.insert(gid);

	//cerr << "G " << gid << ' ' << s << endl;

	/*int inner = -1;
	forn (i, cntG)
	{
		if (!onPoly(gran[gid], e[ gran[i][0] ]))
			continue;

		if (id[i] == id[gid] || colOut[ id[i] ] != colIn[gid])
			continue;

		if (inner == -1 || area[inner] < area[i])
			inner = i;
	}

	if (inner != -1)
		colorBorder(id[inner], s);*/

	forn (i, sz(gg[gid]))
	{
		int to = gg[gid][i];

		if (colOut[to] != colIn[gid])
			continue;

		colorBorder(to, s);
	}

	if (colIn[gid] == colOut[ id[gid] ])
	{
		colIn[gid] = s;
		colorBorder(id[gid], s);
	}
	else
		colIn[gid] = s;
}

void colorBorder (int cid, const string& s)
{
	if (cused.count(cid))
		return;

	//cerr << "C " << cid << ' ' << s << endl;

	cused.insert(cid);

	forn (i, cntG)
		if (id[i] == cid && colIn[i] == colOut[cid])
			colorGran(i, s);

	int outer = par[cid];

	if (outer != -1 && colIn[outer] == colOut[cid])
		colorGran(outer, s);

	colOut[cid] = s;
}

map<string, ld> res;

inline void solve()
{
	a[n++] = mp(mp(0, 0), mp(0, h));
	a[n++] = mp(mp(0, h), mp(w, h));
	a[n++] = mp(mp(w, h), mp(w, 0));
	a[n++] = mp(mp(w, 0), mp(0, 0));

	forn (i, n)
		fore (j, i + 1, n - 1)
			if (merge(a[i].ft, a[i].sc, a[j].ft, a[j].sc))
			{
				swap(a[j], a[n - 1]);
				n--;
				j++;
			}

	sze = 0;

	forn (i, n)
	{
		e[sze++] = a[i].ft;
		e[sze++] = a[i].sc;

		p[i].pb(a[i].ft);
		p[i].pb(a[i].sc);

		fore(j, i + 1, n - 1)
		{
			pt pp;
			if (intersect(a[i].ft, a[i].sc, a[j].ft, a[j].sc, pp))
			{
				e[sze++] = pp;
				p[i].pb(pp);
				p[j].pb(pp);
			}
		}
	}

	sort(e, e + sze);
	sze = int(unique(e, e + sze, cmpEq) - e);

	forn (i, n)
	{
		sort(all(p[i]));
		p[i].erase(unique(all(p[i])), p[i].end());

		forn (j, sz(p[i]) - 1)
		{
			int cur = int(lower_bound(e, e + sze, p[i][j]) - e);
			int nxt = int(lower_bound(e, e + sze, p[i][j + 1]) - e);

			g[nxt].pb(cur);
			g[cur].pb(nxt);
		}
	}

	forn (i, sze)
	{
		used[i].resize(sz(g[i]));
		forn (j, sz(used[i]))
			used[i][j] = 0;

		pole = e[i];
		sort(all(g[i]), cmpAng);
	}

	cntG = 0;

	forn (i, sze)
		forn (j, sz(g[i]))
			if (!used[i][j])
			{
				int v = i, id = j;
				while (!used[v][id])
				{
					used[v][id] = 1;
					gran[cntG].pb(v);

					int to = g[v][id];

					int nid = -1;
					forn (k, sz(g[to]))
						if (g[to][k] == v)
						{
							nid = k;
							break;
						}

					assert(nid != -1);

					nid = (nid + 1) % sz(g[to]);

					v = to, id = nid;
				}

				area[cntG] = getArea(gran[cntG]);

				if (area[cntG] > -EPS)
					cntG++;
				else
					gran[cntG].clear();
			}

	cntCol = 0;
	forn (i, sze)
		col[i] = -1;

	forn (i, sze)
		if (col[i] == -1)
		{
			dfs(i);
			cntCol++;
		}

	forn(i, cntG)
	{
		id[i] = col[ gran[i][0] ];

		colOut[ id[i] ] = "black";
		colIn[i] = "white";
	}

	gg.resize(cntG);
	par.resize(cntCol);

	forn (cid, cntCol)
	{
		pt p;
    	forn (i, cntG)
    		if (id[i] == cid)
    		{
    			p = e[ gran[i][0] ];
    			break;
    		}

		int outer = -1;
		forn (i, cntG)
			if (onPoly(gran[i], p) && id[i] != cid && (outer == -1 || area[outer] > area[i]))
				outer = i;

		par[cid] = outer;
		if (outer != -1)
			gg[outer].pb(cid);
	}

	int m;
	assert(scanf ("%d", &m) == 1);
	forn (i, m)
	{
		//cerr << "-----" << endl;

		int x, y;
		char buf[30];

		assert(scanf ("%d%d%s", &x, &y, buf) == 3);

		string curColor = string(buf);

		int cid = -1;
		forn (j, n)
			if (onSeg(a[j].ft, a[j].sc, mp(x, y)))
			{
				int it = int(lower_bound(e, e + sze, a[j].ft) - e);
				cid = col[it];
				break;
			}

		//cerr << cid << endl;

		if (cid != -1)
		{
			cused.clear();
			gused.clear();
			colorBorder(cid, curColor);
			continue;
		}

		int gid = -1;
		forn (j, cntG)
			if (onPoly(gran[j], mp(x, y)))
				if (gid == -1 || area[j] < area[gid])
					gid = j;

		assert(gid != -1);

		gused.clear();
		cused.clear();
		colorGran(gid, curColor);
	}

	/*cerr << "----------" << endl;

	forn (i, cntG)
	{
		cerr << id[i] << endl;
		cerr << colIn[i] << ' ' << colOut[ id[i] ] << endl;

		forn (j, sz(gran[i]))
		{
			int to = gran[i][j];

			cerr << e[to].x << ' ' << e[to].y << endl;
		}
	}*/

	fore (i, 1, cntCol - 1)
		res[ colOut[i] ] = 0;

	forn (i, cntG)
	{
		if (area[i] < EPS)
			continue;

		res[ colIn[i] ] += area[i];

		int outer = par[ id[i] ];

		if (outer != -1)
			res[ colIn[outer] ] -= area[i];
	}

	for(map<string, ld>::iterator it = res.begin(); it != res.end(); it++)
		printf ("%s %.15f\n", it->ft.c_str(), double(it->sc));
}

int main()
{
#ifdef SU2_PROJ
	assert(freopen("input.txt", "r", stdin));
	assert(freopen("output.txt", "w", stdout));
#endif

	cout << setprecision(25) << fixed;
	cerr << setprecision(10) << fixed;

	srand(int(time(NULL)));

	assert(read());
	solve();

#ifdef SU2_PROJ
	cerr << "TIME: " << clock() << endl;
#endif

	return 0;
}
//hellobig_tq
//orzlxr!


#include<bits/stdc++.h>
using namespace std;
const int N = 5e4+8;
#define double long double
const double eps = 1e-9;
const double pi = acos(-1.0);
const double inf = 1e6;
int cnt;
int segcnt = 0;
double curang;
struct Point{
    double x,y;
    double corss(Point b)const{
        return x * b.y - b.x * y;
    }
    Point operator - (const Point& b)const{
        return (Point){x-b.x,y-b.y};
    }
    double len(){return sqrt(x*x+y*y);}
};
Point segcross(Point a,Point b,Point c,Point d,bool& ok ){
    double u = (b-a).corss(c-a) , v = (a-b).corss(d-b);
    if( fabs(u+v) < eps){
        ok = 0;
        Point tem = {-1,-1};
        return tem;
    }
    ok = 1;
    return (Point){ (c.x*v + d.x*u)/(u+v) , (c.y*v + d.y*u)/(u+v) };
}
struct Seg{
    Point a,b;
    int id;
    bool operator < (const Seg& s)const{
        bool ok1 ,ok2;
        Point c = (Point){cos(curang) , sin(curang)};
        Point o = (Point){0,0};
        Point cr1 = segcross(a,b,o,c,ok1);
        Point cr2 = segcross(s.a,s.b,o,c,ok2);
        // if( ok1 == 0 || ok2 == 0 ) return id < s.id;
        // assert(ok1 && ok2);
        if( fabs( cr1.len() - cr2.len() ) < eps ) return id < s.id;
        return cr1.len() < cr2.len();
    }
};
vector<Point> pol[N];
double ang[N];
vector<int> add[N],del[N];
Seg seg[N];

void add_seg(Point a,Point b){
    double anga = atan2l(a.y,a.x) , angb = atan2l(b.y,b.x);
    if( fabs(anga - angb) < eps ) return;
    if( anga > angb + eps ){
        swap(anga,angb);
        swap(a,b);
    }
    int pa = lower_bound(ang+1,ang+1+cnt,anga) - ang;
    int pb = lower_bound(ang+1,ang+1+cnt,angb) - ang;

    ++segcnt;
    seg[segcnt] = (Seg){a,b,segcnt};
    if( angb - anga > pi + eps ){
        // Point c = segcross(a,b,(Point){-inf,0},(Point){inf,0});
        if( fabs(anga + pi) > eps){
            // ++segcnt;
            // seg[segcnt] = (Seg){c,a,segcnt};
            add[1].push_back(segcnt);
            del[pa].push_back(segcnt);
        }

        if( fabs( angb - pi ) > eps){
            // ++segcnt;
            // seg[segcnt] = (Seg){b,c,segcnt};
            add[pb].push_back(segcnt);
            del[cnt].push_back(segcnt);
        }
    }
    else{
        add[pa].push_back(segcnt);
        del[pb].push_back(segcnt);
    }
}
double area(Point a,Point b,Point c,Point d){
    double res = 0;
    res += (b-a).corss(c-a);
    res += (c-a).corss(d-a);
    if(res < -eps ) res = -res;
    return res * 0.5;
}
void solve(){
    set<Seg> st;
    double ans = 0;
    curang = 0;
    for(int i = 1;i<cnt;++i){
        for(auto it : del[i] )  st.erase(seg[it]);
        curang = ( ang[i] + ang[i+1] ) / 2.0;
        for(auto it : add[i])  st.insert(seg[it]);
        if((int)st.size() >= 2){
            // assert((int)st.size()>=2);
            Seg s1,s2;
            auto it = st.begin();  s1 = (*it);
            ++it; s2 = (*it);
            Point c1 = (Point){inf*cos(ang[i]) , inf * sin(ang[i])};
            Point c2 = (Point){inf*cos(ang[i+1]) , inf * sin(ang[i+1])};
            Point o = (Point){0,0};
            bool ok1,ok2,ok3,ok4;
            Point a1 = segcross(o,c1,s1.a,s1.b,ok1);
            Point a2 = segcross(o,c1,s2.a,s2.b,ok2);
            Point a3 = segcross(o,c2,s2.a,s2.b,ok3);
            Point a4 = segcross(o,c2,s1.a,s1.b,ok4);
            // assert(ok1 && ok2 && ok3 && ok4);
            // if( ok1 == 0 || ok2 == 0 || ok3 == 0 || ok4 == 0) continue;
            ans += area(a1,a2,a3,a4);
        }
    }
    // printf("%.12f",ans);
    cout<<ans<<endl;
}
int main(){
    int n; cin>>n;
    for(int i = 1;i<=n;++i){
        int m; cin>>m;
        Point tem;
        for(int j = 1;j<=m;++j){
            // scanf("%lf %lf",&tem.x,&tem.y);
            cin>>tem.x>>tem.y;
            // cerr<<tem.x<<" "<<tem.y<<" !"<<endl;
            pol[i].push_back(tem);
            ang[++cnt] = atan2l(tem.y,tem.x);
        }
        pol[i].push_back(pol[i][0]);
    }
    ang[++cnt] = -pi; ang[++cnt] = pi;
    sort(ang+1,ang+1+cnt);
    cnt = unique(ang+1,ang+1+cnt) - ang - 1;

    for(int i = 1;i<=n;++i){
        for(int k = 0;k<pol[i].size()-1;++k){
            add_seg(pol[i][k],pol[i][k+1]);
        }
    }

    solve();
    return 0;
}


#include<set>
#include<map>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<deque>
#include<vector>
#include<string>
#include<cstdio>
#include<bitset>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<unordered_map>

#define endl "\n"
#define ll long long
#define int ll
//#define gcd(a,b) __gcd(a,b)
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const int maxn = 1e5 + 7;
const double pi = acos(-1.0);
const int base = 131;
int n,m;
signed main() {
    std::ios::sync_with_stdio(false), cin.tie(0);
    cin>>n>>m;
    if(m==1)cout<<n-1;
    else cout<<n*(m-1)<<endl;
}


/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
struct MinCostMaxFlow{
	#define MAXN 55
	struct edge{
		int to,cost,flow,rev;
		edge(int _to,int _cost,int _flow,int _rev){
			to=_to;cost=_cost;flow=_flow;rev=_rev;
		}
	};
	vector<edge>g[MAXN];
	void add_edge(int x,int y,int f,int c){
		g[x].push_back(edge(y,c,f,(int)g[y].size()));
		g[y].push_back(edge(x,-c,0,(int)g[x].size()-1));
	}
	//flow,cost
	int dist[MAXN],h[MAXN],pre_v[MAXN],pre_e[MAXN];
	pair<int,int>Min_Cost_Max_Flow(int s,int t,int f){
		pair<int,int>ret(0,0);
		memset(h,0,sizeof h);
		while(f){
			memset(dist,inf,sizeof dist);
			memset(pre_v,-1,sizeof pre_v);
			set<pair<int,int> >S;
			S.insert(make_pair(0,s));
			dist[s]=0;
			while(!S.empty()){
				int x=S.begin()->second,now=S.begin()->first;
				S.erase(S.begin());
				if(dist[x]!=now)continue;
				for(int i=0;i<g[x].size();i++){
					if(!g[x][i].flow)continue;
					int to=g[x][i].to,cost=g[x][i].cost;
					if(dist[to]>now+cost+h[x]-h[to]){
						dist[to]=now+cost+h[x]-h[to];
						pre_v[to]=x;pre_e[to]=i;
						S.insert(make_pair(dist[to],to));
					}
				}
			}
			if(pre_v[t]==-1)return ret;
			for(int i=0;i<MAXN;i++)h[i]+=dist[i];
			int now=t,cur=f;
			while(now!=s){
				cur=min(cur,g[pre_v[now]][pre_e[now]].flow);
				now=pre_v[now];
			}
			now=t;f-=cur;
			ret.first+=cur;ret.second+=cur*h[t];
			while(now!=s){
				edge &e=g[pre_v[now]][pre_e[now]];
				e.flow-=cur;
				g[e.to][e.rev].flow+=cur;
				now=pre_v[now];
			}
		}
		return ret;
	}
}G;
int n,m;
vector<pair<int,int> >g[55],g2[55];
int dist[55],dist2[55];
int pre[6666];
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int x,y,z;cin>>x>>y>>z;
		G.add_edge(x,y,1,z);
	}
	vector<pair<int,int> >hv;
	int sum=0;
	while(1){
		auto got=G.Min_Cost_Max_Flow(1,n,1);
		if(got.first==0)break;
		sum+=got.second;
		hv.push_back(make_pair(sum,got.second));
	}
	int q;cin>>q;
	while(q--){
		int x;cin>>x;
		double ans=-1e18;
		int cnt=0;
		for(int i=0;i<hv.size();i++){
			auto p=hv[i];cnt++;
			double got=((double)p.first+x)/(double)cnt;
			double tmp=(double)(i+1==hv.size()?1e18:hv[i+1].second);
			if(got>=p.second&&tmp>=got){ans=got;break;}
		}
		printf("%.12lf\n",ans);
	}
	return 0;
}


#include <assert.h>
#include <memory.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define pb push_back
#define INF 1011111111
#define FOR(i, a, b) for (int _n(b), i(a); i < _n; i++)
#define rep(i, n) FOR(i, 0, n)
#define CL(a, v) memset((a), (v), sizeof(a))
#define mp make_pair
#define X first
#define Y second
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))

typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> pii;

/*** TEMPLATE CODE ENDS HERE */

const int maxn = 1010, maxm = maxn * maxn;

typedef bitset<(maxn << 1) + 5> BitSet;

pair<int, int> edA[maxm + 5], edB[maxm + 5];
BitSet A[(maxn << 1) + 5], B[(maxn << 1) + 5];
BitSet odd;
int n;

int Get(int x) {
  if (x < 0) {
    x = -x, --x;
    return x << 1;
  }
  --x;
  return x << 1 | 1;
}

inline bool Check(const BitSet &x) { return (((x & odd) >> 1) & x).none(); }

BitSet ban;
int ans[maxn + 5];

inline void find(BitSet *f) {
  rep(i, n) {
    if (ban[i << 1] || (f[i << 1] & ban).any() || !Check(f[i << 1])) {
      ans[i] = 1;
    } else {
      ans[i] = 0;
    }
    ban[i << 1 | (!ans[i])] = 1;
  }
}

int main() {
#ifdef LOCAL_HOST
  freopen("input.txt", "r", stdin);
// freopen("output.txt","w",stdout);
#endif

  const string similar = "SIMILAR";

  int m1, m2;
  cin >> n >> m1 >> m2;
  rep(i, m1) {
    int u, v;
    scanf("%d%d", &u, &v);
    u = Get(u);
    v = Get(v);
    A[u ^ 1][v] = 1;
    A[v ^ 1][u] = 1;
    edA[i] = mp(u, v);
  }
  rep(i, m2) {
    int u, v;
    scanf("%d%d", &u, &v);
    u = Get(u);
    v = Get(v);
    B[u ^ 1][v] = 1;
    B[v ^ 1][u] = 1;
    edB[i] = mp(u, v);
  }

  rep(i, n) odd[i << 1 | 1] = 1;
  rep(i, n << 1) A[i][i] = B[i][i] = 1;

  rep(i, n << 1) rep(j, n << 1) if (A[j][i]) A[j] |= A[i];
  rep(i, n << 1) rep(j, n << 1) if (B[j][i]) B[j] |= B[i];

  bool canA = 1, canB = 1;
  rep(i, n) if (A[i << 1][i << 1 | 1] && A[i << 1 | 1][i << 1]) {
    canA = 0;
    break;
  }
  rep(i, n) if (B[i << 1][i << 1 | 1] && B[i << 1 | 1][i << 1]) {
    canB = 0;
    break;
  }
  if (!canA && !canB) {
    cout << similar << endl;
  } else if (canA ^ canB) {
    if (canA) {
      find(A);
    } else {
      find(B);
    }
    rep(i, n) printf("%d ", ans[i]);
    printf("\n");
  } else {
    rep(i, m1) {
      int u = edA[i].X ^ 1, v = edA[i].Y ^ 1;
      if (Check(B[u] | B[v])) {
        ban[u ^ 1] = ban[v ^ 1] = 1;
        find(B);
        rep(i, n) printf("%d ", ans[i]);
        printf("\n");
        return 0;
      }
    }
    rep(i, m2) {
      int u = edB[i].X ^ 1, v = edB[i].Y ^ 1;
      if (Check(A[u] | A[v])) {
        ban[u ^ 1] = ban[v ^ 1] = 1;
        find(A);
        rep(i, n) printf("%d ", ans[i]);
        printf("\n");
        return 0;
      }
    }
    cout << similar << endl;
  }

#ifdef LOCAL_HOST
  printf("TIME: %.3lf\n", double(clock()) / CLOCKS_PER_SEC);
#endif

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,ans=1;
	cin>>a>>b;
	for(int i=min(a,b);i>0;i--)
	{
		ans*=i;
	}
	cout<<ans<<endl;
	return 0;
}


#include <stdio.h>
#include <memory.h>
#include <vector>
#include <time.h>
#include <algorithm>
using namespace std;

#define M 100100

int deg[M], num[M], a[M], b[M];

vector<int> v[M];

int main(){
	int i, j, k, n, m;
	int x, y;
	scanf("%d %d", &n, &m);
	for(i = 0; i < m; i ++){
		scanf("%d %d", &x, &y);
		v[x].push_back(y);
		v[y].push_back(x);
		deg[x] ++, deg[y] ++;
	}

	if(n < 20 and n * (n - 1) < 4 * m){
		puts("-1");
		return 0;
	}
	if(n == 4 and m == 3){
		for(i = 1; i <= 4; i ++) if(!deg[i])break;
		if(i <= 4){
			puts("-1");
			return 0;
		}
	}

	while(1){
		int ans = 0;
		memset(num, 0, sizeof(num));
		int t = rand() % n + 1;
		for(int ii = t; ii < n + t; ii ++){
			if(ii > n) i = ii - n;
			else i = ii;
			if(num[i] < 2){
				int I = v[i].size();
				if(I > 0) x = v[i][0];
				else x = 0;
				if(I > 1) y = v[i][1];
				else y = 0;
				for(j = i + 1; j <= n; j ++) if(i != j and num[j] < 2 and j != x and j != y){
					a[ans] = i, b[ans++] = j;
					num[i] ++;
					num[j] ++;
					if(ans == m){
						for(k = 0; k < ans; k ++){
							printf("%d %d\n", a[k], b[k]);
						}
						return 0;
					}
					if(num[i] == 2) break;
				}
			}
		}

		ans = 0;
		memset(num, 0, sizeof(num));
		t = rand() % n + 1;
		for(int ii = t + n; ii > t; ii --){
			if(ii > n) i = ii - n;
			else i = ii;
			if(num[i] < 2){
				int I = v[i].size();
				if(I > 0) x = v[i][0];
				else x = 0;
				if(I > 1) y = v[i][1];
				else y = 0;
				for(j = i + 1; j <= n; j ++) if(i != j and num[j] < 2 and j != x and j != y){
					a[ans] = i, b[ans++] = j;
					num[i] ++;
					num[j] ++;
					if(ans == m){
						for(k = 0; k < ans; k ++){
							printf("%d %d\n", a[k], b[k]);
						}
						return 0;
					}
					if(num[i] == 2) break;
				}
			}
		}

		if(clock() > 2800000.){
			puts("-1");
			return 0;
		}
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[10001];
int main()
{
	int sum=0,ans=0;
	cin>>a;
	for(int i=0;i<strlen(a);i++)
	{
		if(a[i]==a[i+1])
			sum++;
		else
		{
			if(sum%2!=0)
				ans++;
			sum=0;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

const int N = 220000;

int a[N], b[N], c[N], f[N], g[N];

void KMP(int *c, int n, int *f) {
	f[1] = 0;
	for (int j = 0, i = 1; i < n; i++) {
		while (j > 0 && c[i+1] != c[j+1]) j = f[j];
		if (c[i+1] == c[j+1]) j++;
		f[i+1] = j;
	}
}

int match(int *b, int *c, int n, int *f) {
	int j = 0;
	for (int i = 1; i <= n; i++) {
		while (j > 0 && c[j+1] != b[i]) j = f[j];
		if (c[j+1] == b[i]) j++;
	}
	return j;
}

int chk[N];

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	int n, m; cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i < n; i++) b[i] = a[i+1] - a[i];
	for (int i = 1; i < n; i++) c[n-i] = b[i];
	KMP(c, n-1, f);
	KMP(b, n-1, g);
	int x = match(b, c, n-1, f);
	int y = match(c, b, n-1, g);
	vector<int> ans;
	if (x == n-1) ans.push_back((a[1] + a[n]) % m);
	while (x > 0) {
		chk[n-1-x] |= 1;
		x = f[x];
	}
	chk[n-1] |= 1;
	while (y > 0) {
		chk[y+1] |= 2;
		y = g[y];
	}
	chk[1] |= 2;
	for (int i = 1; i <= n-1; i++) {
		if (chk[i] == 3) {
			if ((a[1] + a[i]) % m == (a[i+1] + a[n]) % m) {
				ans.push_back((a[1] + a[i]) % m);
			}
		}
	}
	sort(ans.begin(), ans.end());
	cout << ans.size() << endl;
	for (int t : ans) cout << t << " ";
	cout << endl;
	return 0;
}


#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <stdlib.h>
#include <sstream>
#include <assert.h>

#include <time.h>
#pragma comment(linker, "/STACK:20000000")

#define fr(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define fd(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define mp make_pair
#define pb push_back
#define ll long long

using namespace std;

int ri(){int x;scanf("%d",&x);return x;}
ll rll(){ll x;scanf("%lld",&x);return x;}

ll dp[1050];
ll a_cycle[1050];

void stupid_solve(int a,int b,int w,int x,int c)
{
	int res = 0;
	for(;c > a;)
	{
		if (b >= x)
			b -= x;
		else
			a--,b = w - (x - b);
		c--;
		res++;
	}

	cout << res << endl;
}

void solve()
{
	memset(dp,-1,sizeof(dp));
	srand(time(NULL));
	ll a,b,w,x,c;
	//a = rand() % 10000;
	//w = rand() % 999 + 2;
	//b = rand() % w;
	//x = rand() % w + 1;
	//c = rand() % 10000;
	cin >> a  >> b >> w >> x >> c;
	//stupid_solve(a,b,w,x,c);
	ll step = 0;
	ll tb = b;
	ll len_cycle = 0;
	ll pre_cycle = 0;
	ll aa = 0;
	ll aaa = 0;
	for(;;)
	{
		dp[b] = step;
		a_cycle[b] = aa;
		while(b >= x)
			b -= x,step++;
		b = w - (x - b);
		step++;
		aa++;
		if (dp[b] != -1)
		{
			len_cycle = step - dp[b];
			pre_cycle = step - len_cycle;
			aaa = aa - a_cycle[b];
			break;
		}
	}
	ll res = 0;
	b = tb;
	for(int i = 1; i <= pre_cycle;i++)
	{
		if (c <= a)
			break;
		if (b >= x)
			b -= x;
		else
			a--,b = w - (x - b);
		c--;
		res++;
	}
	if (c <= a)
	{
		cout << res << endl;
		return;
	}
	ll L = 0,R = 1e15;
	while(L + 1 < R)
	{
		ll mid = (L + R) >> 1;
		ll bb = (ll)a - aaa * mid;
		ll cc = (ll)c - (ll)len_cycle * mid;
		if (cc <= bb)
			R = mid;
		else
			L = mid;
	}
	res += len_cycle * L;
	a -= L * aaa;
	c -= len_cycle * L;
	for(;;)
	{
		if (c <= a)
			break;
		if (b >= x)
			b -= x;
		else
			a--,b = w - (x - b);
		res++;
		c--;
	}
	cout << res << endl;
}

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("C:/Users/CleRIC/Desktop/Универ/acm.timus.ru/input.txt","rt",stdin);
		freopen("C:/Users/CleRIC/Desktop/Универ/acm.timus.ru/output.txt","wt",stdout);
	#else
		//freopen("input.in","rt",stdin);
		//freopen("output.out","wt",stdout);
	#endif

	solve();

	#ifndef ONLINE_JUDGE
		printf("\n\ntime-%.3lf",clock()*1e-3);
	#endif

	return 0;
}


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

main(){
    int x,y,z;
    cin>>x>>y>>z;
    int a=sqrt((x*z)/y);
    int b=x/a;
    int c=z/a;
    cout<<4*(a+b+c);
    return 0;
}


#include<bits/stdc++.h>

#define ll long long
#define dl double

using namespace std;

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

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

    cout << n / 2 - !(n % 2) << endl;
    return 0;
}


    #include<bits/stdc++.h>

    using namespace std;

    #define mp make_pair
    #define pb push_back
    #define F first
    #define S second
    #define eb emplace_back
    #define endl '\n'
    #define INF INT_MAX
    #define MOD 1e9+7
    #define sz(a) (a).size()
    #define len(a) (a).length()
    #define all(v)  v.begin(),v.end()
    #define some(v, x) v.begin(), v.begin()+x
    #define RANGET(i,a) for(ll i=0; i<a; ++i)
    #define RANGE(i,a,b) for(ll i=a; i<b; ++i)
    #define RANGEI(i,a,b,inc) for(ll i=a; i<b; i+=inc)
    #define RANGER(i,a,b) for(ll i=a; i>=b; --i)

    typedef long long ll;
    typedef unsigned long long ull;
    typedef vector<ll> vl;
    typedef vector<vl> vvl;
    typedef vector<int> vi;
    typedef vector<double> vd;
    typedef vector<string> vs;
    typedef vector<char> vc;
    typedef vector<bool> vb;
    typedef vector<pair<int, int>> vpii;
    typedef vector<pair<ll, ll>> vpll;

    namespace io {
        inline int rdi() { int v;cin>>v;return v; }
        inline long long rdll() { long long v;cin>>v;return v;}
        inline string rds() { string s;cin>>s;return s; }
        inline char rdc() { char c;cin>>c;return c; }
        template<class T>
        void rdv(T beg_iter, T end_iter) {
            for(;beg_iter!=end_iter;++beg_iter)cin>>*beg_iter;
        }
        inline void wri(const int v) { cout<<v; }
        inline void wrll(const long long &v) { cout<<v; }
        inline void wrs(const string& s) { cout<<s; }
        inline void wrc(const char c) { cout<<c; }
        template<class T>
        void wrv(T beg_iter, T end_iter, string separator=" ", string end_of_line="\n") {
            for(;beg_iter!=end_iter;++beg_iter) {
                cout<<*beg_iter;
                cout<<separator;
            }
            cout<<end_of_line;
        }
    }
    using namespace io;

    int main()
    {
        ll n,m,r;
        cin>>n>>m>>r;
        ll a[n];ll b[m];
        ll a1 = INT_MAX;
        for(int i=0;i<n;i++){
            cin>>a[i];
            a1 = min(a1,a[i]);
        }
        ll ma = INT_MIN,r1 = 0,c1 = -1;
        for(int i=0;i<m;i++)
        {
            cin>>b[i];
            c1 = max(c1,b[i]);
        }
        // cout<<a1<<" "<<c1<<"\n";
        {
            ll r4 = r;
            ll ans = r/a1;
            r = r - ans*a1;
            r = r + ans*c1;
            // cout<<ans<<"\n";
            if(ans==0||(c1<=a1))
                cout<<r4<<"\n";
            else
            cout<<r<<"\n";
        }
        return 0;
    }


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <map>
#define mp make_pair

using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 998244353;
const string imp = "IMPOSSIBLE";

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
  int n;
  cin >> n;
  string str, s = "";
  cin >> str;
  for(auto i : str)
  {
    if(i != '0')
      s += i;
  }
  if(s.empty())
  {
    cout << "YES";
    return 0;
  }
  n = s.size();
  vector<int> v(n), pref(n);

  for(int i = 0; i < n; i++)
  {
    v[i] = (int)(s[i] - '0');
    pref[i] = v[i] + ((i) ? pref[i-1] : 0);
  }
  //for(auto i : pref) cout << i << " ";
  //for(auto i : v) cout << i << " ";
  for(int i = 0; i < n - 1; i++)
  {
    int sum = pref[i];
    int t = i+1, stI = i;
    while(t < n)
    {
      if(pref[t] - pref[stI] == sum)
      {
        stI = t;
        if(stI == n-1)
        {
          cout << "YES";
          return 0;
        }
      }
      else
        if(t == n-1)
          break;
      t++;
    }
  }
  cout << "NO";
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
#define N 5005
int b[N];
int n,q;
struct Node
{
	vector<int> v;
	map<pii,int> m;
};
Node a[N*4];
vector<pii> c;
int ans[N*20];
#define ls (u<<1)
#define rs (u<<1|1)
void build(int u,int l,int r)
{
	if(l==r) {a[u].v.pb(b[l]); return ;}
	int mid=(l+r)/2;
	build(ls,l,mid);
	build(rs,mid+1,r);
	int i=0,j=0;
	while(i<(int)a[ls].v.size()&&j<(int)a[rs].v.size())
	{
		if(a[ls].v[i]<a[rs].v[j]) a[u].v.pb(a[ls].v[i++]);
		else a[u].v.pb(a[rs].v[j++]);
	}
	while(i<(int)a[ls].v.size()) a[u].v.pb(a[ls].v[i++]);
	while(j<(int)a[rs].v.size()) a[u].v.pb(a[rs].v[j++]);
	// printf("-- %d %d %d ** %u %u\n",u,l,r,a[ls].v.size(),a[rs].v.size());
	// for(int i:a[u].v) printf("%d ",i); cout<<"\n";
}
int solve(int u,int L,int R)
{
	int l=lower_bound(a[u].v.begin(),a[u].v.end(),L)-a[u].v.begin();
	int r=upper_bound(a[u].v.begin(),a[u].v.end(),R)-a[u].v.begin();
	// printf("%d %d %d ** %d %d\n",u,L,R,l,r);
	if(l==(int)a[u].v.size()||l==r) return -1;
	if(l+1==r) return a[u].v[l];
	if(a[u].m[mp(l,r)]) return a[u].m[mp(l,r)];
	int x=solve(ls,L,R),y=solve(rs,L,R);
	if(x!=-1&&y!=-1)
	{
		c.eb(x,y);
		return a[u].m[mp(l,r)]=c.size()+n;
	}
	else return a[u].m[mp(l,r)]=max(x,y);
}
signed main()
{
	cin>>n>>q;
	for(int i=1;i<=n;i++) b[read()]=i;
	build(1,1,n);
	for(int i=1;i<=q;i++)
	{
		int l=read(),r=read();
		ans[i]=solve(1,l,r);
	}
	cout<<c.size()+n<<endl;
	for(auto [x,y]:c) printf("%d %d\n",x,y);
	for(int i=1;i<=q;i++) printf("%d ",ans[i]);
	return 0;
}


// very similar to codeforces journey 721C and bellman ford idea
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <functional>
#include <set>
#include <queue>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <cstring>
#include <numeric>

using namespace std;
typedef long long ll;

const int MAXN = 51;
const int MAXSUM = 2001;
const int INF = 1e8;

int n, s, k;
int dp[MAXSUM][MAXN]; // total sum, last-eaten position
int r[MAXN], color[MAXN];

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

    cin >> n >> s >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> r[i];
    }
    for (int i = 1; i <= n; ++i) {
        char type;
        cin >> type;
        color[i] = type == 'R' ? 1 : type == 'G' ? 2 : 3;
    }

    for (int i = 0; i < MAXSUM; ++i) {
        for (int j = 0; j < MAXN; ++j) {
            dp[i][j] = INF;
        }
    }

    dp[0][s] = 0;

    for (int sum = 0; sum < k; ++sum) {
        for (int cur = 0; cur <= n; ++cur) {
            if (dp[sum][cur] == INF) continue;
            for (int to = 1; to <= n; ++to) {
                if (sum == 0 || (r[to] > r[cur] && color[to] != color[cur])) {
                    int su = min(k, sum + r[to]);
                    int dist = abs(to - cur);
                    dp[su][to] = min(dp[su][to], dp[sum][cur] + dist);
                }
            }
        }
    }

    int res = INF;
    for (int cur = 0; cur <= n; ++cur) {
        res = min(res, dp[k][cur]);
    }
    cout << (res == INF ? -1 : res);
}


#include <map>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <list>
#include <queue>
#include <iostream>
using namespace std;

typedef unsigned long long ull;

const double PI = 3.14159265358979323846e0;

int a[200009];

int main()
{
	int n;
	double r, v;
	cin >> n >> r >> v;
	for (int k = 0; k < n; ++k) {
		double s, f;

		cin >> s >> f;
		f -= s;
		int round = (int)(f / (2 * PI * r));
		double res = round * 2 * PI * r / v;
		f -= round * 2 * PI * r;
		//cout << res << " " << f << endl;
		double low = 0, hi = 2 * PI;
		for (int k = 0; k < 60; ++k) {
			double mid = (low + hi) / 2;
			double l = mid * r + 2 * sin(mid / 2) * r;
			if (l < f) low = mid;
			else hi = mid;
		}
		//cout << low << endl;
		printf("%.9f\n", res + (low + hi) / 2 * r / v + 1e-9);
	}
	//system("pause");
	return 0;
}


#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

typedef long long ll;
#define MOD 1000000007ll

int T;
string s;
int N,K;
int p[500010],e[500010];

map <ll, int> mp[20];

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

void update_mp(void){
	int i,j;

	mp[0][0]++;

	REP(i,K){
		int pr = p[i];

		vector <ll> masks(pr);
		REP(j,T) masks[j%pr] |= (1ll<<j);

		snuke(mp[i],itr){
			ll mask = (itr->first);
			int cnt = (itr->second);
			REP(j,pr){
				ll mask2 = (mask | masks[j]);
				mp[i+1][mask2] = (mp[i+1][mask2] + cnt) % MOD;
			}
		}
	}
}

ll dp[500010][50];

ll func(void){
	int i,j;

	snuke(mp[K],itr){
		ll mask = (itr->first);
		ll cnt = (itr->second);

		bool good = true;
		int covered = 0;
		REP(i,T){
			if(mask&(1ll<<i)){
				if(s[i] == '0') good = false;
				if(s[i] == '1') covered++;
			}
		}

		if(good) dp[K][covered] = (dp[K][covered] + cnt) % MOD;
	}

	int ones = 0;
	REP(i,T) if(s[i] == '1') ones++;

	for(i=K;i<N;i++){
		ll pr = p[i];

		REP(j,ones+1){
			// not in s
			dp[i+1][j] = (dp[i+1][j] + dp[i][j] * (pr - T)) % MOD;
			// already covered
			dp[i+1][j] = (dp[i+1][j] + dp[i][j] * j) % MOD;
			// extend
			if(j < ones) dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j] * (ones - j)) % MOD;
		}
	}

	return dp[N][ones];
}

int main(void){
	int i;

	cin >> s >> N;
	REP(i,N) scanf("%d%d", &p[i], &e[i]);
	T = s.length();
	REP(i,T) s[i] = ((s[i] == '0') ? '1' : '0');

	ll prod = 1;
	REP(i,N) prod = prod * power(p[i], e[i] - 1) % MOD;

	sort(p, p+N);

	while(K < N && p[K] < 40) K++;
	update_mp();

	ll ans = func();

	ans = ans * prod % MOD;
	cout << ans << endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n,a,k,b,ans,pa=1,kl;
int head[5500000],vis[5500000],f[5500000];
queue<int>fi;
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
struct line{int fr,to,next;}q[12000001];
void pushline(int f,int t)
{
	if(f==t)return;
	if(f<0||t<0)return;
	q[++kl].next=head[f];head[f]=kl;q[kl].to=t;
}
void bfs(int x)
{
	fi.push(x);vis[x]=1;
	while(!fi.empty())
	{
		int u=fi.front();fi.pop();
		for(int p=head[u];p;p=q[p].next)
		{
			int v=q[p].to;
			if(!vis[v])
				vis[v]=1,f[v]=f[u]+1,fi.push(v);
		}

	}
}
signed main()
{
    cin>>a>>b>>k;
    for(int i=2;i<=k;i++)pa=pa*i/gcd(pa,i);
    for(int i=0;i<pa;i++)
    for(int j=2;j<=k;j++)
    {
    	pushline(i,i-(i%j));
	}
    for(int i=1;i<pa;i++)pushline(i,i-1);
    if(a/pa==b/pa){bfs(a%pa);cout<<f[b%pa];return 0;}
	bfs(pa-1);
	ans+=(a/pa-b/pa-1)*(f[0]+1);ans+=f[b%pa];
	memset(vis,0,sizeof(vis));memset(f,0,sizeof(f));
	bfs(a%pa);
	ans+=f[0]+1;
    cout<<ans;
}
/*
һ�������Ա��x/k��ȡ��*k
���Ըо����������LCM�Ͼͳ��׶������ˣ�ֻ��-1��
������α仯���ܵþ���LCM����ôֻҪ�����˶���Ĳ��ֱ����������������м����¾ͺ��ˡ�
*/


#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<queue>
#include<cmath>
#include <string>
#include<map>
#include<deque>
#include<vector>
#include<bitset>
#include<string>
#include<cstring>
#include<stack>
#include<set>
#include<functional>
using namespace std;
typedef pair<long long,long long> pll;
int a[33];
bool eq(int t){
	return a[t]==a[t+1]&&a[t]==a[t+2]&&a[t]==a[t+3];
}
bool eqh(int t){
	return a[t]==a[t+1]&&a[t+2]==a[t+3];
}
bool eqs(int t){
	return a[t]==a[t+2]&&a[t+1]==a[t+3];
}
bool feqh,feqs;
int main()
{
	for(int i=0;i<24;i++)scanf("%d",a+i+1);
	if((eq(1)&&eq(9)&&!eq(5)&&!eq(21)&&!eq(17)&&!eq(13))||
	(!eq(1)&&!eq(9)&&eq(5)&&eq(21)&&!eq(17)&&!eq(13))||
	(!eq(1)&&!eq(9)&&!eq(5)&&!eq(21)&&eq(17)&&eq(13))){//�����������
		for(int i=1;i<24;i+=4){
			if(!eqh(i)){feqh=1;break;
			}
		}
		for(int i=1;i<24;i+=4){
			if(!eqs(i)){feqs=1;break;
			}
		}if(feqh&&feqs){
		if(eq(5)){
			if(eqh(9)&&eqh(1)&&eqs(13)&&eqs(17)){
					if(a[1]==a[17]&&a[18]==a[10]&&a[11]==a[14]&&a[13]==a[3]){
					cout<<"YES"<<endl;return 0;
				}else if(a[1]==a[14]&&a[13]==a[9]&&a[11]==a[17]&&a[18]==a[3]){cout<<"YES"<<endl;return 0;
				}
			}
		}
		cout<<"NO"<<endl;return 0;
		}
		if(feqh){//eq��
			if(eq(1)){
				cout<<"NO"<<endl;return 0;
			}else if(eq(17)){
				if(a[7]==a[10]&&a[2]==a[22]&&a[9]==a[21]&&a[1]==a[6]){
					cout<<"YES"<<endl;
				}else if(a[7]==a[4]&a[1]==a[21]&&a[22]==a[10]&&a[9]==a[6]){cout<<"YES"<<endl;
				}else cout<<"no"<<endl;
			}else cout<<"no"<<endl;
		}else{//eq��
			if(eq(1)){
					if(a[7]==a[13]&&a[19]==a[6]&&a[23]==a[17]&&a[15]==a[21]){
					cout<<"YES"<<endl;
				}else if(a[15]==a[5]&&a[7]==a[17]&&a[22]==a[19]&&a[23]==a[13]){cout<<"YES"<<endl;
				}else cout<<"no"<<endl;
			}else{
				cout<<"NO"<<endl;
			}
		}
	}else cout<<"NO"<<endl;
	return 0;
}


//Twenty
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<ctime>
#include<queue>
using namespace std;
typedef long long LL;
int n,ans[100];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d",&n);
	for(int i=max(1,n-81);i<=n;i++) {
	    int tp=i,tpp=i;
	    while(tp) {
		    tpp+=tp%10;
		    tp/=10;
		}
		if(tpp==n) ans[++ans[0]]=i;
	}
	printf("%d\n",ans[0]);
	for(int i=1;i<=ans[0];i++)
	    printf("%d ",ans[i]);
	printf("\n");
	return 0;
}


#include <cstdio>
#define mod 1000000007
long long mul[1000001],div[1000001];
long long dp[1000001],sum[1000001];
long long powm(long long a,long long b)
{
    long long ret=1;
    while(b)
    {
        if(b&1)
            ret=(ret*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return ret;
}
int main()
{
    long long n,k,ans;
    scanf("%I64d%I64d",&n,&k);
    mul[0]=1;
    for(long long i=1;i<=n;i++)
        mul[i]=(mul[i-1]*i)%mod;
    for(long long i=1;i<=n;i++)
        div[i]=powm(mul[i],mod-2);
    ans=0;
    for(long long i=k+1;i<=n;i++)
    {
        dp[i]=(((i-k-1)*mul[i-2])%mod+(mul[i-2]*((sum[i-1]-sum[i-k-1]+mod)%mod))%mod)%mod;
        sum[i]=(sum[i-1]+(dp[i]*div[i-1])%mod)%mod;
        ans=(ans+((((dp[i]*mul[n-1])%mod)*div[i-1])%mod))%mod;
    }
    printf("%I64d\n",ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n>>s;
    int cnt=0;
    for(int i=0;i<s.length(); i++)
    if(s[i]=='8') cnt++;
    while(cnt)
    {
        if(cnt*11 <= s.length())
        {cout<<cnt <<'\n';
        return 0;
        }
        cnt--;
    }

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


#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main() {
    char s[9][9];
    for (int i=1; i<=8; i++) {
        for (int j=1; j<=8; j++) {
            cin>>s[i][j];
        }
    }
    int cntA=10,cntB=10;
    for (int i=1; i<=8; i++) {
        for (int j=1; j<=8; j++) {
            if (s[i][j]=='W') {
                bool p=true;
                for (int k=1; k<=i-1; k++) {
                    if (s[k][j]!='.') {
                        p=false;
                        break;
                    }
                }
                if (p) {
                    int x=abs(1-i);
                    if (x<cntA) {
                        cntA=x;
                    }
               }
            }
            if (s[i][j]=='B') {
                bool q=true;
                for (int k=i+1; k<=8; k++) {
                    if (s[k][j]!='.') {
                        q=false;
                        break;
                    }
                }

                if (q==true) {
                    int y=8-i;
                    if (y<cntB) {
                        cntB=y;
                    }
                }
            }
       }
    }
    if (cntA<=cntB) {
        cout<<"A"<<endl;
    } else {
        cout<<"B"<<endl;
    }
    //system("pause");
    return 0;
}


    #include <functional>
    #include <algorithm>
    #include <stdexcept>
    #include <iostream>
    #include <sstream>
    #include <fstream>
    #include <numeric>
    #include <iomanip>
    #include <cstdlib>
    #include <cstring>
    #include <utility>
    #include <cctype>
    #include <vector>
    #include <string>
    #include <bitset>
    #include <cmath>
    #include <queue>
    #include <stdio.h>
    #include <stack>
    #include <ctime>
    #include <list>
    #include <map>
    #include <set>
    #include <assert.h>
    #define REP(i,n) for(int i=0;i<n;i++)
    #define TR(i,x) for(typeof(x.begin()) i=x.begin();i!=x.end();i++)
    #define ALL(x) x.begin(),x.end()
    #define SORT(x) sort(ALL(x))
    #define CLEAR(x) memset(x,0,sizeof(x))
    #define FILL(x,c) memset(x,c,sizeof(x))

    using namespace std;

    const double eps = 1e-8;

    #define PB push_back
    #define MP make_pair

    typedef map<int,int> MII;
    typedef map<string,int> MSI;
    typedef vector<int> VI;
    typedef vector<string> VS;
    typedef vector<long double> VD;
    typedef pair<int,int> PII;
    typedef long long int64;
    typedef long long ll;
    typedef unsigned int UI;
    typedef long double LD;
    typedef unsigned long long ULL;

    vector<int> ch[26];
    vector< pair<int,int> > con[26];
    char s[1000007];
    int sat[1000007];
    int before[1000007];
    int k,L,R;

    int main()
    {
        gets(s);
        int n = strlen(s);
        REP(i,n)
        {
            before[i] = ch[s[i]-'a'].size();
            ch[s[i]-'a'].PB(i);
        }
        cin>>k>>L>>R;
        char t[10];
        REP(i,k)
        {
            int a,b;
            cin>>t>>a>>b;
            con[t[0] -'a'].PB(MP(a,b));
        }
        int now = 0;
        long long answer = 0;
        CLEAR(sat);
      //  cout<<"here\n";
        REP(i,n)
        {
        //    cout << "here\n";

            REP(j,26)
                TR(it,con[j])
                {
                    if (j==s[i]-'a')
                    {
                        if (it->first <= 1 && it->second >= 1)
                            ++sat[i];
                    }
                    else
                    {
                        if (it->first==0)
                            ++sat[i];
                    }
                }
              //  cout<<"here\n";
            if (sat[i]>=L&&sat[i]<=R)
                ++now;
            TR(it,con[s[i]-'a'])
            {
                if (before[i] >= it->second)
                {
          //          cout<<"here\n";
                    for (int j = before[i]-it->second-1<0 ? 0 : ch[s[i]-'a'][before[i]-it->second-1]+1;j <= min(i-1,ch[s[i]-'a'][before[i]-it->second]);++j)
                    {
                    //    cout<<j<<endl;
                        if (sat[j]>=L&&sat[j]<=R)
                            --now;
                        --sat[j];
                        if (sat[j]>=L&&sat[j]<=R)
                            ++now;
                    }
                }
            }
            TR(it,con[s[i]-'a'])
            {
                if (before[i]+1 >= it->first)
                {
                    int bound = before[i]-it->first+1 < ch[s[i]-'a'].size() ? ch[s[i]-'a'][before[i]-it->first+1] : i;
                    for (int j = before[i]-it->first<0 ? 0 : ch[s[i]-'a'][before[i]-it->first]+1;j <= min(i-1,bound);++j)
                    {
                        if (sat[j]>=L&&sat[j]<=R)
                            --now;
                        ++sat[j];
                        if (sat[j]>=L&&sat[j]<=R)
                            ++now;
                    }
                }
            }
        //    cout<<now<<endl;
            answer += now;
        }
        cout << answer << endl;
        return 0;
    }


#include <bits/stdc++.h>

using namespace std;
/*
int main() {
   // a == b mod m
   // m eh div de a - b
   int n, k;
   cin >> n >> k;
   for (int i = 0; i < n; i++) {
       scanf("%d", a + i);
   }
   for (int i = 0; i < n; i++) {
       for (int j = i + 1; j < n; j++) {
           int d = abs(a[i] - a[j]);
           adj[d].push_back(ii(i, j));
       }
   }
   for (int i = 2; i < ms; i++) {
       for (int j = i + i; j < ms; j += i) {

       }
   }
    return 0;
} /**/

typedef long long ll;

int main() {
    ll n, m, x, y;
    ll a, b;
    cin >> n >> m >> x >> y >> a >> b;
    ll g = __gcd(a, b);
    ll num = min(n / a, m / b), den = 1;
    for (ll q = 1; q * q <= g; q++) {
        if (g % q) continue;
        ll p = min(n * q / a, m * q / b);
        if (num * q < p * den) {
            num = p;
            den = q;
        }
        q = g / q;
        p = min(n * q / a, m * q / b);
        if (num * q < p * den) {
            num = p;
            den = q;
        }
        q = g / q;
    }
    a /= den;
    a *= num;
    b /= den;
    b *= num;
    ll x1, x2, y1, y2;
    if (a % 2 == 0) {
        x1 = x - a/2;
        x2 = x + a/2;
    } else {
        x1 = x - (a + 1) / 2;
        x2 = x + (a) / 2;
    }
    if (x1 < 0) {
        ll d = abs(x1);
        x1 += d;
        x2 += d;
    } else if (x2 > n) {
        ll d = x2 - n;
        x2 -= d;
        x1 -= d;
    }
    if (b % 2 == 0) {
        y1 = y - b/2;
        y2 = y + b/2;
    } else {
        y1 = y - (b + 1) / 2;
        y2 = y + (b) / 2;
    }
    if (y1 < 0) {
        ll d = abs(y1);
        y1 += d;
        y2 += d;
    } else if (y2 > m) {
        ll d = y2 - m;
        y2 -= d;
        y1 -= d;
    }
    cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << endl;
}/**/


#include <iostream>
#include <algorithm>

using namespace std;

long long a, b, st=1;

int main(){
	cin >> a >> b;
	if( b == 1 ){
		cout << a;
	}
	else{
		while(st <= a){
			st*=2;
		}
		cout<<st-1;
	}
}


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

using namespace std;

int main()
{
	int v1, v2;
	cin >> v1 >> v2;
	int t, d;
	cin >> t >> d;
	int sum = v1;
	for (int i = 2; i <= t; i++)
	{
		int cnt = 0;
		while (abs(v1 - v2) < (t - i)*d && cnt < d){
			v1++;
			cnt++;
		}
		cnt = 0;

		if(v1<v2)
		while (v2-v1>=(t - i)*d && cnt < d){
			cnt++;
			v1++;
		}
		cnt = 0;
		if(v1>v2)
		while (v1-v2>(t - i)*d && cnt < d){
			cnt++;
			v1--;
		}
		sum += v1;

	}
	cout << sum;
	return 0;
}


#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <cstring>
#include <string>
#include <queue>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	//ifstream in("in.txt");

	long long a, b, c, d, sum = 0;
	cin >> a >> b;

	while (b > 1)
	{
		c = a;
		d = b;
		a = max(d, c % d);
		b = min(d, c % d);
		sum += c / d;
	}

	if (b) sum += a;
	cout << sum << endl;

	//in.close();
	//system("pause");
	return 0;
}


#pragma GCC target("avx2")
#pragma GCC optimize("O3")

# include <x86intrin.h>
# 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;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++)
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 3123;
const int M = 22;
const int pri = 997;
const int Magic = 2101;

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

int n, m;
ll bal[N];
vector < int > g[N];
pair < int, ll > dp[N][N], ndp[N];
int sz[N];

void dfs (int v, int par = 0) {
	sz[v] = 1;
	dp[v][0] = mp(0, bal[v]);
	//cout << v << ' '<< bal[v] << "st\n";
	for (auto to : g[v]) if (to != par) {
		dfs(to, v);

		for (int j = 0; j <= sz[v] + sz[to]; ++j) {
			ndp[j] = mp(-n, 0);
		}
		for (int j = sz[v]; j >= 0; --j) {
			for (int k = sz[to]; k >= 0; --k) {
				pair < int, ll > nw;
				nw = mp(dp[v][j].F + dp[to][k].F, dp[v][j].S + dp[to][k].S);
				ndp[j + k] = max(ndp[j + k], nw);
				nw = mp(dp[v][j].F + dp[to][k].F + (dp[to][k].S > 0), dp[v][j].S);
				ndp[j + k + 1] = max(ndp[j + k + 1], nw);
			}
		}

		sz[v] += sz[to];
		for (int j = 0; j <= sz[v]; ++j) {
			dp[v][j] = ndp[j];
	//		cout << "state: " << v << ' ' << j << " val " << dp[v][j].F << ' ' << dp[v][j].S << '\n';
		}
	}

}

inline void solve () {
	cin >> n >> m;
	for (int i = 1, x; i <= n; i ++) {
		cin >> x;
		bal[i] = -x;
		g[i].clear();
	}
	for (int i = 1, x; i <= n; i ++) {
		cin >> x;
		bal[i] += x;
	}

	for (int i = 1; i < n; i ++) {
		int l, r;
		cin >> l >> r;
		g[l].pb(r);
		g[r].pb(l);
	}

	for (int i = 1; i <= n; ++ i) {
		for (int j = 0; j <= n; ++ j)
			dp[i][j] = mp(-n, 0);
	}

	dfs(1);
	--m;
	cout << dp[1][m].F + (dp[1][m].S > 0) << '\n';

}

int main () {
   	SpeedForce;
	int tt = 1;
	cin >> tt;
	while(tt--) solve();
   	return Accepted;
}

// B...a


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,k,m=1;
    bool yes=true;
    cin>>n>>k;
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    for(int i=0;i<n;i++)
    {
        if(s[i]==s[i+1])
            m++;
        else
        {
            if(m>k)
            {cout<<"NO"<<endl;yes=false;break;}
            else
                m=1;
        }
    }
    if(yes)
        cout<<"YES"<<endl;
    return 0;
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <deque>

using namespace std;

int tree[800500];
int x[200500], u[200500], t[200500];
pair<int, pair<int, int> > a[200500];

void build(int v, int l, int r){
    if (l == r - 1){
        tree[v] = a[l].second.first - a[l].second.second;
        return;
    }
    int m = (l + r) >> 1;
    build(v + v + 1, l, m);
    build(v + v + 2, m, r);
    tree[v] = min(tree[v + v + 1], tree[v + v + 2]);
}

void update(int v, int l, int r, int a, int b){
    if (l == r - 1){
        tree[v] = b;
        return;
    }
    int m = (l + r) >> 1;
    if (a < m)
        update(v + v + 1, l, m, a, b);
    else
        update(v + v + 2, m, r, a, b);
    tree[v] = min(tree[v + v + 1], tree[v + v + 2]);
}

int get(int v, int l, int r, int a, int b, int c){
    if (l >= b || r <= a)
        return 1e9;
    int m = (l + r) >> 1, k;
    if (a <= l && r <= b){
        if (l == r - 1)
            if(tree[v] <= c){
                return l;
            }else
                return 1e9;
        if (tree[v + v + 1] <= c)
            return get(v + v + 1, l, m, a, b, c);
        else
        if (tree[v + v + 2] <= c)
            return get(v + v + 2, m, r, a, b, c);
        else
            return 1e9;
    }
    k = get(v + v + 1, l, m, a, b, c);
    if (k > 1e8)
        return get(v + v + 2, m, r, a, b, c);
    else
        return k;
}

int main(){
    //freopen("triangles.in", "r", stdin);
    //freopen("triangles.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        cin >> x[i];
    sort(x, x + n);
    for (int i = 0; i < m; i++){
        cin >> a[i].second.first >> a[i].second.second;
        a[i].first = a[i].second.first + a[i].second.second;
    }
    sort(a, a + m);
    build(0, 0, m);
    int pos = 0, ans = 0;
    for (int i = 0; i < n; i++){
        while (pos < m && x[i] > a[pos].second.first + a[pos].second.second)
            pos++;
        int k = get(0, 0, m, pos, m, x[i]);
        //cout << i << " " << k << endl;
        if (k < 1e8){
            update(0, 0, m, k, 2e9 + 1000);
            ans++;
        }
    }
    cout << ans;
    return 0;
}


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

string a, b, c;

int getidx(string s)
{
	if(s == "C") return 1;
	if(s == "C#") return 2;
	if(s == "D") return 3;
	if(s == "D#") return 4;
	if(s == "E") return 5;
	if(s == "F") return 6;
	if(s == "F#") return 7;
	if(s == "G") return 8;
	if(s == "G#") return 9;
	if(s == "A") return 10;
	if(s == "B") return 11;
	if(s == "H") return 12;
}

int main()
{
	string notes[3];
	cin >> notes[0] >> notes[1] >> notes[2];
	sort(notes, notes + 3);
	do
	{
	int p1 = getidx(notes[0]);
	int p2 = getidx(notes[1]);
	int p3 = getidx(notes[2]);

	//cout << notes[0] <<" " << notes[1] << " "<<notes[2] << endl;
    int dis1, dis2;
		if(p1 > p2)
	{
		dis1 = (12 - p1) + p2;
	}
	else
	{
		dis1 = p2 - p1;
	}

	if(p2 > p3)
	{
		dis2 = (12 - p2) + p3;
	}
	else
	{
		dis2 = p3 - p2;
	}

	if(dis1 == 4 && dis2 == 3) { cout << "major"; return 0; }
	if(dis1 == 3 && dis2 == 4) { cout << "minor"; return 0; }

	}while(next_permutation(notes, notes + 3));

	cout << "strange";
	return 0;
}


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

#ifdef DEBUG
#define debug(...) __VA_ARGS__
#else
#define endl '\n'
#define debug(...)
#endif
#define debugf(...) debug(printf(__VA_ARGS__))

const int N = 1e5 + 5;
const int K = 20;
const int oo = 0x3f3f3f3f;

int P[K];
void Build() {
    iota(P, P+K, 0);
}
int Find(int i) {
    return i == P[i] ? i : (P[i] = Find(P[i]));
}
void Union(int i, int j) {
    if ((i=Find(i)) == (j=Find(j))) return;
    P[i] = j;
}
int Components() {
    bitset<K> counted;
    int ans = 0;
    for (int i = 0; i < K; i++) {
        if (!counted[Find(i)]) {
            counted.set(Find(i));
            ans++;
        }
    }
    return ans;
}

int g[K];
bool is_dag[1<<K];

int solve() {
    int n; cin >> n;
    string s, t;
    cin >> s >> t;

    memset(g, 0, sizeof(g));

    Build();
    for (int i = 0; i < n; i++) {
        int si = s[i] - 'a';
        int ti = t[i] - 'a';
        if (si != ti) {
            g[si] |= 1 << ti;
            Union(si, ti);
        }
    }

    memset(is_dag, 0, sizeof(is_dag));
    is_dag[0] = true;
    for (int m = 1; m < (1<<K); m++) {
        for (int i = 0; i < K; i++) {
            if (m & (1<<i))
                is_dag[m] |= is_dag[m &~ (1<<i)] && (g[i] & (m &~ (1<<i))) == 0;
        }
    }

    int best = 0;
    for (int m = 1; m < (1<<K); m++) {
        if (is_dag[m])
            best = max(best, __builtin_popcount(m));
    }

    return 2 * (K - best) + best - Components();
}

int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int t; cin >> t;
    while (t--)
        cout << solve() << endl;

    return 0;
%>


#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}
template<unsigned MOD> struct ModInt {
    static const unsigned static_MOD = MOD;
    unsigned x;
    void undef() { x = (unsigned)-1; }
    bool isnan() const { return x == (unsigned)-1; }
    inline int geti() const { return (int)x; }
    ModInt() { x = 0; }
    ModInt(const ModInt &y) { x = y.x; }
    ModInt(int y) { if (y<0 || (int)MOD<=y) y %= (int)MOD; if (y<0) y += MOD; x=y; }
    ModInt(unsigned y) { if (MOD<=y) x = y % MOD; else x = y; }
    ModInt(long long y) { if (y<0 || MOD<=y) y %= MOD; if (y<0) y += MOD; x=y; }
    ModInt(unsigned long long y) { if (MOD<=y) x = y % MOD; else x = y; }
    ModInt &operator+=(const ModInt y) { if ((x += y.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(const ModInt y) { if ((x -= y.x) & (1u<<31)) x += MOD; return *this; }
    ModInt &operator*=(const ModInt y) { x = (unsigned long long)x * y.x % MOD; return *this; }
    ModInt &operator/=(const ModInt y) { x = (unsigned long long)x * y.inv().x % MOD; return *this; }
    ModInt operator-() const { return (x ? MOD-x: 0); }

    ModInt inv() const {
	unsigned a = MOD, b = x; int u = 0, v = 1;
	while (b) {
	    int t = a / b;
	    a -= t * b; swap(a, b);
	    u -= t * v; swap(u, v);
	}
	if (u < 0) u += MOD;
	return ModInt(u);
    }
    ModInt pow(long long y) const {
	ModInt b = *this, r = 1;
	if (y < 0) { b = b.inv(); y = -y; }
	for (; y; y>>=1) {
	    if (y&1) r *= b;
	    b *= b;
	}
	return r;
    }
    friend ModInt operator+(ModInt x, const ModInt y) { return x += y; }
    friend ModInt operator-(ModInt x, const ModInt y) { return x -= y; }
    friend ModInt operator*(ModInt x, const ModInt y) { return x *= y; }
    friend ModInt operator/(ModInt x, const ModInt y) { return x *= y.inv(); }
    friend bool operator<(const ModInt x, const ModInt y) { return x.x < y.x; }
    friend bool operator==(const ModInt x, const ModInt y) { return x.x == y.x; }
    friend bool operator!=(const ModInt x, const ModInt y) { return x.x != y.x; }
};

const LL MOD = 1000000007;
typedef ModInt<MOD> Mint;

const int MAX = 100;
Mint inv[MAX+1], fact[MAX+1], fact_inv[MAX+1];

void init() {
    inv[1] = 1;
    for (int i=2; i<=MAX; i++) inv[i] = inv[MOD%i] * (MOD-MOD/i);

    fact[0] = fact_inv[0] = 1;
    for (int i=1; i<=MAX; i++) {
	fact[i] = fact[i-1] * i;
	fact_inv[i] = fact_inv[i-1] * inv[i];
    }
}

Mint nCk(int n, int k) {
    return fact[n] * fact_inv[k] * fact_inv[n-k];
}

int N, P;
int C[55];
Mint dp[55][55][55][55];

void MAIN() {
    scanf("%d%d", &N, &P);
    REP (i, N) scanf("%d", C+i);

    init();

    dp[0][0][0][0] = 1;

    REP (i, N) REP (EB, i+1) REP (EW, i+1-EB) REP (OB, i+1-EB-EW) {
	Mint val = dp[i][EB][EW][OB];
	if (val.x == 0u) continue;
	int OW = i-EB-EW-OB;

	if (C[i] != 1) {
	    // B;
	    REP (ow, OW+1) {
		int mypath = (ow + 1) & 1;
		int nEB = EB + (mypath == 0);
		int nOB = OB + (mypath == 1);

		dp[i+1][nEB][EW][nOB] += val * nCk(OW, ow) * (1LL<<(i-OW));
	    }
	}

	if (C[i] != 0) {
	    // W;
	    REP (ob, OB+1) {
		int mypath = (ob + 1) & 1;
		int nEW = EW + (mypath == 0);
		int nOW = OW + (mypath == 1);

		dp[i+1][EB][nEW][OB] += val * nCk(OB, ob) * (1LL<<(i-OB));
	    }
	}
    }

    Mint ans = 0;
    REP (EB, N+1) REP (EW, N+1-EB) REP (OB, N+1-EB-EW) {
	int OW = N-EB-EW-OB;
	int parity = (OB + OW) & 1;
	if (parity == P) ans += dp[N][EB][EW][OB];
    }

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

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int x,y,z,t1,t2,t3;
	cin>>x>>y>>z>>t1>>t2>>t3;
	int stair=0,ele=0;
	stair=abs(x-y)*t1;
	ele+=abs(x-z)*t2+2*t3;
	ele+=abs(x-y)*t2+t3;
	//cout<<ele<<" "<<stair<<"\n";
	ele<=stair?cout<<"YES\n":cout<<"NO\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n = 6, i = 0, cnt = 0;
    int arr[n];
    int sum = 0;
    bool x=false;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
        sum += arr[i];
    }
    sort(arr, arr + n);
    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            for (int k = j+1; k < n; k++)
            {
                int temp=arr[i]+arr[j]+arr[k];
                if((sum-temp)==temp)
                {
                    x=true;
                    break;
                }
            }

        }

    }

    if (x)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}


#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#define ll long long
using namespace std;

int main(){
    ll n;
    cin>>n;
    ll bst=1;

    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            bst=bst*i;
            while(n%i==0) n/=i;
        }
    }
    if(n>1) bst*=n;
    cout<<bst<<endl;
}


//Convert from int to char (0 to 25 )--->(a to z) == (char)(int+97)
//Convert from char int to int char-48

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

string s1,s2,s3;
map<char,int> mp;
map<int,char> mp1;
int main()
{
   mp['A']=0;
   mp['B']=0;
   mp['C']=0;

   cin>>s1>>s2>>s3;

   if(s1[1]=='>') mp[s1[0]]++;
   else  mp[s1[2]]++;
   if(s2[1]=='>') mp[s2[0]]++;
   else  mp[s2[2]]++;
   if(s3[1]=='>') mp[s3[0]]++;
   else  mp[s3[2]]++;

   if(mp['A']==1&&mp['B']==1&&mp['C']==1) { cout<<"Impossible"<<endl; return 0;}

   mp1[mp['A']]='A';
   mp1[mp['B']]='B';
   mp1[mp['C']]='C';

   for(map<int,char>::iterator it=mp1.begin();it!=mp1.end();it++)
    cout<<it->second;

   return 0;
}


#include <bits/stdc++.h>
#include<string>
#define sz(v)   ((int)(v).size())
#define  eps      0.0000000001
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   inf        0x7fffffff
#define    PI        3.1415926536
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define    vi       vector<int>
#define    vd       vector<double>
#define    vvi      vector< vector<int> >
#define    vvpi     vector< vector< pair<int,int> > >
#define    vvpll     vector< vector< pair<long long,long long> > >
#define    vvd      vector< vector<double> >
#define    vs       vector<string>
#define    vvs      vector< vector<string> >
#define     vc        vector<char>
#define     vpi        vector< pair<int ,int> >
#define      pi        pair<int ,int>
#define      pll       pair<long long ,long long>
#define     vpd        vector< pair<double ,double> >
#define     vpll        vector< pair<long long ,long long> >
#define    vll       vector<long long>
#define    dqi        deque< int >
#define     si         set<int>
#define     spi        set< pair<int ,int > >
#define     row          vector< ll >
#define     matrix            vector< row >
#define    lp(i,n)    for(i=0;i<n;i++)
#define     si         set<int>
#define    oo         100000000
#define   MOD         1000000007
#define    X            real
#define    Y            imag
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define    scani(n)                  scanf("%d",&n)
#define    scanll(n)                  scanf("%I64d",&n)
#define    printi(n)                 printf("%d",n)
#define    printll(n)                 printf("%I64d",n)
#define    scand(n)                  scanf("%lf",&n)
#define    printd(n)                 printf("%lf",n)
#define    scans(n)                  scanf("%s",&n)
#define    prints(n)                 printf("%s",n)
typedef  long long     ll ;
typedef  unsigned long long ull;
using namespace std;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1 ;}
ll fun(ll lev)
{
    return  (3*((lev)*(lev+1)/2)-lev);
}

int main()
{
    ll n,i,s=0,ans;

    cin>>n;

    for(i=1;;i++)
    {

        ans=fun(i);

        if(ans>n)
            break;

          if((i+n)%3==0)
            s++;

    }

    cout<<s<<endl;
}