#include<bits/stdc++.h>
#define ll long long
using namespace std;
int t;ll n,s,k,d;
inline ll gcd(ll x,ll y){
	while(y^=x^=y^=x%=y);
	return x;
}
ll exgcd(ll a,ll b,ll &x,ll &y){
    if(b==0){x=1,y=0;return a;}
    int r=exgcd(b,a%b,y,x);
    y-=a/b*x;
    return r;
}
signed main(){
	scanf("%d",&t);
    while(t--){
        scanf("%lld%lld%lld",&n,&s,&k);
        ll c=-s,x,y,d=exgcd(k,n,x,y);
    	if(c%d)puts("-1");
    	else{
    		ll a=c/d,b=n/d;
    		printf("%lld\n",((a*x)%b+b)%b);
		}
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define ZERO {puts("0"); return 0;}
#define NO {puts("No"); return 0;}
#define ALL(obj) begin(obj), end(obj)
#define pb push_back

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

ll Euler (ll x)
{
	ll ans = x;
	for (ll i = 2; i * i <= x; ++i)
	{
		if (x % i == 0) ans = ans * (i-1) / i;
		while (x % i == 0) x /= i;
	}
	if (x != 1)
		ans = ans * (x-1) / x;
	return ans;
}

ll power_mod(ll x, ll k, ll n)
{
	ll ans = 1;
	while (k > 0)
	{
		if (k & 1) ans = ans * x % n;
		x = x * x % n;
		k >>= 1;
	}
	return ans;
}

ll solve()
{
	ll n, s, k; cin >> n >> s >> k;
	s = n - s;
	ll g = __gcd(k, n);
	if (s % g) return -1;
	n /= g, s /= g, k /= g;
	ll phi = Euler(n);
	ll inv_k= power_mod(k, phi-1, n);
	return inv_k*s%n;
}

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


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

#define pb push_back
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define ld long double
#define TIME 1.0*clock()/CLOCKS_PER_SEC
#define pii pair < int , int >
#define Endl '\n'

#pragma GCC optimize("Ofast")

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

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

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
const int FFTM = 998244353;

const int SX[4] = {0 , 1 ,  - 1 , 0};
const int SY[4] = {1 , 0 , 0 ,  - 1};
const int rx[8] = {1,  - 1, 0, 0, 1, 1, -1, -1};
const int ry[8] = {0, 0, 1,  - 1, 1,  - 1, 1, -1};
const int kx[8] = {1, 1, -1, -1, 2, 2, -2, -2};
const int ky[8] = {2, -2, 2, -2, 1, -1, 1, -1};

typedef cc_hash_table< int, int, hash<int>, equal_to<int>, direct_mask_range_hashing<int>, hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("railroad.in", "r", stdin);
//    freopen("railroad.out", "w", stdout);
#endif
    int n;
    cin >> n;
    int a[n];
    for (int i = 0;i < n; ++i)cin >> a[i];
    sort(a, a + n);
    if (a[0] != 1){
        cout << "No" << endl;
        return 0;
    }
    for (int i = 1;i < n; ++i){
        if (a[i] - a[i - 1] != 1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

// Powered by CP Editor (https://cpeditor.org)

//a+b = (a^b) + 2*(a&b)
//b^c = (a^b)^(a^c)
//gcd(x,y) = gcd(x-y,y)
//if n = 5000 then complexity cannot be (n^2*log(n)) means no map ,no sets
//check for long long overflow if input is large
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
//#define mod 1000000007
#define mod 998244353
#define pb push_back
#define ll long long
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define loop(i,n) for(int i=0;i<n;i++)
#define pp  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fill(a,b) memset(a, b, sizeof(a))
#define all(x) (x).begin(), (x).end()

#define en cout<<"\n"

#define trace(x) cout<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl

using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
const long long INF = 2000000000000000000;

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

void solve()
{
	int n;
	cin>>n;
	int ar[n];
	loop(i,n) cin>>ar[i];
	sort(ar,ar+n);
	for(int i=0;i<n;i++)
	{
		if(ar[i]!=i+1)
		{
			cout<<"No";return;
		}
	}
	cout<<"Yes";
}

int32_t main()
{
pp;
int test=1;
// cin>>test;
while(test--)
{
	solve();
	en;
}
return 0 ;
}


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

int main() {
	long long int t,a,b,s,z,r;
	cin>>t;
	s=0;
	while(t--)
	{
	    cin>>a>>b;
	    z=((b+1)*(b))/2;
	    r=((a)*(a-1))/2;
	    s+=z-r;
	}
	cout<<s<<"\n";
	return 0;
}

/*input
1000 1

*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int T = 1; // cin>>T;
	while(T--)
	{
		int N,W;cin>>N>>W;cout<<(N/W)<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main ()
{
    int n;
    cin >> n;
    if(n<=100) cout << "1";
    else
    {
        int l=n/100;
        if(l*100<n) l++;
        cout << l;
    }
}

#include <bits/stdc++.h>
#define INT_MINs -2000000000
#define INT_MAXs 1000000001
#define MID int mid=(l+r)/2
#define REP1(i,x,y) for(int i=x;i<y;i++)
#define REP2(i,x,y) for(int i=x;i<=y;i++)
#define ls (2*k)
#define rs (2*k+1)
#define lson l,mid,2*k
#define rson mid+1,r,2*k+1
#define lc u << 1
#define rc u << 1 | 1
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define IOS ios::sync_with_stdio(0);cin.tie(NULL);
#define pb(a) push_back(a)
#define pi acos(-1)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod=2520;
const int dx[8] = { 0,-1,0,1,-1,-1,1,1}, dy[8] = { 1,0,-1,0,-1,1,-1,1};

void solve(){
    int n;
    cin>>n;
    cout<<(n+99)/100<<endl;
}

int main()
{
    IOS;
    solve();
    return 0;
}


#include <iostream>

int main(){
	int n, i;
    double re=0.0;

    std::cin >> n;

    for(i=0; i<n-1; i++){
        re += (double) (n/(n-1.0-i));
    }

    std::cout << std::fixed
    << re << std::endl;
}

#include <bits/stdc++.h>

template <typename T>
T next() {
    T temp; std::cin >> temp;
    return temp;
}

template <>
int next() {
    int temp; scanf("%d", &temp);
    return temp;
}
template <>
long long next() {
    long long temp; scanf("%lld", &temp);
    return temp;
}
template <>
double next() {
    double temp; scanf("%lf", &temp);
    return temp;
}
template <>
float next() {
    float temp; scanf("%f", &temp);
    return temp;
}

template <typename T1, typename T2>
std::pair<T1, T2> next() {
    std::pair<T1, T2> temp;
    temp.first = next<T1>();
    temp.second = next<T2>();
    return temp;
}

template <typename T>
std::vector<T> next(int n) {
    std::vector<T> temp(n);
    for(int i = 0; i < n; i++)
        temp[i] = next<T>();
    return temp;
}

template <typename T1, typename T2>
std::vector<std::pair<T1, T2>> next(int n) {
    std::vector<std::pair<T1, T2>> temp(n);
    for(int i = 0; i < n; i++)
        temp[i] = next<T1, T2>();
    return temp;
}

template <typename T>
void print(const T &x, char endc = '\n') {
    std::cout << x << endc;
    return;
}
void print(const int &x, char endc = '\n') {
    printf("%d%c", x, endc);
    return;
}
void print(const long long &x, char endc = '\n') {
    printf("%lld%c", x, endc);
    return;
}
void print(const size_t &x, char endc = '\n') {
    printf("%zu%c", x, endc);
    return;
}
void print(const float &x, char endc = '\n') {
    printf("%f%c", x, endc);
    return;
}
void print(const double &x, char endc = '\n') {
    printf("%lf%c", x, endc);
    return;
}

template<typename T1, typename T2>
void print(const std::pair<T1, T2> &p, char sepc = ' ', char endc = '\n') {
    print(p.first, sepc);
    print(p.second, endc);
    return;
}

template<typename T>
void print(const std::vector<T> &v, char sepc = ' ', char endc = '\n') {
    for(const T &e : v) print(e, sepc);
    printf("%c", endc);
    return;
}

template<typename T>
class SparseGraph {
    struct Node {
        std::vector<std::pair<int, T>> adj;
        T value;
    };

private:
    std::vector<Node> nodes;
    int nodeSize;
    int edgeSize = 0;

public:
    SparseGraph(int n) {
        nodes.resize(n);
        nodeSize = n;
    }

    SparseGraph(const std::vector<T> &values) {
        int n = values.size();
        nodes.resize(n);
        nodeSize = n;
        for(int i = 0; i < n; i++)
            nodes[i].value = values[i];
    }

    void addEdge(int u, int v, const T &edgeVal = 0) {
        nodes[u].adj.push_back({v, edgeVal});
        edgeSize++;
    }

    const int &getNodeSize() const {
        return nodeSize;
    }

    const int &getEdgeSize() const {
        return edgeSize;
    }

    const T &valueOf(int here) const {
        return nodes[here].value;
    }

    const std::vector<std::pair<int, T>> &adjOf(int here) const {
        return nodes[here].adj;
    }
};

using namespace std;

double solve(int connected, int disconnected, vector<double> &memo) {
    if(disconnected == 0)
        return 0.0;

    double &ret = memo[connected];
    if(!ret) {
        ret = solve(connected+1, disconnected-1, memo) + 1.0 + 1.0*connected/disconnected;
    }

    return ret;
}

void eachTC() {
    int N = next<int>();
    vector<double> memo(N, 0.0);
    double res = solve(1, N-1, memo);
    printf("%.9lf", res);
}

int main() {
    constexpr bool multipleTC = false;
    int T = multipleTC ? next<int>() : 1;
    while(T--) eachTC();

    return 0;
}


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

#define ull                 unsigned long long
#define ll                  long long
// #define int                 long long
#define pii                 pair<int, int>
#define pll                 pair<ll, ll>
#define pb                  push_back
#define mk                  make_pair
#define ff                  first
#define ss                  second
#define all(a)              a.begin(),a.end()
#define trav(x,v)           for(auto &x:v)
#define rep(i,n)            for(int i=0;i<n;i++)
#define repe(i,n)           for(int i=1;i<=n;i++)
#define read(a,n)           rep(i,n)cin>>a[i]
#define reade(a,n)          repe(i,n)cin>>a[i]
#define FOR(i,a,b)          for(int i=a;i<=b;i++)
#define printar(a,s,e)      FOR(i,s,e)cout<<a[i]<<" ";cout<<'\n'
#define curtime             chrono::high_resolution_clock::now()
#define timedif(start,end)  chrono::duration_cast<chrono::nanoseconds>(end - start).count()

auto time0 = curtime;
const int MD=1e9+7;
const int MDL=998244353;
const int INF=1e9;
const int MX=1e5+5;

void solve(){

    int n;
    string s;
    cin>>n;
    cin>>s;
    if(s[0]!=s[n-1]){
        cout<<"1\n";
        return;
    }
    FOR(i,0,n-2)
        if(s[i]!=s[0] && s[i+1]!=s[0]){
            cout<<"2\n";
            return;
        }
    cout<<"-1\n";

}

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

    time0 = curtime;
    srand(time(NULL));
    int t=1;
    // cin>>t;
    repe(tt,t){
        // cout<<"Case #"<<tt<<": ";
        solve();
    }

    // cerr<<"Execution Time: "<<timedif(time0,curtime)*1e-9<<" sec\n";
    return 0;

}

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

using namespace std;
using namespace __gnu_pbds;

#define pb push_back
#define mp make_pair
#define lli long long int
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define mii map<lli,lli>
#define msi map<string,lli>
#define pii pair<lli,lli>
#define vi vector<lli>
#define vii vector<pair<lli,lli>>
#define vvi vector< vector<lli> >
#define sz(x) (lli)x.size()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX1 998244353
#define MAX2 1000000007

// Policy based data structure
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> Ordered_set;
// Ordered_set s;
// *s.find_by_order(a);
// s.order_of_key(a);
// s.erase(s.find_by_order( s.order_of_key(v[i-k]) ));

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define input(data,n,command) for(lli i=0;i<n;i++){lli tmp;cin>>tmp;data.pb(tmp);command}
#define sort_asc(a) sort(a.begin(),a.end());
//#define sort_desc(a) sort(a.begin(),a.end(),greater<lli>());
#define display(a) for(lli i = 0 ;i<a.size();i++){cout<<a[i]<<" ";} cout<<endl;
#define rep(i,a,b) for(lli i = a;i < b;i++)
#define endl "\n"
#define INF 1000000000000000000
#define MAXN 100010

//Written By MUDIT BHARDWAJ...
/*--------------------------------------------------------------------*/
//vector<pair<lli,lli>>adj[300010];
lli n;
vector<pair<lli,pii>> v;

lli intersect(pair<lli,pii> tmp1,pair<lli,pii> tmp2)
{
    lli t1,l1,r1,t2,l2,r2;
    t1 = tmp1.F;
    l1 = tmp1.S.F;
    r1 = tmp1.S.S;
    t2 = tmp2.F;
    l2 = tmp2.S.F;
    r2 = tmp2.S.S;
    lli l = max(l1,l2);
    lli r = min(r1,r2);
    if(l < r)
    {
        return true;
    }
    else if(l == r)
    {
        if(l1 <= l2)
        {
            if(((t1 != 2)&&(t1 != 4)&&(t2 != 3)&&(t2 != 4)))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        else
        {
            if(((t1 != 3)&&(t1 != 4)&&(t2 != 2)&&(t2 != 4)))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
    else
    {
        return false;
    }
}

lli solve()
{
    //auto start = chrono::steady_clock::now();

    //start from here
    cin>>n;
    rep(i,0,n)
    {
        lli a,b,c;
        cin>>a>>b>>c;
        v.pb(mp(a,mp(b,c)));
    }

    lli ans = 0;
    for(lli i = 0;i<n;i++)
    {
        for(lli j = i+1;j<n;j++)
        {
            if(intersect(v[i],v[j]))
            {
                ans++;
            }
        }
    }
    cout<<ans<<endl;

    //auto end = chrono::steady_clock::now();
    //cout << "Elapsed time in milliseconds : "<< chrono::duration_cast<chrono::milliseconds>(end - start).count()<< " ms" << endl;
    return 0;
}

int main()
{
    ios
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    lli T=1;
    //cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}
/*-----------------------------------------------------------------------*/


#include <bits/stdc++.h>
using namespace std;
int ctoi(char);
#define MAX_N 200001
#define l long
#define ll long long
#define f(a, b) for (ll i = a; i < b; i++)
#define f0(a) for (ll i=0;i<a;i++)
#define input(d) cin >> d;
#define inputs(n,d) for(int i=0;i<n;i++){cin >> d[i];}
#define output(d) cout << d << endl;
#define outputs(n,d) for(int i=0;i<n;i++){cout << d[i] << endl;}

int main(void) {
	//ll n;
	//l n;
	l plus, minus;
	l ans, tmp;
	input(plus);
	input(minus);
	//vector<l> tate(h,0);
	//vector<l> yoko(w,0);
	//vector<l> tate_max(2,0);
	//vector<l> yoko_max(2,0);
	//vector<vector <l> > bakudan(m,vector<l>(2,0));
	//
	tmp = (plus+minus)/2;
	ans = plus - tmp;
	//
	cout << tmp << " " << ans << endl;

	return 0;
}

int ctoi(char c){
	switch(c){
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default : return -1;
	}
}

#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define mp make_pair
#define endl "\n"
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lb lower_bound
#define forn(i,n) for(ll i=0 ; i<n ; i++)
#define arr(a,n) for(ll i=0;i<n;i++){ cin>>a[i]; }
#define ub upper_bound
#define pb push_back
#define pi pair<int,int>
#define mod 1000000007
#define vectormax *max_element
#define vectormin *min_element
#define arraysize 1000000
#define setbit _builtin_popcountll
using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	ll temp=(a+b)/2;
	ll hey=(a-b)/2;
	cout<<temp<<" "<<hey<<endl;
	return 0;
	}


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

typedef long long ll;

int64_t comb(int x, int y) {
    int64_t res(1);
    for (int i = 1; i <= x; ++i) {
        res *= (x + y + 1 - i);
        res /= i;
    }
    return res;
}

string solve(int64_t A, int64_t B, int64_t K) {
    string res;
    while (A + B > 0) {
        if (K == 0) {
            for (int i = 0; i < A; ++i) {
                res.push_back('a');
            }
            for (int i = 0; i < B; ++i) {
                res.push_back('b');
            }
            break;
        }
        auto v = comb(A-1, B);
//        cerr << K << ", " << v << endl;
        if (K >= v) {
            res.push_back('b');
            K -= v;
            B -= 1;
        } else {
            res.push_back('a');
            A -= 1;
        }
    }
    return res;
}

// generated by oj-template v4.7.2 (https://github.com/online-judge-tools/template-generator)
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    int64_t A, B, K;
    cin >> A >> B >> K;
    K--;
    auto ans = solve(A, B, K);
    cout << ans << endl;
    return 0;
}

                        //    I solemnly swear that I am upto no good //

#include <bits/stdc++.h>
using namespace std;
#define sub             freopen("input.txt", "r", stdin);//freopen("output.txt", "w", stdout);
#define ll              long long
#define ld              long double
#define ttime           cerr << '\n'<<"Time (in s): " << double(clock() - clk) * 1.0 / CLOCKS_PER_SEC << '\n';
#define pb              push_back
#define unq(a)          sort(all(a));(a).resize(unique(all(a)) - (a).begin())
#define sz(x)           (int)((x).size())
#define input(arr,n)    for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);
#define all(x)          (x).begin(),(x).end()
#define rep(i,a,b)      for(ll i=a;i<b;i++)
#define PR(x)           cout << #x " = " << (x) << "\n"
#define mp              make_pair
#define ff              first
#define ss              second
#define YY              cout<<"Yes"<<endl
#define NN              cout<<"No"<<endl
#define ppc             __builtin_popcount
#define ppcll           __builtin_popcountll

const long long INF=1e18;
const long long A=200005;
const long long mod=1000000007;

#define endl "\n"
// #define int ll

typedef pair<ll,ll> pairll;
typedef map<ll,ll>  mapll;
typedef map<char,ll> mapch;
bool comp(ll a,ll b){
    return a>b;
}

// Function to find the nCr
ll ncr(int n, int r)
{

    // p holds the value of n*(n-1)*(n-2)...,
    // k holds the value of r*(r-1)...
    long long p = 1, k = 1;

    // C(n, r) == C(n, n-r),
    // choosing the smaller value
    if (n - r < r)
        r = n - r;

    if (r != 0) {
        while (r) {
            p *= n;
            k *= r;

            // gcd of p, k
            long long m = __gcd(p, k);

            // dividing by gcd, to simplify
            // product division by their gcd
            // saves from the overflow
            p /= m;
            k /= m;

            n--;
            r--;
        }

        // k should be simplified to 1
        // as C(n, r) is a natural number
        // (denominator should be 1 ) .
    }

    else
        p = 1;

    // if our approach is correct p = ans and k =1
    return p;
}

ll n,k,tt=1;
void solve(){
    //string s,t;
    // ll m,q,x,y,ans=0;
    ll a,b,ans=0;
    cin>>a>>b>>k;
    string s;
    ll sz=a+b;

    // PR(k);

    while(sz && a && b){
        // PR(k);
        ll p=ncr(sz-1, a-1);
        if(p>=k){
            s.pb('a');
            a--;
        }
        else{
            k-=p;
            s.pb('b');
            b--;
        }
        sz--;
    }

    // cout<<a<<endl<<b<<endl;

    while(a){
        s.pb('a');a--;
    }
    while(b){
        s.pb('b');b--;
    }

    cout<<s<<endl;

}

signed main(){
    // sub;
    fast;
    // cout<<"DDDDD";
    // pre();
    // clock_t clk = clock();
    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    // ttime;
    return 0;
}

                                // Mischief Managed //


#include <iostream>
using namespace std;
int main(void){
    int A, B, C;
    cin >> A >> B >> C;
    if (A*A + B*B < C*C){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int v, t, s, d;
	cin >> v >> t >> s >> d;
	if(v*t <= d && d <= v*s) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


#include <set>
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  set<int> s;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    s.insert(x);
  }
  while (s.size() > 1) {
    int z = *s.begin();
    auto it2 = s.end();
    --it2;
    int x = *it2;
    s.erase(it2);
    s.insert(x - z);
  }
  cout << *s.begin();
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
	int a;
	cin>>a;
	int arr[a];
	for(int i=0;i<a;i++){
		cin>>arr[i];
	}
	sort(arr,arr+a);
	for(int i=0;i<a;i++){
		if(arr[i]!=i+1){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector< pii >
#define vpll vector< pll >
#define mpii map<int,int>
#define mpll map<ll,ll>
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define s(v) v.size()
#define test ll t;cin>>t;while(t--)
#define vec vector<ll>
#define read0(v,n) for(int i=0;i<n;i++)cin>>v[i];
#define read1(v,n) for(int i=1;i<=n;i++)cin>>v[i];
#define trav(a,x) for (auto& a: x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define cut(x) {cout<<x;return 0;}
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORB(i,a,b) for(int i=a;i>=b;i--)

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define nl '\n'
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
#define oset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
ll gcd(ll a, ll b)
{
	if (b==0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
ll pow(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%MOD;
		b/=2;
		a=(a*a)%MOD;
	}
	return ans;
}
ll dp[1000006];
int main()
{
	fast
	ll ans=0;
	dp[1]=1;
	FOR(i,1,1000002)
	{
	    dp[i]=dp[i-1]+i;
	}
	test
	{
	    ll a,b;
	    cin>>a>>b;
	    ans+=dp[b]-dp[a-1];
	}
	cout<<ans<<nl;
}

#include <iostream>

const int LAW = 200;
long long int count[LAW];

int main() {
    for (int i=0; i<LAW; ++i) {
        count[i] = 0;
    }

    long long int N, n;
    std::cin >> N;
    for (long long int i=0; i<N; ++i) {
        std::cin >> n;
        n %= LAW;
        count[n]++;
    }

    long long int answer = 0;
    for (auto c : count) {
        if (c <= 1) continue;
        answer += c * (c - 1) / 2;
    }

    std::cout << answer << std::endl;
}


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

#define ll long long
#define ar array

double calculate_expected(double x, ll nums[], ll n, ll sum, unordered_map<double, double>& visited) {
    if(visited.find(x) != visited.end()){
        return visited[x];
    }

    double expected_val = sum + x*n;
    for(int i=0; i<n; i++) {
        expected_val -= min((double)nums[i], 2*x);
    }

    double exp = expected_val/n;
    visited[x] = exp;
    //cout << endl << x << " expected val: " << exp << endl;
    return exp;
}

double binary_s(double min_v, double max, ll sum, ll n, ll nums[], double err, unordered_map<double, double>& visited) {
    //cout << endl << min_v << " " << max << endl;
    double mid = (max+min_v)/2;
    if(max-min_v < err)
        return mid;

    double quarter = (mid+min_v)/2;
    double three_quarter = (max+mid)/2;

    double min_exp = calculate_expected(min_v, nums, n, sum, visited);
    double quarter_exp = calculate_expected(quarter, nums, n, sum, visited);
    double mid_exp = calculate_expected(mid, nums, n, sum, visited);
    double three_quarter_exp = calculate_expected(three_quarter, nums, n, sum, visited);
    double max_exp = calculate_expected(max, nums, n, sum, visited);

    if(quarter_exp < min_exp && quarter_exp < mid_exp) {
        return binary_s(min_v, mid, sum, n, nums, err, visited);
    }
    if(three_quarter_exp < mid_exp && three_quarter_exp < max_exp) {
        return binary_s(mid, max, sum, n, nums, err, visited);
    }

    return binary_s(quarter, three_quarter, sum, n, nums, err, visited);
}

void solve(ll nums[], ll n) {
    ll sum = 0;
    ll max = 0;
    for(int i=0; i<n; i++) {
        sum += nums[i];
        if(nums[i]>max)
            max = nums[i];
    }

    double average = (sum*1.0)/n;
    unordered_map<double, double> visited;

    double val = binary_s(0, average, sum, n, nums, 0.000001, visited);
    cout.precision(30);
    cout << calculate_expected(val, nums, n, sum, visited) << endl;
}

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

    ll n;
    cin >> n;

    ll nums[n];
    for(int i=0; i<n; i++) {
        cin >> nums[i];
    }

    solve(nums, n);
}

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define double long double

template <typename T>
void print_vec(const vector<T>& v, bool newline = true) {
    for (int i = 0; i < v.size(); ++i) {
        cout << v[i] << " ";
    }
    if (newline) {
        cout << "\n";
    }
}

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

const int maxn = (int)2e5 + 105;
const int mod = (int)1e9 + 7;

#define sz(x) ((int)(x.size()))

#define pb push_back
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)

int fact_setup=0; int * fact;

int ex (int a, int b){
    if(b==0)return 1; int e = ex(a,b/2); e=(1ll*e*e)%mod; if(b&1)e=(1ll*e*a)%mod; return e;
}
int inv (int a){
    return ex(a, mod - 2);
}
int choose (int a, int b){
    if(!fact_setup){
        fact_setup=1;
        fact = new int [maxn];
        fact[0]=1; rep (i,1,maxn-1) fact[i]=(i*fact[i-1])%mod;
    }
    if(a<b)return 0;
    int num = fact[a];
    int denom = (fact[b] * fact[a - b]) % mod;
    return (num * inv(denom)) % mod;
}

#define pii pair <int, int>
#define pvi pair <vector <int>, int>

#define pai array <int,2>
#define pdi array <double, 2>
#define pdt array <double, 3>

#define pti array <int,3>
#define pfi array <int,4>

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

int arr [maxn];

main(){
    cin.tie(0); ios_base::sync_with_stdio(0);
	int n; cin >> n;
	double tot=0;
	rep (i,1,n) {cin >> arr[i];tot+=arr[i];}
	tot/=(double)n;
	sort(arr+1,arr+n+1);

	double cur=0, ans = 0;
	rep (i,1,n){
		double tt = ((n - i + 1) * arr[i] + cur) / (double)n - (arr[i]/2.0);
		ans = max(ans, tt);
		cur+=arr[i];
	}
	cout<<fixed<<setprecision(12) << tot-ans << '\n';
    return 0;
}


#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

double dp[110][110][110];

double f(int a, int b, int c){
    if(a==100||b==100||c==100) return 0;
    if(dp[a][b][c]!=0) return dp[a][b][c];
    return dp[a][b][c] = ((double)a/(a+b+c))*(f(a+1,b,c)+1) + ((double)b/(a+b+c))*(f(a,b+1,c)+1) + ((double)c/(a+b+c))*(f(a,b,c+1)+1);
}

int main(void)
{
    int A,B,C;
    cin >> A >> B >> C;
    printf("%.10f\n", f(A,B,C));
}

/*
  /^--^\
  \____/
 /      \ _____  _ __  __ ____  _     ____   ____  _____
|        || ()_)| |\ \/ /| ===|| |__ / (__` / () \|_   _|
 \__  __/ |_|   |_|/_/\_\|____||____|\____)/__/\__\ |_|
|^|^\ \^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|
| | |\ \| | | | | | | | | | | | | | | | | | | | | | | | |
#####/ /#################################################
| | |\/ | | | | | | | | | | | | | | | | | | | | | | | | |
|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|*/
#pragma GCC optimize("O4,unroll-loops,no-stack-protector")
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<ll,ll>;
#define int ll
#define double long double

#define For(i,a,b)  for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define L(id) (id<<1)
#define R(id) (id<<1|1)
#define LO(x) (x&(-x))

#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define mkp make_pair

#define MOD (ll)(1e9+7)
#define INF (1e15)
#define EPS (1e-6)

#ifdef LOCALMEOW
#define debug(...) do{\
	cerr << __PRETTY_FUNCTION__ << " - " << __LINE__ <<\
	" : ("#__VA_ARGS__ << ") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T> void _OUT(T x) { cerr << x << "\n"; }
template<typename T,typename...I>
void _OUT(T x,I ...tail) { cerr << x << ", "; _OUT(tail...); }
#else
#define debug(...)
#endif
inline void IOS(){ ios::sync_with_stdio(false); cin.tie(0); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	int ans=1,now=b;
	while(p){
		if(p&1) ans=ans*now%MOD;
		p/=2; now=now*now%MOD;
	}
	return ans;
}
void minify(int &a,int b) { if(b<a) a=b; }
void maxify(int &a,int b) { if(b>a) a=b; }

int32_t main(){
	IOS();
	//code...
	int a,b,c; cin>>a>>b>>c;
	if((c==0 && a>b) || (c==1 && a>=b)) cout<<"Takahashi\n";
	else cout<<"Aoki\n";
	return 0;
}


#include<stdio.h>
const int MOD=998244353;
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=(c==45),c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(int x){if(x<0){putchar('-'),x=-x;}if(x>=10){OUT(x/10);}putchar(x%10+48);}
static inline int MPow(int a,int b){return b?1l*MPow(1l*a*a%MOD,b>>1)*(b&1?a:1)%MOD:1;}
int main(void)
{
  int N=IN(),M=IN(),K=IN(),total=0,x=0;
  if(N==1||M==1){return OUT(MPow(K,N>M?N:M)),0;}
  while(++x<=K){total=(1l*total+1l*(1l*MPow(x,N)+MOD-MPow(x-1,N))%MOD*MPow(K-x+1,M)%MOD)%MOD;}
  return OUT(total),0;
}


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

typedef long long ll;
typedef pair<int, ll> pii;
#define pb push_back

const int MOD = 1e9 + 7, N = 2e5 + 5, K = 60;
vector<pii> g[N];
int sub[N];

ll add(ll x, ll y)
{
    x += y;
    while (x >= MOD)
        x -= MOD;
    while (x < 0)
        x += MOD;
    return x;
}

ll mul(ll x, ll y)
{
    x %= MOD;
    return (x * y) % MOD;
}

int subtree_sum(int cur, int last)
{
    sub[cur] = 1;
    for (pii e : g[cur])
        if (e.first != last)
            sub[cur] += subtree_sum(e.first, cur);
    return sub[cur];
}

void merge(vector<int> &b1, vector<int> &b2)
{
    for (int i = 0; i < K; i++)
        b1[i] += b2[i];
}

vector<int> precompute(vector<vector<int>> &b, int cur, int last)
{
    for (pii e : g[cur])
    {
        if (e.first != last)
        {
            vector<int> tmp = precompute(b, e.first, cur);
            int sz = sub[e.first] - 1;
            for (ll i = 0; i < K; i++)
            {
                if ((e.second >> i) & 1)
                    tmp[i] = sz - tmp[i] + 1;
                b[cur][i] += tmp[i];
            }
        }
    }
    return b[cur];
}

// Binary Exponentiation O(logn)
// n^m mod p
int power(int n, int m, int p)
{
    int res = 1;
    while (m > 0)
    {
        if (m & 1)
            res = (res * 1ll * n) % p;
        n = (n * 1ll * n) % p;
        m /= 2;
    }
    return res;
}

ll dfs(vector<vector<int>> &b, int cur, int last, int n, vector<int> par)
{
    // cout << cur << "\n";
    // for (int i = 0; i < 3; i++)
    //     cout << par[i] << " ";
    // cout << "\n";
    // ll v = 0;
    // for (int i = 0; i < K; i++)
    // {
    //     if (par[i] > 0)
    //     {
    //         v = add(v, mul(1ll << i, par[i]));
    //         v %= MOD;
    //     }
    // }
    // cout << v << "\n";
    ll res = 0;
    for (int i = 0; i < K; i++)
    {
        if (par[i] + b[cur][i] > 0)
        {
            res = add(res, mul(1ll << i, par[i] + b[cur][i]));
            res %= MOD;
        }
    }
    merge(par, b[cur]);
    for (pii e : g[cur])
    {
        if (e.first != last)
        {
            vector<int> tmp = par, ctmp = b[e.first];
            int sz = sub[e.first] - 1;
            for (ll i = 0; i < K; i++)
                if ((e.second >> i) & 1)
                    ctmp[i] = sz - ctmp[i] + 1;
            for (int i = 0; i < K; i++)
                tmp[i] -= ctmp[i];
            sz = n - sub[e.first] - 1;
            for (ll i = 0; i < K; i++)
                if ((e.second >> i) & 1)
                    tmp[i] = sz - tmp[i] + 1;
            res = add(res, dfs(b, e.first, cur, n, tmp));
        }
    }
    return res;
}

ll solve()
{
    int n, u, v;
    ll w;
    cin >> n;
    vector<vector<int>> b(n + 1, vector<int>(K));
    for (int i = 0; i < n - 1; i++)
    {
        cin >> u >> v >> w;
        g[u].pb({v, w});
        g[v].pb({u, w});
    }
    subtree_sum(1, 1);
    precompute(b, 1, 1);
    vector<int> par(K);
    return mul(dfs(b, 1, 1, n, par), 500000004);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << solve() << "\n";
    return 0;
}

/*/ Author : Abhishek Chauhan /*/

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

// a+b = a^b + 2*(a&b)
// According to Fermat's little theorem, (a^b)%mod = ((a^(b%(mod - 1)))%mod) if mod is a prime number and not the other way round.
// whenever using a comparator return true only if a<b
// make it forward first if it doesnt work do the reverse
// vector a = ax + ay b = bx + by then dot porduct is |a||b|cos@ //and also for eas you can use (ax*bx)+(ay*by);

#define rep(i,n)             for(int i=0;i<n;i++)
#define int                  long long
#define pb                   push_back
#define mp                   make_pair
#define all(x)               x.begin(),x.end()
#define mod                  1000000007
#define bpop(x)              __builtin_popcountll((x))
#define fastio               ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl                 '\n'

template<class T>
using ordered_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update> ;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

template<class T>
T power(T x, T y){T res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
template<class T>
T powermod(T x, T y, T p){T res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}

int n;
vector<array<int,3>>arr;
int dp[(1<<18)][18];
int solve(int mask,int prev){
    if(mask==((1<<n)-1)){
        int dist = abs(arr[0][0]-arr[prev][0]);
        dist+= abs(arr[0][1]-arr[prev][1]);
        dist+= max((int)0,arr[0][2]-arr[prev][2]);
        return dist;
    }
    int ans =  1e18;
    if(dp[mask][prev]!=-1){
        return dp[mask][prev];
    }
    for(int i=0;i<n;i++){
        if((mask>>i)&1){
            continue;
        }
        int dist = abs(arr[i][0]-arr[prev][0]);
        dist+= abs(arr[i][1]-arr[prev][1]);
        int fuk = dist;
        dist+= max((int)0,arr[i][2]-arr[prev][2]);
        ans = min(ans,dist+fuk+max((int)0,arr[prev][2]-arr[i][2])+solve(mask^(1<<i),prev));
        ans = min(ans,dist+solve(mask^(1<<i),i));
    }
    return dp[mask][prev]=ans;
}
void snow(){

   cin>>n;
   arr.resize(n);
   rep(i,(1<<(18))){
    rep(j,n){
        dp[i][j] = -1;
    }
   }
   for(int i=0;i<n;i++){
    rep(j,3){
        cin>>arr[i][j];
    }
   }
   int ans = solve((1<<0),0);
   cout<<ans<<endl;
}

int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    fastio;
    int _;
    _=1;
    for(int i=1;i<=_;i++){
        snow();
    }
    return 0;
}


#include<algorithm>
#include<iostream>
#include<cstring>
#include<bitset>
#include<cstdio>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
#define neinf 0xc0c0c0c0c0c0c0c0ll
#define inf 0x3f3f3f3f3f3f3f3fll
#define uint unsigned int
#define ull unsigned ll
#define HgS 1000000007
#define ll long long
#define reg register
#define opr operator
#define ret return
#define gc getchar
#define pc putchar
#define cst const
#define db double
#define il inline
il ll rd()
{
	reg ll res=0,lab=1;
	reg char ch=gc();
	while((ch<'0'||ch>'9')&&ch!=EOF)
	{if(ch=='-')lab=-lab;ch=gc();}
	while(ch>='0'&&ch<='9')
		res=(res<<3)+(res<<1)+(ch&15),ch=gc();
	return res*lab;
}
il void prt(ll x,char t='\n')
{
	static char ch[40];reg int tp=0;
	if(!x){fputs("0",stdout);if(t)pc(t);return;}
	if(x<0)pc('-'),x=-x;
	while(x)ch[++tp]=(x%10)^48,x/=10;
	while(tp)pc(ch[tp--]);
	if(t)pc(t);
}
il ll umax(ll a,ll b){return a>b?a:b;}
il ll umin(ll a,ll b){return a<b?a:b;}
il ll uabs(ll x){return x>0?x:-x;}
il ll qpow(ll n,ll e=HgS-2,ll p=HgS)
{
	reg ll res=1;
	while(e){if(e&1)res=res*n%p;n=n*n%p;e>>=1;}
	return res;
}
ll n,ans=inf;
int main()
{
	n=rd();
	for(int i=0;i<=62;++i)ans=umin(ans,i+(n>>i)+n-((n>>i)<<i));
	prt(ans);
	return 0;
}

#include <bits/stdc++.h>
#define ll long long
#define db(x) cout << (#x) << " = " << x << "\n" ;
#define pb push_back
using namespace std;
set <ll> ok;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  ll n;
  cin >> n;
  ll ans = 0;
  for(ll i=7;i<=n;i++){
    ll f = 0 , x = i;
    while(x){
      if(x%10==7){
        f = 1;
        break;
      }
      x = x/10;
    }
    x = i;
    while(x){
      if(x%8==7){
        f = 1;
        break;
      }
      x = x/8;
    }
    ans += f;
  }
  cout << n - ans << endl;
  return 0;
}


#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vi vector <int>
#define ff first
#define ss second
#define vp vector <pair<int,int>>
#define vpp vector <pair<int,pair<int,int>>>
#define seti set<int>
#define setbit(x) __builtin_popcountll(x)
#define sov(v) accumulate(all(v),0)
#define fs(it,a) for(auto it=a.begin();it!=a.end();it++)
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pqmax priority_queue <int,vector <int>>
#define pqmin priority_queue <int,vector <int>,greater<int>>
#define dq deque <int>
#define umi unordered_map<int,int>
#define ums unordered_map<string,int>
#define sp(x,y) fixed << setprecision(y) << x
#define all(x) x.begin(),x.end()
#define f(x,y,z) for(x=y;x<z;x++)
#define si size()
#define countdigit(x) floor( log10(x) +1)
#define M 1000000007
#define Z 998244353
#define fill(arr,x) memset(arr,x,sizeof(arr))
//Use (k%M+m)%m always where k is any no
#define PI 3.1415926535
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> pdbs;
// null for set,mapped_type for map;
//less for assending greater for descending
//ceil(a/b)=(a+b-1)/b
#define ghadi() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();
#define ee "\n"
#define re return

//Author Rahul Sannigrahi

vector<int> take(int n)
{
    int i,j;
    vi v;
    f(i,0,n)
    {
        cin>>j;
        v.pb(j);
    }
    return v;
}

bool sortinrev(const pair<int,int> &a,  //desc of vp
               const pair<int,int> &b)
{
       return (a.first > b.first);
}

void show(vector<int>v)
{
    int i;
    for(i=0;i<v.si;i++)
    {
     cout<<v[i]<<" ";
    }
    cout<<ee;
}

int decode()
{
    int i,j,k,l,n,x1,x2,y1,y2;
    cin>>x1>>y1>>x2>>y2;
    l=y1*x2+y2*x1;
    n=y1+y2;
   // cout<<l<<n;
    double d=(float)l/n;
    cout<<sp(d,10)<<ee;
    re 0;
}

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

    int t=1;
    //cin>>t;
    while(t--)
    decode();
    return 0;
}

#include <iostream>
#include <cmath>
#define ll long long int
using namespace std;

int main() {
    int n;
    cin>>n;
    int a[n],b[n];
    ll ans[1001]={0};
    for(int i=0;i<n;i++)
    {cin>>a[i];}
    for(int i=0;i<n;i++)
    {cin>>b[i];}
    for (int i=0;i<n;i++)
	{
		for (int j=a[i];j<=b[i];j++)
		{
			ans[j]++;
		}
	}
	ll cn=0;
	for (int i=0;i<=1000;i++)
	{
		if (ans[i]==n) cn++;
	}
	cout<<cn<<"\n";

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define d(x) cout<<x<<" "
#define nl cout<<endl
#define rep(var,init_val,final_val) for(int var = init_val; var < final_val; ++var)
#define show(a,b) rep(i,0,b) d(a[i]);nl;
#define showv(a) for(auto x : a) d(x);nl;
#define vi std::vector<int>
#define pi pair<int,int>
#define mod 1000000007
void solve(){
	int n;
	cin>>n;
	int lo = INT_MIN , hi = INT_MAX;
	int a[n] , b[n];
	rep(i,0,n) cin>>a[i];
	rep(i,0,n) cin>>b[i];
	rep(i,0,n){
		lo = max(lo,a[i]);
		hi = min(hi,b[i]);
		}
	cout<<max(0,hi-lo+1)<<endl;
	}

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

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = int64_t;
using vi = vector<int>;
using vs = vector<string>;
using vc = vector<char>;
using vvi = vector<vi>;
using vvs = vector<vs>;
using vvc = vector<vc>;
using pii = pair<int, int>;

int main() {
  int n;
  cin >> n;
  map<int, ll> a;
  ll an;
  rep (i, n) {
    cin >> an;
    an %= 200;
    a[an]++;
  }

  ll ans = 0;
  rep (i, 200) {
    ans += (a[i]*(a[i]-1)) / 2LL;
  }

  cout << ans << endl;

}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

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

const int N = (int)2e5+5;
const int M = (int)3e3+5;
const int Q = 301;
const int logN = 19;

void solve() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    REP(i,0,n-1) {
      unordered_map<char,int> freq;
      REP(j,i,n-1) {
        freq[s[j]]++;
        if(freq['A'] == freq['T'] && freq['C'] == freq['G']) {
          ans++;
        }
      }
    }
    cout << ans;
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    // cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}

#include <bits/stdc++.h>
using namespace std;
#define LL long long
//#define MOD 1000000007
#define MOD 998244353
#define INF 1000000000000000000
#define VE vector
#define VL vector<LL>
#define VVL VE<VL>
#define VVVL VE<VVL>
#define LD long double
#define PB push_back
#define POB pop_back
#define FOR(i,a,k) for(LL i=a;i<k;i++)
#define rep(i,k) FOR(i,0,k)
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define coutl cout<<fixed<<setprecision(15)//

#define MI modint<MOD>
template<int mod>struct modint{
	int x;
	modint():x(0){}
	modint(LL n):x(n>=0?n%mod:(mod-(-n)%mod)%mod){}
	modint &operator+=(const modint &n){if((x+=n.x)>=mod)x-=mod;return *this;}
	modint &operator-=(const modint &n){if((x+=mod-n.x)>=mod)x-=mod;return *this;}
	modint &operator++(){*this+=1;return *this;}
  modint &operator--(){*this-=1;return *this;}
	modint &operator*=(const modint &n){x=(int)((LL)x*n.x%mod);return *this;}
	modint &operator/=(const modint &n){*this*=n.inv();return *this;}
	modint operator-()const{return modint(-x);}
	modint operator+(const modint &n)const{return modint(*this)+=n;}
	modint operator-(const modint &n)const{return modint(*this)-=n;}
	modint operator++(int){modint ret(*this);*this+=1;return ret;}
  modint operator--(int){modint ret(*this);*this-=1;return ret;}
	modint operator*(const modint &n)const{return modint(*this)*=n;}
	modint operator/(const modint &n)const{return modint(*this)/=n;}
	bool operator<(const modint &n)const{return x<n.x;}
	bool operator>(const modint &n)const{return x>n.x;}
	bool operator<=(const modint &n)const{return x<=n.x;}
	bool operator>=(const modint &n)const{return x>=n.x;}
	bool operator!=(const modint &n)const{return x!=n.x;}
	bool operator==(const modint &n)const{return x==n.x;}
	friend istream &operator>>(istream &is,modint &n){LL l;is>>l;n=modint<mod>(l);return is;}
	friend ostream &operator<<(ostream &os,const modint &n){return os<<n.x;}
	int getmod(){return mod;}
	modint inv()const{int a=x,b=mod,c=1,d=0,n;while(b){n=a/b;swap(a-=n*b,b);swap(c-=n*d,d);}return modint(c);}
	modint pow(LL n)const{modint ret(1),m(x);while(n){if(n&1)ret*=m;m*=m;n>>=1;}return ret;}
};

VL yakusuu(LL N){
	LL M=0;
	VL ret;
	for(LL i=0; i<N; i++){
		M++;
		if(M>N/M){
			for(LL i=0; i<N; i++){
				M--;
				if(M==0){
					return ret;
				}
				if(M*M==N){
					continue;
				}
				if(N%M==0){
					ret.PB(N/M);
				}
			}
		}
	  if(N%M==0){
		  ret.PB(M);
		}
	}
	return ret;
}

LL nanjo(LL a,LL n){//aのn乗  N=nanjo(a,n)A
	LL ret=1;
	for(LL i=0;i<n;i++){
		ret*=a;
	}
	return ret;
}

void YesNo(bool f){
	if(f)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

LL kakuketa(LL n){//各桁の和を求める
	LL a=0;
	while(n>0){
		a=a+n%10;
		n=n/10;
	}
	return a;
}

int main(){
	LL M,ans=0,N;
	cin>>N;
	M=N;
	rep(i,20){
		if(M>=10){
			M=M/10;
		}
		if(M<10){
			M=i+2;
			break;
		}
	}
	if(M>=0){
		ans=0;
	}
  if(M>=4){
		ans+=N-999;
	}
	if(M>=7){
		ans+=N-999999;
	}
	if(M>=10){
		ans+=N-999999999;
	}
	if(M>=13){
		ans+=N-999999999999;
	}
	if(M>=16){
		ans+=N-999999999999999;
	}
	cout<<ans<<endl;
	/*LL N,ans;
	cin>>N;
	rep(i,N){
		if(N%10==)
	}
	/*LL K,ans=0;
	cin>>K;
	ans=K-2;//全部同じ数だった場合
	if(K>=4){
		ans+=(1+(K-2)/2)*K/2*3;//２つ同じ数があった場合
	}
	if(K>=6){
		ans+=(1+(K/2+1)*K/6)**6;
	}
	cout<<ans<<endl;
	LL N,M,T,ans=0;
	cin>>N>>M>>T;
	ans=N;
	VL A(M),B(M);
	rep(i,M){
		cin>>A[i]>>B[i];
	}
	rep(i,M){
		ans=ans-A[i]+A[i-1];
		if(ans<=0){
			cout<<"No"<<endl;
			break;
		}
		ans=ans+(B[i]-A[i]);
		if(ans>=M){
			ans=N;
		}
	}
	cout<<"Yes"<<endl;*/
}


#include <bits/stdc++.h>
#define INF 1000000007
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef long long int  lli;
typedef long double ld;
typedef vector<int> vi;
typedef unordered_map<int,int> umi ;
typedef unordered_set<int> usi ;
typedef pair<int,int> pi;
#include <bits/stdc++.h>

using namespace std;

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

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

//declare here -------------------------------------------------------------------------------
const int N =1e5+1 ;
struct edge{
	int D ;
	int T ;
	int K ;
} ;
vector<edge> adj[N] ;
ll dist[N] ;
bool visited[N] ;

// solve here ---------------------------------------------------------------------------------

void solve(){
	int n,m,x,y;
	REP(i,0,N) dist[i]=LLONG_MAX ;
	cin>>n>>m>>x>>y ;
	int u,v,t,k ;
	edge e1 ;
	edge e2 ;
	REP(i,0,m){
		cin>>u>>v>>t>>k ;
		e1.T=t ; e2.T= t ; e1.K=k ; e2.K=k ;
		e1.D=v ; e2.D= u ;
		adj[u].PB(e1) ;
		adj[v].PB(e2) ;
	}

	dist[x]=0 ;
	priority_queue<pair<ll,ll>> q ;
	q.push({0,x}) ;

	while(!q.empty()){
		u=q.top().S ; q.pop() ;
		if(visited[u]) continue ;
		debug(u,dist[u]) ;
		visited[u]=true ;
		for(auto e:adj[u]){
			v=e.D ;
			ll add=e.T ;
			if(dist[u]%e.K==0) add+=0 ;
			else add += (e.K - (dist[u] % e.K)) ;
			if(dist[u]+add < dist[v]){
				dist[v]=dist[u]+add ;
				q.push({-dist[v] ,v}) ;
			}
		}
	}
	if(dist[y]==LLONG_MAX) cout<<-1 ;
	else cout<<dist[y] ;

}

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

int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long test =1 ;
   	//cin>>test ;
    while(test--){
        solve() ;
        cout<<"\n" ;
    }
    return 0 ;
}

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

using namespace std;

template<typename T>
long long modpow(const T n,const T p,const T mod);
template<typename T>
long long modinv(const T n,const T mod);
template<typename T>
bool chmax(T &a,const T &b);
template<typename T>
bool chmin(T &a,const T &b);

long long inf=1000000007;

struct train{
	long long to;
	long long time;
	long long inter;
};

int main(){
	long long n,m,x,y;
	cin>>n>>m>>x>>y;
	vector<vector<train>> kankei(n+1);

	for(long long i=0;i<m;i++){
		long long a,b,t,k;
		cin>>a>>b>>t>>k;
		train hoge={b,t,k};
		train fuga={a,t,k};

		kankei.at(a).push_back(hoge);
		kankei.at(b).push_back(fuga);
	}

	vector<long long> graph(n+1,inf*inf);
	graph.at(x)=0;
	priority_queue<pair<long long,long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>>> que;
	que.push(make_pair(0,x));

	while(!que.empty()){
		long long here=que.top().second;
		long long now=que.top().first;
		que.pop();
		if(graph.at(here)!=now) continue;
		if(here==y){
			cout<<now<<endl;
			return 0;
		}

		for(auto next:kankei.at(here)){
			long long nto=next.to;
			long long ntime=next.time;
			long long ninter=next.inter;

			long long hogetime=now;
			if(now%ninter!=0) hogetime+=ninter-now%ninter;
			hogetime+=ntime;

			if(graph.at(nto)>hogetime){
				graph.at(nto)=hogetime;
				que.push(make_pair(hogetime,nto));
			}
		}
	}

	cout<<-1<<endl;

	return 0;
}

template<typename T>
long long modpow(const T n,const T p,const T mod){
	if(p==0) return 1;
	if(p%2==0){
		long long a=modpow(n,p/2,mod);
		return a*a%mod;
	}
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}

template<typename T>
long long modinv(const T n,const T mod){
	return modpow(n,mod-2,mod);
}

template<typename T>
bool chmax(T &a,const T &b){
	if(a<b){
		a=b;
		return 1;
	}
	return 0;
}

template<typename T>
bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return 1;
	}
	return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first

typedef pair < long long, long long > pll;
typedef pair < int, int > pii;
typedef unsigned long long ull;
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;
typedef long long ll;
typedef double db;

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

const int inf = 1e9, maxn = 2e5 + 48, mod = 1e9 + 7, N = 1e6 + 5e5 + 12;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 300;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = acos(-1);
const ll INF = 1e18;

int n, m, a[N], prv[N];
set < int > q, qq;

void add (int i) {
	q.insert(i);
	qq.erase(a[i]);
}

void del (int i) {
	q.erase(i);
	qq.insert(a[i]);
}

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

	for (int i = 0; i < N; ++i)
		qq.insert(i);

	int ans = inf;
	memset(prv, -1, sizeof(prv));

	for (int i = 1; i <= n; ++i) {
		if (q.count(prv[a[i]]))
			del(prv[a[i]]);

		prv[a[i]] = i;
		add(i);

		while (sz(q) && *q.begin() < i - m + 1)
			del(*q.begin());

		if (i >= m)
			ans = min(ans, *qq.begin());
	}
	cout << ans << endl;
}

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

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define ef(a) emplace_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) (((a) + (b) - 1) / (b))
#define tomax(a, b) ((a) = max((a), (b)))
#define tomin(a, b) ((a) = min((a), (b)))
#define topos(a) ((a) = (((a) % MOD + MOD) % MOD))
#define uni(a) a.resize(unique(iter(a)) - a.begin())
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

int main(){
    StarBurstStream

    int n, m;
    cin >> n >> m;

    vector<vector<int>> pos(n + 1);
    for(int i = 1; i <= n; i++){
        int a;
        cin >> a;
        pos[a].eb(i);
    }

    for(int i = 0; i <= n; i++){
        int lst = 0;
        pos[i].eb(n + 1);
        for(int j : pos[i]){
            if(j - lst - 1 >= m){
                cout << i << "\n";
                return 0;
            }
            lst = j;
        }
    }

    return 0;
}


/******************************************************/
/******************************************************/
/**                                                  **/
/**            BISMILLAHIR RAHMANIR RAHIM            **/
/**         REAZ AHAMMED CHOWDHURY - reaziii         **/
/**  Department of Computer Science and Engineering  **/
/*         INSTITUTE OF SCIENCE AND TECHNOLOGY       **/
/**                                                  **/
/******************************************************/
/******************************************************/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pcase(x)     printf("Case %d: ",x++)
#define fri(f)       for(int i=0;i<f;i++)
#define frj(f)       for(int j=0;j<f;j++)
#define reset(x)     memset(x,-1,sizeof(x))
#define all(x)       x.begin(),x.end()
#define input        freopen("input.txt","r",stdin);
#define output       freopen("output.txt","w",stdout)
#define infi         INT_MAX
#define linfi        LLONG_MAX
#define pii          pair<int,int>
#define pll          pair<ll,ll>
#define mgraph       map<int,vector<int> >
#define pb           push_back
#define clr(x)       memset(x,0,sizeof(x))
#define fro(i,x,y)   for(int i=x;i<y;i++)
#define ech(x,a)     for(auto &x : a)
#define ff           first
#define ss           second
#define vi           vector<int>
#define vl           vector<ll>
#define pi           acos(-1.0)

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type,
        less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        Ordered_set;
template<class T> void read(T& x) {cin >> x;}
template<class H, class... T> void read(H& h, T&... t) {read(h); read(t...);}
template<class A> void read(vector<A>& x) {for (auto &a : x) read(a);}
template<class H> void print(vector<H> &x) {ech(a, x) cout << a << " "; cout << endl;}
template<class P> void debug(P h) {
#ifndef ONLINE_JUDGE
	cerr << h << " ";
#endif
}
template<class W, class... V> void debug(W h, V... t) {
#ifndef ONLINE_JUDGE
	debug(h);
	debug(t...);
	cerr << endl;
#endif

}

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;

bool checkbitt(ll num, int pos) {return (num >> pos) & 1;}
ll setbitt(ll num, ll pos) {return (1 << pos) | num;}
ll resetbitt(ll num, int pos) {if (!checkbitt(num, pos)) return num; else return (1 << pos)^num;}
ll bigmod(ll a, ll b, ll mod) {if (b == 0) return 1; if (b == 1) return a; if (b & 1) {return ((a % mod) * (bigmod(a, b - 1, mod) % mod)) % mod;} ll x = bigmod(a, b / 2, mod); return (x * x) % mod;}
ll geti() {ll x; read(x); return x;}
ll cdiv(ll a, ll b) {ll ret = a / b; if (a % b) ret++; return ret;}
const ll mod =  1e9 + 7;
const ll N   =  2e5 + 10;
int dx[4] = { +0, +0, +1, -1};
int dy[4] = { -1, +1, +0, +0};

//................................___Start from here___...............................//
//................................_____________________..............................//

int solve() {
	ll a, b, c, d;
	read(a, b, c, d);

	b *= a, c *= a;

	if (d >= b && d <= c) {
		cout << "No" << endl;
	}
	else cout << "Yes" << endl;

	return 0;
}
int main(int argc, char* argv[]) {

	if (argc <= 1) {
#ifndef ONLINE_JUDGE
		input;
		output;
#endif
#ifdef ONLINE_JUDGE
		ios_base::sync_with_stdio(false);
		cin.tie(0);
#endif
	}

	int cs = 1, cn = 1;
	// read(cs);
	while (cs--) {
		solve();

	}
}

#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>

using namespace std;

int main()
{

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

     string s;
     cin>>s;

     if(s[0] == s[1] && s[0] == s[2] && s[1]==s[2]){
     	cout<<"Won";
	 }else{
	 	cout<<"Lost";
	 }

    return 0;
}


#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define FOR(i, a, b) for(int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

void Case(int i) { cout << "Case #" << i << ": "; }
#pragma endregion Macros

using D = long double;

int main() {
    int N;
    cin >> N;
    vector<ll> a(N), sum(N+1, 0);
    REP(i, N) cin >> a[i];
    sort(ALL(a));
    REP(i, N) sum[i+1] = sum[i] + a[i];

    D ans = LLINF;

    REP(i, N) {
        // min(A_i, 2x)のsum
        D sum1 = sum[i+1] + a[i] * (N - i - 1);
        // xのsum
        D sum2 = a[i] * N;
        sum2 /= D(2);
        D sum3 = sum[N];
        chmin(ans, ((sum2 - sum1) + sum3) / N);
    }

    cout << ans << endl;
}

#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
using ll = long long;
constexpr int N = 1e6 + 5;

int n;
int a[N];
ll sum[N];

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
    }
    sort(a + 1, a + 1 + n);
    for(int i = 1; i <= n; ++i) {
        sum[i] = sum[i - 1] + a[i];
    }
    double ret = 1e18;
    for(int i = 1; i <= n; ++i) {
        double x = a[i] / 2.0;
        double tt = 1.0 * sum[n] / n + x;
        tt -= (sum[i] + (n - i) * x * 2) / n;
        ret = min(ret, tt);
    }
    printf("%.8lf", ret);
}


#include <bits/stdc++.h>

#define rep(i,n) for(int i=0; i<(n); ++i)
#define fixed_setprecision(n) fixed << setprecision((n))
#define execution_time(ti) printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9

using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

//組み合わせの数nCrを計算
int calcNumOfCombination(int n, int r){
    int num = 1;
    for(int i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}

set<string> se;
string str;

void dfs(string s, int c){
    if(s.length() >= 4){
        se.insert(s);
        return;
    }
    if(str.length() <= c){
        return;
    }

    rep(i, str.length()){
        if(str[i] == 'o' || str[i] == '?'){
            dfs(s + to_string(i), c+1);
        }
    }
}

int main() {
    cin >> str;

    dfs("", 0);

    string t;
    rep(i, str.length()){
        if(str[i] == 'o') t += to_string(i);
    }

    ll res=0;
    for(set<string>::iterator itr = se.begin(); itr != se.end(); itr++){

        ll cnt=0;
        rep(i, t.length()){
            if(itr->find(t[i]) == std::string::npos) break;
            cnt++;
        }
        if(cnt==t.length()) res++;
    }

    cout << res << endl;

    return 0;
}

#include "bits/stdc++.h"
using namespace std;
#define endl "\n"
using ll = long long;
const int MOD = 1e9 + 7;

void solve() {
	int n; cin >> n;
	double ans = 0.0;
	for (int i = 1; i < n; i++) {
		ans += double(n) / double(i);
	}
	cout << setprecision(10) << ans << endl;
}

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

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


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

// clang-format off
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
#define Endl endl
#define itn int
#define fi first
#define se second
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep2(i, a, b) for (int i = (int)(a), i##_len=(b); i < i##_len; i++)
#define rep3(i, a, b) for (int i = (int)(a), i##_len=(b); i >= i##_len; i--)
#define FOR(i, a) for (auto &i: a)
#define ALL(obj) begin(obj), end(obj)
#define _max(x) *max_element(ALL(x))
#define _min(x) *min_element(ALL(x))
#define _sum(x) accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(begin(A), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(begin(A), upper_bound(ALL(A), key))

const int MOD   = 1000000007;
// const int MOD    = 998244353;
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = 3.14159265358979;
template <class T> using V = vector<T>;
template <class T> using VV = vector<vector<T>>;
template <class T> using VVV = vector<vector<vector<T>>>;
template <class T, class S>  using P = pair<T, S>;
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b;return true;}return false;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b;return true;}return false;}
int _ceil(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); }
int _mod(int &a) {a = a >= 0 ? a % MOD : a - (MOD * _ceil(a, MOD));return a;}
int _pow(int a, int b) {int res = 1;for (a %= MOD; b; a = a * a % MOD, b >>= 1)if (b & 1) res = res * a % MOD;return res;}
// clang-format on

