#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class DisjointSet {
    public:
        DisjointSet(int n) : N(n), sz(n), pars(n, -1) {
        }
        void reset() { sz = N, fill(pars.begin(), pars.end(), -1); }
        int find(int x) { return pars[x] < 0 ? x : pars[x] = find(pars[x]); }
        int size() { return sz; }
        int count(int x) { return -pars[find(x)]; }
        bool unite(int x, int y) {
            x = find(x), y = find(y);
            if (x == y) { return false; }
            --sz;
            if (pars[x] < pars[y]) { swap(x, y); }
            pars[y] += pars[x];
            pars[x] = y;
            return true;
        }
        bool isSame(int x, int y) { return find(x) == find(y); }
    private:
        int N, sz;
        vector<int> pars;
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;
    int m;
    cin >> m;
    vector<int> A(m);
    vector<int> B(m);
    for (int i = 0; i < m; ++i) {
        cin >> A[i] >> B[i];
        --A[i], --B[i];
    }
    vector<int> C(n);
    for (int i = 0; i < n; ++i) {
        cin >> C[i];
    }

    auto cmp = [&](int l, int r) {
        return C[l] < C[r];
    };

    vector<int> ord(n, 0);
    iota(ord.begin(), ord.end(), 0);
    sort(ord.begin(), ord.end(), cmp);

    DisjointSet ds(n);

    vector<vector<bool>> E(n, vector<bool>(n, false));
    for (int i = 0; i < m; ++i) {
        int u = A[i], v = B[i];
        E[u][v] = E[v][u] = true;
        if (C[u] == C[v]) {
            ds.unite(u, v);
        }
    }

    vector<int> dirs(m, 0);

    for (int i = 0; i < m; ++i) {
        int u = A[i], v = B[i];
        if (C[u] != C[v]) {
            dirs[i] = C[u] < C[v];
        }
    }

    map<pair<int,int>, int> M;
    for (int i = 0; i < m; ++i) {
        M.emplace(make_pair(A[i], B[i]), i);
    }

    vector<bool> visited(n, false);

    function<void(int,int,int)> dfs = [&](int u, int p, int s) {
        visited[u] = true;
        for (int v = 0; v < n; ++v) {
            if (v == p) {
                continue;
            }
            if (E[u][v] && ds.find(v) == s) {
                auto it = M.find(make_pair(u, v));
                int ans = 0;
                int idx = -1;
                if (it == M.end()) {
                    it = M.find(make_pair(v, u));
                    if (it != M.end()) {
                        ans = 1;
                        idx = it->second;
                        M.erase(it);
                    }
                } else {
                    idx = it->second;
                    M.erase(it);
                }
                // cout << u << "," << v << " : " << idx << " " << ans << endl;
                if (idx >= 0) {
                    dirs[idx] = ans;
                }

                if (!visited[v]) {
                    dfs(v, u, s);
                }
            }
        }
    };
    for (int i = 0; i < n; ++i) {
        if (ds.count(i) > 1 && ds.find(i) == i) {
            dfs(i, -1, i);
        }
    }

    vector<string> DIRS{"->", "<-"};
    for (int i = 0; i < m; ++i) {
        cout << DIRS[dirs[i]] << '\n';
    }

    return 0;
}

//@formatter:off
#include<bits/stdc++.h>
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(i,n) for (ll i = 0; i < ll(n); ++i)
#define rep2(i,s,n) for (ll i = ll(s); i < ll(n); ++i)
#define rep3(i,s,n,d) for(ll i = ll(s); i < ll(n); i+=d)
#define rep(...) overload4(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__)
#define rrep(i,n) for (ll i = ll(n)-1; i >= 0; i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
#ifdef __LOCAL
#define debug(...) { cout << #__VA_ARGS__; cout << ": "; print(__VA_ARGS__); }
#else
#define debug(...) void(0)
#endif
#define INT(...) int __VA_ARGS__;scan(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;scan(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;scan(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;scan(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;scan(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;scan(__VA_ARGS__)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?"":","); return os<<']'; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> void fin(T a) { cout << a << '\n'; exit(0); }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
void scan(){}
template <class Head, class... Tail> void scan(Head& head, Tail&... tail){ cin >> head; scan(tail...); }
template<class T> void print(const T& t){ cout << t << '\n'; }
template <class Head, class... Tail> void print(const Head& head, const Tail&... tail){ cout<<head<<' '; print(tail...); }
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    INT(n, m);
    vvp G(n);
    vi a(m), b(m);
    rep(i, m) {
        scan(a[i], b[i]);
        a[i]--;
        b[i]--;
    }
    vi c(n);
    cin >> c;
    vi ans(m, -1);
    int cnt = 0;
    auto direct = [&](int id, int from, int to) {
        if (a[id] == from) ans[id] = 0;
        else ans[id] = 1;
    };
    rep(i, m) {
        if (c[a[i]] > c[b[i]]) direct(i, a[i], b[i]);
        else if (c[a[i]] < c[b[i]]) direct(i, b[i], a[i]);
        else {
            G[a[i]].eb(b[i], i);
            G[b[i]].eb(a[i], i);
            cnt++;
        }
    }
    vb seen(n);
    auto dfs = [&](auto &self, int u, int p) -> void {
        seen[u] = true;
        for (auto[v, id] : G[u]) {
            if (v == p) continue;
            if (ans[id] < 0) direct(id, u, v);
            if (!seen[v]) {
                self(self, v, u);
            }
        }
    };
    rep(i, n) {
        if (seen[i]) continue;
        dfs(dfs, i, -1);
    }
    rep(i, m) {
        assert(ans[i] >= 0);
        cout << (ans[i] ? "<-" : "->") << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int n,ans;
int a[N],cnt[N],ch1[N],ch2[N],dp[N],sto1[N],sto2[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		a[i]%=200;
		if(!a[i])a[i]=200;
	}
	dp[0]=1;
	for(int i=1;i<=n;i++)
		for(int j=1e4;j>=a[i];j--)
		{
			dp[j]+=dp[j-a[i]];
			if(dp[j-a[i]])
			{
				if(ch1[j])ch2[j]=ch1[j];
				ch1[j]=i;
			}
		}
	for(int i=1;i<=1e4;i++)
	{
		if(dp[i]>=2)
		{
			ans=i;
			break;
		}
		if(dp[i])cnt[i%200]++;
	}
	if(ans)
	{
		int cnt1=0,cnt2=0,x=ans,y=ans;
//		cout<<ans<<endl;
//		cout<<ch2[31]<<endl;
		while(x)
		{
			sto1[++cnt1]=ch1[x];
			x-=a[ch1[x]];

		}
		while(y)
		{
			if(!ch2[y])ch2[y]=ch1[y];
			sto2[++cnt2]=ch2[y];
			y-=a[ch2[y]];
//			printf("%d ",ch2[y]);
		}
		sort(sto1+1,sto1+cnt1+1);
		sort(sto2+1,sto2+cnt2+1);
		sto1[0]=cnt1;sto2[0]=cnt2;
		printf("Yes\n");
		for(int i=0;i<=cnt2;i++)printf("%d ",sto2[i]);
		cout<<endl;
		for(int i=0;i<=cnt1;i++)printf("%d ",sto1[i]);
	}
	else
	{
		ans=-1;
		for(int i=0;i<=200;i++)
		{
			if(cnt[i]>=2)
			{
				ans=i;
				break;
			}
		}
		if(ans==-1)
		{
			printf("No");
			return 0;
		}
		int ans1=-1,ans2=-1;
		for(int i=0;i<=200;i++)
		{
			if(dp[i*200+ans]&&ans1==-1)
			{
				ans1=i*200+ans;
			}
			else if(dp[i*200+ans]&&ans2==-1)
			{
				ans2=i*200+ans;
				break;
			}
		}
		int cnt1=0,cnt2=0;
		while(ans1)
		{
			sto1[++cnt1]=ch1[ans1];
			ans1-=a[ch1[ans1]];
		}
		while(ans2)
		{
			sto2[++cnt2]=ch1[ans2];
			ans2-=a[ch1[ans2]];
		}
		sort(sto1+1,sto1+cnt1+1);
		sort(sto2+1,sto2+cnt2+1);
		sto1[0]=cnt1;sto2[0]=cnt2;
		printf("Yes\n");
		for(int i=0;i<=cnt2;i++)printf("%d ",sto2[i]);
		cout<<endl;
		for(int i=0;i<=cnt1;i++)printf("%d ",sto1[i]);
	}
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

void rec(int *idx, int s, int baki, function<void(int *)> fun)
{
    if (baki == 0) fun(idx);
    else
    {
        if (s < 0) return;
        rec(idx, s - 1, baki, fun);
        idx[baki - 1] = s;
        rec(idx, s - 1, baki - 1, fun);
    }
}

void cmb(int n, int k, function<void(int *)> fun)
{
    int idx[k];
    rec(idx, n - 1, k, fun);
}

ll ok;
vector<ll> a;
vector<vector<vector<ll>>> vec;

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

    ll n;
    cin >> n;
    a = vector<ll>(n);
    vec = vector<vector<vector<ll>>>(200);

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        a[i] %= 200;
    }

    for (int i = 1; i <= n; i++)
    {
        ok = i;
        cmb(n, i, [](int *ind)
        {
            vector<ll> t;
            ll ts = 0;
            for (int j = 0; j < ok; j++)
            {
                t.push_back(ind[j] + 1);
                ts += a[ind[j]];
            }
            if (vec[ts % 200].size() <= 0) vec[ts % 200].push_back(t);
            else
            {
                cout << "YES" << endl;
                cout << vec[ts % 200][0].size();
                for (auto pl : vec[ts % 200][0]) cout << " " << pl;
                cout << endl;
                cout << t.size();
                for (auto pl : t) cout << " " << pl;
                cout << endl;
                exit(0);
            }
        });
    }

    cout << "NO" << endl;

    return 0;
}


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

const int N = 110;;
int a[N * N], b[N * N], c[N], mp[N][N];
int n, m;
bool vis[N];
string ans[N*N];

void dfs(int u) {
    vis[u] = true;
    for (int i = 1; i <= n; i++) {
        if (mp[u][i]) {
            mp[i][u] = false;
            if (!vis[i]) dfs(i);
        }
    }
}

int main() {
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
        cin >> a[i] >> b[i];
    for (int i = 1; i <= n; i++)
        cin >> c[i];
    for (int i = 1; i <= m; i++) {
        if (c[a[i]] > c[b[i]]) ans[i] = "->";
        else if (c[b[i]] > c[a[i]]) ans[i] = "<-";
        else mp[a[i]][b[i]] = mp[b[i]][a[i]] = true;
    }
    for (int i = 1; i <= n; i++)
        if (!vis[i]) dfs(i);
    for (int i = 1; i <= m; i++) {
        if (mp[a[i]][b[i]]) ans[i] = "->";
        else if (mp[b[i]][a[i]]) ans[i] = "<-";
    }
    for (int i = 1; i <= m; i++)
        cout << ans[i] << endl;
    return 0;
}

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

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

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

	int N, M;
	cin >> N >> M;
	vector<pair<int, int>> E[101];
	rep1(i, M) {
		int a, b;
		cin >> a >> b;
		E[a].pb({ b, i });
		E[b].pb({ a, -i });
	}
	int C[101];
	rep1(i, N) cin >> C[i];

	int vis[101] = {};
	int kotae[10000];
	rep1(i, N) {
		if (!vis[i]) {
			pair<int, int> Q[10000];
			int a = 0;
			Q[a++] = { i, 0 };
			while (a) {
				int fr = Q[--a].first;
				int mae = Q[a].second;
				if (vis[fr]) continue;
				vis[fr] = 1;
				for (auto p : E[fr]) {
					int to = p.first;
					int dotti = p.second;
					if (!vis[to]) {
						if (C[fr] == C[to]) {
							kotae[abs(dotti)] = dotti;
							Q[a++] = { to, fr };
						}
					}
					else if (mae != to) {
						kotae[abs(dotti)] = dotti;
					}
				}
			}
		}
		for (auto p : E[i]) {
			int to = p.first;
			int dotti = p.second;
			if (C[i] < C[to]) kotae[abs(dotti)] = -dotti;
			else if (C[i] > C[to]) kotae[abs(dotti)] = dotti;
		}

	}

	rep1(i, M) {
		if (kotae[i] > 0) co("->");
		else co("<-");
	}

	Would you please return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 505;
