#include<bits/stdc++.h>
using namespace std;
const int p = 31;
const int m = 998244353;
typedef long long ll;
typedef long double d;
typedef unsigned long long ull;
typedef int in;
#define ar array
#define ff first
#define ss second
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
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

bitset<200005>isp;
vector<int>prm;
ll dp[200005];
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n;
    cin >> n;
    dp[1] = 1;
    for (int i = 2; i <= n; ++i) {
        dp[i]+=dp[i-1];
        ll tmp = i;
        ll ans = 1ll;
        for (int x=2;x*x<=tmp;++x) {
            if (tmp <= 1)break;
            int ctr = 0;
            while (tmp % x == 0) {
                tmp /= x;
                ctr++;
            }
            if (ctr) {
                ans *= (((ctr + 2) * (ctr + 1) / 2));
            }
        }
        if(tmp!=1){
            ans*=(3);
        }
        dp[i]+=ans;
    }
    cout<<dp[n];
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"; //check time

    return 0;
}

#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
//#define NDEBUG
#endif
#include<bits/stdc++.h>
#define int long long
#define LL long long
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef pair<int,int>PII;typedef vector<int>VI;typedef vector<PII>VII;
template<typename T>void rd(T&x){int f=0,c;while(!isdigit(c=getchar()))f^=!(c^45);x=(c&15);while(isdigit(c=getchar()))x=x*10+(c&15);if(f)x=-x;}
template<typename T>void pt(T x,int c=-1){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);putchar(x%10+48);if(c!=-1)putchar(c);}
const int N=200005;
int n,m,fa[N],a[N],b[N],sa[N],sb[N];
int fd(int k1){return fa[k1]==k1?k1:fa[k1]=fd(fa[k1]);}
signed main(){
	rd(n),rd(m);
	rep(i,1,n)rd(a[i]);
	rep(i,1,n)rd(b[i]),fa[i]=i;
	rep(i,1,n)fa[i]=i;
	rep(i,1,m){
		int k1,k2;
		rd(k1),rd(k2);
		fa[fd(k1)]=fd(k2);
	}
	rep(i,1,n){
		sa[fd(i)]+=a[i];
		sb[fd(i)]+=b[i];
	}
	rep(i,1,n)if(sa[i]!=sb[i]){
		puts("No");
		exit(0);
	}
	puts("Yes");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define M  100000000000000000
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.14159265
#define pb push_back
#define LLMX LONG_LONG_MAX
#define LLMN LONG_LONG_MIN
#define double long double
int n , m , k;

signed main()
{
  //fastio ;
  int a , b , c ;
  cin >> a >> b >> c ;
  if( c == 0)
  {
    if( a > b)
    {
      cout << "Takahashi" ;
    }
    else
    cout <<"Aoki" ;
  }
  else
  {
    if( b > a)
    {
      cout << "Aoki" ;
    }else
    cout  << "Takahashi" ;
  }
}

#include<iostream>
using namespace std;
long A,B,C;
char f(long A,long B,long C)
{
	return A>B?'>':A<B?'<':'=';
}
main()
{
	cin>>A>>B>>C;
	if(A==0)
	{
		if(B==0)
		{
			cout<<"="<<endl;
		}
		else if(B>0)
		{
			cout<<"<"<<endl;
		}
		else
		{
			if(C%2==0)cout<<"<"<<endl;
			else cout<<">"<<endl;
		}
	}
	else if(A>0)
	{
		if(B==0)
		{
			cout<<">"<<endl;
		}
		else if(B>0)
		{
			cout<<f(A,B,C)<<endl;
		}
		else
		{
			if(C%2==1)cout<<">"<<endl;
			else cout<<f(A,-B,C)<<endl;
		}
	}
	else
	{
		if(B==0)
		{
			if(C%2==0)cout<<">"<<endl;
			else cout<<"<"<<endl;
		}
		else if(B>0)
		{
			if(C%2==1)cout<<"<"<<endl;
			else cout<<f(-A,B,C)<<endl;
		}
		else
		{
			if(C%2==0)cout<<f(-A,-B,C)<<endl;
			else cout<<f(-B,-A,C)<<endl;
		}
	}
}


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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define float			double
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vc				vector<char>
#define vb				vector<bool>
#define vf				vector<float>
#define vs				vector<string>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define hashmap         unordered_map
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

template<class T>
void printV(vector<T> a) {for (auto v : a)cout << v << " ";}
template<class T>
void readV(vector<T>& a) {int n = a.size(); for (int i = 0 ; i < n ; i++)cin >> a[i];}
template<class T>
void printA(T* a , int n) {for (int i = 0; i < n  ; i++)cout << a[i] << " ";}
template<class T>
void readA(T* a , int n) {for (int i = 0 ; i < n ; i++)cin >> a[i];}
auto clk = clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
void run_time() {cout << endl<<"Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;}

void aryan_pandeya() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {
	aryan_pandeya();
	FIO;

    int n ;
    cin>>n;
    vector<int> a(n),b(n);
    readV(a);
    readV(b);
    int ans = 0;
    for(int i =0 ; i < n ; i++){
        ans+=(a[i]*b[i]);
    }
    ans==0?cout<<"Yes":cout<<"No";

	return 0;
}

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

#pragma region
#define int long long
#define ll long long
#define ld long double

#define mod 1000000007
#define mod2 998244353
#define ff first
#define ss second
#define pb push_back
#define endl "\n"

#define vi vector<int>
#define si set<int>
#define pii pair<int,int>
#define mii map<int,int>
#define vii vector<pii>
#define sii set<pii>
#define vvi vector<vi>
#define vvii vector<vii>
#define vsi vector<si>

#define in(arr,n)     for(int mm=0;mm<n;mm++)cin >>arr[mm];
#define out(arr,n)    for(int mm=0;mm<n;mm++)cout<<arr[mm]<<" ";cout<<endl;
#define inn(arr,m,n)  for(int mm=m;mm<n;mm++)cin >>arr[mm];
#define outt(arr,m,n) for(int mm=m;mm<n;mm++)cout<<arr[mm]<<" ";cout<<endl;

#define narr int arr[n];in(arr,n)
#define nbrr int brr[n];in(brr,n)
#define cin1(a)       int a;cin>>a;
#define cin2(a,b)     int a,b;cin>>a>>b;
#define cin3(a,b,c)   int a,b,c;cin>>a>>b>>c;
#define cin4(a,b,c,d) int a,b,c,d;cin>>a>>b>>c>>d;
#define fo(i,a,b)     for(int i=a;i<b;i++)
#define rfo(i,a,b)    for(int i=a;i>b;i--)

#define zzz 100000000
#define inf 1000000000000000000
#define max4  10007
#define max5  100007
#define max52 200007
#define max6  1000007

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;

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

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

#define umii unordered_map<int,int,custom_hash>

void solve1();

//bool allprime[10000100]={0};
/*vector<int> set_of_primes;
void sieve_of_primes_upto_10e7()
{
    int n=10000100;
    set_of_primes.push_back(2);int p;
    for(p=3;p*p<=n;p+=2)
    {
        if(allprime[p]==0)
        {
            set_of_primes.push_back(p);
            for(int i=p*p;i<=n;i+=p)
            {
                allprime[i]=1;
            }
        }
    }
    for(p;p<=n;p+=2)
    {
        if(allprime[p]==0)
        {
            set_of_primes.push_back(p);
        }
    }
}*/

int power(int x, int y, int p){//if(x==0&&y==0)return 1;
    int res = 1;x = x % p;if (x == 0) return 0;
    while (y > 0){if (y & 1)res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res%p;
}
int power(int x, int y){//if(x==0&&y==0)return 1;
    int res = 1;if (x == 0) return 0;
    while (y > 0){if (y & 1)res = (res*x);y = y>>1;x = (x*x);}return res;
}

#pragma endregion
int sum(int arr[],int a,int n){int zz=0;for(int i=a;i<n;i++){zz+=arr[i];}return zz;}
int sum(vi  arr  ,int a,int n){int zz=0;for(int i=a;i<n;i++){zz+=arr[i];}return zz;}
int sum(int arr[],int n)      {int zz=0;for(int i=0;i<n;i++){zz+=arr[i];}return zz;}
int sum(vi  arr  ,int n)      {int zz=0;for(int i=0;i<n;i++){zz+=arr[i];}return zz;}

void solve(){int t;cin>>t;while(t--){solve1();}}

signed main(){
    std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   // sieve_of_primes_upto_10e7();
   // vec = set_of_primes;
    solve1();
    return 0;
}

void solve1()
{
    cin2(x,y);
    if(x==y)cout<<x<<endl;
    else cout<<(3-x-y)<<endl;
}


#include<cstdio>
#include<cctype>
#include<cstring>
#include<cmath>
#include<algorithm>
#define LL long long
using namespace std;

template <class I>
inline void read(I &z)
{
    z=0;
    char c=getchar();int base=1;
    while (!isdigit(c) && c!='-') c=getchar();
    if (c=='-') c=getchar(),base=-1;
    while (isdigit(c)) z=z*10+c-'0',c=getchar();
    z*=base;
}

struct E
{
    int to,next;
};

const int N=200010;

E e[N<<1];

int v[N],point=1;

inline void add(int x,int y)
{
    e[++point]=(E){y,v[x]},v[x]=point;
    e[++point]=(E){x,v[y]},v[y]=point;
}

int num=0,x;
int l[N],r[N],d,m;
int s[N];
int f[N<<1];

void dfs(int cur,int fa,int h)
{
    l[cur]=++num;
    f[num]=cur;
    s[num]=h;
    for (int i=v[cur];i;i=e[i].next)
    {
        int u=e[i].to;
        if (u==fa) continue;
        dfs(u,cur,h+1);
    }
    r[cur]=num;
}

struct Persistent_Segment_Tree
{
    struct node
    {
        int lc,rc,sum;
    };
    node a[N*70];
    int root[N],point;
    Persistent_Segment_Tree() { root[0]=point=1; }

    int newnode(int cur)
    {
        a[++point]=a[cur];
        return point;
    }

    void pushup(int cur)
    {
        a[cur].sum=a[a[cur].lc].sum+a[a[cur].rc].sum;
    }

    void build(int cur,int l,int r)
    {
        if (l<r)
        {
            int mid=l+r>>1;
            a[cur].lc=++point,a[cur].rc=++point;
            build(a[cur].lc,l,mid),build(a[cur].rc,mid+1,r);
        }
    }

    int inquire(int his,int cur,int l,int r,int k)
    {
        if (l==r) return a[cur].sum-a[his].sum;
        int mid=l+r>>1,ans=0,sum=a[a[cur].lc].sum-a[a[his].lc].sum;
        if (k<=mid) return inquire(a[his].lc,a[cur].lc,l,mid,k);
        else return inquire(a[his].rc,a[cur].rc,mid+1,r,k);
    }

    void update(int cur,int l,int r,int pos)
    {
        if (l==r)
        {
            ++a[cur].sum;
            return;
        }
        int mid=l+r>>1;
        if (pos<=mid) update(a[cur].lc=newnode(a[cur].lc),l,mid,pos);
        if (pos>mid) update(a[cur].rc=newnode(a[cur].rc),mid+1,r,pos);
        pushup(cur);
    }
};

Persistent_Segment_Tree T;

int n;

int main(int argc, char const *argv[])
{
    read(n);
    for (int i=2;i<=n;++i)
    {
        read(x);
        add(x,i);
    }
    dfs(1,0,1);

    T.build(T.root[0],1,n);
    for (int i=1;i<=num;++i) T.root[i]=T.newnode(T.root[i-1]),T.update(T.root[i],1,n,s[i]);

    read(m);
    for (int i=1;i<=m;++i)
    {
        read(x),read(d);
        printf("%d\n",T.inquire(T.root[l[x]-1],T.root[r[x]],1,n,d+1));
    }
    return 0;
}

#include<bits/stdc++.h>

#define st first
#define nd second
#define pb(x) push_back(x)
#define pp(x) pop_back(x)
#define mp(a, b) make_pair(a, b)
#define all(x) (x).begin(), (x).end()
#define rev(x) reverse(all(x))
#define sor(x) sort(all(x))
#define sz(x) (int)(x).size()
#define rsz(x) resize(x)

using namespace std;

///~~~~~~~~~~~~~~~~~~~~~~~~~~

void debug(){cerr<<"\n";}
template <typename H, typename... T>
void debug(H h, T... t) {cerr<<h; if (sizeof...(t)) cerr << ", "; debug(t...);}
#define deb(x...) cerr<<#x<<" = ";debug(x);

///~~~~~~~~~~~~~~~~~~~~~~~~~

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii > vii;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef string str;

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

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

const int N=2e5+5, INF=1e9+5, mod=1e9+7;
int r[N];
int find(int v){
	if(v==r[v])return v;
	return r[v]=find(r[v]);
}
void Union(int a ,int b){
	r[find(a)]=find(b);
}
int main(){
	BOOST;
	for(int i=0; i<N; i++)r[i]=i;
	int n, m;
	cin>>n>>m;
	for(int i=0; i<n; i++){
		str s;
		cin>>s;
		for(int j=0; j<m; j++){
			if(s[j]=='#')Union(i, j+n);
		}
	}
	Union(0, n);
	Union(n-1, n);
	Union(0, n+m-1);
	set<int> S1, S2;
	for(int i=0; i<n; i++)S1.insert(find(i));
	for(int i=n; i<n+m; i++)S2.insert(find(i));
	cout<<min(sz(S1), sz(S2))-1;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
static const int MAX_N = 16;
static const int MAX_M = 16;
static const int INF = 10001;

int d[MAX_M][MAX_N];

int h, w, a, b;

ll bfs(vector<vector<int>> input, int a, int b, int cnt, int i, int j){
    ll ans = 0;
    if (a == 0 && b == 0) {
        if (cnt == h*w) {
            /*for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    cout << input.at(i).at(j) << " ";
                }
                cout << endl;
            }*/
            return 1;
        }
        else return 0;
    }
    //for (int i = x; i < h; i++) {
        //for (int j = 0; j < w; j++) {
                //if (i == x && j <= y) continue;
    while (i < h && j < w) {
        if (a > 0) {
            if (input.at(i).at(j) == 0 && j < w - 1 && input.at(i).at(j+1) == 0) {
                vector<vector<int>> tmp = input;
                tmp.at(i).at(j) = 1;
                tmp.at(i).at(j+1) = 1;
                ans += bfs(tmp, a-1, b, cnt+2, i, j+1);
                //cout << a << endl;
            }
            if (input.at(i).at(j) == 0 && i < h - 1 && input.at(i+1).at(j) == 0) {
                vector<vector<int>> tmp = input;
                tmp.at(i).at(j) = 1;
                tmp.at(i+1).at(j) = 1;
                ans += bfs(tmp, a-1, b, cnt+2, i, j);
            }
        }
        if (b > 0) {
            if (input.at(i).at(j) == 0) {
                vector<vector<int>> tmp = input;
                tmp.at(i).at(j) = 2;
                ans += bfs(tmp, a, b-1, cnt+1, i, j);
            }
        }
        j++;
        if (j >= w) {
            j = 0;
            i++;
        }
    }
            //}
        //}
    return ans;
}

int main() {
    cin >> h >> w >> a >> b;
    vector<vector<int>> input(h, vector<int>(w, 0));
    ll ans = bfs(input, a, b, 0, 0 ,0);
    cout << ans << endl;
    return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define FI(n) FastIO::read(n)
#define FO(n) FastIO::write(n)
#define ull unsigned long long
#define mst(a,b) memset(a,b,sizeof(a))
#define foR(i,k,j) for(int i=(k);i>=(j);i--)
#define For(i,k,j) for(int i=(k);i<=(j);i++)
#define Foe(i,u) for(int i=lst[u],v=e[i].v;i;i=e[i].nxt,v=e[i].v)
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define Fin(s) freopen(s,"r",stdin)
#define Fout(s) freopen(s,"w",stdout)
#define file(s) Fin(s".in"),Fout(s".out")
#define INF ((1ll<<60)-1)
#define int long long
const int P=998244353; //
using namespace std;
template<typename T>inline void ckmax(T &a,T b) {(a<b)&&(a=b);}
template<typename T>inline void ckmin(T &a,T b) {(a>b)&&(a=b);}
inline int mul(int a,int b) {return 1ull*a*b%P;}
inline int add(int a,int b) {return a+b>=P?a+b-P:a+b;}
inline int sub(int a,int b) {return a-b>=0?a-b:a-b+P;}
inline void mulmod(int &a,int b) {a=mul(a, b);}
inline void addmod(int &a,int b) {((a+=b)>=P)&&(a-=P);}
inline void submod(int &a,int b) {((a-=b)<0)&&(a+=P);}
inline int ksm(int a,int b) {int ans=1; for(;b;b>>=1) {if(b&1) ans=1ll*ans*a%P;a=1ll*a*a%P;}return ans;}
inline void fprint(const int &x,char c=' ') {fprintf(stderr,"%d%c",x,c);}
inline void fprint(const pii &x,char c='\n') {fprintf(stderr,"%d %d%c",x.first,x.second,c);}
inline void fprint(const int *f,const int &n,char c='\n') {for(int i=1;i<=n;i++) fprint(f[i]); fprintf(stderr,"%c",c);}
inline void fprint(const vector<int> &f,char c='\n') {for(int i=0;i<(int)f.size();i++) fprint(f[i]); fprintf(stderr,"%c",c);}
inline int inv(int a) {return ksm(a,P-2);}
namespace FastIO {
  const int SIZE=1<<16; char buf[SIZE],obuf[SIZE],str[64]; int bi=SIZE,bn=SIZE,opt;
  int read(char *s) {
    while (bn) {for (;bi<bn&&buf[bi]<=' ';bi++);if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}
    int sn=0;while (bn) {for (;bi<bn&&buf[bi]>' ';bi++) s[sn++]=buf[bi];if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}s[sn]=0;return sn;
  }
  bool read(int& x) {if(x)x=0;int bf=0,n=read(str); if(!n) return 0; int i=0; if (str[i]=='-') bf=1,i=1; for(x=0;i<n;i++) x=x*10+str[i]-'0'; if(bf) x=-x; return 1;}
  void write(int x) {
    if(!x) obuf[opt++]='0'; else {if(x<0) obuf[opt++]='-',x=-x;int sn=0; while(x)str[sn++]=x%10+'0',x/=10;for (int i=sn-1;i>=0;i--) obuf[opt++]=str[i];}
    if (opt>=(SIZE>>1)){fwrite(obuf,1,opt,stdout); opt=0;}
  }
  void write(char x) {obuf[opt++]=x;if (opt>=(SIZE>>1)){fwrite(obuf,1,opt,stdout); opt=0;}}
	void Fflush() {if (opt) fwrite(obuf,1,opt,stdout); opt=0;}
};
inline int read() {int x; FI(x); return x;}
const int MN=3e5+5;
int cnt[25],n,m; char s[25];
signed main() {
	#ifndef ONLINE_JUDGE
		freopen("pro.in","r",stdin);
		freopen("pro.out","w",stdout);
	#endif
	n=read(),m=read();
	For(i,1,n) {
		FI(s+1); int nowcnt=0;
//		cerr<<(s+1)<<endl;
		For(j,1,m) nowcnt+=s[j]-'0';
//		cerr<<nowcnt<<endl;
		cnt[nowcnt]++;
	}
	int ans=0;
	For(i,0,m) {
		For(j,i,m) {
			if((i+j)&1) {
				ans+=cnt[i]*cnt[j];
			}
		}
	}
	cout<<ans<<endl;
	return FastIO::Fflush(),0;
}
/*

*/


#include "bits/stdc++.h"
#include "random"
#include <unistd.h>

using namespace std;

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x, y) x = max(x,y)
#define chmin(x, y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i, n) for(int i = 0 ; i < n; ++i)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

int Uniform_Random(int a, int b){ // (a <= x <= b)

  random_device rd;
  mt19937 mt(rd());

  uniform_int_distribution<int> rv1(a, b);
  return rv1(mt);
}

bool check(int n){
  while(n){
    if(n % 10 == 7)
      return true;
    n /= 10;
  }
  return false;
}

bool octal(int n){
  while(n){
    if (n % 8 == 7)
      return true;
    n /= 8;
  }
  return false;
}

int main(){

  int N; cin >> N;
  set<int> st;

  for(int i = 1; i <= N; ++i){
    if(check(i)){
      st.insert(i);
      // cout << i << endl;
    }
    else if(octal(i)){
      st.insert(i);
      // cout << i << endl;
      }
  }

  cout << N - st.size() << endl;

  return 0;
}


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

typedef long long ll;
#define int long long
#define fs first
#define sc second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define MP make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef FlameDragon
    freopen("in.txt", "r", stdin);
#endif
    int n;
    cin >> n;
    int k = 5;
    vector<vector<int>> a(n, vector<int>(k));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < k; j++) {
            cin >> a[i][j];
        }
    }
    const int INF = 1e9 + 123;
    int l = 0, r = INF;
    auto check = [&](int x) -> bool {
        vector<int> cnt(1 << k);
        for (int i = 0; i < n; i++) {
            int mask = 0;
            for (int j = 0; j < k; j++) {
                if (a[i][j] >= x) {
                    mask ^= 1 << j;
                }
            }
            cnt[mask] = 1;
        }
        for (int i = 0; i < (1 << k); i++) {
            for (int j = 0; j < (1 << k); j++) {
                for (int p = 0; p < (1 << k); p++) {
                    if (cnt[i] && cnt[j] && cnt[p] && (i | j | p) == ((1 << k) - 1)) {
                        return true;
                    }
                }
            }
        }
        return false;
    };
    while (r - l > 1) {
        int mid = (l + r) / 2;
        if (check(mid)) {
            l = mid;
        } else {
            r = mid;
        }
    }
    cout << l << '\n';
}

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define deb(...)
#endif
#define endl "\n"
#define pb push_back
#define int long long
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define all(c) c.begin(),c.end()
#define read(v) for(auto &it:v) cin>>it;
const int inf = 1e18;
const int N   = 2e5 + 5;
const int mod = 1000000007;

int madd(int a, int b)
{
    return (a + b) % mod;
}
int msub(int a, int b)
{
    return (((a - b) % mod) + mod) % mod;
}
int mmul(int a, int b)
{
    return ((a % mod) * (b % mod)) % mod;
}
int mpow(int base, int exp)
{
    int res = 1;
    while (exp)
    {
        if (exp % 2 == 1)
        {
            res = (res * base) % mod;
        }
        exp >>= 1;
        base = (base * base) % mod;
    }
    return res;
}
int minv(int base)
{
    return mpow(base, mod - 2);
}
int mdiv(int a, int b)
{
    return mmul(a, minv(b));
}
int dp[N][2];
int n;
int a[N];
void test_case() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    dp[0][0] = 1;
    dp[0][1] = 0;

    dp[1][0] = 1;
    dp[1][1] = 1;
    for (int i = 2; i <= n; i++) {
        dp[i][1] = madd(dp[i - 1][0], dp[i - 1][1]);
        dp[i][0] = dp[i - 1][1];
    }
    int ans = madd(dp[n - 1][0], dp[n - 1][1]);
    ans = mmul(ans, a[1]);
    int good = madd(dp[n - 1][0], dp[n - 1][1]);
    // deb(ans)
    for (int i = 2; i <= n; i++) {

        int left = madd(dp[i - 2][0], dp[i - 2][1]);
        if (i - 2 == 0) {
            left = 1;
        }
        int right = madd(dp[n - i][0], dp[n - i][1]);
        if (n - i == 0) {
            right = 1;
        }
        // deb(left, right)
        ans = madd(ans, mmul(a[i], mmul(left, right)));

        ans = msub(ans, mmul(a[i], msub(good, mmul(left, right))));
    }
    cout << ans << endl;

}

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