char zyanken(char a, char b) {
  if (a == b) {
    return a;
  }
  if (a > b) swap(a, b);
  if (a == 'P' and b == 'R') {
    return a;
  } else if (a == 'P' and b == 'S') {
    return b;
  } else {
    return a;
  }
}

class CLargeRPSTournament {
public:
  static void solve(istream &cin, ostream &cout) {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    while (1) {
      if (k == 0) {
        cout << s[0] << endl;
        return;
      }
      if (k < 10 and _pow(2, k) <= n) {
        int m = _pow(2, k);
        V<char> list(m);
        rep(i, m) list[i] = s[i];
        while (list.size() > 1) {
          V<char> list2;
          rep(i, list.size() / 2) {
            list2.emplace_back(zyanken(list[2 * i], list[2 * i + 1]));
          }
          list = list2;
        }
        cout << list[0] << endl;
        return;
      }
      if (n % 2 == 0) {
      string list2;
        rep(i, n / 2) {
          list2 += (zyanken(s[(2 * i)%n], s[(2 * i + 1)%n]));
        }
        n = list2.size();
        k--;
        s = list2;
      } else {
        string list2;
        rep(i, n ) {
          list2+=(zyanken(s[(2 * i)%n], s[(2 * i + 1)%n]));
        }
        n = list2.size();
        k--;
        s = list2;
      }
    }
  }
};