char en = '\n';
ll inf = 1e16;
ll mod = 998244353;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

using namespace __gnu_pbds; //(or pb_ds)
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    pbds;

char arr[N][N];

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

  ll n;
  cin >> n;

  ll a[n + 5];
  ll b[n + 5];

  map<ll, vector<ll>> indices;
  for (ll i = 1; i <= n; i++) {
    cin >> a[i];
    indices[i + a[i]].push_back(i);
  }
  for (ll i = 1; i <= n; i++) {
    cin >> b[i];
  }

  for (auto &it : indices) {
    reverse(it.second.begin(), it.second.end());
  }
  pbds X;
  ll res = 0;

  for (ll i = 1; i <= n; i++) {
    ll req = b[i] + i;
    if (indices.find(req) == indices.end()) {
      cout << -1 << en;
      return 0;
    }
    vector<ll> &vect = indices[req];
    ll indx = vect.back();
    vect.pop_back();
    if (vect.empty()) {
      indices.erase(req);
    }

    // adjust for changes
    // find indices > indx
    ll change = (i - 1) - X.order_of_key(indx);

    X.insert(indx);
    res += indx + change - i;
  }
  cout << res << en;

  return 0;
}

#include<unordered_map>
#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,a[200005],b[200005],ans,rf[200005],res[200005],cnt,bit[200005];
unordered_map<ll,ll>tmp,tmp2;
queue<ll>q[200005];
//void m_sort(int l,int r)
//{
//	if(l==r)return;
//	int mid=(l+r)>>1,i=l,j=mid+1,k=l;
//	m_sort(l,mid);m_sort(mid+1,r);
//	while(i<=mid&&j<=r)
//		if(a[i]<=a[j])res[k++]=a[i++];
//		else res[k++]=a[j++],ans+=mid-i+1;
//	while(i<=mid)res[k++]=a[i++];
//	while(j<=r)res[k++]=a[j++];
//	for(int t=l;t<=r;++t)a[t]=res[t];
//}
il int lowbit(int x){return x&(-x);}
void add(int x){while(x<=n)++bit[x],x+=lowbit(x);}
int query(int x)
{
	int res=0;
	while(x)res+=bit[x],x-=lowbit(x);
	return res;
}
int main()
{
	n=rd();
	for(int i=1;i<=n;++i)++tmp[a[i]=rd()-n+i];
	for(int i=1;i<=n;++i)--tmp[b[i]=rd()-n+i];
	for(int i=1;i<=n;++i)if(tmp[a[i]]||tmp[b[i]]){puts("-1");return 0;}
//	for(int i=1;i<=n;++i)cerr<<a[i]<<' ';
//	cerr<<endl;
//	for(int i=1;i<=n;++i)cerr<<b[i]<<' ';
//	cerr<<endl;
	for(int i=1;i<=n;++i)
	{
		if(tmp2.find(b[i])==tmp2.end())tmp2[b[i]]=++cnt,rf[cnt]=b[i];
		q[tmp2[b[i]]].push(i);
//		cerr<<tmp2[b[i]]<<' ';
	}
//	cerr<<endl;
//	for(int i=1;i<=n;++i)a[i]=q[tmp2[a[i]]].front(),q[tmp2[a[i]]].pop();
//	for(int i=1;i<=n;++i)cerr<<a[i]<<' ';
//	cerr<<endl;
//	m_sort(1,n);
	for(int i=1;i<=n;++i)
	{
		int val=q[tmp2[a[i]]].front();q[tmp2[a[i]]].pop();
		ans+=query(n)-query(val);add(val);
	}
	prt(ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define run ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0);
#define mod 1000000007
#define decimal(n,k) cout<<fixed<<setprecision(k)<<n<<endl
#define LL_MAX LLONG_MAX
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define maxa(v) *max_element(v, v + v.size())
#define mina(v) *min_element(v, v + v.size())
int exp(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int modinv(int x){return exp(x,mod-2);}
int add(int a,int b){a%=mod,b%=mod;a=((a+b)%mod+mod)%mod;return a;}
int sub(int a,int b){a%=mod,b%=mod;a=((a-b)%mod+mod)%mod;return a;}
int mul(int a,int b){a%=mod,b%=mod;a=((a*b)%mod+mod)%mod;return a;}
int gcd(int a, int b){if (b == 0)return a; return gcd(b, a % b);}
int Log2n( int n){ return (n > 1) ? 1 + Log2n(n / 2) : 0;}
int fac[100009];int ncr_mod(int n,int k){int ans=fac[n];ans*=modinv(fac[k]);ans%=mod;ans*=modinv(fac[n-k]);ans%=mod;return ans;}
vector<int>v_prime;void Sieve(int n){bool prime[n + 1];memset(prime,true,sizeof(prime));for (int p = 2; p*p <=n;p++){if(prime[p] ==true) {for(int i = p*p; i<= n; i += p)prime[i]=false;}}for(int p = 2;p<= n;p++)if (prime[p])v_prime.pb(p);}
vector<int>v_factor;void factors(int n){ for (int i=1; i<=sqrt(n); i++) {if (n%i == 0) {if (n/i == i) v_factor.pb(i);else { v_factor.pb(i),v_factor.pb(n/i);};} } sort(all(v_factor)); }
void out(vector<int>&a){for(int i=0;i<a.size();i++) cout<<a[i]<<" ";  cout<<endl;}

// s.top().second;

signed main()
 {

       run;

/*
open for mod factorial

     fac[0]=1;
       for(int i=1;i<100009;i++)
      {
         fac[i]=fac[i-1]*i;
          fac[i]%=mod;
      }
 */

/*
for sieve open this and use v_prime

       int pp=pow(10,6)+100000;
          Sieve(pp);

*/

 // USE v_factor For calculating factors

int  t=1;
 //cin>>t;
 while(t--)
{
         // vector< pair <int,int> > vp;
        //  map<int,int>mp; // x.second-->frequency
       //   set<int>st;

          int  n,i,x,y,ok=0,sum=0,ans=0,j,k,cnt=0,m,c=0;
          int  h[100009]={0},a,b;
          ans=-LL_MAX;

                cin>>a>>b>>x>>y;

               for(i=a;i<=b;i++)
               {
                   for(j=x;j<=y;j++)
                   {
                       ans=max(ans,i-j);
                   }
               }
               cout<<ans;
}
}

#include <iostream>
using namespace std;
#define int long long int
int32_t main() {

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<b-c<<endl;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353

using namespace std;
using namespace __gnu_pbds;

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

ordered_set<ll> ors;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ld PI=3.14159265359;

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

ll fac[1000001];

void init(ll m) {
    // prime();
    fac[0]=fac[1]=1;
    repf(i,2,1000001) fac[i]=(fac[i-1]*i)%m;
}

ll nCr(ll n, ll r, ll m) {
    if(n<r || r<0) return 0;
    ll nr=fac[n];
    ll dr=(fac[n-r]*fac[r])%m;
    dr=invmod(dr,m);
    ll res=(nr*dr)%m;
    return res;
}

void solve(ll tt) {
    ll n;
    cin>>n;
    ld x0,y0,xh,yh;
    cin>>x0>>y0>>xh>>yh;
    ld angle=2*PI/n;
    ld x1,y1;
    x1=(x0+xh)+(x0-xh)*cos(angle)-(y0-yh)*sin(angle);
    y1=(y0+yh)+(x0-xh)*sin(angle)+(y0-yh)*cos(angle);
    x1/=2,y1/=2;
    cout<<fixed;
    cout<<setprecision(10)<<x1<<" "<<y1<<endl;
}

int main()
{
    IOS;
    // init(mod);
    ll t=1;
    // cin>>t;
    repf(tt,1,t+1) {
        solve(tt);
    }
}

#include <bits/stdc++.h>
#define rep(i,s,n) for (int i = s; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using Matrix = vector<vector<int>>;

const ll INF = LLONG_MAX;
const ld EPS = 1e-14;
const ll MOD = 1e9+7;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};

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

using C = complex<double>;
C inC() {
    double x, y;
    cin >> x >> y;
    return C(x,y);
}
int main() {
    /*
    int n, x0, y0, xn2, yn2;
    cin >> n >> x0 >> y0 >> xn2 >> yn2;
    ld theta = (180.0 / (ld)n) * M_PI / 180.0;
    ld a = sqrtl((x0 - xn2) * (x0 - xn2) + (y0 - yn2) * (y0 - yn2));
    ld b = a * cosl(theta);
    ld c = a * sinl(theta);
    */
    int n;
    cin >> n;
    C s = inC();
    C t = inC();
    C o = (s + t) / 2.0;
    double rad = 2 * M_PI / n;
    C r(cos(rad), sin(rad));
    C ans = o + (s - o) * r;
    cout << fixed << setprecision(10);
    cout << ans.real() << " " << ans.imag() << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
struct State {
  int begin, end, cost;
  State(int begin_, int end_, int cost_) : begin(begin_), end(end_), cost(cost_) { }
};
bool done[1000][1000];
int main() {
  int N, M; cin >> N >> M;
  vector<vector<int>> G(N);
  vector<vector<char>> C(N);
  for(int i = 0; i < M; i++) {
    int a, b; char c;
    cin >> a >> b >> c;
    a--; b--;
    G[a].push_back(b);
    C[a].push_back(c);
    G[b].push_back(a);
    C[b].push_back(c);
  }
  queue<State> Q;
  Q.emplace(0, N - 1, 0);
  done[0][N - 1] = true;
  int ans = 1e9;
  while(!Q.empty()) {
    State s = Q.front();
    Q.pop();
    for (int i = 0; i < (int)G[s.begin].size(); i++) {
      for (int j = 0; j < (int)G[s.end].size(); j++) {
        if(C[s.begin][i] != C[s.end][j]) {
          continue;
        }
        int u = G[s.begin][i];
        int v = G[s.end][j];
        if(u == s.end && v == s.begin) {
          ans = min(ans, s.cost + 1);
        }
        if(u == v) {
          ans = min(ans, s.cost + 2);
        }
        if(done[u][v]) {
          continue;
        }
        done[u][v] = true;
        Q.emplace(u, v, s.cost + 2);
        // cerr << "(" << u+1 << "," << v+1 << ") = " << s.cost + 2 << endl;
      }
    }
  }
  if (ans == 1e9) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}

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

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

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

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

#define en "\n"

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

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

struct Edge{
    int from, to, id=-1;
    int cost=1;

    Edge(int from, int to, int cost=1, int id=-1): from(from), to(to), cost(cost), id(id) {}
    Edge() {}

    friend istream &operator>>(istream  &input, Edge &e ){
        char c;
        input >> e.from >> e.to >> c;
        e.from--; e.to--; e.cost = c-'a';
        return input;
    }

    Edge rev(void){
        return Edge(to, from, cost, id);
    }
};

vector<vector<Edge>> edge(1010);
bool connect[1010][1010];
int d[1010][1010][27];

void Main(){
    int N,M; cin >> N >> M;
    vector<Edge> edge2[N][26];
    REP(_,M){
        Edge e; cin >> e;
        edge[e.from].emplace_back(e);
        edge[e.to].emplace_back(e.rev());

        connect[e.from][e.to] = connect[e.to][e.from] = true;

        edge2[e.from][e.cost].emplace_back(e);
        edge2[e.to][e.cost].emplace_back(e.rev());
    }
    REP(i,N)REP(j,N){
        REP(x,27) d[i][j][x] = INF;
    }

    if(connect[0][N-1]){
        cout << 1 << en;
        return;
    }

    int ans = INF;
    priority_queue<Pair,vector<Pair>,greater<Pair>> q;
    q.emplace(0,tpl(0,N-1,26));
    while(!q.empty()){
        auto p = q.top(); q.pop();
        int cost = p.first, x, y, c;
        tie(x,y,c) = p.second;

        if(!chmin(d[x][y][c], cost)) continue;
        if(x==y){
            chmin(ans, cost);
            continue;
        }
        if(connect[x][y]){
            chmin(ans, cost+1);
            continue;
        }

        REP(i,26){
            for(auto& ex : edge2[x][i])for(auto& ey : edge2[y][i]){
                q.emplace(cost+2, tpl(ex.to,ey.to,i));
            }
        }
    }

    cout << (ans<INF ? ans : -1) << en;
    return;
}

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


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+50;
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        s=s*10+ch-'0';
        ch=getchar();
    }
    return s*f;
}
int u[N],n,k,a[N];
int main(){
   cin>>n>>k;
    for(int i=1;i<=n;i++)
    {a[i]=read();u[a[i]]++;}
    int ans=0;
for(int j=1;j<=k;j++)
{
    for(int i=0;i<=n;i++)
    {
        if(!u[i]){ans+=i;break;}
        u[i]--;
    }
}
    cout<<ans;
}

#include<bits/stdc++.h>

#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9+10
#define INFL 1e18
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {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;}

//cout<< fixed << setprecision(10)
//__builtin_popcountll();
//|_2.4_|=2

int main(){

    fast;
    int n,k,i,j;
    cin>>n>>k;
    int f[n+10]={0};
    for(i=0;i<n;i++)
    {
        int x;
        cin>>x;
        f[x]++;
    }
    int ans=0;
    i=0;
    while(k!=0)
    {
        if(f[i]>=k)
        {
            i++;
            continue;
        }
        else
        {
            ans=ans+(k-f[i])*i;
            k=f[i];
            i++;
        }

    }
    cout<<ans;

}


#include <bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000000000005

using namespace std;

int main (){

	long long ans, n,i;
	cin>>n;
	i=1000;
	ans = 0;
	while (i<=n){
		ans += n-i+1;
		i=i*1000;
	}
	cout<<ans;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
template<class T> void chmax(T& a, T b){
    if(a < b){
        a = b;
    }
}
template<class T> void chmin(T& a, T b){
    if(a > b){
        a = b;
    }
}
int main()
{
    string n;

    cin >> n;

    int l = n.size();
    ll ans = 0;

    int com = l/3;

    if(l <= 3){
        ans = 0;
    }

    for(int i = 1; i <= 5; i++){
        if(l > i*3){
            if(l < (i+1)*3+1){
                ll N = stol(n);
                N -= pow(10,i*3) -1;

                ans += N*i;

                break;
            }
            else ans += (pow(10,(i+1)*3) - pow(10,i*3))*i;
        }
    }

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


//
// Created by saa on 2021/5/27.
//
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int h=0;
    int w=0;
    int min=300;
    int sum=0;
    cin>>h>>w;
    vector<int> blocks(h*w);

    for(int n=0;n<blocks.size();n++)
    {
        cin>>blocks[n];
        if(blocks[n]<min)
        {
            min=blocks[n];
        }
    }

    for(int n=0;n<blocks.size();n++)
    {
        sum+=blocks[n]-min;
    }

    cout<<sum<<"\n";

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
#define vvint vector<vector<int>>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 998244353LL;

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

void solve() {
    int h,w;
    cin >> h >> w;
    vvint a(h, vint(w));
    REP(i,h) {
        cin >> a[i];
    }
    int val = INT_MAX;
    REP(i,h) {
        REP(j,w) {
            val = min(val, a[i][j]);
        }
    }
    ll ans = 0;
    REP(i,h) {
        REP(j,w) {
            ans += a[i][j] - val;
        }
    }
    cout << ans << endl;
}

int main() {
    solve();
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}


// нахуй такие задачи пиздец

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,k,a[15],is[200005];
struct P{
	long double k,x;
}f[200005],sum[200005];//f[i]=k*f[1]+x
P operator +(P i,P j){
	return {i.k+j.k,i.x+j.x};
}
P operator -(P i,P j){
	return {i.k-j.k,i.x-j.x};
}
P operator /(P i,double j){
	return {i.k/j,i.x/j};
}
int main(){
	cin>>n>>m>>k;
	for(int i=1;i<=k;i++)cin>>a[i],is[a[i]]=1;
	for(int i=n-1;i>=0;i--){
		if(!is[i])f[i]=(sum[i+1]-sum[i+m+1])/m+(P){0,1};
		else f[i]=(P){1,0};
		sum[i]=sum[i+1]+f[i];
	}
	if(fabs(f[0].k-1)<1e-6)puts("-1");
	else {
		long double x=-f[0].x/(f[0].k-1);
		printf("%.4Lf\n",x);
	}
}

#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int N, Q; cin >> N;
    vector<int> A(N), T(N);
    REP(i, 0, N) cin >> A[i] >> T[i];

    cin >> Q;
    vector<ll> X(Q);
    REP(i, 0, Q) cin >> X[i];

    set<ll> S;
    REP(i, 0, Q) S.insert(X[i]);

    ll offset = 0;
    REP(i, 0, N) {
        if (T[i] == 1) {
            offset += A[i];
        } else if (T[i] == 2) {
            auto itr = S.lower_bound(A[i] - offset);

            bool deleted = false;
            auto jtr = S.begin();
            while (jtr != itr) {
                jtr = S.erase(jtr);
                deleted = true;
            }
            if (deleted) {
                S.insert(A[i] - offset);
            }
        } else {
            auto itr = S.lower_bound(A[i] - offset);

            bool deleted = false;
            while (itr != S.end()) {
                itr = S.erase(itr);
                deleted = true;
            }
            if (deleted) {
                S.insert(A[i] - offset);
            }
        }
    }
    // for (auto x : S) cout << x << " ";
    // cout << endl;

    REP(i, 0, Q) {
        auto itr = S.lower_bound(X[i]);
        if (itr != S.begin() && (itr == S.end() || *itr > X[i])) itr = prev(itr);
        // cout << "# i : " << i << ", X[i] : " << X[i] << ", itr : " << *itr << endl;
        cout << *itr + offset << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[15];
bool cmp (int a, int b) {
	return a > b;
}
int g2(int x) {
	int ind = 0, res = 0;
	while (x) {
		a[ind ++] = x % 10;
		x /= 10;
	}
	sort(a, a + ind);
	for (int i = 0; i < ind; i ++) {
		if (a[i] != 0) {
			res *= 10;
			res += a[i];
		}
	}
	return res;
}
int g1(int x) {
	int ind = 0, res = 0;
	while (x) {
		a[ind ++] = x % 10;
		x /= 10;
	}
	sort(a, a + ind, cmp);
	for (int i = 0; i < ind; i ++) {
		res *= 10;
		res += a[i];
	}
	return res;
}
int f(int x) {
	return g1(x) - g2(x);
}
int main() {
	int n, k, tmp, flag = 0;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < k; i ++) {
		tmp = f(n);
		if (tmp == n) {
			printf("%d\n", tmp);
			flag = 1;
			break;
		}
		n = tmp;
	}
	if (!flag) printf("%d\n", n);
	return 0;
}

// Umang_US

#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 2*100005
#define sec second
#define fi first
#define be begin()
#define en end()
#define sortv(v) sort(v.begin(),v.end());
#define sortr(v) sort(v.rbegin(),v.rend());
#define w() ll _;cin>>_;while(_--)
#define edge pair<ll,ll>
#define pq priority_queue<ll>
#define mod 1000000007
#define Endl "\n"
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;
// multiset<ll>::iterator it=next(s.begin(), i);// iterator for index i
// cout<<fixed<<setprecision(10);
// https://www.youtube.com/watch?v=o2gqyVR7B4I

//------------------------HARDER--------------------------------

int ase(int n)
{
	string s=to_string(n);
	sortv(s);

	n=stoi(s);
	return n;
}

int des(int n)
{
	string s=to_string(n);
	sortr(s);

	 n=stoi(s);
	return n;
}

int main()
{
	fast;

	int n,k;
	cin>>n>>k;

	int a[k+3]={0};

	int i;
	a[0]=n;

	for(i=1;i<=k;i++)
	{
		a[i] = des(a[i-1])-ase(a[i-1]);
	}

	cout<<a[k]<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define cases long long t; cin>>t; while(t--)
#define ll long long
#define MOD 1000000007
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    ll i,j,flag=0,k,flag2=0;
    cin>>s;
    for(j=s.size()-1;j>=0;j--){
        if(s[j]!='0'){
            k=j; flag2=1; break;
        }
    }
  	if(flag2==0) cout<<"Yes"<<endl;
  	else{
  	    if(k%2==0){
  	        j=k;
  	        for(i=0;i<k/2;i++){
                if(s[i]!=s[j]){
   	                cout<<"No"<<endl;
   	                flag=1;
   	                break;
   	            }
   	            j--;
   	        }
  	    }
  	    else{
  	        j=k;
  	        for(i=0;i<=k/2;i++){
                if(s[i]!=s[j]){
   	                cout<<"No"<<endl;
   	                flag=1;
   	                break;
   	            }
                j--;
   	        }
  	    }
  	    if(flag==0) cout<<"Yes"<<endl;
    }
 	   return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define x first
#define y second
#define pi pair
#define K 1000000007
using namespace std;

ll a[2000000];
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll test_case=1;//cin>>test_case;
	while(test_case--)
	{
        ll m,h;cin>>m>>h;
        if(h%m==0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define rg register
#define In inline
#define ll long long

const int N = 2e5;
const ll mod = 998244353;

namespace IO{
	In ll read(){
		ll s = 0,ww = 1;
		char ch = getchar();
		while(ch < '0' || ch > '9'){if(ch == '-')ww = -1;ch = getchar();}
		while('0' <= ch && ch <= '9'){s = 10 * s + ch - '0';ch = getchar();}
		return s * ww;
	}
	In void write(ll x){
		if(x < 0)putchar('-'),x = -x;
		if(x > 9)write(x / 10);
		putchar('0' + x % 10);
	}
};
using namespace IO;

namespace ModCalc{
	In void Inc(ll &x,ll y){
		x += y;if(x >= mod)x -= mod;
	}
	In void Dec(ll &x,ll y){
		x -= y;if(x < 0)x += mod;
	}
	In ll Add(ll x,ll y){
		Inc(x,y);return x;
	}
	In ll Sub(ll x,ll y){
		Dec(x,y);return x;
	}
};
using namespace ModCalc;

int n;
bool vis[N+5];
vector<int> vc;
vector<int> E[N+5];//i[N+5],Eo[N+5];
queue<int> Q;

In ll power(ll a,ll n){
	ll s = 1,x = a;
	while(n){
		if(n & 1) s = s * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return s;
}
void bfs(int s){
	Q.push(s);vis[s] = 1;
//	vc.resize(0);
	while(!Q.empty()){
		int u = Q.front();
		Q.pop();vc.push_back(u);
		for(auto v : E[u]){
			if(vis[v])continue;
			vis[v] = 1;
			Q.push(v);
		}
	}
/*	int d = vc.size(),en = 0;
	for(auto u : vc)en += E[u].size();
	en >>= 1;
cout<<"d="<<d<<" en="<<en<<endl;
	if(en == d)return 2;else return power(2,d);*/
}

int main(){
//	freopen("B.in","r",stdin);
//	freopen("B.out","w",stdout);
	n = read();
	for(rg int i = 1;i <= n;i++){
		int f = read();
		if(f == i)continue;
		else E[i].push_back(f),E[f].push_back(i);
	}
	ll ans = 1;
	for(rg int i = 1;i <= n;i++)if(!vis[i])bfs(i),ans = ans * 2 % mod;
	write(Sub(ans,1)),putchar('\n');
	return 0;
}

#line 1 "a.cpp"
#include<iostream>
using namespace std;
#line 1 "/home/kotatsugame/library/datastructure/UF.cpp"
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,1)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a){return parent[a]!=a?parent[a]=find(parent[a]):a;}
	bool same(int a,int b){return find(a)==find(b);}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
			rank[b]+=rank[a];
		}
		else
		{
			parent[b]=a;
			rank[a]+=rank[b];
		}
		return true;
	}
	int size(int a){return rank[find(a)];}
};
#line 4 "a.cpp"
const long mod=998244353;
int N,P[2<<17];
main()
{
	cin>>N;
	UF uf(N);
	int cnt=N;
	for(int i=0;i<N;i++)
	{
		cin>>P[i];
		P[i]--;
		cnt-=uf.unite(i,P[i]);
	}
	long ans=1;
	for(;cnt--;)ans=ans*2%mod;
	cout<<(ans+mod-1)%mod<<endl;
}


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

struct UnionFind{
    vector<int> data;
	vector<map<int,int> > cl;
    UnionFind(int size) : data(size, -1),cl(size) {}
    bool unite(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return 0;
        if(data[y]<data[x])swap(x,y);
        data[x]+=data[y],data[y]=x;
		for(auto i:cl[y]){
			cl[x][i.first]+=i.second;
		}
        return 1;
    }
    bool find(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0 ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n,q;
	cin>>n>>q;
	vi in(n);
	rep(i,n)cin>>in[i];
	UnionFind uf(n);
	rep(i,n)uf.cl[i][in[i]]=1;
	while(q--){
		int t,a,b;
		cin>>t>>a>>b;
		if(t==1){
			uf.unite(a-1,b-1);
		}else{
			int r=uf.root(a-1);
			cout<<uf.cl[r][b]<<endl;
		}
	}

}

#include<bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <chrono>
#include <complex>
using namespace std;
#define ll long long
#define ld long double
#define ui unsigned int
#define ull unsigned ll
#define mp                   make_pair
#define eb                   emplace_back
#define pb                   push_back
#define pf                   push_front
#define popb                 pop_back
#define popf                 pop_front
#define hashmap              unordered_map
#define hashset              unordered_set
#define lb                   lower_bound
#define ub                   upper_bound
#define all(a)               (a).begin(), (a).end()
#define rall(a)              (a).rbegin(), (a).rend()
#define ff                   first
#define ss                   second
#define foi(n) for(ll i=0;i<n;i++)
#define foj(n) for(ll j=0;j<n;j++)
#define fok(n) for(ll k=0;k<n;k++)
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define forrr(i,b,a) for(ll i=b;i>=a;i--)
#define forrrr(i,a,b,k) for(ll i=a;i<b;i=i+k)
#define graph          vector<vector<int>>
#define sz(v) v.size()
typedef pair<int, int> pii;
typedef pair<ll, ll>   pll;
typedef vector<int>         vi;
typedef vector<ll>          vll;
typedef vector<string>      vs;
typedef vector<double>      vd;
typedef vector<pii>         vpii;
typedef vector<pll>         vpll;
typedef pair< ll, pll>      plll;
typedef vector<plll>      vplll;
typedef  vector<string> 	     vs;
typedef  vector<char>	         vc;
typedef  vector<bool>            vb;
typedef  map<string, int>         msi;
typedef  map<int, int>	         mii;
typedef  map<ll, ll>             mll;
typedef  map<char, int>           mci;
typedef  map<int, string>	     mis;
typedef  pair<string, int>       psi;
typedef  pair<string, string>    pss;
typedef priority_queue <ll> pq;
typedef priority_queue<pii, vector<pii>, greater<pii> > pqq;
const ll MOD = 1000000007;
ll TT = 1;
void solve();
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("error1.txt", "w", stderr);
	freopen("output1.txt", "w", stdout);
#endif

	//ll t ; cin >> t;
	//while (t--)
	{
		solve();
		cout << "\n";
	}

	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
	return 0;
}
ll ceils(ll x, ll y) {
	return x / y + ((x % y) != 0);
}
ll gcd(ll a, ll b) {
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
void solve()
{
	ll n, d, h;
	cin >> n >> d >> h;
	vpll x;
	foi(n) {
		ll y, z;
		cin >> y >> z;
		x.pb(mp(y, z));
	}
	ld ans = 0;
	foi(n) {
		if ((ld)x[i].ss - ((ld)h - (ld)x[i].ss) / ((ld)d - (ld)x[i].ff) * (ld)x[i].ff > 0)
			ans = max(ans, (ld)x[i].ss - ((ld)h - (ld)x[i].ss) / ((ld)d - (ld)x[i].ff) * (ld)x[i].ff);
	}
	cout << fixed << setprecision(10);
	cout << ans;

}


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

#define fo(i, x, y) for (int i = (x); i <= (y); ++i)
#define fd(i, x, y) for (int i = (x); i >= (y); --i)

typedef long long ll;

int getint()
{
	char ch;
	int res = 0, p;
	while (!isdigit(ch = getchar()) && (ch ^ '-'));
	p = ch == '-'? ch = getchar(), -1 : 1;
	while (isdigit(ch))
		res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
	return res * p;
}

void work()
{
	ll x;
	scanf("%lld", &x);
	int cnt = 0;
	while (x & 1 ^ 1) x >>= 1, cnt++;
	switch(cnt)
	{
		case 0: {printf("Odd\n"); break;}
		case 1: {printf("Same\n"); break;}
		default: {printf("Even\n"); break;}
	}
}

int main()
{
	int T;
	T = getint();
	while (T--) work();
	return 0;
}

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

int main(){

    int t ;
    cin >> t ;

    ll a[t] ;
    rep(i, t) cin >> a[i] ;

    rep(i, t){
        if(a[i] % 2 == 0){
            a[i] /= 2 ;
            if(a[i] % 2 == 0) cout << "Even" << endl ;
            else cout << "Same" << endl ;
        }
        else cout << "Odd" << endl ;
    }
}


#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <unordered_map>
#include <climits>
#include <algorithm>
#include <map>
#include <queue>
#include <random>
#include <chrono>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;

#define randoom mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//use rng() for random

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

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define rep(i,n) for (int i=1;i <=int(n);i++)
pii a[200001];

int main(){
    int n,w; cin >> n >> w;
    vector<pair<pii,int>> events;
    rep(i,n){
        int ppp;
        cin >> a[i].fi >> a[i].se >> ppp;
        events.pb(mp(mp(a[i].fi,1),ppp));events.pb(mp(mp(a[i].se,-1),ppp));

    }
    sort(all(events));
    int pp=0;
    for (auto p:events){
        pp+=p.fi.se*p.se;
        if (pp>w) {
            cout << "No"; return 0;
        }
    }
    cout << "Yes";

    return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;
int main(){

    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i,m) cin >> a[i];
    sort(all(a));

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

    int h=mod;
    rep(i,m){
        if(i!=0){
            if(a[i]-a[i-1]-1!=0) h=min(h,a[i]-a[i-1]-1);
        }
    }
    if(a[0]-1!=0) h=min(h,a[0]-1);
    if(n-a[m-1]!=0) h=min(h,n-a[m-1]);

    ll count=0;
    rep(i,m){
        if(i!=0){
            if(a[i]-a[i-1]-1!=0) count+=(a[i]-a[i-1]-2)/h+1;
        }
    }
    if(a[0]-1!=0) count+=(a[0]-1-1)/h+1;
    // cout << count << endl;
    if(n-a[m-1]!=0) count+=(n-a[m-1]-1)/h+1;

    cout << count << endl;
    // cout << h << endl;

    return 0;
}


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

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

    long long n;
    cin >> n;
    long long p = sqrt(2 * n + 2);
    while ((p + 1) * p <= 2 * n + 2)
        p++;

    cout << n + 1 - p + 1;

    return 0;
}

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  ll n;
  cin >> n;

  ll ans = 2;
  for (ll l = 1; l <= 1e7; l++) {
    ll a = (2 * n - l * (l - 1));
    ll b = a / (2 * l);
    if (a % (2 * l) == 0 && b > 0 && b < n) {
      ans += 2;
    }
  }
  cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define int long long int
#define vi vector<int>
#define pb push_back
#define endl "\n"
#define all(v) v.begin(),v.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define deb(x) cout<<"["#x<<":"<<x<<"]"<<"  ";
#define deb2(x,y) cout<<"["#x<<":"<<x<<" "#y<<":"<<y<<"]";
#define inp int n;cin>>n;int a[n];for(int i=0;i<n;i++)cin>>a[i];
#define out(a) for(int i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
using namespace std;

void AKM()
{
  int a1,b1,a2,b2;
  cin>>a1>>b1>>a2>>b2;
  if(a1==a2&&b1==b2){
    cout<<0<<endl;
    return;
  }
   if((a1-b1==a2-b2)||(a1+b1==a2+b2)||(abs(a1-a2)+abs(b1-b2)<= 3)){
    cout<<1<<endl;
    return;
  }
  if(((a1%2==a2%2)&&(b1%2==b2%2))||((a1%2!=a2%2)&&(b1%2!=b2%2))){
    cout<<2<<endl;
    return;
  }

  if((abs((a1+b1)-(a2+b2))<=4)||(abs((a1-b1)-(a2-b2))<=4)){
      cout<<2<<endl;
    return;
  }
  cout<<3<<endl;

}

int32_t main()
{

    fastio;
    cout<<fixed;
    cout.precision(15);
    int __TESTCASES=1;
    //cin>>__TESTCASES;
    while(__TESTCASES--){
    AKM();
}
}

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b); i-- > (a); )
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int((x).size())
#define lb(x...) lower_bound(x)
#define ub(x...) upper_bound(x)

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

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

