/*** author: yuji9511 ***/
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
using vll = vector<ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
struct UnionFind {
private:
    ll N;
    vector<ll> parent;
    vector<ll> num;
    vector<ll> diff_weight;

public:
    UnionFind(ll n){
        N = n;
        parent.resize(N);
        iota(parent.begin(), parent.end(), 0);
        num.assign(N, 1);
        diff_weight.assign(N, 0);
    }

    ll root(ll x){
        if(x == parent[x]){
            return x;
        }else{
            ll r = root(parent[x]);
            diff_weight[x] += diff_weight[parent[x]];
            return parent[x] = r;
        }
    }

    void unite(ll a, ll b, ll w = 0){
        if(a > b) swap(a,b);
        w += weight(a); w -= weight(b);
        a = root(a); b = root(b);
        if(a == b) return;
        if(sz(a) < sz(b)){
            parent[a] = b;
        }else{
            parent[b] = a;
        }
        ll sum = num[a] + num[b];
        num[a] = sum;
        num[b] = sum;
        diff_weight[b] = w;
    }

    bool same(ll a, ll b){ return root(a) == root(b);}

    ll sz(ll x){ return num[root(x)];}

    ll weight(ll x){
        root(x);
        return diff_weight[x];
    }

    ll diff(ll a, ll b){
        return weight(b) - weight(a);
    }
};

void solve(){
    ll N,Q;
    cin >> N >> Q;
    vll C(N);
    rep(i,0,N) cin >> C[i];

    map<int,int> mp[200010];
    UnionFind uf(N+1);
    rep(i,0,N){
        mp[i][C[i]] = 1;
    }

    while(Q--){
        ll t,a,b;
        cin >> t >> a >> b;
        if(t == 1){
            a--; b--;
            if(a > b) swap(a,b);
            if(uf.same(a,b)) continue;
            ll ra = uf.root(a), rb = uf.root(b);
            if(uf.sz(a) < uf.sz(b)){
                uf.unite(a,b);
                if(uf.root(a) != rb) exit(1);
                for(auto &e: mp[ra]){
                    mp[rb][e.first] += e.second;
                }
                mp[ra].clear();
            }else{
                uf.unite(a,b);
                if(uf.root(a) != ra) exit(1);
                for(auto &e: mp[rb]){
                    mp[ra][e.first] += e.second;
                }
                mp[rb].clear();
            }

        }else{
            a--;
            ll res = mp[uf.root(a)][b];
            print(res);
        }

    }

}

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

#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(register int i=(a);i>=(b);--i)
#define int long long
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}
#define fi first
#define se second
#define mkp make_pair
#define pb push_back
typedef pair<int,int>pii;
#define maxn 1000005
#define N 1003
int n,m,a[N][N];
char str[N][N];
queue<pii>q;
bool vis[N][2];
int ff[N<<1];
inline int getf(int x){
	while(x!=ff[x])x=ff[x]=ff[ff[x]];
	return x;
}
inline void merge(int x,int y){
	ff[getf(x)]=getf(y);
}
set<int>s;
signed main()
{
	n=read(),m=read();
	For(i,1,n)cin>>(str[i]+1);
	For(i,1,n)For(j,1,m)a[i][j]=(str[i][j]=='#');
	a[1][1]=a[1][m]=a[n][1]=a[n][m]=1;
	For(i,1,n+m)ff[i]=i;
	For(i,1,n)For(j,1,m)if(a[i][j])merge(i,j+n);
	int res=2e9;
	For(i,1,n)s.insert(getf(i));//cout<<getf(i)<<" ";puts("");
	res=min(res,(int)s.size());//cout<<s.size()<<endl;
	s.clear();
	For(i,1,m)s.insert(getf(i+n));//,cout<<getf(i+n)<<' ';puts("");
	res=min(res,(int)s.size());//cout<<s.size()<<endl;
	cout<<res-1;
	return 0;
}
/*
10 10
,#,,,,,,,, ok
#,,,#,,,,, ok
,,..,...,,
,,..,...,,
,,..,...,,
,,,,#,,,,, ok
,#,,,,,,#,
,,..,...,,
,,,,,,,,,,

max(hang lie)

1
..........

*/


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

int N;
const int M = 10000;
const int m = 100;
int A[M], B[m];

void init() {
    int min_v = 1000000;
    for (int i = 0; i < m; i++) {
        min_v = 1000000;
        for (int j = i * m; j < (i + 1) * m; j++) {
            min_v = min(min_v, A[j]);
        }
        B[i] = min_v;
    }
}

int getLeft(int i) {
    int ret = 0;
    int b = i / m; // iが所属するバケットの要素番号
    // iが所属するバケット内を走査
    for (int j = i - 1; j >= b * m; j--) {
        if (A[j] >= A[i]) ret++;
        else return ret;
    }
    if (b == 0) return ret;
    b--;
    while (b >= 0) {
        if (B[b] >= A[i]) b--;
        else break;
    }
    if (b == -1) return ret + m * (i / m);
    for (int j = (b + 1) * m - 1; j >= b * m; j--) {
        if (A[j] >= A[i]) ret++;
        else break;
    }
    return ret + m * (i / m - b - 1);
}

int getRight(int i) {
    int b = i / m;
    int ret = 0;
    for (int j = i + 1; j < (b + 1) * m; j++) {
        if (A[j] >= A[i]) ret++;
        else return ret;
    }
    if (b == m - 1) return ret;
    b++;
    while (b < m) {
        if (B[b] >= A[i]) b++;
        else break;
    }
    if (b == m) return ret + m * (m - i / m - 1);
    for (int j = b * m; j < (b + 1) * m; j++) {
        if (A[j] >= A[i]) ret++;
        else break;
    }
    return ret + m * (b - i / m - 1);
}

int main() {
    cin >> N;
    int best = 0;
    fill(A, A + M, 0);
    fill(B, B + m, 0);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    init();
    for (int i = 0; i < N; i++) {
        int l = 1 + getLeft(i) + getRight(i);
        best = max(best, A[i] * l);
    }
    cout << best << "\n";
    return 0;
}

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

#define ll long long
#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(0);

void solve(int, int, vector<ll> &, vector<int> &, ll, int);

int main()
{
    int ans = 0;

    int n;
    cin >> n;
    vector<int> heights(n);
    for (auto &i : heights)
        cin >> i;

    stack<int> s;
    heights.push_back(0);

    for (int i = 0; i < heights.size(); i++)
    {
        while (!s.empty() && heights[s.top()] >= heights[i])
        {
            int cur = s.top();
            s.pop();

            ans = max(ans, heights[cur] * (s.empty() ? i : (i - s.top() - 1)));
        }
        s.push(i);
    }

    cout << ans;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0,endrep=(n); i<endrep; ++i)
#define rep1(i,n) for(ll i=1,endrep=(n); i<=endrep; ++i)
#define revrep(i,n) for(ll i=(n)-1; i>=0; --i)
inline constexpr ll Inf = (1ULL << 60) -123456789;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define newl '\n'
#define YN(e) ((e)?"Yes":"No")
#define all(a) begin(a),end(a)
#define rall(a) rbegin(a),rend(a)
template <class T,class U> bool updmax(T& a, U b) { if(b>a){ a=b; return true;} return false;}
template <class T,class U> bool updmin(T& a, U b) { if(b<a){ a=b; return true;} return false;}
inline constexpr int Mod = 1000000007;
//inline constexpr int Mod = 998244353;
#define dbg(a) cout << #a << ": " << a << endl;
#define dbg1(a,n) cout<<#a<<": "; rep(i,n) cout<<a[i]<<" "; cout<<endl;
#define dbg2(m,h,w) cout<<#m<<":"<<endl; rep(i,h){ rep(j,w)cout<<m[i][j]<<" "; cout<<endl; }
int rng(int n) { return rand()/(RAND_MAX+1.0)*n; }

ll dp[105][105][105];
int main() {
    fastio;
    ll ans{Inf};
    ll N,X;
    cin >> N >> X;
    vector<ll> a(N);
    rep(i,N) cin >> a[i];
    rep1(k,N) {
        rep(i,N+1) rep(j,k+1) rep(l,k) dp[i][j][l] = -Inf;
        dp[0][0][0] = 0;
        rep(i,N) rep(j,k+1) rep(l,k) {
            updmax(dp[i+1][j][l], dp[i][j][l]);
            updmax(dp[i+1][j+1][(l+a[i])%k], dp[i][j][l] + a[i]);
        }
        ll m = dp[N][k][X%k];
        if (m < 0) continue;
        updmin(ans, (X-m)/k);
    }
    cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10;
long long n, x;
void mx(long long &a, long long b){
	if(b <= x) a = max(a, b);
}
long long a[maxn];
long long dp[2][maxn][maxn][maxn];
// mod tot res
int main(){
	memset(dp, -1, sizeof dp);
	cin >> n >> x;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int mod = 1; mod <= n; mod++) dp[0][mod][0][0] = 0;
	for(int i = 0; i < n; i++){
		int now = i & 1;
		for(int mod = 1; mod <= n; mod++){
			for(int tot = 0; tot <= i; tot++){
				for(int res = 0; res < mod; res++){
					if(dp[now][mod][tot][res] == -1) continue;
					mx(dp[now ^ 1][mod][tot + 1][(res + a[i + 1]) % mod], dp[now][mod][tot][res] + a[i + 1]);
					mx(dp[now ^ 1][mod][tot][res], dp[now][mod][tot][res]);
				}
			}
		}
	}
//	for(int mod = 1; mod <= n; mod++)
//		for(int tot = 0; tot <= n; tot++){
//			for(int res = 0; res < mod; res++){
//				printf("dp[%d][%d][%d] = %lld\n", mod, tot, res, dp[n & 1][mod][tot][res]);
//			}
//		}
	int now = n & 1;
	long long ans = x;
	for(int tot = 1; tot <= n; tot++){
		if(dp[now][tot][tot][x % tot] > 0 && x >= dp[now][tot][tot][x % tot] ) ans = min(ans, (x - dp[now][tot][tot][x % tot]) / tot);
//		printf("tot = %d x %% tot = %lld ans = %lld\n", tot, x % tot, ans);
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  int A,B; cin >> A >> B;
  int limit = 2*A + 100;
  cout << limit - B << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 1000000000000
typedef long long ll;

int main()
{
  int a, b, ans = 0;
  cin >> a >> b;

  cout << 2 * a + 100 - b << endl;
}


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

template <class T, class U>
inline bool chmin(T &a, U b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T, class U>
inline bool chmax(T &a, U b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
constexpr ll inf = 3e18;
#line 2 "main.cpp"

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N;cin>>N;
    double ans=0;
    REP(i,N)ans+=(double)N/i;
    printf("%.12lf\n",ans);
}

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

int main() {
    std::ios_base::sync_with_stdio(false);

    int N; cin>>N;

    long long sum = 0;

    while(N--){

        long long A; long long B;
        cin>>A>>B;

        sum += (B - A + 1)*(B+A)/2;

    }

    cout<<sum<<"\n";

    return 0;
}


#include "bits/stdc++.h"
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	sort(A.begin(), A.end());

	int max = 0,maxk = 2;
	for (int k = 2; k <= A.at(N - 1); k++) {
		int cnt = 0;
		for (int i = 0; i < N; i++) {
			if (A.at(i) % k == 0) cnt++;
		}
		if (cnt >= max) {
			max = cnt;
			maxk = k;
		}
	}
	cout << maxk << "\n";
}

#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>

ll n, sm, res, a;
map<ll, ll>m;

void solve()
{
	cin >> n;
	sm = 0;
	res = 0;
	m.clear();
	m[0] = 1;
	for(int i = 1; i <= n; i++)
	{
		cin >> a;
		if(i & 1)sm += a;
		else sm -= a;
		res += m[sm];
		m[sm]++;
	}
	cout << res << "\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt", "r", stdin);
#endif
	solve();
	return 0;
}


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

#define rep(i, n) for(int i = 0, i##_len=(n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((int)(x).size())

void _cin() {} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail) { cin >> head; _cin(forward<Tail>(tail)...); }
#define cin(Type, ...) Type __VA_ARGS__; _cin(__VA_ARGS__)
#define cinv(Type, xs, n) vector<Type> xs(n); rep(i, n) cin >> xs[i]
#define cinv2(Type, xs, ys, n) vector<Type> xs(n), ys(n); rep(i, n) cin >> xs[i] >> ys[i]
#define cinv3(Type, xs, ys, zs, n) vector<Type> xs(n), ys(n), zs(n); rep(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define cinvv(Type, xs, h, w) vector<vector<Type>> xs(h, vector<Type>(w)); rep(i, h) rep(j, w) cin >> xs[i][j]