signed main() {
  CLargeRPSTournament solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

	#include <bits/stdc++.h>
	#define loop(n) for(ll i=0;i<n;i++)
	#define loopj(n) for(ll j=0;j<n;j++)
	#define loopR(i,a,b,c) for(ll i=a;i>=b;i-=c)
	#define rng(i,a,b,c) for(ll i = a; i<b;i+=c)
	#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	#define ll long long
	#define ld long double
	#define pb push_back
	#define mp make_pair
	#define all(s) s.begin(),s.end()
	ll mod=10e9+7;
	using namespace std;
	//--------------------------\\
	//code once think twice

	void go()
	{
		ll a,b,v;

		cin>>a>>b>>v;

		ll x=a*a+b*b;

		if(x<(v*v))
		cout<<"Yes"<<'\n';
		else
		cout<<"No"<<'\n';

    }

	int main()
	{

    ll t;

	fast;

//    cin>>t;
//
//	loop(t)
	go();

	}


#include<iostream>
#include<vector>
#include<string>
#include<cstdio>
#include<iomanip>

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

const ll LLMAX = (1llu<<(sizeof(ll)*8-1)) - 1;
const int IMAX = (1llu<<(sizeof(int)*8-1)) - 1;

double sx, sy, gx, gy;

int main(){
  cin >> sx >> sy >> gx >> gy;

  double d = abs((gx - sx) *  gy / (sy + gy));
  if(sx <= gx){
    cout << setprecision(20) << gx - d << endl;
  } else {
    cout << setprecision(20) << gx + d << endl;
  }

  return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main() {
  double Sx, Sy, Gx, Gy;
  cin >> Sx >> Sy >> Gx >> Gy;

  double x;
  x = (10000000000 * Sy * (Gx - Sx) / (Sy + Gy) + 10000000000 * Sx) /10000000000;
  cout << std::fixed << std::setprecision(10) << x << endl;
}


# include <iostream>
# include <vector>
using namespace std;
int main()
{
    string s;
    cin>>s;
    long long t;
    char p;
    t=0;
    p='0';
    long long k;
    k=0;
    vector<char>v;
    for(int i=s.size()-2; i>0; i--)
    {
        if(s[i]==s[i-1] && s[i]!=s[i+1])
        {
            if(s[i]==p)
            {
                int h;
                h=s.size()-(i+1)-(k+2);
                t=t+max(h,0);
                k=s.size()-(i+1);
            }
            else
            {
                t=t+s.size()-(i+1);
                k=s.size()-(i+1);
                p=s[i];
            }
            v.push_back(s[i]);
        }
    }
    char l;
    int r;
    l='0';
    long long w=v.size();
    r=0;
    int g;
    for(int i=0; i<s.size()-2; i++)
    {
        if(s[i]==s[i+1] && s[i]!=s[i+2])
        {
            l=v[v.size()-1];
            v.pop_back();
            i=i+1;
            g=i;
        }
        else
        {
            if(s[i]==l)
            {
               r=r+1;
            }
        }
    }
    if(g!=s.size()-2)
    {
    if(s[s.size()-1]==l)
    {
        r=r+1;
    }
    if(s[s.size()-2]==l)
    {
        r=r+1;
    }
    }
  //  cout<<r<<endl;
  long long z;
  z=t-r;
    cout<<z;
}

#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long int
#define f first
#define s second
using namespace  std;
ll mod=1e9+7;
int decimal(int x)
{
    int f=0;
    while(x){if(x%10==7)f=1;x/=10;}
    return f;
}
int octal(int x)
{
    vector<int>oc;
    while(x){oc.pb(x%8);x/=8;}
    int f=0;
    for(auto i:oc)if(i==7)f=1;
    return f;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(decimal(i)||octal(i))ans++;
    }
    cout<<n-ans<<endl;
    return 0;
}


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

int32_t main()
{
  int n;cin>>n;
  vector<int>arr(n);
  for(int i=0;i<n;i++)
    cin>>arr[i];
    sort(arr.begin(),arr.end());
  vector<int>pref(n+1,0);
  for(int i=1;i<=n;i++)
    pref[i]=pref[i-1]+arr[i-1];

  int ans=0;
  for(int i=1;i<=n;i++)
  {
    ans+=pref[n]-pref[i]-(n-i)*arr[i-1];
  }
  cout<<ans<<endl;
}

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

#define endl "\n"
#define int long long int
#define ll long long
#define F first
#define S second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define mll unordered_map<ll,ll>
#define dec(v) sort(v.rbegin(),v.rend());
#define REP(i, n) for (int i = 0; i < (n); i++)
#define in(v) for(auto &i:v) cin>>i;
#define out(v) for(auto i:v) cout<<i<<" ";
#define nl cout<<endl;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<ll> vll;

#define deb(x) cout << ">" << #x << '=' << x << endl;
#define setbits(n) __builtin_popcountll(n)
#define done {cout<<"-1"<<endl; return;}

#define inf INT_MAX
#define ninf INT_MIN
const ll N = 2e5 + 10;
#define mod 1000000007

vector<int> adj[N];
vector<int> vis(N+1);
int c;

void dfs(int n){
  vis[n]=1;
  c++;
  for(auto i:adj[n]){
    if(!vis[i]){
      dfs(i);
    }
  }
}

void solveit(){
  int n;
  cin>>n;
  vi v(n);
  in(v);
  vpii edg;
  for(int i=0;i<n/2;i++){
    if(v[i]!=v[n-i-1]){
      adj[v[i]].pb(v[n-i-1]);
      adj[v[n-i-1]].pb(v[i]);
    }
  }
  int ans=0;
  for(int i=0;i<=2e5;i++){
    if(!vis[i]){
      c=0;
      dfs(i);
      ans+=c-1;
    }
  }
  cout<<ans<<endl;

}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int testcases =1;
  //cin >> testcases;
  while (testcases--)  solveit();
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
  return 0;
}