//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>
#include<fstream>
#include<array>
#include<assert.h>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

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

	int N;
	cin >> N;

	int cnt[] = { 0,0,0 };
	int tk = N;
	int sum = 0;
	int d = 0;
	while (tk > 0)
	{
		d++;
		cnt[(tk % 10) % 3]++;
		sum += tk % 10;
		tk /= 10;
	}

	sum %= 3;

	if (sum == 0)cout << 0 << endl;
	else if (sum == 1)
	{
		if (d>1&&cnt[1] > 0)cout << 1 << endl;
		else if (d>2&&cnt[2] > 1)cout << 2 << endl;
		else cout << -1 << endl;
	}
	else
	{
		if (d > 1 && cnt[2] > 0)cout << 1 << endl;
		else if (d > 2 && cnt[1] > 1)cout << 2 << endl;
		else cout << -1 << endl;
	}

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1e5 + 9;
const int mod = 1e9 + 7;

int n, res = -1;
char a[20];

void solve(int idx, int sum, int cnt) {

    if (idx == n) {
        if (sum && sum%3 == 0)
            res = max(res, cnt);
        return;
    }

    solve(idx + 1, sum + (a[idx] - '0'), cnt + 1);
    solve(idx + 1, sum, cnt);
}
int main() {

    scanf("%s",a);
    n = strlen(a);
    solve(0, 0, 0);
    printf("%d", (res == -1 ? res : n - res));
    return 0;
}