const int N = 3000 + 10, inf = 1e9 + 10, K = 5;
int a[N][K];
bool exists[1 << K];
int n;

bool f(int x) {
	rep(S, 0, 1 << K) {
		exists[S] = 0;
		rep(i, 0, n) {
			bool ok = 1;
			rep(j, 0, K) if (S >> j & 1) ok &= x <= a[i][j];
			exists[S] |= ok;
		}
	}
	rep(j, 0, n) {
		rep(i, 0, j) {
			int T = 0;
			rep(k, 0, K) if (x > max(a[i][k], a[j][k])) T |= 1 << k;
			if (exists[T]) return 1;
		}
	}
	return 0;
}

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

	cin >> n;
	rep(i, 0, n) rep(j, 0, K) cin >> a[i][j];
	int l = 0, r = inf;
	while (r - l > 1) {
		// [l, r)
		int m = (l + r) / 2;
		(f(m) ? l : r) = m;
	}
	cout << l << '\n';
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
//#include <atcoder/all>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;

int f(int b,int r,int c){
  return b*500*500+r*500+c;
}

int main(){
  int R,C; cin >> R >> C;
  vvi g(500*500*2);
  vvi co(500*500*2);
  rep(r,R) rep(c,C-1){
    int in; cin >> in;
    g[f(0,r,c)].pb(f(0,r,c+1));
    g[f(0,r,c+1)].pb(f(0,r,c));
    co[f(0,r,c)].pb(in);
    co[f(0,r,c+1)].pb(in);
  }
  rep(r,R-1) rep(c,C){
    int in; cin >> in;
    g[f(0,r,c)].pb(f(0,r+1,c));
    co[f(0,r,c)].pb(in);
  }
  rep(r,R-1) rep(c,C){
    g[f(1,r+1,c)].pb(f(1,r,c));
    co[f(1,r+1,c)].pb(1);
  }
  rep(r,R) rep(c,C){
    g[f(0,r,c)].pb(f(1,r,c));
    co[f(0,r,c)].pb(1);
    g[f(1,r,c)].pb(f(0,r,c));
    co[f(1,r,c)].pb(0);
  }
  vector<int> D(500*500*2, -1);
  vector<bool> used(500*500*2, false);
  priority_queue<pair<int,int>,
                 vector<pair<int,int>>,
                 greater<pair<int,int>>> q;
  q.push({(int)0,f(0,0,0)});
  D[0]=0;
  while(!q.empty()){
    int d = q.top().first; int to = q.top().second; q.pop();
    if(used[to]) continue;
    used[to] = true; //D[to] = d;
    rep(i,sz(g[to])){
      int nxt=g[to][i];
      int nd = d+co[to][i];
      if(D[nxt] != -1 && D[nxt] <= nd) continue;
      D[nxt]=nd;
      q.push({nd, nxt});
    }
  }

  int ans = D[f(0,R-1,C-1)];
  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using T2 = tuple<int,int,int, int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){

    int R, C; cin>>R>>C;
    vector<vec_int> A(R, vec_int(C-1));
    rep(i,R)rep(j,C-1)cin>>A.at(i).at(j);

    vector<vec_int> B(R-1, vec_int (C));
    rep(i,R-1)rep(j,C)cin>>B.at(i).at(j);

    vector<vec_int> visited(R, vec_int(C, 0));

    priority_queue<T2, vector<T2>, greater<T2>> pq;
    pq.emplace(0, 0, 0, 0);

    while(!pq.empty()){
        int cost, r, c, type; tie(cost, r, c, type)=pq.top(); pq.pop();
        if(visited.at(r).at(c)==1)continue;
        if(r==R-1&&c==C-1){
            cout<<cost<<endl;
            return 0;
        }
        visited.at(r).at(c) = 1;
        if(c<C-1){
            if(visited.at(r).at(c+1)==0){
                pq.emplace(cost+A.at(r).at(c), r, c+1, 1);
            }
        }
        if(c>0){
            if(visited.at(r).at(c-1)==0){
                pq.emplace(cost+A.at(r).at(c-1), r, c-1, 1);
            }
        }
        if(r<R-1){
            if(visited.at(r+1).at(c)==0){
                pq.emplace(cost+B.at(r).at(c), r+1, c, 0);
            }
        }
        if(type==1){
            for(int i=0;i<r;i++){
                if(visited.at(i).at(c)==0){
                    pq.emplace(cost+(r-i+1), i, c, 0);
                }
            }
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
namespace Flandre_Scarlet
{
    #define mod 1145141919
	#define F(i,l,r) for(int i=l;i<=r;++i)
	#define D(i,r,l) for(int i=r;i>=l;--i)
	#define Fs(i,l,r,c) for(int i=l;i<=r;c)
	#define Ds(i,r,l,c) for(int i=r;i>=l;c)
	#define MEM(x,a) memset(x,a,sizeof(x))
	#define FK(x) MEM(x,0)
	#define Tra(i,u) for(int i=G.st(u),v=G.to(i);~i;i=G.nx(i),v=G.to(i))
	#define p_b push_back
	#define sz(a) ((int)a.size())
	#define all(a) a.begin(),a.end()
	#define iter(a,p) (a.begin()+p)
	#define PUT(a,n) F(i,1,n) printf("%d ",a[i]); puts("");
	int I() {char c=getchar(); int x=0; int f=1; while(c<'0' or c>'9') f=(c=='-')?-1:1,c=getchar(); while(c>='0' and c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar(); return ((f==1)?x:-x);}
	template <typename T> void Rd(T& arg){arg=I();}
	template <typename T,typename...Types> void Rd(T& arg,Types&...args){arg=I(); Rd(args...);}
	void RA(int *p,int n) {F(i,1,n) *p=I(),++p;}
	char a[10];
    void Input()
    {
        scanf("%s",a);
    }
    int n=4; int C[15][15];
    int must,may;
    int f[15];
    int qpow(int a,int b,int m=mod) {int r=1; while(b) {if (b&1) r=r*a%m; a=a*a%m,b>>=1;} return r;}
    void Sakuya()
    {
        C[0][0]=1;
        F(i,1,10)
        {
            C[i][0]=1;
            F(j,1,i)
            {
                C[i][j]=C[i-1][j]+C[i-1][j-1];
            }
        }

        must=may=0;
        F(i,0,9)
        {
            if (a[i]=='o') ++must;
            if (a[i]=='?') ++may;
        }
        f[0]=qpow(may,n);
        F(i,1,must)
        {
            f[i]=qpow(may+i,n);
            F(j,0,i-1) f[i]-=C[i][j]*f[j];
        }
        printf("%d\n",f[must]);
    }
    void IsMyWife()
    {
        Input();
        Sakuya();
    }
}
#undef int //long long
int main()
{
    Flandre_Scarlet::IsMyWife();
    getchar();
    return 0;
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int N=1e5+10;
int a[11];

int main()
{
    string s;
    cin>>s;
    memset(a,0,sizeof a);
    for(int i=0; i<s.size(); i++)
    {
        int k=s[i]-'0';
        a[k]++;
    }
    if(s.size()>=3)
    {
        for(int i=100; i<=999; i++)
        {
            int x,y,z;
            x=i%10;
            y=i/10%10;
            z=i/100%10;
            if(x==y&&x==z)
            {
                if(a[x]>=3)
                {
                    if(i%8==0)
                    {
                        cout<<"Yes"<<endl;
                        return 0;
                    }
                }
                else
                    continue;
            }
            else if(x==y)
            {
                if(a[x]>=2&&a[z]>=1)
                {
                    if(i%8==0)
                    {
                        cout<<"Yes"<<endl;
                        return 0;
                    }
                }
                else
                    continue;
            }
            else if(y==z)
            {
                if(a[x]>=1&&a[z]>=2)
                {
                    if(i%8==0)
                    {
                        cout<<"Yes"<<endl;
                        return 0;
                    }
                }
                else
                    continue;
            }
            else
            {
                if(a[x]>=1&&a[z]>=1&&a[y]>=1)
                {
                    if(i%8==0)
                    {
                        cout<<"Yes"<<endl;
                        return 0;
                    }
                }
                else
                    continue;
            }
        }
        cout<<"No"<<endl;
        return 0;
    }
    else if(s.size()==2)
    {
        for(int i=10; i<=99; i++)
        {
            int x=i%10;
            int y=i/10;
            if(x==y)
            {
                if(a[x]>=2)
                {
                    if(i%8==0)
                    {
                        cout<<"Yes"<<endl;
                        return 0;
                    }
                }
                else
                    continue;
            }
            else
            {
                if(a[x]>=1&&a[y]>=1)
                {
                    if(i%8==0)
                    {
                        cout<<"Yes"<<endl;
                        return 0;
                    }
                }
                else
                    continue;
            }
        }
        cout<<"No"<<endl;
        return 0;
    }
    else
    {
        if(a[8])
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>

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

using namespace std;
using lint=long long;

template<class G>
class Fenwick_tree{
	vector<G> a;
public:
	Fenwick_tree(int n=0){ build(n); }
	Fenwick_tree(const vector<G>& a){ build(a); }
	void build(int n){
		a.assign(n,G{});
	}
	void build(const vector<G>& a){
		this->a=a;
		for(int i=1;i<=a.size();i++) if(i+(i&-i)<=a.size()) (this->a)[i+(i&-i)-1]+=(this->a)[i-1];
	}
	void add(int i,const G& val){
		for(i++;i<=a.size();i+=i&-i) a[i-1]+=val;
	}
	G sum(int l,int r)const{
		if(l==0){
			G res{};
			for(;r>0;r-=r&-r) res+=a[r-1];
			return res;
		}
		return sum(0,r)-sum(0,l);
	}
	int lower_bound(G val)const{
		if(!(G{}<val)) return 0;
		int x=0,k;
		for(k=1;k<=a.size();k<<=1);
		for(k>>=1;k>0;k>>=1) if(x+k<=a.size() && a[x+k-1]<val) val-=a[x+k-1], x+=k;
		return x;
	}
	int upper_bound(G val)const{
		if(val<G{}) return 0;
		int x=0,k;
		for(k=1;k<=a.size();k<<=1);
		for(k>>=1;k>0;k>>=1) if(x+k<=a.size() && !(val<a[x+k-1])) val-=a[x+k-1], x+=k;
		return x;
	}
};

template<class T>
long long inversion_number(const vector<T>& a){
	auto X=a;
	sort(X.begin(),X.end());
	X.erase(unique(X.begin(),X.end()),X.end());

	long long res=0;
	Fenwick_tree<int> F(X.size());
	rep(i,a.size()){
		int x=lower_bound(X.begin(),X.end(),a[i])-X.begin();
		res+=F.sum(x+1,X.size());
		F.add(x,1);
	}
	return res;
}

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n),b(n);
	rep(i,n) scanf("%d",&a[i]);
	rep(i,n) scanf("%d",&b[i]);

	map<int,vector<int>> L,R;
	rep(i,n){
		L[a[i]+i].emplace_back(i);
		R[b[i]+i].emplace_back(i);
	}

	if(L.size()!=R.size()){
		puts("-1");
		return 0;
	}

	vector<int> seq(n);
	for(auto [x,v1]:L){
		if(R.count(x)==0 || R[x].size()!=v1.size()){
			puts("-1");
			return 0;
		}
		auto& v2=R[x];
		rep(i,v1.size()) seq[v1[i]]=v2[i];
	}
	printf("%lld\n",inversion_number(seq));

	return 0;
}


#include "bits/stdc++.h"
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, m =0, n = 0, p = 0, q = 0, mod=998244353;
    string s;
    char moji;
    cin >> a;
    n=0;
    for(int i=1;n<a;i*=2)
    {
        m++;
        for(int j=0;j<i&&n+j<a;j++)
        {
            cout << m << ' ';
        }
        n+=i;
    }
    return 0;
}

#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
template<typename T>
void __p(T a) {
	cout << a;
}
template<typename T, typename F>
void __p(pair<T, F> a) {
	cout << "{";
	__p(a.first);
	cout << ",";
	__p(a.second);
	cout << "}";
}
template<typename T>
void __p(std::vector<T> a) {
	cout << "{";
	for (auto it = a.begin(); it < a.end(); it++)
		__p(*it), cout << ",}"[it + 1 == a.end()];
}
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) {
	__p(a1);
	__p(a...);
}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout << name << " : ";
	__p(arg1);
	cout << endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	int bracket = 0, i = 0;
	for (;; i++)
		if (names[i] == ',' && bracket == 0)
			break;
		else if (names[i] == '(')
			bracket++;
		else if (names[i] == ')')
			bracket--;
	const char *comma = names + i;
	cout.write(names, comma - names) << " : ";
	__p(arg1);
	cout << " | ";
	__f(comma + 1, args...);
}
#define trace(...) cout<<"Line:"<<__LINE__<<" ", __f(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif
typedef long long int ll;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<ll , ll> pp;
typedef pair<pair<ll, ll>, ll> ppp;
#define X first
#define Y second
#define getones(n) __builtin_popcountll(n)
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define frv(i,a,b) for (ll i = (a), _b = (b); i < _b; i++)
#define frrv(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define fr(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define frr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fordata(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) fr(i,sizeof(ar)/sizeof(ll)) ar[i]=val
#define fill2(ar,val) fr(i,sizeof(ar)/sizeof(ar[0])) fr(j,sizeof(ar[0])/sizeof(ll)) ar[i][j]=val
#define fill0(ar) memset(ar,0,sizeof(ar))
#define sz(x) (int)x.size()
#define len(x) (int)x.length()
#define all(ar) ar.begin(), ar.end()
#define INF 1000000000000000000
#define PI 3.14159265358979323846L
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
const ll N = 1e6 + 1;
const ll K = 1e9 + 7;
#define vv vector<ll>
const ll globalmod = 1e9 + 9;
int main() {
	ll t = 1;
	// cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		fr(i, n) {
			ll temp = (log2(i + 1) + 1);
			cout << temp << " ";
		}
	}
}