#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#include <bits/stdc++.h>
#ifdef __LOCAL
	#include <debug/debugger.h>
#endif
#include <ext/pb_ds/assoc_container.hpp>
#define PB push_back
#define PI acos(-1)
#define all(x) x.begin(),x.end()
#define vi vector<ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define vb vector<bool>
#define vull vector<ull>
#define vvi vector<vector<ll> >
#define vvii vector<vii>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define read(x) long long x;cin>>x;
#define FOR(a,b,c,d) for(int a=b;a<=c;a+=d)
#define MP make_pair
#define F first
#define AS assign
#define S second
#define debug(x) cout<<(#x)<<": "<<(x)<<"\n"
#define SZ(x) x.size()
#define mod 1000000007
#define lg2(x) 63-(__builtin_ctzll(x))
#define RZ resize
#define IN insert
#define X real()
#define Y imag()
#define INF (((1LL<<62LL)-1LL)*2)-1LL
#define FBO find_by_order
#define OFK order_of_key
#define INPUT(x) freopen(x,"r",stdin)
#define OUTPUT(x) freopen(x,"w",stdout)
#define EPS 1e-9
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
typedef unsigned long long ull;
typedef long double d64;
typedef complex<ll>P;
ll modpow(ll x,ll n,ll m) {if(n==0)return 1%m;long long u = modpow(x,n/2,m);u = (u*u)%m;if(n%2==1)u=(u*x)%m;return u;}