#include <bits/stdc++.h>

#define int long long
#define double long double
using namespace std;

const double ESP = 1e-11;
double X, Y, R;

double dist(double u1, double v1, double u2, double v2) {
    return (u1 - u2) * (u1 - u2) + (v1 - v2) * (v1 - v2);
}

int bsl(int x) {
    int rs = ceil(Y), l = -1e9, r = floor(Y);
    while (l <= r) {
        int mid = (l + r) / 2;
        if (dist(x, mid, X, Y) <= R * R || abs(dist(x, mid, X, Y) - R * R) < ESP) {
            rs = mid;
            r = mid - 1;
        } else
            l = mid + 1;
    }
    return rs;
}

int bsr(int x) {
    int rs = floor(Y), l = ceil(Y), r = 1e9;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (dist(x, mid, X, Y) <= R * R || abs(dist(x, mid, X, Y) - R * R) < ESP) {
            rs = mid;
            l = mid + 1;
        } else
            r = mid - 1;
    }
    return rs;
}

int32_t main() {
#ifdef ACM
    freopen("input", "r", stdin);
#endif
    cin >> X >> Y >> R;
    int rs = 0, l = ceil(X - R), r = floor(X + R);
    for (int x = l; x <= r; x++) {
        int ll = bsl(x), rr = bsr(x);
        rs += rr - ll + 1;
    }
    cout << rs;
}

#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
//#define MOD 998244353LL
#define doublecout(a) cout<<setprecision(16)<<a<<endl;
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける

//123.456や-78を10000倍して整数に
ll xch(string ins){
  /////////////「.」があるかないかチェック
  int flag;
  flag=0;
  for(ll i=0;i<ins.size();i++){
    if (ins[i]=='.'){
      flag=1;
      break;
    }
  }
  if (flag==0){
    ins+=".";
  }
  /////////////「.」があるかないかチェックここまで

  ll ret=0;
  ll nm=0;
  for(ll i=0;i<ins.size();i++){
    if (nm!=0)nm--;
    if (ins[i]=='.') nm=4;/////////////////////////ここが0埋めの数になる
  }
  for(ll i=0;i<nm;i++){
    ins+="0";
  }

  for(ll i=0;i<ins.size();i++){//ここで文字→数値に変換
    if (ins[i]=='-')continue;
    if (ins[i]=='.')continue;
    ret*=10;
    ret+=ins[i]-48;
  }
  if (ins[0]=='-')ret=-ret;

  return ret;
}

//整数の割り算、割ったあまりが正の整数になるやつ
//bbbは正の数
constexpr ll floordiv(ll aaa,ll bbb)
{
  if (aaa<0){
    return (aaa-bbb+1)/bbb;
  }else{
    return aaa/bbb;
  }
}

int main(){
  ll ans=0;
  string ss0,ss1,ss2;
  cin >> ss0>>ss1>>ss2;
  ll x=xch(ss0);
  ll y=xch(ss1);
  ll r=xch(ss2);

  ll topn=y+r;
  ll rr=r*r;
  topn-=topn%10000;

  for(ll i=topn;i>=y-r;i-=10000){
    ll yy=abs(i-y);
    ll xx2=rr-yy*yy;
    if (xx2<0)continue;

    double dx=sqrt(xx2);
    ll ldx=dx;
    if (ldx*ldx>xx2)ldx--;
    ans+=floordiv(x+ldx,10000)-floordiv(x-ldx+9999,10000)+1;
  }
  cout<<ans<<endl;
  return 0;
}


//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,avx512f")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#include <memory>
#include <random>
#include <functional>
#include <complex>
#include <immintrin.h>
#ifdef DEBUG
#include "./Lib/debug_VC.hpp"
#include "./Lib/Timer.hpp"
#include "./Lib/sample.hpp"
#else
#define dump(...)
#endif

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
template<class T>
inline auto sort(T& t) { std::sort(ALL(t)); }
template<class T>
inline auto rsort(T& t) { std::sort((t).rbegin(), (t).rend()); }
template<class T>
inline auto unique(T& t) { (t).erase(unique((t).begin(), (t).end()), (t).end()); }
template<class T, class S>
inline auto chmax(T& t, const S& s) { if (s > t) { t = s; return true; } return false; }
template<class T, class S>
inline auto chmin(T& t, const S& s) { if (s < t) { t = s; return true; } return false; }
inline auto BR() { std::cout << "\n"; }

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std {
template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } };
}

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

//=============================================================================================

signed main() {
    ll n;
    cin >> n;
    VL a(n), b(n);
    cin >> a >> b;
    multiset<ll, std::greater<ll>> odd, even;
    REP(i, n) {
        ((i & 1) ? odd : even).emplace(b[i] - a[i]);
    }

    ll ans = 0;
    REPC(x, a) { ans += x; }
    dump(ans, odd, even);
    while (!odd.empty() && *odd.begin() + *even.begin() > 0) {
        ans += *odd.begin() + *even.begin();
        odd.erase(odd.begin());
        even.erase(even.begin());
    }
    cout << ans << endl;
}


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

int main()
{
	int N,W;
	cin >> N >> W;
	cout << N/W << endl;
	return 0;
}

#include<iostream>

using namespace std;