#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<bitset>
#include<cstdlib>
#include<set>
#include<unordered_map>
#define l(x) (x<<1)
#define r(x) ((x<<1)|1)
#define low(x) (x&(-x))
#define IL inline
#define reg register
#define LL long long
#define N 500010
#define MOD 998244353
#define MO 1000000007
#define INF 0x3f3f3f3f
using namespace std;

int T,n,m,i,j,k,x,y,z,sum,cnt;
int b[N],p[N],q[N];

struct Data{
	int x,y,id,p;
}a[N],Ans[N];

IL int Abs(int x){return (x<0)?-x:x;}
IL void Swap(int &a,int &b){a^=b^=a^=b;}
IL int Min(int a,int b){return (a<b)?a:b;}
IL int Max(int a,int b){return (a>b)?a:b;}

IL bool cmp(const Data a,const Data b){return (a.x==b.x)?a.y<b.y:a.x<b.x;}

IL LL Mi(LL x,LL y){
	LL p=x,t=1,Res=1;
	for (;t<=y;(t&y)?Res=(Res*p)%MOD:0,p=(p*p)%MOD,t<<=1);
	return Res;
}

IL int read(){
	int p=0,f=1;	char	c=getchar();
	while (c<48||c>57)	{if (c=='-')	f=-1;	c=getchar();}
	while (c>=48&&c<=57)	p=(p<<1)+(p<<3)+c-48,c=getchar();
	return p*f;
}