ll n;
vector<vector<ll> >G;
vi color;
vb mk;
vi coun;

void dfs(int x,int e){
	if(coun[color[x]]==0){
		mk[x]=1;
	}
	coun[color[x]]++;
		for(auto c:G[x]){
			if(c!=e){
				dfs(c,x);
			}
		}
	coun[color[x]]--;
}

int main(){
fast

		cin>>n;
			G.AS(n+5,vector<ll>());
			color.RZ(n+5);
			mk.RZ(n+5);
			coun.RZ(100040);

			for(int i=1;i<=n;i++){
				cin>>color[i];
			}

			for(ll a,b,i=1;i<=n-1;i++){
				cin>>a>>b;
				G[a].PB(b);
				G[b].PB(a);
			}

			dfs(1,1);

		for(int i=1;i<=n;i++){
			if(mk[i])cout<<i<<"\n";
		}

	return 0;
}

#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

const int N = 100005;

int C[N];
vi g[N];
int cols[N];
vi ans;

void dfs(int c, int p) {
  if(cols[C[c]] == 0) {
    ans.pb(c);
  }
  cols[C[c]]++;
  rep(i,0,g[c].size()) {
    int u = g[c][i];
    if(u != p) {
      dfs(u, c);
    }
  }
  cols[C[c]]--;
}