int main(){
  int32_t X{},Y{};
  cin >> X >> Y;
  if(X-Y<3 && Y-X <3){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const ll MOD = 998244353;
const double PI = 3.141592653589793238;
int main() {
  ll N;
  cin >> N;
  vector<ll> A(N), sum(N, 0), sumsum(N, 0), maxi(N, 0);
  for (ll i = 0; i < N; ++i) {
    cin >> A[i];
    sum[i] = A[i];
    if (i != 0) sum[i] += sum[i - 1];
    sumsum[i] = sum[i];
    if (i != 0) sumsum[i] += sumsum[i - 1];
    if (i != 0) maxi[i] = maxi[i - 1];
    maxi[i] = max(maxi[i], A[i]);
  }
  for (ll k = 0; k < N; ++k) {
    cout << (k + 1) * maxi[k] + sumsum[k] << "\n";
  }
}

#include <iostream>

long sum(const long &a, const long &b) {
	return (a + b) * (b - a + 1) / 2;
}

int main() {
	int t;
	std::cin >> t;
	while(t--) {
		long l, r;
		std::cin >> l >> r;
		long minc = l, maxc = r - l;
		if (minc > maxc) std::cout << 0 << '\n'; //if minimum of c > r - l, there is no such pair
		else std::cout << sum(r - l + 1 - maxc, r -	l + 1 - minc) << '\n';
	}
}


#include<bits/stdc++.h>
using namespace std;
namespace Sakurajima_Mai{
    #define ms(a) memset(a,0,sizeof(a))
    #define repi(i,a,b) for(int i=a,bbb=b;i<=bbb;++i)//attention reg int or reg ll ?
    #define repd(i,a,b) for(int i=a,bbb=b;i>=bbb;--i)
    #define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
    #define ce(i,r) i==r?'\n':' '
    #define pb push_back
    #define all(x) x.begin(),x.end()
    #define gmn(a,b) a=min(a,b)
    #define gmx(a,b) a=max(a,b)
    #define fi first
    #define se second
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double db;
    const int infi=2e9;//infi??,????inf????int
    const ll infl=4e18;
    inline ll ceil_div(ll a,ll b){ return (a+b-1)/b; }
    inline ll pos_mod(ll a,ll b){ return (a%b+b)%b; }
    //std::mt19937 rnd(time(0));//std::mt19937_64 rnd(time(0));
}
using namespace Sakurajima_Mai;
namespace Fast_Read{
    inline int qi(){
        int f=0,fu=1; char c=getchar();
        while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
        while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
        return f*fu;
    }
    inline ll ql(){
        ll f=0;int fu=1; char c=getchar();
        while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
        while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
        return f*fu;
    }
    inline db qd(){
        char c=getchar();int flag=1;double ans=0;
        while((!(c>='0'&&c<='9'))&&c!='-') c=getchar();
        if(c=='-') flag=-1,c=getchar();
        while(c>='0'&&c<='9') ans=ans*10+(c^48),c=getchar();
        if(c=='.'){c=getchar();for(int Bit=10;c>='0'&&c<='9';Bit=(Bit<<3)+(Bit<<1)) ans+=(double)(c^48)*1.0/Bit,c=getchar();}
        return ans*flag;
    }
}
namespace Read{
    #define si(a) scanf("%d",&a)
    #define sl(a) scanf("%lld",&a)
    #define sd(a) scanf("%lf",&a)
    #define ss(a) scanf("%s",a)
    #define rai(x,a,b) repi(i,a,b) x[i]=qi()
    #define ral(x,a,b) repi(i,a,b) x[i]=ql()
}
namespace Out{
    #define pi(x) printf("%d",x)
    #define pl(x) printf("%lld",x)
    #define ps(x) printf("%s",x)
    #define pc(x) printf("%c",x)
    #define pe() puts("")
}
namespace DeBug{
    #define MARK false
    #define DB if(MARK)
    #define pr(x) cout<<#x<<": "<<x<<endl
    #define pra(x,a,b) cout<<#x<<": "<<endl; \
            repi(i,a,b) cout<<x[i]<<" ";     \
            puts("");
    #define FR(a) freopen(a,"r",stdin)
    #define FO(a) freopen(a,"w",stdout)
}
using namespace Fast_Read;
using namespace Read;
using namespace Out;
using namespace DeBug;
ll a[5],m[5];
ll exgcd(ll a,ll b,ll &x,ll &y)
{
    if(!a&&!b)  return -1;
    if(!b){ x=1,y=0; return a; }
    ll d=exgcd(b,a%b,y,x);
    y-=a/b*x;
    return d;
}
ll qmul(ll a,ll b,ll mod)
{
    ll res=0; a%=mod,b%=mod;
    while(b){
        if(b&1){ res=(res+a)%mod; }
        b>>=1,a=(a+a)%mod;
    }
    return res;
}
ll excrt(ll *a,ll *m,int n)// 模m余a 注意所有m的lcm会不会爆ll
{
    ll x,y,M=m[1],ans=a[1];
    repi(i,2,n){
        ll ta=M,tb=m[i],c=(a[i]-ans%tb+tb)%tb;
        ll d=exgcd(ta,tb,x,y),bg=tb/d;
        if(c%d!=0) return infl;
        x=qmul(x,c/d,bg);
        ans+=x*M,M*=bg,ans=(ans%M+M)%M;
    }
    return (ans%M+M)%M;//最小非负解
}
int main()
{
    int T=qi();
    while(T--)
    {
         ll x=ql(),y=ql(),p=ql(),q=ql();
         ll ans=infl;
         m[1]=2*(x+y),m[2]=p+q;
         repi(i,x,x+y-1)repi(j,p,p+q-1) a[1]=i,a[2]=j,gmn(ans,excrt(a,m,2));
         if(ans==infl) puts("infinity");
         else pl(ans),pe();
    }
    return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); ++i)

ll INF = 1ll << 60;

//拡張ユークリッドの互除法
//ap+bq = gcd(a,b)となるp,qを求め、gcd(a,b)を返す
ll extGCD(ll a, ll b, ll &p, ll &q){
  if(b == 0){
    p = 1;
    q = 0;
    return a;
  }

  ll d = extGCD(b, a%b, q, p);
  q -= a/b*p;

  return d;

}

//中国剰余定理
//x≡b1(mod m1),x≡b2(mod m2)を満たすx≡r(mod lcm(m1,m2))のr, lcmを返す
pll crt(ll b1, ll b2, ll m1, ll m2){
  ll p, q;
  ll d = extGCD/*拡張ユークリッドの互除法*/(m1, m2, p, q);
  if((b2-b1)%d != 0)
    return make_pair(0, -1);
  ll m = m1*m2/d;
  ll tmp = (b2-b1)/d*p%(m2/d);
  ll r = ((b1+m1*tmp)%m+m)%m;
  return make_pair(r, m);
}

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

  rep(i, 0, t){
    ll ans = INF;
    ll x, y, p, q;
    cin >> x >> y >> p >> q;
    rep(t1, x, x+y){
      rep(t2, p, p+q){
        auto [r, lcm] = crt(t1, t2, 2*(x+y), p+q);
        if(lcm == -1)
          continue;
        if(ans > r)
          ans = r;
      }
    }
    if(ans == INF)
      cout << "infinity" << endl;
    else
      cout << ans << endl;

  }

  return 0;

}


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

typedef long long int ll;
#define All(a) (a).begin(),(a).end()
#define INF 2e18;
#define MOD 1000000007

int main(){
	ll n,m,ans,a,M=0;
	cin >> n>>m;
	vector<vector<ll>> v(n+1);
	for(ll i=0;i<n;i++){
		cin >> a;
		M=max(M,a);
		v[a].push_back(i);
	}
	for(ll i=0;i<=n;i++){
		if(v[i].empty()){
			cout << i << endl;
			return 0;
		}
		//cout << v[i].front()<<" "<<v[i].back() << endl;
		if(n-m-1>=v[i].back() || v[i].front()>=m){
				cout <<i<<endl;
				return 0;
		}
		for(auto itr=v[i].begin();itr!=v[i].end()-1;itr++){
			if(*(itr+1)-*itr>m){
				//cout<<*(itr+1)<<" "<<*itr<<endl;
				cout << i << endl;
				return 0;
			}
		}
	}
	//cout << ans << endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

constexpr int N = 800;

int dp[N + 1][N + 1];
int a[N + 1][N + 1];
int n, k;

int query(int xi, int yi, int xf, int yf) {
	return dp[xf][yf] - dp[xi - 1][yf] - dp[xf][yi - 1] + dp[xi - 1][yi - 1];
}

bool check(int x) {
	int i, j;

	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++) {
			dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + (a[i][j] <= x);
		}
	}

	for (i = 1; i + k - 1 <= n; i++) {
		for (j = 1; j + k - 1 <= n; j++) {
			if (query(i, j, i + k - 1, j + k - 1) >= (k * k + 1) / 2) {
				return true;
			}
		}
	}

	return false;
}

int main() {
	int l, r, m, i, j;
	vector<int> v;

	scanf("%d%d", &n, &k);

	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++) {
			scanf("%d", a[i] + j);
			v.push_back(a[i][j]);
		}
	}

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

	l = 0;
	r = v.size() - 1;

	while (l < r) {
		m = l + (r - l) / 2;

		if (check(v[m])) {
			r = m;
		}
		else {
			l = m + 1;
		}
	}

	printf("%d\n", v[l]);

	return 0;
}


#include<bits/stdc++.h>
#include <iterator>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll long long
#define ull long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) prllf("%lld\n",x)
#define pdd pair<dd,dd>
#define read_arr(a,n) for(ll i=1;i<=n;i++)cin>>a[i];
#define init_arr(a,n) for(ll i=1;i<=n;i++)a[i]=n-i+1;
#define prec(x) cout<<fixed<<setprecision(x)
#define fre freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
#define arr array
using namespace std;

void solve(ll tc){

	ll n;
	cin>>n;
	vector<pair<ll,string> > m(n);
	for(ll i=0;i<n;i++){
		cin>>m[i].ss>>m[i].ff;
	}

	sort(all(m));

	cout<<m[n-2].ss;

}

int main(){
//	fre;
	ll t;
	t=1;
//	cin>>t;

	ll tc=1;

	while(t--){
		solve(tc);
		tc++;
	}

}

#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<pair<int, string> > v(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i].second >> v[i].first;
    }
    sort(v.begin(), v.end());
    cout << v[n - 2].second;
    return 0;
}


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

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

const int mod = 1e9 + 7;
int dp[2][100][100];
int AB[200], *A = AB, *B = AB + 100;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M, K;
	cin >> N >> M >> K;
	rep(i, N) {
		cin >> A[i];
	}
	auto mae = dp[0], ato = dp[1];
	int are = modpow(2 * M, mod - 2);

	rep(i, M) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		if (x < y) swap(x, y);
		mae[x][x]--;
		mae[x][y]++;
		mae[y][y]--;
	}
	rep(x, N) rep(y, x + 1) {
		mae[x][y] = (ll(mae[x][y] + mod) * are + (x == y)) % mod;
		mae[y][x] = mae[x][y];
	}

	const ll ma = (1ll << 32) - 1;

	rep(i, 30) {
		if (K >> i & 1) {
			rep(i, N) {
				ll t1 = 0, t2 = 0;
				rep(j, N) {
					auto tmp = (ll)mae[i][j] * A[j];
					t1 += tmp >> 32;
					t2 += tmp & ma;
				}
				B[i] = ((t1 % mod << 32) + t2) % mod;
			}
			swap(A, B);
		}
		if (!K | i >= 31 - __builtin_clz(K)) break;
		rep(x, N) rep(y, x + 1) {
			auto tmp1 = mae[x];
			auto tmp2 = mae[y];
			ll t1 = 0, t2 = 0;
			rep(z, N) {
				auto tmp = *tmp1++ * (ll)*tmp2++;
				t1 += tmp >> 32;
				t2 += tmp & ma;
			}
			ato[y][x] = (ato[x][y] = ((t1 % mod << 32) + t2) % mod);
		}
		swap(mae, ato);
	}

	rep(i, N) co(A[i]);

	Would you please return 0;
}

// Author : heyuhhh
// Created Time : 2021/03/07 19:18:55
#include<bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 2e5 + 5, M = 17, MOD = 1e9 + 7;

inline int add(int x, int y) {
    return x + y >= MOD ? x + y - MOD : x + y;
}
inline int dec(int x, int y) {
    return x - y < 0 ? x - y + MOD : x - y;
}
inline int mul(int x, int y) {
    return 1ll * x * y % MOD;
}

string s;
int n, k;
int dp[N][M];
int cnt[M];

int trans(char t) {
    if (t >= '0' && t <= '9') {
        return t - '0';
    }
    return t - 'A' + 10;
}