int main(){
	#ifdef __Marvolo
	freopen("zht.in","r",stdin);
	freopen("zht.out","w",stdout);
	#endif
	n=read();
	for (i=1;i<=n;i++)	a[i].x=read(),a[i].p=i;
	for (i=1;i<=n;i++)	b[i]=read();
	for (i=1;i<=n;i++)	a[i].id=read(),a[i].y=b[a[i].id];

	for (i=1;i<=n;i++){
		if (a[i].id==i)	continue;
		if (a[i].y>=a[i].x)	{
			puts("-1");	return 0;
		}
	}

	for (i=1;i<=n;i++)	p[a[i].id]=i;
	for (i=1;i<=n;i++)	q[i]=a[i].id;

	sort(a+1,a+1+n,cmp);
	for (i=1;i<=n;i++){
		x=p[a[i].p];	y=q[a[i].p];
		if (x==a[i].p)	continue;
		p[a[i].p]=q[a[i].p]=a[i].p;
		p[y]=x;	q[x]=y;

		cnt++;
		Ans[cnt].x=a[i].p;	Ans[cnt].y=x;

	}

	cout<<cnt<<endl;
	for (i=1;i<=cnt;i++)
		printf("%d %d\n",Ans[i].x,Ans[i].y);
	return 0;
}