int main() {
  int n;
  S(n);
  rep(i,1,n+1) {
    S(C[i]);
  }
  rep(i,0,n-1) {
    int u,v;
    S2(u,v);
    g[u].pb(v);
    g[v].pb(u);
  }
  dfs(1, -1);
  sort(all(ans));
  rep(i,0,ans.size()) {
    P(ans[i]);
  }
  return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}

const int MAX_N = 200100;
int par[MAX_N]; // 親
int rank_[MAX_N]; // 木の深さ
int cnt_[MAX_N]; // 属する頂点の個数(親のみ正しい)

// n要素で初期化
void UFinit(){
    for(int i=0;i<MAX_N;i++){
        par[i] = i;
        rank_[i] = 0;
        cnt_[i] = 1;
    }
}

// 木の根を求める
int find(int x){
    if(par[x] == x){
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

// xとyの属する集合を併合
void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rank_[x] < rank_[y]){
        par[x] = y;
        cnt_[y] += cnt_[x];
    }else{
        par[y] = x;
        cnt_[x] += cnt_[y];
        if(rank_[x] == rank_[y]) rank_[x]++;
    }
}

// xとyが同じ集合に属するか否か
bool same(int x, int y){
    return find(x) == find(y);
}

ll mod_pow(ll x, ll n, ll mod){ // x ^ n % mod
    ll res = 1;
    while(n > 0){
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    UFinit();
    int n;
    cin >> n;
    int f[n] = {};
    rep(i,n){
        cin >> f[i];
        f[i]--;
        unite(i,f[i]);
    }
    ll cnt = 0;
    rep(i,n){
        if(find(i) == i) cnt++;
    }
    const ll MOD = 998244353;

    ll ans = mod_pow(2,cnt,MOD) + MOD - 1;
    ans %= MOD;

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

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <random>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

const int mod = 998244353;
int n;
int w[100];
int fact[101];
int dp[101][101][5101];

signed main() {
	int i, j, k;

	cin >> n;
	rep(i, n) cin >> w[i];

	fact[0] = 1;
	for (i = 1; i <= n; i++) {
		fact[i] = fact[i - 1] * i % mod;
	}

	int sumW = 0;
	rep(i, n) sumW += w[i];
	if (sumW % 2 == 1) {
		cout << 0 << endl;
		return 0;
	}

	dp[0][0][0] = 1;
	rep(i, n) {
		for (j = 0; j <= i; j++) {
			rep(k, 5001) {
				dp[i + 1][j][k] += dp[i][j][k];
				dp[i + 1][j][k] %= mod;
				dp[i + 1][j + 1][k + w[i]] += dp[i][j][k];
				dp[i + 1][j + 1][k + w[i]] %= mod;
			}
		}
	}

	int ans = 0;
	for (i = 1; i < n; i++) {
		int res = dp[n][i][sumW / 2];
		ans += res * fact[i] % mod * fact[n - i] % mod;
		ans %= mod;
	}

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


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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define all(a) (a).begin(),(a).end()
#define ODD(x) ( ((x)&1)==0?0:1 )
#define SIGN(x) ( ((x) > 0) - ((x) < 0)  )
#define dbg(x) cerr << #x"= " << x << endl

std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }

void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(0);
    int n;cin>>n;
    vi a(n);
    FOR(i,n) cin>>a[i];
    sort(all(a));
    ll ret=a[0]+1;
    for(int i=1;i<n;++i){
        ret = ret * (a[i]-a[i-1]+1) % MOD;
    }
    cout << ret;

    return 0;
}

#include <iostream>
#include <algorithm>
using namespace std;
#pragma warning (disable: 4996)

long long mod = 1000000007;
long long N, A[1 << 18], Q[1 << 18];
long long Answer = 1;

int main() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> A[i];
    sort(A + 1, A + N + 1);
    for(int i = 1; i <= N; i++) Q[i] = A[i] - A[i - 1];

    for(int i = 1; i <= N; i++) {
        Answer *= (Q[i] + 1LL);
        Answer %= mod;
    }

    cout << Answer << endl;
    return 0;
}