void print() { cout << endl; }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...); }
template <class Type> void print(vector<Type> &vec) { for (auto& a : vec) { cout << a; if (&a != &vec.back()) cout << " "; } cout << endl; }
template <class Type> void print(vector<vector<Type>> &df) { for (auto& vec : df) { print(vec); } }

void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void yesno(bool b) { cout << (b ? "yes" : "no") << endl; }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a < b) { a = b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;

const ll U = 10000;

void Main() {
	cin(double, dx, dy, dr);
	ll x = ll(abs(dx) * U + 0.5) % U + 1000010000;
	ll y = ll(abs(dy) * U + 0.5) % U + 1000010000;
	ll r = ll(dr * U + 0.5);
	ll ans = 0;
	for (ll i = (x - r + U - 1) / U * U; i <= x + r; i += U) {
		ll a = r * r - (i - x)*(i - x);
		ll ok = 0;
		ll ng = 1100000000;
		while (ng - ok > 1) {
			ll t = (ng + ok) / 2;
			if (t*t <= a)ok = t;
			else ng = t;
		}
		ll u = (y + ok) / U;
		ll d = (y - ok - 1) / U;
		ans += u - d;
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(16);
	//int t; cin >> t; while (t--)
	Main();
}

#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5,M=7;
int dp[N][M],n;
string s,x;
void solve(){
	cin>>n>>s>>x;
	dp[n][0]=1;
	for(int i=n-1,p10=1;i>=0;i--,p10=(p10*10)%7){
		int dig = ((s[i]-'0')*p10)%7;
		for(int j=0;j<M;j++){
			if(x[i]=='T'){
				dp[i][j] = ( dp[i+1][j] | dp[i+1][(j+dig)%7] );
			}else{
				dp[i][j] = ( dp[i+1][j] & dp[i+1][(j+dig)%7] );
			}
		}
	}
	cout<<(dp[0][0]?"Takahashi" : "Aoki");
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin);
    freopen("output.txt" , "w" , stdout);
#endif
    // int t;
    // cin>>t;
    // while(t--)
        solve();
}


#include <bits/stdc++.h>
using namespace std;
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#ifdef WA_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

using ll  = long long;
using ull = unsigned long long;
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=int(a);i<=(int)(b);i++)
#define per(i,a,b) for(int i=int(a);i>=(int)(b);i--)
const int mod  = 1e9+7;
const int inf  = 0x3f3f3f3f;
const int maxn = 1e5+10;
int main() {
#ifndef WA_DEBUG
    ios::sync_with_stdio(false);cin.tie(nullptr);
#endif
    int n;
    cin>>n;
    vector<int> a(n+1);
    int Min=inf;
    rep(i,1,n) {
        cin>>a[i];
        Min=min(a[i],Min);
    }
    set<int> s;
    rep(i,1,n) {
        rep(j,1,maxn) {
            if(j*j>a[i]) break;
            if(a[i]%j==0) {
                s.insert(j);
                if(j*j!=a[i]) s.insert(a[i]/j);
            }
        }
    }
    int cnt=0;
    for(int x:s) {
        int ans=-1;
        rep(i,1,n) {
            if(a[i]%x==0) {
                if(ans==-1) ans=a[i]/x;
                else ans=__gcd(ans,a[i]/x);
            }
        }
        if(ans==1&&x<=Min) cnt++;
    }
    cout<<cnt<<'\n';
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define int long long int
#define pii pair<int,int>
const int INF= 1e12;
const int MAX=5e6+5;
const int MAXK=105;
const int mod = 1e9+7;
int gcd(int a, int b)
{
    while(b!=0)
    {
        a=a%b;
        swap(a,b);
    }
    return a;
}
int binpow(int a,int b)
{
    int res=1;
    while(b>0)
    {
        if(b%2==1)
            res=res*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return res;
}
/*
 * check modulus when using binpow
 */
map<int,int> mp;
int find_set(int x)
{
    if(mp[x]==x)
    {
        return x;
    }
    return mp[x]=find_set(mp[x]);
}
void solve()
{
    int cnt=0;
    int n;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        mp[ar[i]]=ar[i];
    }
    for(int i=0;i<n/2;i++)
    {
        int x=find_set(ar[i]);
        int y=find_set(ar[n-1-i]);
        if(x!=y)
        {
            cnt++;
            mp[x]=y;
        }
    }
    cout<<cnt<<"\n";

}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif // ONLINE_JUDGE
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)
    {
        //cout<<"Case #"<<i<<": ";
        solve();
    }
}


#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int maxN = 1e6 + 5;
ll arr[maxN] = { 0 };
void init()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
}
/*
 * 1) First filter out the pairs which have gcd > 1. To compute this, we
 * we need to know (1/2 + 1/3 + ... + 1/n) * n = nlogn
 * 2) Second exclude those pairs where gcd(a, b) = min(a, b)
 */
int main()
{
    init();
    int l, r;
    cin >> l >> r;
    ll res = 0;
    for (int i = r; i >= 2; --i) {
        int num = r / i - (l - 1) / i;
        arr[i] += 1LL * num * num;
        for (int j = 2 * i; j <= r; j += i) {
            arr[i] -= arr[j];
        }
        res += arr[i];
    }
    for (int i = max(2, l); i <= r; ++i) {
        int rr = r / i;
        res -= rr * 2 - 1;
    }
    cout << res << endl;
    return 0;
}

#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int main(){
  int L,R; cin >> L >> R;
  int N = R;
  vector<ll> T(N+1,0);
  T[1] = 1;
  for(int a=1; a<=N; a++) for(int b=a*2; b<=N; b+=a) T[b] -= T[a];

  ll ans = 0;

  for(int g=2; g<=R; g++){
    int l = max(1, (L-1) / g);
    int r = R / g;
    for(int i=1; i<=r; i++) ans += T[i] * (r/i - l/i) * (r/i - l/i);
  }

  cout << ans << "\n";
  return 0;
}

struct ios_do_not_sync{
  ios_do_not_sync(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} ios_do_not_sync_inst;


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

#define MOD 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define vvi vector<vector<int>>
#define INF (int)1e9
#define fora(i,a,b) for(ll i=a;i<b;i++)
#define forn(n) for(ll i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fir first
#define sec second
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp(x,y) make_pair(x,y)
#define mli map<ll,int>
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define sortv(v) sort(v.begin(), v.end())
#define minv(v) min_element(v.begin(), v.end())
#define maxv(v) max_element(v.begin(), v.end())
#define ubv(v,n) upper_bound(v.begin(), v.end(), n)
#define lbv(v,n) lower_bound(v.begin(), v.end(), n)
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

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

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

}

int main()
{
fast;
ll a,b;
cin>>a>>b;
if(a==b)
{
    cout<<a;
}
else
{
    cout<<3-a-b;
}
    return 0;
}
//0xAAAAAAAA=even bits set to 1 ; 0x55555555 = odd bits set to 1

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

int main() {
  int x, y;
  cin >> x >> y;
  int answer;
  if (x == y) answer = x;
  else if (x == 0 && y == 1) answer = 2;
  else if (x == 1 && y == 0) answer = 2;
  else if (x == 1 && y == 2) answer = 0;
  else if (x == 2 && y == 1) answer = 0;
  else if (x == 0 && y == 2) answer = 1;
  else if (x == 2 && y == 0) answer = 1;

  cout << answer;
}


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

long long solve(long long x){
    long long ans = 0 ; // 指数の数+1を数える
    if(x == 1) return 1; // 1は1の0乗なので0 + 1 = 1
    for(long long p = 2 ; p * p  <=x ; p++){
        while( x % p == 0){
            ans++ ;
            x /= p ;
        }
    }

    if( x > 1 ) ans++ ; // 最後に残ったのが1でないならそいつも指数の1つ
    return ans + 1;
}

int main(){
    int N ;
    cin >> N ;
    for(int i = 1 ; i <= N ; i++){
        cout << solve((long long)i) << " ";
    }
    cout << endl;
}