#include<bits/stdc++.h>
#define pb push_back
#define endl ("\n")
#define mp make_pair
#define lb lower_bound
#define ff first
#define ss second
#define cn continue
#define br break
#define ins insert
#define int long long
#define bit(x) __builtin_popcount(x)
#define all(x) x.begin(),x.end()
#define up upper_bound
#define read(a,n) rep(i,0,n){cin>>a[i];}
#define print(a,n) rep(i,0,n) cout<<a[i]<<" ";
#define rep(i, a, n) for(int i = a; i < n; i++)
#define mod 1000000007
#define yy cout<<"YES"<<endl;
#define nn cout<<"NO"<<endl;
using namespace std;

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1 ;
    //cin >> t ;

    while (t--)
    {
        int n;
        cin >> n;
        int p = log2(n);
        int q = pow(2, p);
        int v = n / q, s = n % q;
        int a = p + v + s;

        while (p > 0) {
            a = min(a, p + v + s);
            q /= 2; p--;
            if (q == 0)
                break;
            v = n / q; s = n % q;
        }

        cout << a << endl;

    }
    return 0;
}


#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define SIZE 400005

struct Edge{

	int a,b;
};

ll N = 1;
ll uniformity[6*SIZE],partial[6*SIZE];
int global_index = 0;
int LEFT[SIZE],RIGHT[SIZE];
vector<int> G[SIZE];
Edge edge[SIZE];

void init(ll first_N){
	while(N < first_N)N *= 2;
}

void add(ll left,ll right,ll value,ll node_id,ll node_left,ll node_right){

	if(right <= node_left || left >= node_right)return;
	else if(left <= node_left && right >= node_right){
		uniformity[node_id] += value;
	}else{
		partial[node_id] += (min(right,node_right)-max(left,node_left))*value;
		add(left,right,value,2*node_id+1,node_left,(node_left+node_right)/2);
		add(left,right,value,2*node_id+2,(node_left+node_right)/2,node_right);
	}
}

ll getSum(ll left,ll right,ll node_id,ll node_left,ll node_right){
	if(right <= node_left || left >= node_right)return 0;
	else if(left <= node_left && right >= node_right){
		return (node_right-node_left)*uniformity[node_id]+partial[node_id];

	}else{
		ll sum = (min(right,node_right)-max(left,node_left))*uniformity[node_id];

		sum += getSum(left,right,2*node_id+1,node_left,(node_left+node_right)/2);
		sum += getSum(left,right,2*node_id+2,(node_left+node_right)/2,node_right);
		return sum;
	}
}

//オイラーツアーで、ノードのカバー範囲を計算する
void euler_tour(int node_id,int pre_node){
	LEFT[node_id] = global_index++;

	for(int i = 0; i < G[node_id].size(); i++){
		if(G[node_id][i] == pre_node)continue;
		euler_tour(G[node_id][i],node_id);
	}
	RIGHT[node_id] = global_index++;
}

int main(){

	ll first_N;
	scanf("%lld",&first_N);

	int from,to;
	for(int i = 0; i < first_N-1; i++){

		scanf("%d %d",&from,&to);
		from--;
		to--;

		edge[i].a = from;
		edge[i].b = to;

		G[from].push_back(to);
		G[to].push_back(from);
	}

	euler_tour(0,-1);

	init(RIGHT[0]);

	for(ll i = 0; i <= 2*N-2; i++){
		uniformity[i] = 0;
		partial[i] = 0;
	}

	int command,tmp;
	ll x;

	int a,b;

	ll Q;
	scanf("%lld",&Q);

	for(ll i = 0; i < Q; i++){

		//printf("クエリ;%lld\n",i);

		scanf("%d %d %lld",&command,&tmp,&x);

		tmp--;

		a = edge[tmp].a;
		b = edge[tmp].b;

		//printf("a:%d b:%d\n",a,b);

		if(command == 1){ //a[tmp]からたどる

			if(LEFT[a] < LEFT[b]){ //Aの方が外側

				add(LEFT[0],RIGHT[0]+1,x,0,0,N);
				add(LEFT[b],RIGHT[b]+1,-x,0,0,N);

			}else{ //Aの方が内側

				add(LEFT[a],RIGHT[a]+1,x,0,0,N);
			}
			//printf("%d-%dから引き\n",LEFT[b],RIGHT[b]);

		}else{ //command == 2;

			if(LEFT[b] < LEFT[a]){ //bの方が外側

				add(LEFT[0],RIGHT[0]+1,x,0,0,N);
				add(LEFT[a],RIGHT[a]+1,-x,0,0,N);

			}else{ //bの方が内側

				add(LEFT[b],RIGHT[b]+1,x,0,0,N);
			}
		}
	}

	for(int i = 0; i < first_N; i++){

		printf("%lld\n",getSum(LEFT[i],LEFT[i]+1,0,0,N));
	}

	return 0;
}

#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define eps (double)(1e-9)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

using Graph = vector<vector<int>>;

vector<ll> d, sum;
void dfs1(const Graph &G, int v, int p, int D) {
	d[v] = D;
    for (auto nv : G[v]) {
		if (nv == p)continue;
		dfs1(G, nv, v, D+1);
	}
}

void dfs2(const Graph &G, int v, int p){
    for (auto nv : G[v]) {
		if (nv == p)continue;
        sum[nv] += sum[v];
		dfs2(G, nv, v);
	}
}