#include <bits/stdc++.h>
#define int long long

using namespace std;

const int MAX_N = 2e5 + 7;
const int MOD = 1e9 + 7;
char s[MAX_N];
int d[MAX_N], dp[MAX_N][17];
int n, k, state;

signed main() {
    scanf("%s%lld", s, &k);
    n = strlen(s);
    for (int i = 0; i < n; ++i) {
        if (s[i] >= '0' && s[i] <= '9') d[i] = s[i] - '0';
        else d[i] = s[i] - 'A' + 10;
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 1; j <= k; ++j) {
            dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * j % MOD) % MOD;
            dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j] * (16 - j) % MOD) % MOD;
        }
        if (i) dp[i + 1][1] = (dp[i + 1][1] + 15) % MOD;
        for (int j = 0; j < d[i]; ++j) {
            int nstate = state;
            if (i || j) nstate |= (1 << j);
            int st = __builtin_popcount(nstate);
            dp[i + 1][st] = (dp[i + 1][st] + 1) % MOD;
        }
        state |= (1 << d[i]);
    }
    int st = __builtin_popcount(state);
    dp[n][st] = (dp[n][st] + 1) % MOD;
    printf("%lld\n", dp[n][k]);
    return 0;
}

// atcoder/abc194/F/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  str s;
  int kind;
  while (cin >> s >> kind) {
    const int N = 2 * 1e5 + 5;
    const int M = 18;
    static lli dp[N][2][2][M];
    fill(&dp[0][0][0][0], &dp[N - 1][2 - 1][2 - 1][M - 1] + 1, 0);
    dp[0][false][true][0] = 1;

    map<char, int> m;
    str t = "0123456789ABCDEF";
    for (int i = 0; i < t.size(); ++i) {
      m[t[i]] = i;
    }

    set<char> vis;

    for (int i = 0; i < s.size(); ++i) {
      for (int less = 0; less < 2; ++less) {
        for (int prefix = 0; prefix < 2; ++prefix) {
          for (int k = 0; k <= kind; ++k) {
            const lli curr = dp[i][less][prefix][k];
            if (curr == 0) continue;
            if (less) {
              (dp[i + 1][less][prefix][k] += curr * k) %= mod;
              unless (prefix) {
                (dp[i + 1][less][prefix][k + 1] += curr * (16 - k)) %= mod;
              } else {
                (dp[i + 1][less][true][k] += curr) %= mod;
                (dp[i + 1][less][false][k + 1] += curr * (15 - k)) %= mod;
              }
            } else {
              for (int p = 0; p < m[s[i]]; ++p) {
                if (i == 0 && p == 0) {
                  (dp[i + 1][true][true][0] += curr) %= mod;
                } else {
                  (dp[i + 1][true][false][vis.size() + 1 - vis.count(t[p])] += curr) %= mod;
                }
              }
            }
          }
        }
      }
      const int prev = vis.size();
      vis.insert(s[i]);
      if (i) {
        dp[i + 1][false][false][vis.size()] += dp[i][false][false][prev];
      } else {
        dp[i + 1][false][false][vis.size()] += dp[i][false][true][prev];
      }
    }

    lli x = 0;
    x += dp[s.size()][true][false][kind];
    x += dp[s.size()][false][false][kind];
    cout << x % mod << endl;
  }
  return 0;
}