//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define LD long double
#define ST string
#define BS bitset
#define PA pair<LL,LL>
#define VE vector
#define VL VE<LL>
#define VP VE<PA>
#define VVL VE<VL>
#define VVVL VE<VVL>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define FI first
#define SE second
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define MP make_pair
#define TS to_string
#define TU to_ullong
#define BPL __builtin_popcountll
#define FOR(i,a,n) for(i=a;i<n;++i)
#define FORR(i,a,n) for(i=n-1;i>=a;--i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FORR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define UBn(a,n) upper_bound(ALL(a),n)-a.begin()
#define LB(a,n) *lower_bound(ALL(a),n)
#define LBn(a,n) lower_bound(ALL(a),n)-a.begin()
#define INF 1000000000000000003
#define PI 3.14159265358979323846264338327950288
//#define MOD 1000000007
#define MOD 998244353
#define ERR 1e-10
#define coutl cout<<fixed<<setprecision(15)
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void YN(LL a){if(a)cout<<"YES"<<endl;else cout<<"NO"<<endl;}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL dig(LL n){LL ret=0;while(n)n/=10,++ret;return ret;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
LL cmod(LL a,LL m){if(a%m<0)return a%m+abs(m);else return a%m;}
LL cdiv(LL a,LL b){return ((a<0&&b<0)||(a>=0&&b>=0)?a/b:(a-b+1)/b);}
LL DIV(LL a,LL d,LL m){LL l=m,x=1,y=0,k;while(l){k=d/l;d-=k*l;swap(l,d);x-=k*y;swap(x,y);}return cmod(a*cmod(x,m),m);}
LL POW(LL a,LL n,LL m){LL ans=1;while(n>0){if(n&1)ans=ans*a%m;a=a*a%m;n>>=1;}return ans;}
VL fact,finv,inv;
void comi(LL n){LL i;fact.resize(max(2LL,n+1));finv.resize(max(2LL,n+1));inv.resize(max(2LL,n+1));fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[0]=inv[1]=1;FOR(i,2,n+1){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(PA a,PA b){if(a.SE!=b.SE)return a.SE<b.SE;return a.FI<b.FI;}
template<typename T>bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>void vout(VE<T> &v){LL i;rep(i,v.size()){cout<<v[i];if(i<v.size()-1)cout<<" ";}cout<<endl;}
template<typename T>void v2out(VE<VE<T>> &v){for(auto a:v)vout(a);}

int main(){
    FAST;
    LL i,j,ans=0,N;
    cin>>N;
    VL v(N,1);
    rep(i,N)for(j=i*2+1;j<N;j+=i+1)chmax(v[j],v[i]+1);
    vout(v);
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>
#include<math.h>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,n) for(ll i=1;i<=n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}

int main(void){
    ll N;
    cin>>N;
    long double ans=0.0;
    REP(i,N-1){
        long double fue=0.0;
        fue+=N;
        fue/=(N-i);
        ans+=fue;
    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
    return 0;
}

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

const int N = 100005;
double dp[N];

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

  for (int i = n-1; i >= 1; i--) {
    dp[i] = dp[i+1]+(1.0)*n/(n-i);
  }
  cout << fixed << setprecision(10) << dp[1] << '\n';
}


#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
#include<functional>
using namespace std;
#define rep(i,a,n) for(ll i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
const ll mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const ll INF = 1000;

class UnionFind {
public:
	//親の番号を格納する
	vector<int> par;

	//最初は全てが根であるとして初期化
	UnionFind(int N) {
		par.resize(N);
		for (int i = 0; i < N; i++)par[i] = i;
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (par[A] == A) return A;
		return par[A] = root(par[A]);
	}

	//AとBをくっ付ける
	bool unite(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//Bの親をAに変更する
		par[B] = A;

		return true;
	}
	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

template<class T>
class SegTree {
public:
	T size;
	vector<T> seg; //配列
	T e; //単位元
	function <T(T, T)> f; //演算
	function<T(T, T)> updata; //更新
	SegTree(T n, T _e, function<T(T, T)> _f, function<T(T, T)> _updata) { //コンストラクタ(初期化)
		f = _f;
		e = _e;
		updata = _updata;
		size = 1;
		while (size < n)size *= 2;
		seg.resize(size * 2 - 1, e);
	}

	void change(T n, T k) { //一点更新
		n += size - 1;
		seg[n] = updata(seg[n], k);
		while (n > 0) {
			n = (n - 1) / 2;
			seg[n] = f(seg[n * 2 + 1], seg[n * 2 + 2]);
		}
	}
	T query(T a, T b, T l, T r, T k) {
		if (b <= l || r <= a)return e;
		if (a <= l && r <= b)return seg[k];
		T v1 = query(a, b, l, (l + r) / 2, k * 2 + 1);
		T v2 = query(a, b, (l + r) / 2, r, k * 2 + 2);
		return f(v1, v2);
	}

};

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

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbをmod.mで割った余りを求める
llint C(llint n, llint r, llint m) {
	llint ans = 1;
	for (llint i = 0; i < r; i++) {
		ans *= n - i;
		ans %= m;
	}
	for (llint i = 1; i <= r; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

llint gcd(llint a, llint b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}

int main() {
	int n;
	cin >> n;
	hei(llint) a(n);
	rep(i, 0, n)cin >> a[i];
	llint G = a[0];
	rep(i, 1, n) {
		G = gcd(G, a[i]);
	}
	cout << G << endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int ans = A[0];
    rep(i, N) ans = __gcd(ans, A[i]);
    cout << ans << endl;

}


#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 6;
const int mod = 1e9 + 7;
int a[N], dif[N];
signed main() {
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + 1 + n);
	a[0] = 0;
	for(int i = 1; i <= n; i++) {
		dif[i - 1] = a[i] - a[i - 1] + 1;
	}
	int ans = 1;
	for(int i = 0; i < n; i++) {
		ans = (ans * dif[i]) % mod;
	}
	cout << ans;
}

/***************************************************************
	File name: B.cpp
	Author: ljfcnyali
	Create time: 2021年04月18日 星期日 20时03分40秒
***************************************************************/
#include<bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for ( int i = (a), _end_ = (b); i <= _end_; ++ i )
#define mem(a) memset ( (a), 0, sizeof ( a ) )
#define str(a) strlen ( a )
#define pii pair<int, int>
#define int long long
typedef long long LL;

const int maxn = 1e5 + 10;
const int Mod = 1e9 + 7;

int n, ans = 1;
map<int, bool> Map;

signed main()
{
	scanf("%lld", &n);
	REP(i, 1, n) { int x; scanf("%lld", &x); Map[x] = true; }
	int lst = 0;
	for ( auto it : Map ) { ans = ans * (it.first - lst + 1) % Mod; lst = it.first; }
	printf("%lld\n", ans);
    return 0;
}


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

void solve(){
   int n;cin>>n;
   map<int,int> cnt;
   set<int> s;
   for(int i=0;i<n;i++){
      int x;cin>>x;
      s.insert(x);cnt[x]++;
   }
   int ans=0;
   for(int x:s)   ans+=(n-cnt[x])*cnt[x];
   cout<<ans/2<<"\n";
}

signed main(){
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   clock_t t1=clock();
   int t;
   //cin>>t;
   t=1;
   while(t--){
      solve();
   }
   cerr<<"Time elapsed: "<<(double)(clock()-t1)/1000<<" s"<<endl;
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
//#define float double
#define IOS  std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int v=1000000007;
//fflush(stdout) write after cout or printf
// * understand question thoroughly (constraints, neg numbers or only positive numbers )...
//....get clarity on input and output types
// *  get idea to solve inclusive of all corner cases and all conditions
//* check for time and space complexity
//* implement it correctly

 double sqroot(double n){
   double l=0,r=1000;
   double mid;
   while(r-l>=1e-10){
      mid=l+(r-l)/2;
     if(mid*mid<n)
       l=mid;
      else if(mid*mid>n)
       r=mid;
       else if(abs(mid*mid-n)<=1e-10){
         break; }}
   return mid;}
vector<int> fact(200005,1);
int fac(int n){
  if(n==0 or n==1)
  return fact[n]=1;
return fact[n]=(n%v*(fac(n-1))%v)%v;
  }
int bin(int n,int k){
  int ans=1;int a=n;
  while(k!=0){
  if(k&1){
    ans=ans*a;
    ans=ans%v;}
  a=((a%v)*(a%v))%v;k=k/2;}
  return ans%v;}
int com(int n,int r){
  if(fact[n]==1){
  int ans=((fac(n)%v)*(bin(fact[n-r],v-2)%v))%v;
  ans=ans*(bin(fact[r],v-2)%v);
  return ans%v;}
  else if(fact[n]!=1){
    int ans=((fact[n]%v) * (bin(fact[n-r],v-2)%v))%v;
  ans=ans*(bin(fact[r],v-2)%v);
  return ans%v;}}

bool valid(int i,int x,int y){
  if(i>=x and i<=y){
    return true;
  }
  return false;
}
vector<int>prime;
bool isprime[100005];

void seive_of_erasthones(){
for(int i=2;i<100005;i++){
  isprime[i]=true;}
for(int i=2;i<100005;i++){
  if(isprime[i]){
    prime.push_back(i);
    for(int j=i*i;j<100005;j+=i)
    isprime[j]=false;
  }
}

}

int32_t main()
{ IOS;

int t=1;
//cin>>t;

while(t--!=0){
 int n;
 cin>>n;
int a[n];
unordered_map<int,int>mp;
for(int i=0;i<n;i++){
cin>>a[i];
mp[a[i]]++;}
int ans=0;
ans+=(n*(n-1))/2;
for(auto x:mp){
  if(x.second>=2){
    ans-=(x.second*(x.second-1))/2;
  }
}
cout<<ans<<endl;

}

 return 0;}


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

#ifdef LOCAL
    #define D(a) cerr << #a << " = " << a << endl
#else
    #define D(a) 8
#endif
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define all(a) (a).begin(),(a).end()
#define dforn(i,n) dforsn(i,0,n)
#define forn(i,n) forsn(i,0,n)
#define si(a) int((a).size())
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first
#define endl '\n'
using pii = pair<int,int>;
using vi = vector<int>;
using ll = long long;

const int M = 998244353;
int add(int a, int b){ return a+b < M ? a+b : a+b-M; }
int mul(int a, int b){ return int(ll(a)*b % M); }
int pot(int b, int e){ // O(log e)
	int r=1;
    while (e) {
        if (e&1) r = mul(r,b);
        e >>= 1; b = mul(b,b);
    }
    return r;
}
int inv(int x){ return pot(x, M-2); } // Change M-2 for Phi(M)-1 if M isn't prime
const int INV3 = inv(3);

const int N = 5e3;
int h, w;
char mov[N][N];

int memo[N][N];
int dp(int i, int j) {
    if (i < 0 || j < 0 || i >= h || j >= w) return 0;
    if (i == h - 1 && j == w - 1) return 1;

    int &res = memo[i][j];
    if (res != -1) return res;
    res = 0;

    if (mov[i][j] != 'R') {
        int confs = mov[i][j] == '.' ? mul(INV3, 2) : 1;
        res = add(res, mul(confs, dp(i + 1, j)));
    }

    if (mov[i][j] != 'D') {
        int confs = mov[i][j] == '.' ? mul(INV3, 2) : 1;
        res = add(res, mul(confs, dp(i, j + 1)));
    }

    return res;
}

int main() {
    fastio;

    fill(memo[0], memo[N], -1);
    fill(mov[0], mov[N], '.');

    cin >> h >> w;
    int k; cin >> k;
    forn(_, k) {
        int i, j; char c; cin >> i >> j >> c; i--, j--;
        mov[i][j] = c;
    }

    int all_confs = pot(3, h * w - k);
    cout << mul(dp(0, 0), all_confs) << endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> X(M), Y(M), Z(M);
    for(int i = 0; i < M; i++) {
        cin >> X[i] >> Y[i] >> Z[i];
    }
    vector<long long> dp((1 << N));
    for(int i = 0; i < (1 << N); i++){
        int cnt = __builtin_popcount(i);
        bool f = true;
        for(int j = 0; j < M; j++){
            int t = (i & ((1 << Y[j]) - 1));
            int cnt2 = __builtin_popcount(t);
            if(cnt <= X[j] && cnt2 > Z[j]){
                f = false;
                break;
            }
        }
        if(!f) continue;
        if(i == 0) dp[i] = 1;
        for(int j = 0; j < N; j++){
            if((i & (1 << j)) == 0){
                dp[i ^ (1 << j)] += dp[i];
            }
        }
    }
    cout << dp[(1 << N) - 1] << endl;
}


#include <iostream>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <iomanip>
#include <cmath>

// 最大公約数
template<typename T> T gcd(T a, T b)
{
	if (a < b) {
		return gcd(b, a);
	}
	else {
		const T mod = a % b;
		if (mod == 0) {
			return b;
		}
		else {
			return gcd(b, mod);
		}
	}
}

int main()
{
	int A, B;
	std::cin >> A >> B;
	const int max = 2 * A + 100;
	std::cout << max - B << std::endl;
	return 0;
}

#include <bits/stdc++.h>

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; while(t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template<typename T> istream& operator>>(istream &is, vector<T> &v) { for(auto &it : v) is >> it; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << " end.\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

const int N = 2e5+5;

void solve(){
    int a, b;
    cin >> a >> b;
    cout << 2*a +100 - b << "\n";
}
int main()
{
    Fast;
    //louisfghbvc
        solve();
    return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll mod = 1000000007;
int main(){
    int n;
    cin >> n;
    int judge = 0;
    vector<P>vec(n);
    rep(i,n){
        P pp;
        int a,b;
        cin >> a >> b;
        pp.first = a;
        pp.second = b;
        vec[i] = pp;
    }
    rep(i,n){
        rep(j,n){
            rep(k,n){
                if(i != j && j != k){
                    if(i != k){
                        if(vec[i].first == vec[j].first){
                            if(vec[j].first == vec[k].first){
                                judge = 1;
                                cout << "Yes" << endl;
                                return 0;
                            }
                        }
                        else if(vec[i].first != vec[j].first && vec[j].first != vec[k].first){
                            ll x1 = vec[i].first - vec[j].first;
                            ll x2 = vec[j].first - vec[k].first;
                            ll y1 = vec[i].second - vec[j].second;
                            ll y2 = vec[j].second - vec[k].second;
                            if(x1 * y2 == x2 * y1){
                                judge = 1;
                                cout << "Yes" << endl;
                                return 0;
                            }
                        }
                    }
                }
            }
        }
    }
    if(judge == 0){
        cout << "No" << endl;
    }
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<ll, ll>;
using tp = tuple<ll, ll, ll>;

template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;

#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
#define rep(i, m, n) for(ll i = (ll)(m); i < (ll)(n); ++i)
#define rep2(i, m, n) for(ll i = (ll)(n)-1; i >= (ll)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)

constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
static const ld pi = 3.141592653589793L;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

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

//グラフ関連
struct Edge {
    int to, rev;
    ll cap;
    Edge(int _to, ll _cap, int _rev) : to(_to), cap(_cap), rev(_rev) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, int from, int to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (int)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (int)G[from].size() - 1));
}

void solve() {
    ll n, k;
    cin >> n >> k;

    ll num = 0;
    ll pre = 0;
    k--;
    rep(s, 3, n * 3 + 1) {
        //合計
        ll tmp = pre;
        if(s <= 2 * n + 1) {
            ll r = min(s - 1 - 1, n);
            ll l = max(1LL, s - 1 - n);
            tmp += r - l + 1;
        }
        if(s >= n + 2) {
            ll r = min(s - (n + 1) - 1, n);
            ll l = max(1LL, s - (n + 1) - n);
            tmp -= r - l + 1;
        }
        pre = tmp;

        //cout << s << " " << num << en;
        if(num + tmp <= k) {
            num += tmp;
            continue;
        }
        rep(i, 1, n + 1) {
            ll r = min(s - i - 1, n);
            ll l = max(1LL, s - i - n);
            ll nxt = max(0LL,r - l + 1);
            if(num + nxt <= k) {
                //cout<<num<<" "<<nxt<<" "<<k<<en;
                num += nxt;
                continue;
            }
            ll j = k - num + l;
            cout << i << " " << j << " " << s - i - j << en;
            return;
        }
    }
}

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

    // ll t;
    // cin >> t;
    // REP(i, t - 1) {
    //     solve();
    // }

    solve();

    return 0;
}


#include <bits/stdc++.h>
#include <bitset>
#include <fstream>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 2147483647;
// 9,223,372,036,854,775,807
const ll INFL = 9223372036854775807;

/*!
* @struct UnionFind
* @brief ランク(木の高さ)を用いたUnion Find木
*
*/
template<class T>
struct UnionFind
{
    // rank[x] rootを0としたときの木の高さ
    vector<T> rank;
    // parents[x] xの親ノード
    vector<T> parents;
    /*!
        @fn UnionFind
        @param n ノード総数
        @return なし
        @brief コンストラクタ。親ノードは自身のノードNumberで初期化される
    */
    UnionFind(){}
    UnionFind(T n){
        rank.resize(n,0);
        parents.resize(n,0);
        for(T i=0;i<n;i++){
            makeTree(i);
        }
    }
    /*!
        @fn makeTree
        @param x
        @return なし
        @brief 親番号xのUnion Find木を作る。ノード数の最大値をxとする。
    */
    void makeTree(T x){
        parents[x] = x;
        rank[x] = 0;
    }
    /*!
        @fn findRoot
        @param x ノード番号x
        @return parents[x] ノード番号xの親ノード番号
        @brief xの親ノード番号を再帰関数で発見する
        @n \image html "./img/img1.jpg"
    */
    T findRoot(T x){
        if(x !=parents[x]){
            parents[x] = findRoot(parents[x]);
        }
        return parents[x];
    }
    /*!
        @fn isSame
        @param あるノード番号x,y
        @return
        @brief あるノードx,yが同じ親をもてば、true
    */
    bool isSame(T x,T y){
        return findRoot(x) == findRoot(y);
    }
    /*!
        @fn unite
        @param x,y ノードx,y
        @return true...x,yが同じ親。false...x,yが違う親
        @brief 木を結合する
    */
    bool unite(T x, T y){
        x = findRoot(x);
        y = findRoot(y);
        if(x == y) return false;
        if(rank[x] > rank[y]){
            parents[y] = x;
        }
        else{
            parents[x] = y;
            if(rank[x]==rank[y]){
                rank[y] ++;
            }
        }
        return true;
    }
};

int main() {
    ll n;

    cin >> n;
    vector<ll> a;
    ll maxtmp=0;
    for(int i=0;i<n;i++){
        ll tmp;
        cin >> tmp;
        a.push_back(tmp);
        maxtmp = max(maxtmp,tmp);
    }
    ll cnt=0;
    if(n%2==1){
        a.erase(a.begin()+n/2);
        n -=1;
    }
    // union find
    // aの最大値を入れる
    UnionFind<ll> tree(maxtmp+1);
    for(int i=0;i<n;i++){
        tree.makeTree(a.at(i));
    }
    for(int i=0;i<n/2;i++){
        if(a.at(i)!=a.at(a.size()-1-i)&&tree.isSame(a.at(i),a.at(a.size()-1-i))==false){
            cnt++;
            tree.unite(a.at(i),a.at(a.size()-i-1));
        }
    }
    cout << cnt << endl;
    return 0;
}

#include <bits/stdc++.h>
#include<cmath>
#include<string>
#define pb push_back
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) x.begin(),x.end()
#define int long long
#define ll long long
using namespace std;

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

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

int n;
const int nax = 2e5+2;
vector<int> v(nax), par(nax, -1);

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

	cin >> n;

	//for(int i=1; i< nax; i++){

	//}

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

	int l = 0, r = n-1;
	while(l < r){
		int a = v[l];
		int b = v[r];
		while(a != par[a]){
			int temp = a;
			a = par[a];
			par[temp] = par[a];
		}
		while(b != par[b]){
			int temp = b;
			b = par[b];
			par[temp] = par[b];
		}
		if(a != b){
			par[a] = b;
		}
		l++;
		r--;
	}
	int ans = 0;
	for(int i=1; i< nax; i++){
		if(par[i] == -1)
			continue;

		if(par[i] != i)
			ans += 1;
	}
	cout << ans;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define M 998244353
#define N 200000
typedef long long int LL;
LL fact[301],invfact[301],sum[301],sum2[301];
LL ap[N][301],p2[301];
LL mult(LL a, LL b){
    return a*b%M;
}
LL add(LL a, LL b){
    return (a+b+M)%M;
}
LL c(LL n, LL k){
    return mult(fact[n],mult(invfact[k],invfact[n-k]));
}
LL p(LL b, LL x){
    if(x==0) return 1LL;
    LL sub=p(b,x/2);
    sub=mult(sub,sub);
    if(x&1) sub=mult(sub,b);
    return sub;
}
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",a+i);
    }
    for(int i=0;i<n;i++){
        ap[i][0]=1;
    }
    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
            ap[i][j]=mult(ap[i][j-1],a[i]);
        }
    }
    fact[0]=invfact[0]=1;
    for(int i=1;i<301;i++){
        fact[i]=mult(fact[i-1],i),invfact[i]=p(fact[i],M-2);
    }
    p2[0]=1;
    for(int i=1;i<301;i++){
        p2[i]=mult(2,p2[i-1]);
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<=k;j++){
            sum[j]=add(sum[j],ap[i][j]);
        }
    }
    int tinv=p(2,M-2);
    for(int X=1;X<=k;X++){
        int ans=0;
        for(int x=0;x<=X;x++){
            ans=add(ans,mult(c(X,x),mult(sum[X-x],sum[x])));
        }
        ans=add(ans,-mult(p2[X],sum[X]));
        ans=mult(ans,tinv);
        cout<<ans<<"\n";
    }
}

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

    struct mint {
      ll x;
      mint(ll x=0):x((x%mod+mod)%mod){}
      mint operator-() const { return mint(-x);}
      mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
      }
      mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
      }
      mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
      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 pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
      }

      mint inv() const { return pow(mod-2);}
      mint& operator/=(const mint a) { return *this *= a.inv();}
      mint operator/(const mint a) const { return mint(*this) /= a;}
     };
      istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
      ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
      struct combination {
      vector<mint> fact, ifact;
      combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
      }
      mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
      }
     } c(2000005);

    int main() {
      int N,K;
      cin>>N>>K;
      vector<ll>A(N);
      rep(i,N){cin>>A[i];}
      vector<mint>sum(K+1);//sum[k]=A[0]^k+A[1]^k+A[2]^k+...
      rep(i,N){
        mint now=1;
        rep(j,K+1){
          sum[j]+=now;
          now*=A[i];
        }
      }
      for(int i=1;i<=K;i++){
        mint ans=0;
        for(int j=0;j<=i;j++){
          ans+=c(i,j)*sum[j]*sum[i-j];
          ans-=sum[i]*c(i,j);
        }
        ans/=2;
        cout<<ans<<endl;
      }
      return 0;
    }