int main() {
    int n, q;
    cin >> n;
    Graph G(n);
    vector<ll> a(n-1), b(n-1);
    rep(i, n-1){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    d.resize(n);
    sum.resize(n);
    dfs1(G, 0, -1, 0);
    cin >> q;
    rep(i, q){
        ll t, e, x;
        cin >> t >> e >> x; e--;
        if(t == 1){
            if(d[a[e]] < d[b[e]]){
                sum[0] += x;
                sum[b[e]] -= x;
            }else{
                sum[a[e]] += x;
            }
        }else{
            if(d[b[e]] < d[a[e]]){
                sum[0] += x;
                sum[a[e]] -= x;
            }else{
                sum[b[e]] += x;
            }
        }
    }
    dfs2(G, 0, -1);
    rep(i, n)cout << sum[i] << endl;
}


/* dont stick to an approach */
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>
#include <numeric>
#include <cstdlib>

using namespace std;

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

#define PB push_back

#define For(i, n) for (ll i = 0; i < n; i++)

#define trav(a,x) for (auto& a : x)

#define PYES cout<<"YES\n"
#define PNO cout<<"NO\n"
#define PYes cout<<"Yes\n"
#define PNo cout<<"No\n"
#define endl '\n'

#define sq(x)           (x*x)

#define vll             vector<ll>
#define rev(v)          reverse(v.begin(),v.end())
#define srt(v)          sort(v.begin(),v.end())
#define grtsrt(v)       sort(v.begin(),v.end(),greater<int>())
#define mnv(v)          *min_element(v.begin(),v.end())
#define mxv(v)          *max_element(v.begin(),v.end())
#define all(v)          v.begin(),v.end()

#define Fas ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

//--------------------------------------------functions-------------------------------------------------//

ll power(ll a,ll b){ll result=1;while(b>0){if(b%2 == 1){result *= a;} a *= a;b /= 2;}return result;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
ll countSetBits(ll x){ll Count=0;while(x>0){if(x&1) Count++;x=x>>1;}return Count;}
bool isPerfectSquare(ll n){ll sr = sqrt(n);if (sr * sr == n)return true;else return false;}
ll mod(ll x,ll M){return ((x%M + M)%M);}
ll add(ll a, ll b,ll M){return mod(mod(a,M)+mod(b,M),M);}
ll mul(ll a, ll b,ll M){return mod(mod(a,M)*mod(b,M),M);}
ll powerM(ll a,ll b,ll M){
    ll res=1ll;
    while(b){
        if(b%2ll==1ll){
            res=mul(a,res,M);
        }
        a=mul(a,a,M);b/=2ll;
    }
    return res;
}
//------------------------------------sieve of erantothenes-----------------------------------------------//
//ll MAXN=1e7+100;
//vector<ll> fact(MAXN);
//void sieve_of_erantothenes()
//{
//    fact[1] = 1;
//    for (ll i = 2; i <= MAXN; i++)
//        fact[i] = i;
//    for (ll i = 4; i <= MAXN; i += 2)
//        fact[i] = 2;
//    for (ll i = 3; i * i <= MAXN; i++){
//        if (fact[i] == i){
//            for (ll j = i * i; j <= MAXN; j += i)
//                if (fact[j] == j)
//                    fact[j] = i;
//        }
//    }
//}
//----------------------------------------nCr mod------------------------------------------------------//
ll modInverse(ll n,ll M){
    return powerM(n,M-2,M);
}
ll nCrM(ll n,ll r,ll M){
    if(n<r) return 0;
    if(r==0) return 1;
    vector<ll> fact(n+1);
    fact[0]=1;
    for(ll i=1;i<=n;i++){
        fact[i]=mul(fact[i-1],i,M);
    }
    return mul(mul(fact[n],modInverse(fact[r],M),M),modInverse(fact[n-r],M),M);
}
//-----------------------------------------------solve-----------------------------------------------------//
void solve(){
    set<ll> sa,sb;
    ll n,m;cin>>n>>m;
    for(ll i=0;i<n;i++){
        ll a;cin>>a;
        sa.insert(a);
    }
    for(ll i=0;i<m;i++){
        ll a;cin>>a;
        sb.insert(a);
    }
    set<ll> ans;
    trav(w, sa){
        if(sb.find(w)==sb.end()){
            ans.insert(w);
        }
    }
    trav(w, sb){
        if(sa.find(w)==sa.end()){
            ans.insert(w);
        }
    }
    trav(w,ans){
        cout<<w<<" ";
    }
    cout<<endl;
}

int main(){
    Fas;

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

//    ll t=0;
//    cin>>t;
//    while(t--)
        solve();

    return 0;
}

// Problem: E - Divide Both
// Contest: AtCoder - AtCoder Beginner Contest 206（Sponsored by Panasonic）
// URL: https://atcoder.jp/contests/abc206/tasks/abc206_e
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;
#define ll long long
#define pi pair<int,int>
#define pll pair<ll,ll>
#define ld  long double
#define vi vector<int>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vpll vector<pll>
#define vpi vector<pi>
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define all(c)  (c).begin(),(c).end()
#define sz(c) int((c).size())
#define MP make_pair

#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define FORI(i, a, b) for(int i = (a); i >= (b); i--)

const int INF = 1e9 + 7;
const long long MOD = 1e9 + 7;

// credits : tourist
string to_string(string s) {return '"' + s + '"';}string to_string(const char* s) {return to_string((string) s);}string to_string(bool b) {return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void debug_out() { cerr << "\n"; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {cerr << " " << to_string(H) << "\n";debug_out(T...);}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
ll gcd(ll x , ll y){
    if(y == 0)  return x;
    if(x == 0)  return y;
    if(x < y) swap(x , y);
    return gcd(x % y , y);
}

const int N = 1e6 + 8;

ll dp[N]; /* number of pairs with gcd = g*/

ll brute(int L , int R, int g){
   ll p = 0;
   for(int i = L; i <= R; i++){
      for(int j = i + 1; j <= R; j++){
         p += gcd(i , j) == g;
      }
   }
   return p;
}
void solve(){
   int L , R;
   cin >> L >> R;

   for(int g = R;  g >= 1; g--){
      int cnt = 0;
      for(int m = g; m <= R; m += g){
         if(m != g) {
            dp[g] -= dp[m];
         }
         if(m >= L) cnt++;
      }
      ll val = 1LL * cnt * (cnt - 1) / 2;
      dp[g] += val;
   }

   ll ans = 0;
   for(int g = 2; g <= R; g++){
      ll val = dp[g];
      ll remove = 0;
      if(g >= L) remove = (R / g) - 1;

      ans += 2LL * (val - remove);
   }
   cout << ans << endl;
}

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

    int tt = 1;
    // cin >> tt;

    #ifdef SIEVE
    construct();
    #endif

    #ifdef NCR
    compute_combinations_table(MOD);
    #endif

    #ifdef FACTORIALS
    compute_factorials(MOD);
    #endif

    for(int tc = 1; tc <= tt; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
}


#include <bits/stdc++.h>
#include <string>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
// cout << fixed << setprecision(8) << result << endl;

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i,n){
        ll a, b;
        cin >> a >> b;
        ans += (b - a + 1)*(b+a)/2;
    }
    cout << ans << endl;
}

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <string>
#include <iomanip>
#include <iostream>
#include <map>
#include <unordered_map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;

#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define fi first
#define sc second

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsort(v) sort(v.rbegin(),v.rend())

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)

// const int MOD = 998244353;
const int MOD = 1e9+7;
const int MAX = 2147483647;     // 1<<31-1
const int MIN = -2147483648;    // 1<<31
const ll INF = 1e18;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

#define ts to_string
string ts(char c) { return string(1, c); }
string ts(bool b) { return b ? "0" : "1"; }
string ts(const char* s) { return (string)s; }
string ts(string s) { return s; }
template<class A, class B> string ts(pair<A, B> p) {
    return "("+ts(p.fi)+", "+ts(p.sc)+")";
}
template<class T> string ts(T v) { // containers with begin(), end()
    string res = "";
    for (const auto& x: v) {
        res += ts(x) + " ";
    }
    return res;
}

void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
    cerr << ts(h); if (sizeof...(t)) cerr << ", ";
    DBG(t...);
}

#ifdef LOCAL
#include "../../snippits/debugger.cpp"
#define dbg(...) cerr << "L(" << __LINE__ << "): [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#define print_segtree(...) 0
#endif

const vector<vector<int>> dirs = { {0,1},{1,0},{-1,0},{0,-1} };

// distance from origin
struct cmp {
    bool operator()(const pii& lhs, const pii& rhs) const {
        return (abs(lhs.fi)+abs(lhs.sc))<((abs(rhs.fi)+abs(rhs.sc)));
    }
};

// getline(cin, str) for getting a line of string
// call cin.ignore() BETWEEEN cin >> x and getline()!!!
// don't mod before you sort!!!
// clear global state
// remember to %= the result!

// INITIALIZE CORRECTLY, ARE YOU DOING (i,0,*N+1*) WHEN NEEDED?
// PRIORITY QUEUES ARE SORTED BIG TO SMALL
// NEVER assign element to a reference and then pop!!!!!

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

    int t = 1;
    cin >> t;

    ll res = 0;
    while (t--) {
        int a, b;
        cin >> a >> b;
        res += 1LL*(a+b)*(b-a+1)/2;
    }

    cout << res << '\n';

    return 0;
}


#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define fs first
#define sc second
#define endl '\n'

int A, B, C;
double mem[100][100][100];
double dp(int a, int b, int c) {
	if (a >= 100 || b >= 100 || c >= 100)
		return (a - A) + (b - B) + (c - C);

	if (mem[a][b][c] >= 0)
		return mem[a][b][c];

	double ad = (double)a, bd = (double)b, cd = (double)c;

	double sm = 0;
	if(a > 0)
		sm += (ad / (ad + bd + cd)) * dp(a + 1, b, c);

	if(b > 0)
		sm += (bd / (ad + bd + cd)) * dp(a, b + 1, c);

	if(c > 0)
		sm += (cd / (ad + bd + cd)) * dp(a, b, c + 1);
	return mem[a][b][c] = sm;
}

set<int> generate_sums(vector<int> A, int cap) {
	int n = A.size();
	set<int> ans;
	for (int i = 0; i < (1 << n); i++) {
		int sm = 0;
		for (int j = 0; j < n; j++) {
			if (i & (1 << j) && sm < cap) {
				sm += A[j];
			}
		}
		ans.insert(sm);
	}
	return ans;
}

void solve() {
	int n, t;
	cin >> n >> t;
	vector<int> A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}

	vector<int> F(n / 2), S(n % 2 ? n /2 + 1: n / 2);
	for (int i = 0; i < n / 2; i++) {
		F[i] = A[i];
	}
	for (int i = n / 2; i < n; i++)
		S[i - n / 2] = A[i];
	set<int> fsums = generate_sums(F, t), ssums = generate_sums(S, t);
	int ans = 0;
	for (int val1 : fsums) {
		auto fnd = ssums.upper_bound(t - val1);
		if (fnd == ssums.begin())
			continue;
		fnd--;
		ans = max(ans, *fnd + val1);
	}
	cout << ans << endl;

}

signed main() {
	cin.sync_with_stdio(false); cin.tie(nullptr);
	/*ll t;
	cin >> t;
	while (t--)*/
		solve();
	return 0;
}

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

long long a[100];

long long n,tog;

vector<long long> v1,v2;

long long res;

void dfs1(long long d,long long sum)
{
    if(d==n/2+1)
    {
        v1.push_back(sum);
        res=max(res,sum);
        return;
    }
    if(sum+a[d]<=tog)dfs1(d+1,sum+a[d]);
    dfs1(d+1,sum);
}

void dfs2(long long d,long long sum)
{
    if(d==n+1)
    {
        v2.push_back(sum);
        res=max(res,sum);
        return;
    }
    if(sum+a[d]<=tog)dfs2(d+1,sum+a[d]);
    dfs2(d+1,sum);
}

int main()
{

    cin>>n>>tog;
    for(long long i=1;i<=n;i++) cin>>a[i];
    dfs1(1,0);
    dfs2(n/2+1,0);

    sort(v1.begin(),v1.end());

    sort(v2.begin(),v2.end());

    for(long long i=0;i!=v1.size();i++)
    {
        if(v2.size()==0) break;
        long long l=0,r=v2.size()-1;
        while(l<r)
        {
            long long mid=l+r+1>>1;
            if(v2[mid]<=tog-v1[i]) l=mid;
            else r=mid-1;
        }
        if(v2[l]+v1[i]<=tog)
        {
            res=max(res,v2[l]+v1[i]);
        }
    }
    cout<<res;
}


/*
**    author : Dhiraj Govindvira
**      date : 19 June 2021 ~ Saturday
**      time : 05:30:08 PM
*/

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

#ifdef DHIRAJ
    #include "D:/dhiraj/Programming/debug.h"
#else
    #define dbg(...) 1
    #define cerr if(0) cerr
#endif

using ll = long long int;
#define endl '\n'

template <typename T, typename U>
inline istream & operator >> (istream &in, pair<T, U> &p) {
    in >> p.first >> p.second;
    return in;
}
template <typename T>
inline istream & operator >> (istream &in, vector<T> &v) {
    for(T &x : v) in >> x;
    return in;
}

void solve(ll &tc)
{
    ll n;
    cin >> n;

    n = 1.08 * n;
    if(n == 206) {
        cout << "so-so" << endl;
    }
    else if(n < 206) {
        cout << "Yay!" << endl;
    }
    else {
        cout << ":(" << endl;
    }
}

int main()
{
    #ifdef DHIRAJ
        freopen("D:/dhiraj/Programming/i1.txt", "r", stdin);
        freopen("D:/dhiraj/Programming/o1.txt", "w", stdout);
        freopen("D:/dhiraj/Programming/e1.txt", "w", stderr);
    #endif

    ios::sync_with_stdio(0);
    cin.tie(0);

    ll rep = 3;
    while(rep--) {
        ll tc = 1;
        for(ll i = 1; i <= tc; i++) {
            // cout << "Case #" << i << ": ";
            cerr << "Case #" << i << "\n";
            solve(i);
        }
        if(dbg()) break;
    }
    return 0;
}

#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>

#define all(v) begin(v), end(v)
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)

using namespace std;

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

template <class S> using pqg = priority_queue<S, vector<S>, greater<S>>;
template <class S> using pq  = priority_queue<S>;

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pi = pair<int,int>;
using pl = pair<ll, ll>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vvpi = vector<vpi>;
using vvpl = vector<vpl>;

const ll MOD = 1000000007;
const ll MAX = 500000;
const ll INF = 1000000000;
const ll INFLL = 1000000000000000000;

struct mint {
  ll x;

  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
  mint operator+=(const mint& a) {
    x += a.x;
    if (x >= MOD) x -= MOD;
    return *this;
  }
  mint operator-=(const mint& a) {
    if (x < a.x) x += MOD;
    x -= a.x;
    return *this;
  }
  mint operator*=(const mint& a) {
    x = x * a.x % MOD;
    return *this;
  }
  mint operator/=(const mint& a) { return *this *= a.inv(); }
  mint operator+(const mint& a) const { return mint(*this) += a; }
  mint operator-(const mint& a) const { return mint(*this) -= a; }
  mint operator*(const mint& a) const { return mint(*this) *= a; }
  mint operator/(const mint& a) const { return mint(*this) /= a; }
  mint inv(void) const { return pow(MOD - 2); }
  mint pow(ll a) const {
    if (!a) return 1;
    mint t = pow(a >> 1);
    t *= t;
    if (a & 1) t *= (*this);
    return t;
  }
  friend ostream& operator<<(ostream& os, const mint& a) {
    os << a.x;
    return os;
  }
};