#include "bits/stdc++.h"
#include <chrono>
#include <random>
#define lli long long int
using namespace std;
#define mod 1000000007
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INF 1000000000
#define common cout << "Case #" << w+1 << ": "
#define maxn 10010

void setIO(string name) {
	ios_base::sync_with_stdio(0); cin.tie(0);
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}

template< typename T>
void PVecPrint(vector<T>&v)
{
    for(int i=0;i<(int)v.size();i++)
        cout << v[i].first << "," << v[i].second << ' ';
    cout << '\n';
}
template<class T>
void VecPrint(vector<T>&v)
{
    for(int i=0;i<v.size();i++)
        cout << v[i] << ' ';
    cout << '\n';
}
/*-------------------------------------------------------------------Code-----------------------------------------------------------------*/

int main()
{
    int n;
    cin >> n;
    n-=3;
    vector<int>v{6,10,15};
    int t=12;
    set<int>s;
    while (t<10000 and n>0)
    {
        v.push_back(t);
        s.insert(t);
        n-=1;
        t+=6;
    }
    // cout << n << ' ' << s.size() << ' ' << v.size() << '\n';
    t=20;
    while (t<10000 and n>0)
    {
        if(s.find(t)==s.end())
        {
            v.push_back(t);
            s.insert(t);
            n-=1;
        }
        t+=10;
    }
    // cout << n << ' ' << s.size() << ' ' << v.size() << '\n';
    t=30;
    while (t<10000 and n>0)
    {
        if(s.find(t)==s.end())
        {
            v.push_back(t);
            s.insert(t);
            n-=1;
        }
        t+=15;
    }
    // cout << s.size() << ' ' << v.size() << '\n';
    // cout << n << '\n';
    VecPrint<int>(v);
}


//    created: 16.02.2021 03:26:23

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

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

int decimalNumber(int n){
    int tmp = 0;
    while (n)
    {
        tmp = n % 10;
        n = n / 10;
        if(tmp == 7){
            return false;
        }
    }
    return true;
}

int eightBase(int n){
    int tmp = 0;
    while (n)
    {
        tmp = n % 8;
        n = n / 8;
        if(tmp == 7){
            return false;
        }
    }
    return true;
}

int main() {
    cin.tie(0);
     ios_base::sync_with_stdio(false);
    int N;
    int ans=0;
    cin >> N;
    FOR(i,1,N){
        if (decimalNumber(i)){
            if (eightBase(i))ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define RREP_(i, a_, b_, a, b, ...) for (Int i = Int(b) - 1, low##i = (a); i >= low##i; i--)
#define RREP(i, ...) RREP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(v) std::begin(v), std::end(v)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on
struct in {
    template <class T> operator T() {
        T t;
        std::cin >> t;
        return t;
    }
};
void out() { std::cout << "\n"; }
template <class Head, class... Tail> void out(Head&& h, Tail&&... t) {
    std::cout << h << (sizeof...(Tail) == 0 ? "" : " "), out(std::forward<Tail>(t)...);
}
template <class T> bool chmin(T& a, const T& b) { return a > b ? a = b, true : false; }
template <class T> bool chmax(T& a, const T& b) { return a < b ? a = b, true : false; }
template <class T> using V = std::vector<T>;

/**
 *    author:  knshnb
 *    created: Sat Dec 19 21:02:02 JST 2020
 **/

signed main() {
    Int n = in();
    Int ans = 0;
    REP(x, 1, n + 1) {
        bool ok = true;
        for (Int d : {10, 8}) {
            Int y = x;
            while (y) {
                if (y % d == 7) ok = false;
                y /= d;
            }
        }
        ans += ok;
    }
    out(ans);
}


#include <bits/stdc++.h>
#define LOCAL
#define mkp make_pair
#define ft first
#define sd second
using namespace std;
typedef long long ll;
typedef long double lld;
typedef pair<ll,ll> pll;
const lld pi = 3.14159265358979323846;
const ll maxn=1e5+10;
const ll mod=998244353;
void init(void);
ll pow_mod(ll a,ll k);

void solve() {
	ll n,num=0,i=1;
	cin >> n;
	n*=2;
	while(1){
		ll x=n-i*(i-1);
		if(x<=0)break;
		if(x%(2*i)==0)num++;
		i++;
	}
	cout << num*2;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//init();
	ll T=1;
	//cin >> T;
	while(T--){
		solve();
	}
	return 0;
}

void init (void)
{
	#ifdef LOCAL
		freopen ("data.txt", "r", stdin);
		freopen ("out.txt", "w", stdout);
	#endif
}

ll pow_mod(ll a,ll k)
{
    ll ans = 1;
    a %= mod;
    while(k)
    {
        if(k % 2) ans *= a;
        a = (a * a) % mod;
        k /= 2;
        ans %= mod;
    }
    return ans;
}

#include<bits/stdc++.h>

using namespace std;
#define local
#ifdef local

template<class T>
void _E(T x) { cerr << x; }

void _E(double x) { cerr << fixed << setprecision(6) << x; }

void _E(string s) { cerr << "\"" << s << "\""; }

template<class A, class B>
void _E(pair<A, B> x) {
    cerr << '(';
    _E(x.first);
    cerr << ", ";
    _E(x.second);
    cerr << ")";
}

template<class T>
void _E(vector<T> x) {
    cerr << "[";
    for (auto it = x.begin(); it != x.end(); ++it) {
        if (it != x.begin()) cerr << ", ";
        _E(*it);
    }
    cerr << "]";
}

template<class T>
void _E(deque<T> x) {
    cerr << "[";
    for (auto it = x.begin(); it != x.end(); ++it) {
        if (it != x.begin()) cerr << ", ";
        _E(*it);
    }
    cerr << "]";
}

void ERR() {}

template<class A, class... B>
void ERR(A x, B... y) {
    _E(x);
    cerr << (sizeof...(y) ? ", " : " ");
    ERR(y...);
}

#define debug(x...) do { cerr << "{ "#x" } -> { "; ERR(x); cerr << "}" << endl; } while(false)
#else
#define debug(...) 114514.1919810
#endif
using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f3f
#define ll long long
#define db double
#define eps 1e-3
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define endl "\n"
const ll mod = 1e9 + 7;
const ll maxn = 2e6 + 10;
vector<ll> f(maxn), invf(maxn);

ll qpow(ll a, ll b) {
    ll ret = 1;
    for (; b; a = a * a % mod, b >>= 1) {
        if (b & 1) {
            ret = ret * a % mod;
        }
    }
    return ret;
}

void prework() {
    f[0] = 1;
    _rep(i, 1, maxn - 1) {
        f[i] = f[i - 1] * i % mod;
    }
    invf[maxn - 1] = qpow(f[maxn - 1], mod - 2);
    for (ll i = maxn - 2; i >= 0; i--) {
        invf[i] = invf[i + 1] * (i + 1) % mod;
    }

}

ll C(ll n, ll m) {
    if (n > m || m < 0)return 0;
    if (n == 0 || m == n) return 1;
    ll res = (f[m] * invf[m - n] % mod * invf[n]) % mod;
    return res;
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _;
    cin >> _;
    while (_--) {
        ll x;
        cin >> x;
        cout << (x & 1 ? "Odd" : (x % 4 == 0 ? "Even" : "Same")) << endl;
    }

}
// 2 4 6 5 3 1
// 6 5 4 3 2
// 2 4 5 3 1 6
// 5 4 3 2 1 - 5
// 2 4 3 1 5 6
// 4 3 2 1 1 - 4


#include <iostream>
#include <vector>
#include <unordered_set>

int main()
{
    long long N;
    std::cin >> N;

    std::unordered_set<long long> hashset;

    for(long long i = 2; (i * i) <= N; i++){
        hashset.emplace(i*i);
        long long t = i*i;
        while(1){
            t *= i;
            if(t > N){
                break;
            }
            hashset.emplace(t);
        }
    }

    std::cout << N - hashset.size() << std::endl;

    return 0;
}