#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
const int INF = 1e9;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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) {
    for (int i = 0; i < int(v.size()); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << ' ';
    }
    return os;
}
int main() {
    string s;
    cin >> s;
    deque<char> t;
    bool rev = 0;
    for (char c : s) {
        if (c == 'R') {
            rev ^= 1;
            continue;
        }
        if (rev) {
            t.push_front(c);
        } else {
            t.push_back(c);
        }
    }
    if (rev) reverse(all(t));
    string ans;
    for (int c : t) {
        if (!ans.empty() and ans.back() == c) {
            ans.pop_back();
        } else {
            ans += c;
        }
    }
    cout << ans << '\n';
}

#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

template<typename T>
void printArray(vector<T> &printVec) {
    if(printVec.empty()) return;
    cout << printVec[0];
    for(int i = 1; i < printVec.size(); ++i) cout << " " << printVec[i];
    cout << endl;
}

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    vector<int> res(N + 1, 0);

    int c = 2;
    for(int i = N; i >= 1; --i) {
        int mn = 0;
        for(int j = i * 2; j <= N; j += i) {
            mn = max(mn, res[j]);
        }
        res[i] = mn + 1;
    }

    for(int i = 1; i <= N; ++i) {
        for(int j = i * 2; j <= N; j += i) {
            if(i % j == 0 && res[i] == res[j]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    for(int i = 1; i <= N; ++i) {
        cout << res[i] << " ";
    }
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*b);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
#define num_l(a,v) POSL(a,v) //v未満の要素数
#define num_eql(a,v) POSU(a,v) //v以下の要素数
#define num_h(a,v) (a.size() - POSU(a,v)) //vより大きい要素数
#define num_eqh(a,v) (a.size() - POSL(a,v)) //v以上の要素数
// static_cast< long long ll >

//chrono::system_clock::time_point start, end;
clock_t start;

bool did[50*52];
int tile[51][51];
int point[51][51];
int N = 50;
int si,sj;

string now = "";
int len = 0;
string ans="";

int score = 0;
int best_s = 0;

string D = "DURL";
int di[] = {1,-1,0,0};
int dj[] = {0,0,1,-1};

string D2 = "RLDU";
int di2[] = {0,0,1,-1};
int dj2[] = {1,-1,0,0};

string D3 = "DRUL";
int di3[] = {1,0,-1,0};
int dj3[] = {0,1,0,-1};

void calc(int i,int j,char &x){
  if(i<0 || j<0 || i>=50 || j>=50)return;
  if(did[ tile[i][j] ])return;
  clock_t end = clock();
  double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
  if(time >= 700)return;

  now[len] = x;
  len++;
  did[ tile[i][j] ] = true;
  score += point[i][j];

  if(score > best_s){
    best_s = score;
    ans = now.substr(0,len);
  }

  FOR(k,0,4){
    calc(i+di[k],j+dj[k],D[k]);
  }

  len--;
  did[ tile[i][j] ] = false;
  score -= point[i][j];
}

void calc2(int i,int j,char &x){
  if(i<0 || j<0 || i>=50 || j>=50)return;
  if(did[ tile[i][j] ])return;
  clock_t end = clock();
  double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
  if(time >= 1330)return;

  now[len] = x;
  len++;
  did[ tile[i][j] ] = true;
  score += point[i][j];

  if(score > best_s){
    best_s = score;
    ans = now.substr(0,len);
  }

  FOR(k,0,4){
    calc2(i+di2[k],j+dj2[k],D2[k]);
  }

  len--;
  did[ tile[i][j] ] = false;
  score -= point[i][j];
}

void calc3(int i,int j,char &x){
  if(i<0 || j<0 || i>=50 || j>=50)return;
  if(did[ tile[i][j] ])return;
  clock_t end = clock();
  double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
  if(time >= 1950)return;

  now[len] = x;
  len++;
  did[ tile[i][j] ] = true;
  score += point[i][j];

  if(score > best_s){
    best_s = score;
    ans = now.substr(0,len);
  }
  FOR(k,0,4){
    calc3(i+di3[k],j+dj3[k],D3[k]);
  }
  len--;
  did[ tile[i][j] ] = false;
  score -= point[i][j];
}

int main(){
  FOR(i,0,N*N) now += 'D';

  mt19937_64 mt(1);
  uniform_real_distribution<double> rnd(0.00,1.00);

  cin >> si >> sj;
  FOR(i,0,N)FOR(j,0,N){
    cin >> tile[i][j];
  }
  FOR(i,0,N)FOR(j,0,N){
    cin >> point[i][j];
  }

  start = clock();

  char a = 'U';
  calc(si,sj,a);
  calc2(si,sj,a);
  calc3(si,sj,a);

  if(ans.size() == 0) ans = "U";
  cout << ans.substr(1,ans.size()-1) << endl;

}

#include <iostream>
#include <iterator>
#include <list>
#include <cmath>

constexpr int GRID_SIZE = 50;

struct Pos{
    int i;
    int j;
};

enum MOVE
{
    Up,
    Left,
    Dwon,
    Right,
    LAST
};

char move_char(MOVE move){
    if (move == Up)
    {
        return 'U';
    }
    else if (move == Dwon)
    {
        return 'D';
    }
    else if (move == Right)
    {
        return 'R';
    }
    else if (move == Left)
    {
        return 'L';
    }
    return 'O';
}

struct ListItem
{
    Pos pos;
    int label;
    MOVE move;
};

bool legal(
    Pos pos,
    int pos_label,
    int grid_label[GRID_SIZE][GRID_SIZE],
    std::list<ListItem> lst,
    MOVE move)
{
    if(move == Dwon){
        pos.i += 1;
        if (GRID_SIZE <= pos.i)
            return true;
    }else if(move == Up){
        pos.i -= 1;
        if(pos.i<0)
            return true;
    }else if(move == Right){
        pos.j += 1;
        if (GRID_SIZE <= pos.j)
            return true;
    }else if(move == Left){
        pos.j -= 1;
        if (pos.j < 0)
            return true;
    }

    int label = grid_label[pos.i][pos.j];
    if(label == pos_label){
        return true;
    }
    for (auto itr = lst.rbegin(); itr != lst.rend(); itr++){
        if ((*itr).label == label)
            return true;
    }
    return false;
}

int main()
{
    Pos start;
    int grid_label[GRID_SIZE][GRID_SIZE];
    int grid_score[GRID_SIZE][GRID_SIZE];

    std::cin >> start.i >> start.j;
    for (int x = 0; x < GRID_SIZE; x++)
    {
        for (int y = 0; y < GRID_SIZE; y++)
        {
            std::cin >> grid_label[x][y];
        }
    }
    for (int x = 0; x < GRID_SIZE; x++)
    {
        for (int y = 0; y < GRID_SIZE; y++)
        {
            std::cin >> grid_score[x][y];
        }
    }

    std::list<ListItem> lst;
    Pos pos = start;
    MOVE search_order[4] = {Up,Left,Dwon,Right};
    int di = pos.i - GRID_SIZE / 2, dj = pos.j - GRID_SIZE / 2;
    int i_bias, j_bias;
    if(std::abs(di) > std::abs(dj)){
        i_bias = 0;
        j_bias = 1;
    }else{
        i_bias = 1;
        j_bias = 0;
    }

    search_order[i_bias + (0 < di ? 0 : 2)] = Up;
    search_order[i_bias + (0 < di ? 2 : 0)] = Dwon;
    search_order[j_bias + (0 < dj ? 0 : 2)] = Right;
    search_order[j_bias + (0 < dj ? 2 : 0)] = Left;

    while(true)
    {
        int pos_label = grid_label[pos.i][pos.j];
        MOVE illegal_move = LAST;
        for (int move_index = 0; move_index < 4; move_index++)
        {
            MOVE move = search_order[move_index];
            if(!legal(pos, pos_label, grid_label, lst, move)){
                illegal_move = move;
                break;
            }
        }

        if(illegal_move == LAST){
            for (auto itr = lst.begin(); itr != lst.end(); itr++)
            {
                MOVE move = (*itr).move;
                std::cout << move_char(move);
            }
            std::cout << std::endl;
            break;
        }else{
            lst.push_back({pos, pos_label, illegal_move});
            if (illegal_move == Dwon)
            {
                pos.i += 1;
            }
            else if (illegal_move == Up)
            {
                pos.i -= 1;
            }
            else if (illegal_move == Right)
            {
                pos.j += 1;
            }
            else if (illegal_move == Left)
            {
                pos.j -= 1;
            }
        }
    }
    return 0;
}


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

int main() {
    ios::sync_with_stdio(false);

    int n, m, x, y;
    cin >> n >> m >> x >> y;
    x--, y--;
    vector<string> g(n);
    for (int i = 0; i < n; i++) cin >> g[i];

    int ans = 0;
    for (int i = x; i < n && g[i][y] != '#'; i++) ans++;
    for (int j = y; j < m && g[x][j] != '#'; j++) ans++;
    for (int i = x; i >= 0 && g[i][y] != '#'; i--) ans++;
    for (int j = y; j >= 0 && g[x][j] != '#'; j--) ans++;

    cout << ans - 3 << '\n';

    return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define pb emplace_back
#define INF 0x3f3f3f3f
#define f first
#define s second
#define FOR(i, n) for(int i = 1; i <= n; i ++)
#define FFOR(i, a, b) for(int i = a; i <= b; i ++)
#define pii pair<int, int>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define mem(x, a) memset(x, a, sizeof(x))
#define loli ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int maxn = 1e6 + 50;

bitset<maxn> vis;
int n, m, a[20], to[20][maxn], b[maxn], dp[1 << 18][20];
vector<int> vc[maxn];

signed main(){
	loli;
	cin >> n >> m;
	FOR(i, m) {
		int a, b;
		cin >> a >> b;
		vc[a].pb(b);
		vc[b].pb(a);
	}
	int k;
	cin >> k;
	mem(to, INF);
	FOR(i, k) cin >> a[i], b[a[i]] = i;
	FOR(i, k) {
		queue<int> q;
		q.push(a[i]);
		to[i][a[i]] = 0;
		vis = 0;
		vis[a[i]] = 1;
		while(!q.empty()) {
			int a = q.front(); q.pop();
			for(int t : vc[a]) {
				if(vis[t]) continue;
				to[i][t] = to[i][a] + 1;
				vis[t] = 1;
				q.push(t);
			}
		}
	}
	vis = 0;
	int ans = INF;
	/*
	cout << ans << endl;
	FOR(i, k) {
		FOR(j, k) cout << to[i][a[j]] << " ";
		cout << "\n";
	}
	*/
	mem(dp, INF);
	for(int i = 0; i < k; i ++) dp[(1 << i)][i] = 0;
	for(int i = 1; i < (1 << k); i ++) {
		for(int j = 0; j < k; j ++) {
			if((i >> j) & 1) {
				for(int u = 0; u < k; u ++) {
					if(j != u and ((i >> u) & 1)) {
						dp[i][u] = min(dp[i][u], dp[i ^ (1 << u)][j] + to[j + 1][a[u + 1]]);
					}
				}
			}
		}
	}
	int t = *min_element(dp[(1 << k) - 1], dp[(1 << k) - 1] + k);
	cout << (t == INF? -1 : t + 1) << "\n";
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    int N;
    ll K;
    cin >> N >> K;
    vector<vll> T(N,vll(N));
    REP(i,N){
        REP(j,N){
            cin >> T[i][j];
        }
    }
    vint idxs(N);
    REP(i,N)idxs[i] = i;
    ll ans = 0;
    do{
        ll t = 0;
        REP(i,N){
            t += T[idxs[i]][idxs[(i+1)%N]];
        }
        if(t == K)ans++;
    }while(next_permutation(idxs.begin()+1,idxs.end()));
    cout << ans << endl;
}

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

using namespace std;
using namespace std::chrono;

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma optimization_level 3
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define pb push_back
#define galen_colin {ios_base::sync_with_stdio(false);}
#define orz {cin.tie(NULL); cout.tie(NULL);}
#define fix(prec) {cout << setprecision(prec) << fixed;}
#define mp make_pair
#define f first
#define s second
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
	cout << ""; for(int i = 0; i < v.size(); i++) {if (i) cout << " "; cout << v[i];} return cout << "\n";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
	cin >> p.first;
	return cin >> p.second;
}
template<typename A> istream& operator>>(istream& cin, vector<A> &v) {
    for(auto &x:v)cin>>x;
    return cin;
}

void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}

const ld pi = 3.14159265358979323846;
const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;
const ll INF = 1e9+7;

ll n, m, k, q, l, r, x, y, z;

const ll sz = 1e6 + 1;
ll a[sz] = {0};
ll b[sz];
ll c[sz];
string s, t;
ll ans = 0;
vi vis(10);
vl adj[10];
void dfs(int u, ll tot){

	vis[u] = 1;
	if(u!=0 && tot + adj[u][0] == k){
		ans++;
	}
	for(int i=1;i<n;i++){

		if(!vis[i])dfs(i, tot + adj[u][i]);
	}
	vis[u] = 0;
}
void solve(int tc = 0) {
	cin>>n>>k;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>x;
			adj[i].pb(x);
		}
	}
	dfs(0, 0);
	cout<<ans;
}