void run() {
    cin >> s >> k;
    n = s.length();
    int pre = 0;
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= min(i, k); ++j) {
            if (j == 0) {
                if (i > 0) {
                    dp[i + 1][1] = add(dp[i + 1][1], 15);
                    dp[i + 1][0] = add(dp[i + 1][0], 1);
                }
            } else {
                dp[i + 1][j + 1] = add(dp[i + 1][j + 1], mul(16 - j, dp[i][j]));
                dp[i + 1][j] = add(dp[i + 1][j], mul(j, dp[i][j]));
            }
        }
        for (int t = (pre == 0); t < trans(s[i]); ++t) {
            if (++cnt[t] == 1) dp[i + 1][pre + 1] = add(dp[i + 1][pre + 1], 1);
            else dp[i + 1][pre] = add(dp[i + 1][pre], 1);
            --cnt[t];
        }
        if (++cnt[trans(s[i])] == 1) ++pre;
    }
    int ans = dp[n][k] + (pre == k);
    cout << ans << '\n';
}
int main() {
#ifdef Local
    freopen("input.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}


#ifdef _LOCAL
    #include "local_include.hpp"
#else
    #include <bits/stdc++.h>
    using namespace std;
#endif
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

#define fto(i, s, e) for (int i = (s); i <= (e); ++i)
#define fto1(i, s, e) for (int i = (s); i < (e); ++i)
#define fdto(i, s, e) for (int i = (s); i >= (e); --i)
#define fit(it, a) for (auto it = (a).begin(); it != (a).end(); ++it)
#define fat(i, a) for (auto i : (a))

#define ll long long
#define ii pair<int, int>
#define pll pair<ll, ll>
template<class T, class Cmp = less<T>> using oss = tree<T, null_type, Cmp, rb_tree_tag, tree_order_statistics_node_update>;

#define bc __builtin_popcountll
#define y1 ansdj
#define endl '\n'
#define ff first
#define ss second
#define sz(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define bug(...) _bug(cout, __VA_ARGS__)
#define buga(a, s, e) cout << '{'; if (e < s) cout << '}'; else fto (__i, s, e) cout << a[__i] << " }"[__i == e]; cout << endl

template<class T1, class T2> ostream& operator<<(ostream &os, pair<T1, T2> const &v) {
    return os << '(' << v.ff << ", " << v.ss << ')';
}

template<typename T>
void _bug(ostream &os, T const &var) { os << var << endl; }

template<typename T, typename... Args>
void _bug(ostream &os, T const &var, Args const &... args) {
    os << var << ' ';
    _bug(os, args...);
}

double const pi = acos(-1);
#define oo 1000000007
#define OO 1000000000000000003LL
int const maxn = 1e5+3;

void gcd(int a, int b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
    } else {
        gcd(b, a%b, x, y);
        ll tmp = x;
        x = y;
        y = tmp - a/b*y;
    }
}

#define multi_test 1
void _main() {
    int n, s, k;
    cin >> n >> s >> k;
    int g = __gcd(n-s, __gcd(n, k));
    n /= g, s /= g, k /= g;
    g = __gcd(k, n);
    if (g != 1) bug(-1);
    else {
        ll x, y;
        gcd(k, n, x, y);
        x *= (n-s);
        x %= n;
        if (x < 0) x += n;
        bug(x);
    }
}

int main() {
    #ifdef _LOCAL
        freopen("main.inp", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int t = 1;
    if (multi_test) cin >> t;
    while (t--) {
        _main();
    }

    #ifdef _LOCAL
        cerr << 0.001*clock() << endl;
    #endif
    return 0;
}

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rrep(i,n) for(ll i=n-1; i>=0; i--)
#define fi first
#define se second
#define pcnt __builtin_popcountll
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
string zero_padding(int val, int nf){ ostringstream sout;sout << setfill('0') << setw(nf) << val; return sout.str();};
const ld eps = 1e-10;
ull mo = 1000000007;
ld PI=asin(1)*2;
//using namespace atcoder;

vector<vector<PlP>> G(100010);
int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> A(M), B(M), C(M), D(M);
    rep(i,M){
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        A[i]--; B[i]--;
    }
    rep(i,M){
        G[A[i]].push_back({C[i],{D[i],B[i]}});
        G[B[i]].push_back({C[i],{D[i],A[i]}});
    }
    vector<ll> d1(N,1e18);
    priority_queue<Pll, vector<Pll>, greater<Pll>> que;
    que.push(Pll(0,0));
    while(!que.empty()){
        ll t = que.top().fi;
        ll v = que.top().se;
        que.pop();
        if(d1[v] <= t) continue;
        //if(d1[v] != 1e18) continue;
        d1[v] = t;
        for(auto& p:G[v]){
            ll c = p.fi;
            ll d = p.se.fi;
            ll u = p.se.se;
            ll rd1 = max(ll(sqrt(ld(d))-1),ll(t));
            ll rd2 = max(ll(sqrt(ld(d))),ll(t));
            ll tt1 = ll(rd1) + c + ll(d/(rd1+1));
            ll tt2 = ll(rd2) + c + ll(d/(rd2+1));
            // cout << L << " " << R << " " << r1 << " " << r2 << endl;

            que.push(Pll(min(tt1,tt2),u));
        }
    }
    if(d1[N-1] == 1e18){
        drop(-1);
    }
    cout << d1[N-1] << endl;
}


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

void solve(){
	long double r,x,y;
	cin>>r>>x>>y;
	long double d=sqrt(x*x+y*y);
	if(d==r)cout<<1;
	else if(d<=r+r)cout<<2;
	else cout<<ceil(d/r);
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

#include <bits/stdc++.h>
using namespace std;
//const long nPrime = 1000000007;
//const long nPrime = 998244353;
int main() {
    long r,x,y;
    cin >> r >> x >> y;
    if(x*x+y*y == r*r){
        cout << "1" << endl;
        return 0;
    }
    long nSq = (x*x+y*y+r*r-1) / (r*r);
    long nAns = long(sqrt(double(nSq)));
    if(nAns * nAns < nSq){
        nAns++;
    }
    nAns = max(nAns , 2L);
    cout << nAns << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000030;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;
typedef pair<int,P> PP;

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

ll mod(ll val, ll M) {
    val = val % M;
    if(val < 0) {
        val += M;
    }
    return val;
}

template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

int dp[1010][1010];

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    vector<int> B(M);
    for(int i = 0;i < N;i++) {
        cin >> A.at(i);
    }
    for(int i = 0;i < M;i++) {
        cin >> B.at(i);
    }
    for(int i = 0;i <= N;i++) {
        for(int j = 0;j <= M;j++) {
            dp[i][j] = 0;
        }
    }
    for(int i = 0;i <= N;i++) {
        dp[i][0] = i;
    }
    for(int i = 0;i <= M;i++) {
        dp[0][i] = i;
    }
    for(int i = 1;i <= N;i++) {
        for(int j = 1;j <= M;j++) {
            int c = 0;
            if(A.at(i - 1) != B.at(j - 1)) c = 1;
            dp[i][j] = min({dp[i - 1][j] + 1,dp[i][j - 1] + 1,dp[i - 1][j - 1] + c});
        }
    }
    cout << dp[N][M] << endl;
}

/*ver 7*/
#include <bits/stdc++.h>
using namespace std;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
using pll = pair<ll,ll>;
using mll = map<ll,ll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
#define each(x,v) for(auto& x : v)
#define reps(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
const ll INF = 1LL << 60;
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<=b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){}
template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
template <typename T> void in1(T &s) {rep(i,s.size()){in(s[i]);}}
template <typename T> void in2(T &s,T &t) {rep(i,s.size()){in(s[i],t[i]);}}
template <typename T> void in3(T &s,T &t,T &u) {rep(i,s.size()){in(s[i],t[i],u[i]);}}
template <typename T> void in4(T &s,T &t,T &u,T &v) {rep(i,s.size()){in(s[i],t[i],u[i],v[i]);}}
template <typename T> void in5(T &s,T &t,T &u,T &v,T &w) {rep(i,s.size()){in(s[i],t[i],u[i],v[i],w[i]);}}
void out(){cout << endl;}
template <typename T,class... U> void out(const T &t,const U &...u){cout << t; if(sizeof...(u)) cout << " "; out(u...);}
void die(){cout << endl;exit(0);}
template <typename T,class... U> void die(const T &t,const U &...u){cout << t; if(sizeof...(u)) cout << " "; die(u...);}
template <typename T> void outv(T s) {rep(i,s.size()){if(i!=0)cout<<" ";cout<<s[i];}cout<<endl;}
template <typename T> void out1(T s) {rep(i,s.size()){out(s[i]);}}
template <typename T> void out2(T s,T t) {rep(i,s.size()){out(s[i],t[i]);}}
template <typename T> void out3(T s,T t,T u) {rep(i,s.size()){out(s[i],t[i],u[i]);}}
template <typename T> void out4(T s,T t,T u,T v) {rep(i,s.size()){out(s[i],t[i],u[i],v[i]);}}
template <typename T> void out5(T s,T t,T u,T v,T w) {rep(i,s.size()){out(s[i],t[i],u[i],v[i],w[i]);}}
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
template <typename T> T allSum(vector<T> a){T ans=T();each(it,a)ans+=it;return ans;}
ll ceilDiv(ll a,ll b) {return (a+b-1)/b;}
ld dist(pair<ld,ld> a, pair<ld,ld> b){return sqrt(abs(a.fi-b.fi)*abs(a.fi-b.fi)+abs(a.se-b.se)*abs(a.se-b.se));} // ２点間の距離
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
#define YES(n) ((n) ? "YES" : "NO"  )
#define Yes(n) ((n) ? "Yes" : "No"  )
#define yes(n) ((n) ? "yes" : "no"  )

int main(){
  init();
  inl(n);
  out(n-1);
  return 0;
}


#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=(ll)(n)-1; i>=0; --i)
inline constexpr ll Inf = (1ULL << 60) -123456789;
#define fastio cin.tie(0); ios_base::sync_with_stdio(false); cout<<fixed<<setprecision(10);
#define newl '\n'
#define YN(e) ((e)?"Yes":"No")
#define all(a) begin(a),end(a)
#define rall(a) rbegin(a),rend(a)
#define delif(c,pred) (c).erase(remove_if(all(c),(pred)), end(c))
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) cerr << #a << ": " << a << endl;
#define dbgs(s) cerr << #s << endl;
#define dbg1(a,n) cerr<<#a<<": "; rep(i,n) cerr<<a[i]<<" "; cerr<<endl;
#define dbg2(m,h,w) cerr<<#m<<":"<<endl; rep(i,h){ rep(j,w)cerr<<m[i][j]<<" "; cerr<<endl; }
template <class T, class U> ostream& operator << (ostream& os, pair<T,U> v) {os<<v.first<<","<<v.second;return os;}
template <class T, size_t N> ostream& operator << (ostream& os, array<T,N> v) {rep(i,N)os<<v[i]<<(i+1<(ll)N?" ":"");return os;}
int rng(int n) { return rand()/(RAND_MAX+1.0)*n; }