struct UnionFind {
  vector<int> parent, siz;

  UnionFind(int n) : parent(n), siz(n, 1) {
    for (int i = 0; i < n; ++i) parent[i] = i;
  }

  int root(int x) {
    if (parent[x] == x) return x;
    return parent[x] = root(parent[x]);
  }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);

    if (x == y) return false;

    if (siz[x] > siz[y]) swap(x, y);

    siz[y] += siz[x];
    parent[x] = y;

    return true;
  }

  int size(int x) {
    return siz[root(x)];
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }
};

int main(void) {

  int n;
  cin >> n;

  int x = n * 1.08;
  if (x < 206) cout << "Yay!" << endl;
  else if (x == 206) cout << "so-so" << endl;
  else cout << ":(" << endl;

  return (0);
}


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

using P = pair<long long, long long>;

long long b, c;

long long solve();

int main() {
  cin >> b >> c;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  vector<P> v;
  v.emplace_back(b - c / 2, b);
  v.emplace_back(-b - (c - 1) / 2, -b);
  v.emplace_back(-b, -(b - (c - 1) / 2));
  if (c >= 2) v.emplace_back(b, b + (c - 2) / 2);
  {
    vector<P> tmp;
    sort(v.begin(), v.end());
    for (auto &[l, r] : v)
      if (l >= r) swap(l, r);
    int len = v.size();
    long long l = v[0].first, r = v[0].second;
    for (int i = 1; i < len; ++i) {
      if (v[i].first <= r)
        r = max(v[i].second, r);
      else {
        tmp.emplace_back(l, r);
        l = v[i].first, r = v[i].second;
      }
    }
    tmp.emplace_back(l, r);
    swap(v, tmp);
  }
  long long res = 0;
  for (auto [l, r] : v) res += r - l + 1;
  return res;
}

#include <bits/stdc++.h>
#define ll long long
#define SZ(vvv) ((int)vvv.size())
#define all(vvv) (vvv.begin(), vvv.end())
#define fastIO cout << fixed << setprecision(7), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;
const int N = 1e5 + 9, M = 1e3 + 3, MOD = 1e9 + 7, OO = 1e9;
const ll INF = 1e15;

void runtestcase() {
    int n;
    cin >> n;
    vector<int> vec(n);
    ll total = 0;
    for (int i = 0; i < n; ++i) {
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end());
    for (int i = 0; i < n; ++i) {
        total += n - (upper_bound(vec.begin(), vec.end(), vec[i]) - vec.begin());
    }
    cout << total;
}

int main() {
//    freopen("/home/omar/input.in", "rt", stdin);
//    freopen("/home/omar/output.in", "wt", stdout);
#ifdef LOCAL
#endif
    fastIO;
    int t = 1, tt = 1;
//    cin >> t;
    while(t--)
        runtestcase();
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,b,a) for(int i=b;i>=a;i--)
#define efo(i,u,v) for(int i=BB[u],v=B[BB[u]][1];i;v=B[i=B[i][0]][1])
#define mset(a,x) memset(a,x,sizeof(a))
template<typename T> bool chkmin(T &a,const T &b) {return b<a?a=b,1:0;}
template<typename T> bool chkmax(T &a,const T &b) {return b>a?a=b,1:0;}
using namespace std;
typedef long long ll;
typedef double db;
char ch;
int read(){int n=0,p=1;for(ch=getchar();ch<'0' || '9'<ch;ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int N=105;
int n,a[N][N],fa[N],sz[N];
int getfa(int x)
{
	if(!fa[x]) return x;
	fa[x]=getfa(fa[x]);
	return fa[x];
}
bool vis[N],insta[N];
int sta[N],cnt[N];
void mrg(int x,int y)
{
	int fx=getfa(x),fy=getfa(y);
	if(fx==fy) return;
	fa[fy]=fx;
	sz[fx]+=sz[fy],sz[fy]=0;
}
void dfs(int x)
{
	if(vis[x])
	{
		if(insta[x])
		for(int i=sta[0];sta[i]!=x;i--)
			mrg(sta[i],x);
		return;
	}
	sta[++sta[0]]=x,insta[x]=1;
	vis[x]=1;
	fo(y,1,n)
		if(a[x][y]) dfs(y);
	sta[sta[0]--]=0,insta[x]=0;
}
void dfs1(int x)
{
	vis[x]=1,++cnt[x];
	fo(y,1,n) if(a[x][y] && !vis[y])
	{
		dfs1(y);
	}
}
int main()
{
	//freopen("!.in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d\n",&n);
	fo(i,1,n)
	{
		fo(j,1,n) a[i][j]=getchar()-'0';
		scanf("\n");
		sz[i]=1;
	}
	fo(i,1,n)
	{
		mset(vis,0);
		dfs(i);
	}
	fo(i,1,n)
	{
		mset(vis,0);
		dfs1(i);
	}
	db ans=0;
	fo(i,1,n)
		if(getfa(i)==i) ans+=sz[i]*1.0/cnt[i];
	printf("%.12lf\n",ans);
	return 0;
}

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

using namespace std;
int ed[101][101];
int visit[101];
void cle()
{
    for(int i = 0; i < 101; i++)visit[i]=0;
}
double cc = 0;
void dfs(int v)
{
    visit[v] = 1;
    cc++;
    for(int i = 1; i < 101; i++)
    {
        if(ed[i][v] == 1 && visit[i] == 0)
        {
            dfs(i);
        }
    }
}
int main()
{
    int n;
    cin >>n;
    for(int i = 1; i <= n; i++)
    {
        string y; cin >> y;
        for(int j = 1; j <= n; j++)
        {
            ed[i][j]= y[j - 1] - '0';
        }
    }
    double u = 0;
    for(int i = 0; i < n; i++)
    {
        cle();
        cc = 0;
        dfs(i+1);
        u+= 1. /cc;
    }
    printf("%.14lf", u);

}


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

// using mint = long double;
// using mint = modint998244353;
// using mint = modint1000000007;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> T;
typedef pair<ll, vector<ll> > Pd;

const ll INF = 1e18;
const ll fact_table = 32008;

priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
// priority_queue <ll, vector<ll>, greater<ll> > pqls;
priority_queue <P, vector<P>, greater<P> > pqps;
//small priority queue
//top pop

ll dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
ll dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
//↓,→,↑,←

/*
#define endl "\n"
#ifdef ENJAPMA
#undef endl
#endif
*/

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pc(x) cout << x << ",";
#define rep(i, n) for (ll i = 0; i < (n); i ++)
#define rep2(i, a, b) for (ll i = a; i <= (b); i++)
#define rep3(i, a, b) for (ll i = a; i >= (b); i--)
#define all(c) begin(c), end(c)

typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

// vec v(n) -> 長さnのベクトルを宣言
// mat dp(h, vec(w)) -> h * w の行列を宣言

const ll mod = 998244353ll;
// const ll mod = 1000000007ll;

ll mypow(ll a, ll b, ll m = mod) {ll x = 1; while (b) {while (!(b & 1)) {(a *= a) %= m; b >>= 1;}(x *= a) %= m; b--;} return x;}
vec rv(ll read) { vec res(read); for (int i = 0; i < read; i++) { cin >> res[i]; } return res;}
void YES(bool cond) { if (cond) { p("YES");} else { p("NO");} return;}
void Yes(bool cond) { if (cond) { p("Yes");} else { p("No");} return;}
void line() { p("--------------------"); return;}

/*
ll fact[fact_table + 5], rfact[fact_table + 5];

void c3_init() {
    fact[0] = rfact[0] = 1;
    for (ll i = 1; i <= fact_table; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table], mod - 2, mod);
    for (ll i = fact_table; i >= 1; i--) {
        rfact[i - 1] = rfact[i] * i;
        rfact[i - 1] %= mod;
    }
    return;
}
ll c3(ll n, ll r) {
    return (((fact[n] * rfact[r]) % mod ) * rfact[n - r]) % mod;
}
*/

bool icpc = false;
bool multicase = false;

ll n, m;
ll table[200005];

bool solve() {
    ll k;
    cin >> k;
    for (ll i = 1; i <= 200000; i++) {
        ll cnt = 0;
        for (ll j = 1; j * j <= i; j++) {
            if (i % j == 0) {
                cnt ++;
                if (j * j < i) cnt ++;
            }
        }
        table[i] = table[i - 1] + cnt;
    }
    ll ans = 0;
    for (int i = 1; i <= k; i++) {
        ll r = k / i;
        ans += table[r];
    }
    p(ans);
    return true;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    if (icpc) {
        while (solve());
        return 0;
    }
    ll q, testcase = 1;
    if (multicase) {
        cin >> q;
    } else {
        q = 1;
    }
    while (q--) {
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }

// solve();
    return 0;
}

#include <bits/stdc++.h>
#define li long int
#define lli long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si size()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define lb lower_bound
#define ub upper_bound
#define BS binary_search
#define pll pair < lli, lli >
#define pii pair < int, int>
#define vi vector < int >
#define vvi vector < vector < int > >
#define vlli vector < lli >
#define all(x) x.begin(), x.end()
#define vvlli vector < vector < lli > >
#define vp vector < pll >
#define vvp vector< vector< pll> >
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<lli  , null_type, less<lli>, rb_tree_tag,tree_order_statistics_node_update>
#define fill(a,n) for(lli iiii=0;iiii<n;iiii++)	cin>>a[iiii];
#define mpii map<int, int>
# define precision(x) cout << fixed << setprecision(x)
#define REP(i, a, b) for (int i=a; i<=b; i++)
using namespace __gnu_pbds;
lli mod=1e9+7;
using namespace std;

#define MAXN 200001
lli spf[MAXN];

void sieve()
{
	spf[1] = 1;
	for (lli i=2; i<MAXN; i++) 		spf[i] = i;

	for (int i=4; i<MAXN; i+=2)		spf[i] = 2;

	for (int i=3; i*i<MAXN; i++)
	{
		if (spf[i] == i)
		{
			for (int j=i*i; j<MAXN; j+=i)
				if (spf[j]==j)
					spf[j] = i;
		}
	}
}

vector<lli> getFactorization(lli x)
{
	vlli ret;
	while (x != 1)
	{
		ret.push_back(spf[x]);
		x = x / spf[x];
	}
	return ret;
}

int main()
{
	//vlli p = getFactorization(x);
    fastio;
	sieve();
	lli k,i;
	cin>>k;
	vlli dp(k+1,-1);	dp[1]=1;
	for(i=2;i<=k;i++)
	{
		//x+y+x=k;	k+2 C 2 = ((k+2)*(k+1))/2;
		vlli p = getFactorization(i);
		set<lli> VAL;
		for(auto ii:p)	VAL.insert(ii);
		vlli val; lli sz=VAL.si;
		for(auto ii:VAL)	val.pb(ii);
		vlli f(sz,0);
		for(auto ii:p)
		{
			lli ind=lb(all(val),ii)	- val.begin();
			f[ind]++;
		}
		dp[i]=1;
		for(auto ii:f)	dp[i]=dp[i]*(((ii+2)*(ii+1))/2);
	}
	//for(i=1;i<=10;i++)	cout<<"dp["<<i<<"]="<<dp[i]<<"\n";
	lli ans=0;
	for(i=1;i<=k;i++)	ans+=dp[i];
	//cout<<"ans= ";
	cout<<ans<<"\n";
}