int main() {
	#ifdef HACKX
		auto begin = std::chrono::high_resolution_clock::now();
	#endif

	galen_colin orz

	// usaco("cowland");

	int tc = 1;
	// cin >> tc;
	for (int t = 0; t < tc; t++) solve(t);

	#ifdef HACKX
		auto end = std::chrono::high_resolution_clock::now();
		cout << setprecision(4) << fixed;
		// cout << "Execution time: " << std::chrono::duration_cast<std::chrono::duration<double>>(end - begin).count() << " seconds" << endl;
	#endif
}


#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
#include <cassert>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) ((m).find((a)) != m.end())
#define CONTAINS_SET(m, a) ((m).find((a)) != m.end())
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; exit(0); }
void Yes() { cout << "Yes" << endl; exit(0); }
void No() { cout << "No" << endl; exit(0); }

int N, M;
int A[200010];

signed main()
{
	cin >> N >> M;
	REP(i, M) cin >> A[i + 1];
	A[0] = 0;
	A[M + 1] = N + 1;

	ARY_SORT(A, M + 2);

	int k = INT_MAX;
	for (int i = 0; i <= M; i++)
	{
		if (A[i + 1] - A[i] == 1) continue;
		k = min(k, A[i + 1] - A[i] - 1);
	}

	int ans = 0;

	for (int i = 0; i <= M; i++)
	{
		if (A[i + 1] - A[i] == 1) continue;

		int s = A[i + 1] - A[i] - 1;
		ans += ((s + (k - 1)) / k);
	}

	cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<vector<vector<int> > > vvvi;
typedef vector<vector<int> > vvi;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int> wid;
  int pre = 0;
  vector<int> a(m);
  for(int i =0; i<m; i++){
    cin>>a.at(i);
  }
  sort(a.begin(), a.end());
  for(int i =0; i<m; i++){
    int tmp = a.at(i);
    if(tmp-pre != 1) wid.push_back(tmp-pre-1);
    pre = tmp;
  }
  int ans =0;

  if(pre!=n) wid.push_back(n+1-pre-1);
  if(wid.size() >0){
    sort(wid.begin(), wid.end());
    int haba = wid.at(0);
    for(int i =0; i<wid.size(); i++){
      ans += ((wid.at(i)-1)/haba)+1;
    }
  }
  cout<<ans<<endl;
}