using P = pair<ll,ll>;
ll a[505][505], b[505][505];
int main() {
    fastio;
    ll r,c;
    cin >> r >> c;
    auto z = [&](ll v, ll h, ll f=0)->ll { return f*r*c + v*c + h; };
    auto rz = [&](ll p)->array<ll,3> { return {p%(r*c)/c, p%c, p/(r*c)}; };
    rep(i,r) rep(j,c-1) cin >> a[i][j];
    rep(i,r-1) rep(j,c) cin >> b[i][j];
    priority_queue<P,vector<P>, greater<>> q;
    vector<ll> cost(r*c*2, Inf);
    q.push({0,z(0,0)});
    cost[z(0,0)] = 0;
    while (!q.empty()) {
        auto [co,p] = q.top(); q.pop();
        auto [v,h,f] = rz(p);
        if (co != cost[p]) continue;
        auto push = [&, co=co](ll nc, ll np) { if (updmin(cost[np], co+nc)) q.push({co+nc,np}); };
        if (f == 0) {
            if (h < c-1) push(a[v][h], z(v,h+1,0));
            if (h > 0) push(a[v][h-1], z(v,h-1,0));
            if (v < r-1) push(b[v][h], z(v+1,h,0));
            if (v > 0) push(1, z(v,h,1));
        } else {
            if (v < r-1) push(0, z(v,h,0));
            if (v > 0) push(1, z(v-1,h,1));
        }
    }
    ll ans = cost[z(r-1,c-1,0)];
    cout << ans << endl;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debugF(cerr, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

class Dijkstra{
public:
    static vl solve(vector<vector<pii>> &g, int s, int target = -1){
        //g[v] = list of (u,w) , where v->u with weight w.
        int n = g.size();
        assert(s >= 0 && s < n);

        vl dist(n, -1);
        vector<bool> used(n, false);
        set<pair<ll,int>> S;
        S.insert({0,s});

        while(!S.empty()){
            auto min_data = *S.begin();
            S.erase(S.begin());

            ll min_dist = min_data.first;
            int v = min_data.second;
            dist[v] = min_dist;
            used[v] = true;

            if(target == v)
                break;

            for(auto u_data : g[v]){
                int u = u_data.first;
                int w = u_data.second;
                if(w < 0){
                    throw new invalid_argument("graph with negative edges");
                }
                if(used[u])
                    continue;
                if(dist[u] == -1 || (dist[v]+w < dist[u])){
                    if(dist[u] != -1)
                        S.erase({dist[u],u});
                    dist[u] = dist[v] + w;
                    S.insert({dist[u],u});
                }
            }
        }
        return dist;
    }
};

void solve(){
    int n, m, i, j, u, v;
    cin >> n >> m;

    auto getI = [&](int i, int j, bool flag){
        int idx = i*m + j;
        if(flag) idx += n*m;
        return idx;
    };

    int N = 2*n*m;
    vector<vector<pii>> g(N);
    for(i=0;i<n;i++){
        for(j=0;j<m-1;j++){
            int a; cin >> a;
            u = getI(i,j,false);
            if(j+1 < m){
                v = getI(i,j+1,false);
                g[u].push_back({v, a});
                g[v].push_back({u, a});
            }
        }
    }
    for(i=0;i<n-1;i++){
        for(j=0;j<m;j++){
            int b; cin >> b;
            u = getI(i,j,false);
            int uu = getI(i,j,true);
            if(i+1 < n){
                v = getI(i+1,j,false);
                g[u].push_back({v, b});
                int vv = getI(i+1,j,true);
                g[vv].push_back({uu,1});
            }
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            u = getI(i,j,false);
            int uu = getI(i,j,true);
            g[u].push_back({uu, 1});
            g[uu].push_back({u, 0});
        }
    }

    int sv = getI(0,0,false);
    int tv = getI(n-1, m-1, false);
    auto ans = Dijkstra::solve(g, sv, tv);
    cout << ans[tv] << "\n";
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int nt = 1;
    for(int tt=1;tt<=nt;tt++){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)
		cout << (int)log2(2 * i) << ' ';
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const double pi = acos(-1.0);
typedef long long ll;

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

    int n;
    cin >> n;
    int  ans = 0;
    for(int i = 1; i <= n; i++) {
        int a = i;
        bool ok = true;
        while(a > 0) {
            int b = a % 10;
            if(b == 7) {
                ok = false;
            }
            a = a / 10;
        }
        int c = i;
        while(c > 0) {
            int d = c % 8;
            if(d == 7) {
                ok = false;
            }
            c = c / 8;
        }
        if(ok) {
            ans++;
        }
    }
    cout << ans << endl;
}


#include<iostream>
#include<cstring>
#include<vector>
#include<queue>

using namespace std;

const int N = 1e3 + 10;

int n,m;

vector<int>v[N][30];
int mp[N][N];

int dist[N][N];

struct node{
    int x,y,sum;
    bool operator < (const node &p)const{
        return sum > p.sum;
    }
};

int flag[N][N],ans = 0x3f3f3f3f;
void dij(){
    memset(dist,0x3f,sizeof dist);
    priority_queue<node>q;
    q.push({1,n,0});
    dist[1][n] = 0;
    while(q.size()){
        node p = q.top();
        q.pop();
        if(flag[p.x][p.y]) continue;
        flag[p.x][p.y] = 1;
        if(p.x == p.y){
            ans = min(ans,dist[p.x][p.y]);
        }
        if(mp[p.x][p.y]) ans = min(ans,dist[p.x][p.y] + 1);
        for(int i = 0; i <= 25; i++){
            for(auto j : v[p.x][i]){
                for(auto k : v[p.y][i]){
                    if(dist[j][k] > dist[p.x][p.y] + 2){
                        dist[j][k] = dist[p.x][p.y] + 2;
                        q.push({j,k,dist[j][k]});
                    }
                }
            }
        }
    }
}

int main(){
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int a,b;char c;
        scanf("%d %d %c",&a,&b,&c);
        v[a][c - 'a'].push_back(b);
        v[b][c - 'a'].push_back(a);
        mp[a][b] = 1;
        mp[b][a] = 1;
    }

    dij();

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

    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 per(i, n) for(int i = (n)-1; i >= 0 ; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#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;
using P = pair<int, int>;
//using mint = modint1000000007;

void Main() {
	cin(int, n);
	vector<ll> op = { 0ll, -1ll*(1ll<<50), 1ll << 50 };
	int lo = 2;
	rep(i, n) {
		cin(ll, a, t);
		if (t == 1ll) {
			op[0] += a;
			op[1] += a;
			op[2] += a;
		}
		else if (t == 2ll) {
			chmax(op[1], a);
			chmax(op[2], a);
			lo = 2;
		}
		else if (t == 3ll) {
			chmin(op[1], a);
			chmin(op[2], a);
			lo = 3;
		}
	}
	cin(int, q);
	while (q--) {
		cin(ll, x);
		if(lo==2)	print(max(op[1], min(op[2],x + op[0])));
		else print(min(op[2], max(op[1],x + op[0])));
	}
}

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;

bool check(string s) {
	int n = s.length();
	for (int i = 0, j = n - 1; i < n; ++i, --j)
		if (s[i] ^ s[j])
			return false;
	return true;
}

signed main() {
	string s;
	cin >> s;

	for (int i = 0; i < 20; ++i) {
		if (check(s)) {
			cout << "Yes" << '\n';
			system("pause");
			return 0;
		}
		s = "0" + s;
	}
	puts("No");
	return 0;
}

//#include <tourist>
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

typedef pair<ll, ll> p;
const int INF = 1e9;
const double eps = 1e-7;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const long double pi = 4 * atan(1);
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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 <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (T &x : v)
        is >> x;
    return is;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//g++ yarudake.cpp -std=c++17 -I .
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
bool check(string s)
{
    rep(i, s.size() / 2)
    {
        if (s[i] != s[s.size() - 1 - i])
            return false;
    }
    return true;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    reverse(ALL(s));
    if (check(s))
        return yes, 0;
    for (int i = 0; i < 10; i++)
    {
        s.push_back('0');
        if (check(s))
            return yes, 0;
    }
    no;
}


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

int main() {
  char S, T;
  cin >> S;
  cin >> T;

  if(S=='Y') cout << char(T-32) << endl;
  else cout << T << endl;
  return 0;
}

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

int main(){
    int a,b; cin>>a>>b;
    cout << (a+b)/2 << " " << (a-b)/2 << endl;
}


#include <bits/stdc++.h>

typedef long long LL;

const int MAXN = 1e5 + 10;

int n, m;
int a[MAXN], b[MAXN];

int main() {
	scanf("%d", &n), m = n >> 1;
	for (int i = 1; i <= n; ++i) scanf("%d", a + i);
	for (int i = 1, x; i <= n; ++i) {
		scanf("%d", &x);
		if (i & 1) b[i / 2 + 1] = x - a[i];
		else b[i / 2 + m] = x - a[i];
	}
	std::sort(b + 1, b + m + 1), std::sort(b + m + 1, b + n + 1);
	LL sum = std::accumulate(a + 1, a + n + 1, 0LL);
	for (int i = 1; i <= m; ++i) sum += std::max(b[i] + b[i + m], 0);
	printf("%lld\n", sum);
	return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pi;

string s;
int n, m;

ll odd, even;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    odd = 0, even = 0;
    cin >> n >> m;
    for(int i = 1;i <= n;i++){
        cin >> s;
        int cnt = 0;
        for(int i = 0;i < s.length();i++){
            cnt += s[i] - '0';
        }
        if(cnt & 1){
            odd++;
        }else{
            even++;
        }
    }
    cout << odd * even << endl;
    return 0;
}


//oct 10,2020
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define int                     long long
#define double                  long double
#define endl                    "\n"
#define pb                      push_back
#define PI                      3.1415926535897932384626433832795l
#define F                       first
#define S                       second
#define mp                      make_pair
#define f(i,n)                  for(int i=0;i<n;i++)
#define loop(i,a,b)             for(int i=a;i<b;i++)
#define fastio                  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)                  (v).begin(),(v).end()
#define rall(v)                 (v).rbegin(),(v).rend()
#define gcd(a,b)                __gcd((a),(b))
#define fill(a,value)           memset(a,value,sizeof(a));
#define minn(v)                 *min_element(v.begin(), v.end());
#define maxx(v)                 *max_element(v.begin(), v.end());
#define print(x)                cout<<(x)<<endl;
#define sum(v)+x                accumulate(v.begin(), v.end(),x);
#define debug(x)                cout<<#x<<'='<<(x)<<endl;
typedef pair<int,int>           pii;
typedef vector<int>             vi;
const int mod=1e9+7;
const int MOD=998244353;

signed main()
{
    char s;
    cin>>s;
    char t;
    cin>>t;
    if(s=='Y')print((char)toupper(t))
    else print(t)

	return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double lf;
typedef long double Lf;
typedef pair<int, int> pii;

const int maxn = 2e5 + 5;

int n, m;
int a[maxn], b[maxn];

class Dsu{
public:
	int fa[maxn];
	ll f[maxn], g[maxn];
	inline int find(int x){ return (x == fa[x] ? x : (fa[x] = find(fa[x]))); }
	inline void init(){
		FOR(i, 0, maxn)
			fa[i] = i, f[i] = a[i], g[i] = b[i];
		return;
	}
	inline void merge(int u, int v){
		u = find(u); v = find(v);
		if(u == v)
			return;
		f[v] += f[u];
		g[v] += g[u];
		fa[u] = v;
		return;
	}
}dsu;

int main(){
	scanf("%d%d", &n, &m);
	FOR(i, 0, n)
		scanf("%d", a + i);
	FOR(i, 0, n)
		scanf("%d", b + i);

	dsu.init();

	FOR(i, 0, m){
		int u, v;
		scanf("%d%d", &u, &v); --u; --v;
		dsu.merge(u, v);
	}

	FOR(i, 0, n) if(dsu.find(i) == i && dsu.f[i] != dsu.g[i]){
		puts("No");
		return 0;
	}

	puts("Yes");
	return 0;
}


/*
 * Author: Moon-light
 * 并查集的启发式合并优化
 * 因为这里使用的是按集合大小合并，所以可以加上路径压缩
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define lowbit(x) ((x)&(-x))
#define sz(x) ((int)x.size())
#define fr(x) freopen(x,'r',stdin)
#define fw(x) freopen(x,'w',stdout)
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) begin(a),end(a)
#define bitcnt(x) (__builtin_popcountll(x))
#define rep(i,a,b) for(int i = (a);i<=(b); ++i)
#define per(i,a,b) for(int i = (a);i>=(b); --i)
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VB;
typedef double db;

template <class T> void clear(T& a) { T().swap(a);}
template <class T,class S>
inline bool upmin(T& a,const S&b){ return a>b ? a=b,1:0;}
template <class T,class S>
inline bool upmax(T&a, const S&b){ return a<b? a=b,1:0;}

//fast read(improved by fread)
char buf[1<<21],*p1=buf,*p2=buf;
inline int getc(){
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;
}
inline int redi() {
    int ret = 0,f = 0;char ch = getc();
    while (!isdigit (ch)) {
        if (ch == '-') f = 1;
        ch = getc();
    }
    while (isdigit (ch)) {
        ret = ret * 10 + ch - 48;
        ch = getc();
    }
    return f?-ret:ret;
}

//global variable
const int N = 2e5+100;
const int mod = 1e9+7;
int n,q;
int p[N];
int a,b,op;
unordered_map<int,int> cs[N];
//functions
LL qmi(LL a,LL k,LL mod){
    LL res = 1;
    while(k){
        if(k&1) res = res*a%mod;
        k >>= 1;
        a = a*a%mod;
    }
    return mod;
}
int gcd(int a,int b) {
    return b==0? a:gcd(b,a%b);
}

int find(int x){
    if(p[x] != x){
        p[x] = find(p[x]);
    }
    return p[x];
}

void merge(int x,int y){
    int fa = find(x);
    int fb = find(y);
    if(fa == fb) return ;

    //小集合并到大集合上去
    if(cs[fa].size() > cs[fb].size()){
        swap(fa,fb);
    }
    p[fa] = fb;
    for(auto &x:cs[fa]){
        cs[fb][x.first] += x.second;
    }

}
//

//code from here! Come on! Have a pleasant experience~
int main()
{
    IO;
    cin>>n>>q;

    int c;
    rep(i,1,n){
        cin>>c;
        cs[i][c] ++;
        p[i] = i;
    }

    rep(i,1,q){
        cin>>op>>a>>b;
        if(op == 1){
            merge(a,b);
        }else{
            int f = find(a);
            cout<<cs[f][b]<<endl;
        }
    }
    return 0;
}

#include<cstdio>
#include<cctype>

#define maxn 202202

inline int read(){
	int r=0,f=0;
	char c;
	while(!isdigit(c=getchar()))f|=(c=='-');
	while(isdigit(c))r=(r<<1)+(r<<3)+(c^48),c=getchar();
	return f?-r:r;
}

inline char get_c(){
	char c;
	while(!isalpha(c=getchar()));
	return c;
}

int n,m,f[maxn],rt[maxn];

int find(int x){
	return x^f[x]?f[x]=find(f[x]):x;
}

struct val_seg{

	#define ls(p) tr[p].ls
	#define rs(p) tr[p].rs
	#define cnt(p) tr[p].cnt

	struct TR{
		int ls,rs,cnt;
	}tr[maxn<<6];

	int tot;

	inline int new_tr(){return ++tot;}

	void add(int p,int x,int l,int r){
		if(l==r){
			cnt(p)++;
			return;
		}
		int mid=(l+r)>>1;
		if(x<=mid){
			if(!ls(p))ls(p)=new_tr();
			add(ls(p),x,l,mid);
		}
		else {
			if(!rs(p))rs(p)=new_tr();
			add(rs(p),x,mid+1,r);
		}
	}

	int merge(int x,int y,int l,int r){
		if(!x||!y)return x+y;
		if(l==r){
			cnt(x)+=cnt(y);
			return x;
		}
		int mid=(l+r)>>1;
		ls(x)=merge(ls(x),ls(y),l,mid);
		rs(x)=merge(rs(x),rs(y),mid+1,r);
		return x;
	}

	int query(int p,int l,int r,int pos){
		if(!p)return 0;
		if(l==r)return cnt(p);
		int mid=(l+r)>>1;
		if(pos<=mid)return query(ls(p),l,mid,pos);
		return query(rs(p),mid+1,r,pos);
	}

	inline int ask(int p,int k){
		if(cnt(p)<k)return 0;
		return query(p,k,1,n);
	}

	#undef ls
	#undef rs
	#undef cnt

}v_s;

inline int get_new(){return v_s.new_tr();}

inline void Union(int u,int v){
	int fu=find(u),fv=find(v);
	if(fu==fv)return;
	f[fv]=fu;
	rt[fu]=v_s.merge(rt[fu],rt[fv],1,n);
}

int main(){
	n=read(),m=read();
	for(int i=1;i<=n;i++){
		int x=read();
		f[i]=i;
		rt[i]=get_new();
		v_s.add(rt[i],x,1,n);
	}
	for(int i=1;i<=m;i++){
		int opt=read(),x=read(),y=read();
		if(opt==1)Union(x,y);
		else printf("%d\n",v_s.query(rt[find(x)],1,n,y));
	}
	return 0;
}


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

#define faster      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi          acos(-1.0)
#define nl          '\n'

///Library
#define mem(a,b)    memset(a,b,sizeof(a))
#define all(a)      a.begin(),a.end()
#define Sort(x)     sort(x.begin(),x.end())
#define Reverse(x)  reverse(x.begin(),x.end())
#define SortA(ar,s) sort(ar,ar+s)
#define SortD(ar,s) sort(ar,ar+s,greater<int>())
#define gcd(a,b)    __gcd(a,b)
#define lcm(a,b)    (a*(b/gcd(a,b)))
#define sq(x)       (x)*(x)

#define for0(a, n)      for(int i=a; i<n; i++)
#define for1(a, n)      for(int i=a; i<=n; i++)
#define rfor0(n, a)     for(int i=n-1; i>=a; i--)
#define rfor1(n, a)     for(int i=n; i>a; i--)

#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min(b,min(c,d)))
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max(b,max(c,d)))
#define ABS(x)             ((x)<0?-(x):(x))
#define pb                 push_back
#define mod                1000000007
#define end                printf("\n")
#define yes                printf("YES\n")
#define no                 printf("NO\n")

///data type
typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<n-a+b<<nl;
    return 0;
}

//Pradeep_7
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#define IO ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define tc(x) int x; cin >> x; for(int tt=1;tt<=x;tt++)
#define int long long int
using namespace std;
class Input
{
public:
	Input()
	{
		IO;
	}
};
Input setup;
int32_t main()
{
	int n,a,b;
	cin>>n>>a>>b;
	cout<<(n-a)+b;

}


#include<fstream>
#include<iostream>
#include<sstream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    long long m;
    string x;

    cin >> x >> m;

  if(x.size() == 1){
    if(stoi(x)<=m){
      cout << 1 << endl;
    }
    else{
      cout << 0 << endl;
    }
    return 0;
  }

  int d = 0;
  for(auto t: x) d = max(int(t-'0'),d);

  long long left = d;
  long long right = m+1;

  while(right-left>1){
    long long mid = (left + right)/2;
    long long v = 0;

    for(auto c:x){
      if(v > m/mid) v = m + 1;
      else v = v*mid + (c-'0');
    }
    if(v <= m) left = mid ;
    else right = mid ;
  }

  cout << left - d << endl;

  return 0;
}

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

int main(void){
    int N;
    string S;

    cin >> N;
    cin >> S;

    int sum{0};

    vector<vector<int>> nums(4,vector<int>(N+1, 0));

    for(int i{0}; i<N; ++i){
        nums[0][i+1] = nums[0][i];
        nums[1][i+1] = nums[1][i];
        nums[2][i+1] = nums[2][i];
        nums[3][i+1] = nums[3][i];
        if(S.at(i)=='A'){
            ++nums[0][i+1];
        }
        else if(S.at(i)=='T'){
            ++nums[1][i+1];
        }
        else if(S.at(i)=='C'){
            ++nums[2][i+1];
        }
        else if(S.at(i)=='G'){
            ++nums[3][i+1];
        }
    }

    for(int is{0}; is<N-1; ++is){
        for(int ie{is+2}; ie<=N; ie+=2){
            int num_A = nums[0][ie] - nums[0][is];
            int num_T = nums[1][ie] - nums[1][is];
            int num_C = nums[2][ie] - nums[2][is];
            int num_G = nums[3][ie] - nums[3][is];
            if(num_A == num_T and num_C == num_G){
                ++sum;
            }
        }
    }

    cout << sum << endl;
}


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

int main(){
   long long n;
   cin>>n;
   long long a=0;
   for(long long i=0;i<n;i++){
    long long s;
    cin>>s;
    if(s>10){
        s=s-10;
        a+=s;
    }
   }
   cout<<a<<endl;
    return 0;
}

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

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

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int n; cin >> n;
    vector<ll> x(n);
    rep (i, n) cin >> x[i];

    ll tmp = 0;

    rep (i, n) tmp += abs(x[i]);
    cout << tmp << endl;

    tmp = 0;
    rep (i, n) tmp += x[i]*x[i];
    cout << sqrtf64x(tmp) << endl;

    tmp = 0;
    rep (i, n) tmp = max(tmp, abs(x[i]));
    cout << tmp << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <fstream>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define x first
#define y second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cerr << #x << ": " << x << '\n';
#define FOR(i, n) for (int i = 0; i < n; ++i)
#define FORN(i, n) for (int i = 1; i <= n; ++i)
#define pb push_back
#define trav(a, x) for (auto& a : x)
using vi = vector<int>;
template <typename T>
std::istream& operator >>(std::istream& input, std::vector<T>& data)
{
    for (T& x : data)
        input >> x;
    return input;
}
template <typename T>
std::ostream& operator <<(std::ostream& output, const pair <T, T> & data)
{
    output << "(" << data.x << "," << data.y << ")";
    return output;
}
template <typename T>
std::ostream& operator <<(std::ostream& output, const std::vector<T>& data)
{
    for (const T& x : data)
        output << x << " ";
    return output;
}
ll div_up(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll div_down(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down
ll math_mod(ll a, ll b) { return a - b * div_down(a, b); }
#define tcT template<class T
#define tcTU tcT, class U
tcT> using V = vector<T>;
tcT> void re(V<T>& x) {
    trav(a, x)
        cin >> a;
}
tcT> bool ckmin(T& a, const T& b) {
    return b < a ? a = b, 1 : 0;
} // set a = min(a,b)
tcT> bool ckmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0;
}
ll gcd(ll a, ll b) {
    while (b) {
        tie(a, b) = mp(b, a % b);
    }
    return a;
}
signed main() {
    #ifdef LOCAL
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n;
    cin >> n;
    vi a(2 * n);
    cin >> a;
    vi sign(2 * n);
    V <ii> ord;
    FOR (i, 2 * n) {
        ord.app(mp(a[i], i));
    }
    sort(all(ord));
    FOR (i, n) {
        sign[ord[i].y] = -1;
    }
    FOR (i, n) {
        sign[ord[i + n].y] = 1;
    }
    string ans;
    vi S;
    trav (e, sign) {
        if (S.empty() || S.back() == e) {
            ans += '(';
            S.app(e);
        }
        else {
            ans += ')';
            S.pop_back();
        }
    }
    assert(S.empty());
    cout << ans << endl;
}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <set>
#include <sstream>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define debug(s, param) std::cerr << s << param << std::endl;

using namespace std;
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;

const int INF = 1e9;
const ll INFL = 1e18;
const ll MOD = 1000000007;

// https://atcoder.jp/contests/abc196/tasks/abc196_c

int main() {
  ll n; cin >> n;
  int ans = 0;
  reps (i, 1, 1000001) {
    ll digit = (ll)floor(log10(i)) + 1;
    ll num = i * pow(10, digit) + i;
    if (num > n) break;
    ++ans;
  }
  cout << ans << endl;
  return 0;
}


#include <iostream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <deque>
#include <bitset>
#include <list>
using namespace std;
#define pp pair<long long,long long>
#define f first
#define s second
#define ppp pair<pair<long long,long long>,long long>
#define pb push_back
#define ll long long
pp arr[2010],barr[2010];
int main() {
	ll t,n,i,j,k,l;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	ll ans=1e6;
	for (i=1;i<=n;i++) {
		cin>>arr[i].f>>barr[i].f;
		arr[i].s=i;barr[i].s=i;
		ans=min(ans,arr[i].f+barr[i].f);
	}
	sort(arr+1,arr+n+1);
	sort(barr+1,barr+n+1);
	if (arr[1].s==barr[1].s) {
		ans=min(ans,max(arr[1].f,barr[2].f));

		ans=min(ans,max(arr[2].f,barr[1].f));
	} else {
		ans=min(ans,max(arr[1].f,barr[1].f));
	}
	cout<<ans<<'\n';
	return 0;
}

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using graph = vector<vector<int>>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    vll a(n), b(n);
    ll ans = inf;
    REP(i, n){
        cin >> a[i] >> b[i];
    }
    REP(i, n){
        REP(j, n){
            if(i != j){
                ans = min(ans, max(a[i], b[j]));
            }else{
                ans = min(ans, a[i] + b[j]);
            }
        }
    }

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


#include <iostream>
#include <cmath>

using namespace::std;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int a, b, x, y;
	cin >> a >> b >> x >> y;
	int dif = a - b;
	int t = 0;
	if (dif > 0) {
		t += x;
		t += min(y, 2*x) * (dif - 1);
	}
	else if (dif < 0) {
		t += x;
		t += min(y, 2*x) * (-dif);
	}
	else {
		t += x;
	}
	cout << t;
	return 0;
}

#include <algorithm>
// #include <atcoder/all>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
constexpr double PI = 3.141592653589793;
constexpr int INF = 1e9 + 10;
constexpr ll INFL = 1e18 + 10;

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 <typename T>
void dump(const std::vector<T> &ar) {
  for (T e : ar) {
    std::cout << e << "\n";
  }
}

template <typename T>
void dump(const std::set<T> &s) {
  for (T e : s) {
    std::cout << e << " ";
  }
  std::cout << "\n";
}

using namespace std;
// using namespace atcoder;
// cout << setprecision(20) << ans << "\n";

template <typename T>
void print(T ans) {
  cout << ans << "\n";
}

template <>
void print(double ans) {
  cout << setprecision(20) << ans << "\n";
}

ll getDigit(ll x) { return log10(x) + 1; }

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

  int a, b, x, y;
  cin >> a >> b >> x >> y;

  vector<int> atower(110, INF), btower(110, INF);
  if (a == b) {
    cout << x << "\n";
    return 0;
  }
  if (a > b) {
    atower[a] = 0;
    btower[a] = x;
    for (int i = a; i > b - 1; --i) {
      btower[i - 1] = min(atower[i] + x, btower[i] + y);
      atower[i - 1] = min(atower[i] + y, btower[i - 1] + x);
    }
    cout << btower[b] << "\n";
    return 0;
  }

  atower[a] = 0;
  btower[a] = x;
  for (int i = a; i < b + 1; i++) {
    atower[i + 1] = min(atower[i] + y, btower[i] + x);
    btower[i + 1] = min(atower[i + 1] + x, btower[i] + y);
  }
  cout << btower[b] << "\n";

  return 0;
}


#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
#define pll pair<ll , ll >
#define all(x) (x).begin(),(x).end()
#define SZ(x) (ll)(x).size()
#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}
const int maxn = 1000*100+5 ;
const ll inf = 9223372036854775807 ;
const ll mod = 1e9 + 7 ;
const int lg = 20 ;

int main()
{
	migmig ;
	ll v ,  t , s , d ;
	cin>>v>>t>>s>>d ;
	if(d < t * v || d > s * v){
		cout<<"Yes" ;
	}else cout<<"No" ;
}

  #include<bits/stdc++.h>
  using namespace std;
  using ll = long long;
  #define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
  #define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
  #define repc(i,f,n) for(char i=(f); (i) <= (n); i++)
  #define PI 3.14159265358979323846264338327950L
  #define debug(x) cout<<#x<<" :: "<<x<<"\n";
  #define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
  #define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
  #define P pair<int, int>
  #define Pl pair<ll, ll>
  #define dvec vector<vector<ll>>
  #define OUT(x) cout << x << endl; return 0;
  //printf("%.10f\n")
  //cout << fixed << setprecision(10);
  template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
  template<class T> inline bool chmaxe(T& a, T b){if (a <= b) { a = b; return true; } return false;}
  template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
  const ll MOD = 1000000007ll;
  const ll INF = 1e+18;
  const int iINF = 1e9;
  const double EPS = 1e-8;

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

  ll ans = 0;
  rep(i, 0, N){
    ans += A[i] * B[i];
  }

  if(ans == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
	return b==0?a:gcd(b,a%b);
}
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
int n;
ll dp[40];
int main(){
	scanf("%d",&n);
	dp[1]=1;
	for(int i=2;i<=n;i++)
		dp[i]=lcm(dp[i-1],i);
	printf("%lld",dp[n]+1);
	return 0;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)
//__builtin_popcountll()

int main(){

    fast;
    int n,i,j;
    cin>>n;
    vector<int>v;
    for(i=2;i<=n;i++)
    {
    	int f=0;

    	for(j=2;j*j<=i;j++)
    	{
    		if(i%j==0)
    		{
    			f=1;
    			break;
			}
		}
		if(f==0)
		v.pb(i);
	}

	ll ans=1;
	for(i=0;i<v.size();i++)
	{

		for(j=0;j<10;j++)
		{
			if(power(v[i],j)>n)
			{
				break;
			}
		}
		j--;
		ans=ans*power(v[i],j);
	}
	cout<<ans+1;

}


/**         (buri nazar wale tera muh kala 😑)
 *
 * @Author   : rudraksh
 * @Created  : Thursday, November 26th 2020, 8:30:41 pm
 * @Email    : rudrakshk@iitbhilai.ac.in
 *
 *   “Think twice, code once.”
 */

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

typedef long long int ll;
typedef unsigned long long ull;
typedef double db;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef map<int,int> MI;
typedef pair<int,PI> PIP;

#define ar array
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define eb emplace_back
#define F first
#define S second
#define repa(i,a,n) for(int i=a;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define pera(i,a,n) for(int i=a;i>=n;i--)
#define per(i,n) for(int i=n;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define loop(it,x) for(auto it=x.begin();it!=x.end();it++)
#define MS0(x) memset((x), 0, sizeof((x)))
#define MS1(x) memset((x), -1, sizeof((x)))
#define CP(dst,src) memcpy(dst, src, sizeof(src))
#define SZ(x) ((ll)(x).size())
#define watch(x) cout << (#x) << " is " << (x) << endl
#define TIME    cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";

const ll mod=1e9+7;
const double pi=acos(-1);

void print() { cout<<'\n'; }
// void print() { cout<<endl; }

template <typename T, typename... Params>
void print(const T& var1, const Params&... var2)
{
    cout<<var1<<' ';
    print(var2...);
}

ll power(ll a,ll b)
{
    if(b==0) return 1;
    ll c = power(a,b/2);
    if(b%2==0) return (c*c)%mod;
    else return (a*((c*c)))%mod;
}

/************************* after all those #defines, finally i can code *****************************/

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a == c && b == d) print(0);
    else if(a+b == c+d) print(1);
    else if(a-b == c-d) print(1);
    else if(abs(a-c) + abs(b-d) <= 3) print(1);
    else if(abs(a-c) <= 5 && abs(b-d) <= 5) print(2);
    else if(abs(abs(c-a) - abs(d-b)) <= 3) print(2);
    else if(((d + (a-c))%2 + 2)%2) print(2);
    else print(3);

    return 0;
}

#include<iostream>
#include<climits>
#define int long long
#define endl '\n'
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define infi INT_MAX
#define rinfi INT_MIN
#define inf LLONG_MAX
#define rinf LLONG_MIN
#define ff first
#define ss second
#ifndef ONLINE_JUDGE
#define line cout<<"here - "<<__LINE__<<"\n";
#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
#define db(a,b) cout<<#a<<" --> "<<(a)<<"\n";cin>>b;
#else
#define line
#define dbg(a)
#define db(a,b)
#endif
char _;
using namespace std;
int r1,r2,c1,c2;
int solve(int x,int y)
{
    if(x==r2 && y==c2)
    return 0;
    if(abs(x-r2)+abs(y-c2)<=3)
        return 1;
    int m1=abs(abs(x-r2)-abs(y-c2));
    int w=0;
    int p=0;
    if(abs(x-r2)==0 || abs(y-c2)==0)
        p=0;
    else p=1;
    if(m1==0)
        return 1;
   if(m1<=3)
    return p+1;
   if(abs(x-r2)%2 != abs(y-c2)%2)
    w=1;
   return w+2;

}
main()
{
    fast
    int tc=1,i,j;
//    cin>>tc;
    while(tc--)
    {
      cin>>r1>>c1>>r2>>c2;
      int ans=inf;
      for(i=-3;i<=3;i++)
      {
          for(j=-3;j<=3;j++)
          {
              if(abs(i)+abs(j)>3)
                continue;
              int x1=r1+i;
              int y1=c1+j;
              int f=0;
              if(x1==r1 && y1==c1)
                f=0;
              else f=1;
              f+=solve(x1,y1);
              ans=min(ans,f);
          }
      }
      cout<<ans<<endl;
    }
}