// ＵＴＦ−８

#include<bits/stdc++.h>

using namespace std;
using ll = long long int;
using lc = complex<ll>;

/* #include<atcoder/all> */
/* using namespace atcoder; */

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

int main(void) {
    constexpr ll MOD = 1 ? 1e9+7 : 998244353;
    const double PI = acos(-1);
    constexpr double eps = 1e-10;
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    auto f = [&](char x) {
        if('0' <= x && x <= '9')
            return x - '0';
        return x - 'A' + 10;
    };

    if(1) {
        string n;
        ll k;
        cin >> n >> k;
        ll s = n.size();

        vector<vector<ll>> dq(s, vector<ll>(16+1)); // dp ぴったし, dq 未満
        dq[0][0] = 1;
        dq[0][1] = n[0] == '1' ? 0 : (f(n[0]) - 1);

        set<ll> v;
        v.insert(f(n[0]));
        for(ll i=1; i<s; i++) {
                (dq[i][0] += (dq[i-1][0])) %= MOD;
            for(ll j=0; j<=16; j++) {
                (dq[i][j] += (j * dq[i-1][j])) %= MOD;
                if(j == 0)
                    (dq[i][j+1] += ((15-j) * dq[i-1][j])) %= MOD;
                else if(j < 16)
                    (dq[i][j+1] += ((16-j) * dq[i-1][j])) %= MOD;
            }
            for(ll j=0; j<f(n[i]); j++) {
                (dq[i][v.size() + !v.count(j)] += 1) %= MOD;
            }
            v.insert(f(n[i]));
        }
        ll r = dq[s-1][k] + (v.size() == k);
        cout << (r % MOD) << endl;
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll, ll>;
const ll INF = ll(1e18);
const ll mod = ll(998244353);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (b) - 1; (i) >= (a); --(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int multipf(vector<string>& s){
    cout << s[0];
    rep1(i, s.size() - 1)cout << " " << s[i];
    cout << endl;
    return 0;
}

int multipf(vector<ll>& n){
    cout << n[0];
    rep1(i, n.size() - 1)cout << " " << n[i];
    cout << endl;
    return 0;
}

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

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

int main() {
  ll h,w;
  cin >> h >> w;
  vvl g(h,vl(w,0));
  rep0(i,h)rep0(j,w){
    char c;
    cin >> c;
    if(c=='#')g[i][j] = 1;
  }
  ll ans = 0;
  rep0(i,h-1)rep0(j,w-1){
    ll c = g[i][j]+g[i+1][j]+g[i][j+1]+g[i+1][j+1];
    if(c  == 1|| c == 3)ans++;
  }
  pf(ans);
  return 0;
}


/*Allah Vorosha*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define in insert
#define rev reverse
#define all(x) (x).begin(),(x).end()
#define all2(x) (x).rbegin(),(x).rend()
#define sz(v) (int)v.size()
#define yes cout << "YES\n"
#define no cout << "NO\n";
#define take for(auto &it : a) cin >> it;
#define vi vector<int>
#define vii vector<pair<int, int > >
#define vl vector<ll>
#define fi first
#define se second
#define l_b lower_bound
#define u_b upper_bound
#define ed printf("\n")
#define mems(a, b) memset(a, b, sizeof(a))
#define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T> void read(T &x) { cin >> x; }
template<class T, class ...U> void read(T &x, U& ... u) { read(x); read(u...); }
template<class T> void print1(const T &x) { cout << x << '\n'; }
template<class T, class ...U> void print1(const T &x, const U& ... u) { print1(x); print1(u...); }
template<class T> void print2(const T &x) { cout << x << ' '; }
template<class T, class ...U> void print2(const T &x, const U& ... u) { print2(x); print2(u...); }

const int N = 2e5 + 5, mod = 1e9 + 7, M = 5e5 + 5;
const ll inf = 9e18;
int cs = 1;

vector<int> primes;
bool mark[1000005];

void sieve() {
    primes.pb(2);
    for(int i = 4; i <= N; i += 2) mark[i] = 1;
    for(ll i = 3; i <= N; i += 2) {
        if(!mark[i]) {
            primes.pb(i);
            for(ll j = i * i; j <= N; j += (2 * i)) mark[j] = 1;
        }
    }
}

int n, an;
ll dp[55][1 << 16];
vi b, a;

ll myf(int i, int mask) {
    if(i >= n) {
        ll ans = 1;
        for(int j = 0; j < n; j++) {
            if((mask & (1 << j))) {
                ans *= b[j];
            }
        }
        bool ok = 1;
        for(int j = 0; j < an; j++) {
            if(__gcd(a[j] * 1ll, ans) == 1) {
                ok = 0;
                break;
            }
        }
        if(ok) return ans;
        else return inf;
    }
    ll &ret = dp[i][mask];
    if(ret != -1) return ret;
    ret = myf(i + 1, mask);
    ret = min(ret, myf(i + 1, (mask | (1 << i))));
    return ret;
}

void solve() {
    sieve();
    for(int i = 0; ; i++) {
        if(primes[i] <= 50) {
            b.pb(primes[i]);
        }
        else {
            break;
        }
    }
    n = sz(b);
    read(an);
    a.resize(an);
    take;
    mems(dp, -1);
    print1(myf(0, 0));
}

int main() {
    ios;
    /*int tc;
    read(tc);
    while(tc--> 0)*/
    solve();
    return 0;
}

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

typedef long long ll;

#define maxINF 1e18
#define minINF 1e-18
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pri(a,s,n) for(int i = s; i < n; i++) cout<<a[i]<<" "; cout << endl

int main()
{
    FASTIO;
    int t = 1; //cin >> t;
    for(int qw = 1; qw <= t; qw++){
        ll n,x=0,ans = 2e18; cin >> n;
        vector<ll> a(n);
        for(int i = 0; i < n; i++){
            cin >> a[i];
        }
        ll p[15] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
        for(int i = 1; i < 32768; i++){
            x = 1;
            for(int j = 0; j <= 14; j++){
               if((i>>j) & 1) x *= p[j];
            }
            int j;
            for(j = 0; j < n; j++){
                if(__gcd(x,a[j]) == 1) break;
            }
            if(j == n) ans = min(ans,x);
        }

        cout << ans << endl;

    }
}


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

long long N; string arr[101]; long long memo[101][2];

long long dp(long long idx, long long state){
	if(idx == N){
		if(state == 1)return 1;
		else return 0;
	}
	if(memo[idx][state] != -1)return memo[idx][state];
	if(arr[idx] == "AND"){
		return memo[idx][state] = dp(idx + 1, state & 0) + dp(idx + 1, state & 1);
	}else{
		return memo[idx][state] = dp(idx + 1, state | 0) + dp(idx + 1, state | 1);
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cin>>N;
	memset(memo, -1, sizeof memo);
	for(long long i = 0; i < N; i++){
		cin>>arr[i];
	}
	cout<<dp(0, 1) + dp(0, 0)<<'\n';
}

// Problem: A - Slot
// Contest: AtCoder - AtCoder Beginner Contest 189
// URL: https://atcoder.jp/contests/abc189/tasks/abc189_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define INF 1000000000000000000
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

double pi=acos(-1.0);
int md=1e9+7;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};
const int N=3e5+5;

template<class T>
T abst(T a)
{return a<0?-a:a;}

void solve()
{
	string s;cin>>s;
	if(s[0]==s[1] and s[1]==s[2])
	cout<<"Won";
	else
	cout<<"Lost";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long arr[300010];
long long arr2[300010];
int main()
{

    long long a,b,c,d,e,i,j;
    cin >> a >> b;

    long long k=0,chk=0;
    for(i=0;i<a;i++)
    {
        cin >> d;
        arr[d]++;
        chk=max(d,chk);
        k=max(arr[d],k);

    }
    for(i=0;i<=chk;i++){
            if(i==0)
       arr2[i]=min(arr[i],b);
      else{
        arr2[i]=min(arr[i],arr2[i-1]);
      }
      if(arr2[i]==0)
        break;

    }
    long long past=0,sum=0;
    for(i=chk;i>=0;i--){
            long long present=arr2[i];
            sum=sum+(present-past)*(i+1);
            past=present;

    }
    cout << sum << endl;

}

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

int main(){
  int N, X;
  cin >> N >> X;
  int tmp = 0;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (A != X){
      if (tmp != 0){
        cout << " ";
      }
      cout << A;
      tmp++;
    }
  }
  cout << endl;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <unordered_map>
using namespace std;
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) (sort(all(v)), v.erase(unique(all(v)), v.end()))
typedef long long ll;
typedef pair<int, int> p;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, x; cin >> n >> x; x *= 100;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		int a, b;
		cin >> a >> b;
		sum += a * b;
		if (sum > x) {
			cout << i; return 0;
		}
	}
	cout << -1;
}

#include <bits/stdc++.h>

#define TYPE 5

using namespace std;

typedef long long LL;

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

int main()
{
   vector<pair<int,string>> data;

   int n;

   cin >> n;

   for(int i=0; i<n; i++){
      string name;
      int h;
      cin >> name >> h;
      data.push_back(make_pair(h,name));
   }

   sort(data.begin(), data.end(), greater<pair<int,string> >());

   cout << data.at(1).second << endl;

   return 0;
}


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

    #include <bits/stdc++.h>

    using namespace std;

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

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

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

    #define FOR(i, a, b) for (int i=a; i<(b); i++)
    #define F0R(i, a) for (int i=0; i<(a); i++)
    #define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
    #define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
    #define trav(a,x) for (auto& a : x)
    #define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

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

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

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

    const int MOD = 1000000007;
    const char nl = '\n';
    const int MX = 100001; //check the limits, dummy
    const char sp =' ';
    int main() {
        ios_base::sync_with_stdio(0); cin.tie(0);
        ll x1,x2,y1,y2;
        cin >> x1>>y1 >>x2 >>y2;
        double a=(double)((x2*y1)+(x1*y2))/(y1+y2);
        printf("%.10f",a);
        return 0;
    }

    // read the question correctly (ll vs int)
    // template by bqi343(Benq),Geothermal.
    /* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
        * DON'T GET STUCK ON ONE APPROACH
    */

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

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

short A[501][501], B[501][501];
int D[1 << 18];

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int tiisaikazu() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	int tmp = *(int*)ci;
	int dig = 36 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	ci += 40 - dig >> 3;
	return tmp;
}

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

	int H = tiisaikazu(), W = tiisaikazu();
	rep(i, H) rep(j, W - 1) A[i][j] = tiisaikazu() << 1;
	rep(i, H - 1) rep(j, W) B[i][j] = tiisaikazu() << 1;

	priority_queue<ll, vector<ll>, greater<ll>> q;
	D[0] = -2e9 + 1;
	q.push((ll)D[0] << 32);
	int owa = (H - 1) << 9 | W - 1;

	while (q.size()) {
		auto tmp = q.top();
		q.pop();
		int d0 = tmp >> 32;
		int hwp = tmp & (1 << 20) - 1;
		if (D[hwp] != d0) continue;

		int h = hwp >> 9;
		int w = hwp & 511;
		int p = (d0 & 1) << 1 | 1;
		d0 |= 1;

		if (hwp == owa) break;

		if (w > 0) if (D[hwp - 1] > d0 + A[h][w - 1]) {
			D[hwp - 1] = d0 + A[h][w - 1];
			q.push((ll)(d0 + A[h][w - 1]) << 32 | hwp - 1);
		}
		if (w < W - 1) if (D[hwp + 1] > d0 + A[h][w]) {
			D[hwp + 1] = d0 + A[h][w];
			q.push((ll)(d0 + A[h][w]) << 32 | hwp + 1);
		}
		if (h > 0) if (D[hwp - 512] > d0 + p) {
			D[hwp - 512] = d0 + p;
			q.push((ll)(d0 + p) << 32 | hwp - 512);
		}
		if (h < H - 1) if (D[hwp + 512] > d0 + B[h][w]) {
			D[hwp + 512] = d0 + B[h][w];
			q.push((ll)(d0 + B[h][w]) << 32 | hwp + 512);
		}
	}

	co(D[owa] - D[0] >> 1);

	Would you please return 0;
}


#include<iostream>
using namespace std;

int main()
{
    string s;
    cin>>s;
    s[3] = s[0];
    s[0] = s[1];
    s[1] = s[2];
    s[2] = s[3];
    cout<<s<<"\n";
}

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

vector<long long> divisor(long long N) {
    //dが約数ならN/dも約数で、計算量は√N
    vector<long long> ret1, ret2;
    for (long long i=1; i*i<=N; i++)
    {
        if (N%i==0) {
            ret1.push_back(i);
            if (i*i != N) ret2.push_back(N/i);
        }
    }
    reverse(ret2.begin(), ret2.end());
    //反転してから結合
    for (long long i:ret2) ret1.push_back(i);
    return ret1;
}

int main() {
    long long N;
    cin >> N;
    //dが約数ならN/dも約数で、計算量は√N
    vector<long long> ret;
    ret = divisor(N);
    for (long long i:ret) cout << i << endl;
}


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

#define ll long long
#define MAX_SIZE  1000000000

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

    int a,b,c;
    cin >> a >> b >> c;
    a -= b;
    if(b<=0){
        cout << "0" << endl;
        return 0;
    }else{
        cout << a+c << endl;
    }

    return 0;
}

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {

    int N,A,B;
    cin >> N >> A >> B ;
    cout << ((N+B)-A) << "\n";

    return 0;
}


#include <bits/stdc++.h>
// #include <atcoder/all>
// #include "icld.cpp"
using namespace std;
using ll = long long int;
using vi = vector<int>;
using si = set<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using ss = string;
using db = double;
template<typename T> using minpq = priority_queue <T,vector<T>,greater<T>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
#define V vector
#define P pair<int,int>
#define rep(i,s,n) for(int i=(s);i<(int)(n);i++)
#define rev(i,s,n) for(int i=(s);i>=(int)(n);i--)
#define reciv(v,n) vi (v)((n)); rep(i,0,(n))cin>>v[i]
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define ci(x) cin >> x
#define cii(x) ll x;cin >> x
#define cci(x,y) ll x,y;cin >> x >> y
#define co(x) cout << x << endl
#define pb push_back
#define eb emplace_back
#define rz resize
#define sz(x) int(x.size())
#define yn cout<<"Yes"<<endl;else cout<<"No"<<endl
#define YN cout<<"YES"<<endl;else cout<<"NO"<<endl
template<class T>void chmax(T &x,T y){x=max(x,y);}
template<class T>void chmin(T &x,T y){x=min(x,y);}

ll n;
int f(ll x){
  ss s=to_string(x);
  s+=s;
  ll nx=stoll(s);

  if(nx<=n)return 1;
  return  0;
}

int main(){
  ci(n);
  ll ans=0;

  rep(i,1,1e6+1){
    int now=f(i);

    if(now==1)ans++;
  }

  co(ans);
}

 #include "bits/stdc++.h"

 #define FIXED_FLOAT(x)  std::fixed <<std::setprecision(20) << (x)
 #define all(v) (v).begin(), (v).end()
 using namespace  std;
 #define forn(i,n) for (int i = 0; i < (n); ++i)
 using ll = long long;
 int mod = (ll)1e9 + 7;
 #define PI acos(-1)
 typedef pair<int, int> pairs;

 const int INF = 1e9 + 1;
 const int N = 2e5 + 100;
 const double eps = 1e-3;

 template <typename XPAX>
 void ckma(XPAX &x, XPAX y) {
     x = (x < y ? y : x);
 }
 template <typename XPAX>
 void ckmi(XPAX &x, XPAX y) {
     x = (x > y ? y : x);
 }

 void solve() {

 	int n;
 	cin >> n;
 	string s;
 	cin >> s;
 	++n;
 	vector<int> a(n);
 	forn(i, n) {
 		cin >> a[i];
 	}
 	int k = INF;
 	forn(i, n - 1) ckmi(k, abs(a[i + 1] - a[i]));

 	cout << k << '\n';
 	forn(i, k) {
 		forn(j, n) {
 			cout << a[j] / k + (i < a[j] % k) << ' ';
 		}
 		cout << '\n';
 	}

 }
 void test_case() {
     int t;
     cin >> t;
     forn(p, t) {

         //cout << "Case #" << p + 1 << ": ";
         solve();
     }
 }
 int main() {

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

     solve();

 }


#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>

#define endl '\n'
#define ull unsigned long long
#define ll long long
#define ul unsigned long
#define ld long double
#define PI 3.14159265359

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t = 1;
	// cin >> t;
	while (t--) {
		char s, t;
		cin >> s >> t;
		if (s == 'Y' && t >= 'a' && t <= 'z')
			t -= 32;
		cout << t << endl;
	}
}

#include <iostream>
using namespace std;
int main() {
    char x,y;
    cin>>x>>y;
    if(x=='Y'){
        y=toupper(y);
    }
    else{
       y=tolower(y);
    }
   cout<<y<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define f first
#define s second
#define ld long double
const int nax=205;
map<int,int> vis,dp;
int x,y;
int find(int v)
{
    if(vis[v])
    return dp[v];
    vis[v]=1;
    dp[v]=1e18;
    int& res=dp[v];
    res=min(res,abs(v-x));
    if(v==1)
    return res;
    if(v%2==0)
    res=min(res,1+find(v/2));
    else
    res=min(res,1+min(find(v+1),find(v-1)));
    return res;
}
void solve()
{
    cin>>x>>y;
    cout<<find(y);
}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int t=1;
    //cin>>t;
    while(t--)
    solve();
    return 0;
}

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

int main(){
  LL X,Y; cin>>X>>Y;
  if(X>Y){ cout<<(X-Y)<<endl; return 0; }
  LL L=0, LV=Y, R=1, RV=Y+1;
  LL ans=Y-X;
  rep(i,70){
    ans=min(ans,abs(LV-X)+L);
    ans=min(ans,abs(RV-X)+R);
    LL newL,newR;
    if(LV%2==0){
      LV/=2; RV=LV+1;
      newL=min(L+1,R+2); newR=min(L+2,R+2);
    }
    else {
      RV/=2; LV=RV-1;
      newL=min(L+2,R+2); newR=min(L+2,R+1);
    }
    L=newL; R=newR;
  }
  cout<<ans<<endl;
  return 0;
}


#include <bits/stdc++.h>

int main() {
  int n; std::cin >> n;
  std::vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; ++i) std::cin >> a[i];
  for (int i = 0; i < n; ++i) std::cin >> b[i];
  for (int i = 0; i < n; ++i) std::cin >> c[i];
  for (int i = 0; i < n; ++i) --a[i], --b[i], --c[i];

  // Bを基準に考える
  // a_count[i] := iがaに何個あるか eg. a_count[2] == 2の場合
  std::vector<int> a_count(n, 0);
  for (int i = 0; i < n; ++i) ++a_count[a[i]];

  std::vector<int> b_count(n, 0); // b_count[i] := b[i]==a[i]となる個数;
  for (int i = 0; i < n; ++i) b_count[i] = a_count[b[i]]; // b_count[i] := b[i]=a[j]となるjが何個あるか

  std::vector<int> c_count(n+1, 0); // c_count[i] := iがcに何個あるか
  for (int i = 0; i < n; ++i) ++c_count[c[i]];

  long long ans = 0;
  for (int i = 0; i < n; ++i)
    ans += b_count[i] * c_count[i];
  std::cout << ans << std::endl;

  return 0;
}

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

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

  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N);

  rep(i, N) {
    cin >> A.at(i);
  }

  rep(i, N) {
    cin >> B.at(i);
  }

  rep(i, N) {
    cin >> C.at(i);
  }

  int64_t ret = 0;

  vector<int> m(N);

  rep(i, N) {
    m[B[C[i]-1]]++;
  }

  rep(i, N) {
    ret += m[A[i]];
  }

  cout << ret << endl;
}


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

using namespace std;

template<class T>
using V = vector<T>;
template<class T>
using VV = V<V<T>>;

using ld = long double;
#define ll long long
using ull = unsigned ll;
using PLL = pair<ll, ll>;
using VLL = V<ll>;
using VB = V<bool>;
using VVB = VV<bool>;
using VVLL = VV<ll>;
using Gr = VVLL;
using MLL = map<ll, ll>;
#define UMLL unordered_map<ll, ll, custom_hash>

#define fast ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr);

#define R &
#define CR const R

#define FORI(i, a, b) for(ll i = a, max##i = b; i < max##i; ++i)
#define FOR(i, n) FORI(i, 0, n)
#define RFORI(i, a, b) for(ll i = a, min##i = b; i >= min##i; --i)
#define RFOR(i, n) RFORI(i, n, 0)
#define FORA(i, a) for(auto i : a)
#define FORAR(i, a) for(auto R i : a)
#define FORACR(i, a) for(auto CR i : a)
#define ALL(obj) begin(obj), end(obj)
#define Count(q) while(q--)
#define OK cerr << "OK\n";

#define mp make_pair
#define pb push_back

//#define DEBUG

template<class T>
T sqr(T x)
{
    return x * x;
}

void YES(bool g, ostream R os, bool upper = true)
{
    if(g)
        if(upper)
            os << "YES";
        else
            os << "Yes";
    else
        if(upper)
            os << "NO";
        else
            os << "No";

    os << "\n";
}

template<class T>
void show(T CR t, ostream R os = cerr)
{
    FORACR(i, t)
        os << i << " ";
    os << "\n";
}

template<class T>
void show2d(T CR t, ostream R os = cerr)
{
    FORACR(i, t)
        show(i, os);
    os << "\n";
}

constexpr ll MOD = 1e9 + 7; //998244353;
constexpr ll len = 'z' - 'a' + 1;

constexpr ll INF = 1e18, MINF = -INF;

constexpr ld PI = atanl(1.0L) * 4;
constexpr ld eps = 1e-9, EPS = 1e-9;

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

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

//arr
void init() {}

ll sgn(ll a)
{
    if(a > 0)
        return 1;
    if(a < 0)
        return -1;
    return 0;
}

void solve(istream R is, ostream R os)
{
    ll a, b, c;
    is >> a >> b >> c;

    ll x = pow(sgn(a), c), y = pow(sgn(b), c);
    if(x < y)
        os << "<";
    else if(x > y)
        os << ">";
    else
    {
        a = abs(a);
        b = abs(b);

        if(a > b)
            os << ">";
        else if(a < b)
            os << "<";
        else
            os << "=";
    }
}

void tester(istream R is, ostream R os)
{
    auto seed = time(nullptr);
    //cerr << "seed: " << seed << "\n";
    srand(seed);
    fast
    init();
    ll q = 1;
    //is >> q;

    os << setprecision(999);
    Count(q)
        solve(is, os);
}

int main()
{
    ifstream in("input.txt");
    ofstream out("output.txt");

    tester(cin, cout);
}

#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<long long>>;
using Graph = vector<vector<int>>;
const long long INF = 1LL <<59;
const long long Mo=1000000007;

//vector<long long> seen;
vector<int> seen;

long long dfs(const Graph &G, int v, long long cnt) {
  seen[v] = cnt;	//判定だけならcntをboolに
  // v から行ける各頂点 next_v について
  for (auto next_v : G[v]) {
    if (seen[next_v]>=0) continue; // next_v が探索済だったらスルー
    dfs(G, next_v, cnt+1); // 再帰的に探索
  }
  //cout<<grp<<" "<<cnt<<endl;
  return 0;
}

long long gcn(long long x,long long y){
  if(x%y==0){
    return y;
  }
  else{
    return gcn(y,x%y);
  }
}

long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
int main(void){
  long long res,tmp,tmp1,tmp2,cnt,idx,cur,prev;
  long long flg;
  long long i,j,n,k,l;
  long long a,b,c;

  cin>>a>>b>>c;

  if(c%2==0){
    if(abs(a)==abs(b)){
      cout<<"="<<endl;
    }
    else if(abs(a)>abs(b)){
      cout<<">"<<endl;
    }
    else{
      cout<<"<"<<endl;
    }
    return 0;
  }
  else{
    if(a>b){
      cout<<">"<<endl;
    }
    else if(a<b){
      cout<<"<"<<endl;
    }
    else{
      cout<<"="<<endl;
    }
    return 0;
  }

  //cout<<res<<endl;
  //cout<<setprecision(15)<<t<<endl;
  //cout<<res<<endl;

  return 0;
}

/*
Graph G(n);
seen.assign(n,-1);
for(i=0; i<m; i++) {
  cin>>tmp1>>tmp2;
  tmp1--;
  tmp2--;
  G[tmp1].push_back(tmp2);
  G[tmp2].push_back(tmp1);
}
*/