/* HAVE PATIENCE YOU CAN SOLVE EVERY QUESTION
   JUST THINK*/
   //#pragma GCC optimize("Ofast")
   //#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
//#include <unordered_set>
//#include <unordered_map>

using namespace std;
int mod = 1000000007;
const double pi = 3.141592653689793238460;
const int inf = 0x3f3f3f3f;
const int   N = 2e5 + 5;
const int pr = 31;
#define ll long long
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define MEM(x) memset(x,inf,sizeof(x))
#define fi first
#define se second
#define forn(i, n) for (int i = 0; i< n; i++)
#define forl(i,l,u) for(int i=(int)l;i<=(int)u;++i)
#define all(v) (v).begin(), (v).end()
#define sum(a)   ( accumulate ((a).begin(), (a).end(), 0ll))
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

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

}
int f(int x, int y, string a[]) {
    int l;
    if (a[x][y] == '+')l = 1;
    else l = -1;
    return l;
}

int n;
long long dp[501][501];
vector<int > one(n);
vector<int> zero(n);
int main()
{
//#define int ll
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    ll n;
    cin >> n;
    ll ans = 1e18;
    forl(i, 0, 61) {
        ll b = (ll)pow(2, (ll)i);
        ll c = n % b;
        ll a = n / b;
        ans = min(ans, (a + (ll)i + c));
    }
    cout << ans << endl;
}

#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=2e3+100;
ll mod=1e9+7;
ll dp[N];
char cng(char c){
    if (c=='A') return 'B';
    return 'A';
}
int32_t main(){
    char aa,ab,ba,bb;
    ll n;
    cin >> n;
    cin >> aa >> ab >> ba >> bb;

    dp[2]=1;
    for (int i=3;i<=n;i++){
        if (ab=='B'){
            if (bb=='A'){
                if (ba=='A'){
                    for (int j=2;j<i;j++){
                        dp[i]+=dp[j];
                        dp[i]%=mod;
                    }
                }
                else{
                    dp[i]=dp[i-1]+dp[i-2];
                    dp[i]%=mod;
                }
            }
            else{
                   // cout << 1/0;
                dp[i]=dp[i-1];
            }
        }
        else{
            if (aa=='B'){
                if (ba=='B'){
                    for (int j=2;j<i;j++){
                        dp[i]+=dp[j];
                        dp[i]%=mod;
                    }
                }
                else{
                    dp[i]=dp[i-1]+dp[i-2];
                    dp[i]%=mod;
                }
            }
            else{
                   // cout << 1/0;
                dp[i]=dp[i-1];
            }
        }

    }
    cout << dp[n] << endl;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<double, double>;
using pld = pair<ld, ld>;

ll gcd(ll a, ll b)
{
    while (b)
    {
        ll aux = b;
        b = a % b;
        a = aux;
    }
    return a;
}

int main()
{
    auto mod_inverse = [](const ll p, const ll m)
    {
        auto ext_euclid = [](const ll a, const ll b)
        {
            ll old_r = a, r = b;
            ll old_s = 1, s = 0;
            ll old_t = 0, t = 1;
            ll q, new_r, new_s, new_t;
            while (r != 0)
            {
                q = old_r / r;
                new_s = old_s - s * q;
                new_t = old_t - t * q;
                new_r = old_r % r;
                old_r = r, r = new_r;
                old_s = s, s = new_s;
                old_t = t, t = new_t;
            }
            return old_s;
        };
        ll modular_inverse = ext_euclid(p, m);
        if (modular_inverse < 0)
        {
            modular_inverse += m;
        }
        return modular_inverse;
    };

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

    int T;
    cin >> T;

    while (T--)
    {
        ll N, S, K;
        cin >> N >> S >> K;
        ll their_gcd = gcd(K, N);

        if ((N - S) % their_gcd)
        {
            cout << "-1\n";
        }
        else
        {
            const ll K1 = K / their_gcd, P1 = (N - S) / their_gcd, N1 = N / their_gcd;

            cout << (P1 * mod_inverse(K1, N1)) % N1 << "\n";
        }
    }
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x, y) CPP_CAT_I(x, y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x, y) x##y

#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define M5 100007
#define M9 1000000000

// util {{{
#define FOR(i, start, end) for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end); i < CPP_CAT(i, xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f, c, ...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); })(c))
#define ll long long int
#define VI vector<int>
template <typename C>
i64 SIZE(const C &c)
{
    return static_cast<i64>(c.size());
}

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template <typename T, typename U, typename Comp = less<>>
bool chmax(T &xmax, const U &x, Comp comp = {})
{
    if (comp(xmax, x))
    {
        xmax = x;
        return true;
    }
    return false;
}

template <typename T, typename U, typename Comp = less<>>
bool chmin(T &xmin, const U &x, Comp comp = {})
{
    if (comp(x, xmin))
    {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit
{
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit()
    {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

bool isOK(int mid, double key)
{
}

int binary_search(double key)
{
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key))
            right = mid;
        else
            left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

bool isKaibun(string st)
{
    bool ans = true;
    int n = st.length();
    REP(i, n / 2)
    {
        if (st[i] != st[n - i - 1])
        {
            return false;
        }
    }
    return true;
}

int toInt(char a)
{
    return a - '0';
}

int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

void solve()
{
    int a, b, c;
    cin >> a >> b;
    if (a != b)
    {
        cout << (3 - (a + b)) % 3 << endl;
    }
    else
    {
        cout << a << endl;
    }
}

signed main()
{

    solve();

    return 0;
}


//
// Created by yamunaku on 2020/10/24.
//

#include <bits/stdc++.h>
//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main() {
    //CFS;
    int n, m;
    cin >> n >> m;
    if (n == 1 && m == 0) {
        cout << 1 SP 2 << endl;
        return 0;
    }
    if (m < 0 || m >= n - 1) {
        cout << -1 << endl;
        return 0;
    }
    rep(i, n - 1) {
        cout << i * 20 + 10 SP i * 20 + 20 << endl;
    }
    if (m == 0) {
        cout << IINF - 1 SP IINF << endl;
    } else {
        cout << 5 SP m * 20 + 25 << endl;
    }
    return 0;
}

#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
    int n, m;
    while(cin>>n>>m){
        if(m<0 || (m>=n-1 && m!=0)){
        	printf("-1\n");
        }
        else{
        	if(m>0){
        		int tmp = 2;
        		for(int i=0; i<m+1; ++i){
        			printf("%d %d\n",tmp, tmp+1);
        			tmp+=2;
        		}
        		printf("1 %d\n",tmp);
        		++tmp;
        		for(int i=m; i<n-2; ++i){
        			printf("%d %d\n",tmp, tmp+1);
        			tmp+=2;
        		}
        	}
        	else{
        		int tmp = 1;
        		for(int i=0; i<n; ++i){
        			printf("%d %d\n",tmp, tmp+1);
        			tmp+=2;
        		}
        	}
        }
    }
  return 0;
}


// #pragma GCC optimize("Ofast,unroll-loops")
// #pragma GCC target("avx,avx2,fma")

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

#define ll long long
#define ull unsigned long long
#define dd double
#define ld long double
#define sl(n) scanf("%lld", &n)
#define si(n) scanf("%d", &n)
#define sd(n) scanf("%lf", &n)
#define pll pair <ll, ll>
#define pii pair <int, int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define inf (1LL << 61)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define for1(i, stop) for(ll i = 1; i <= stop; ++i)
#define for0(i, stop) for(ll i = 0; i < stop; ++i)
#define rep1(i, start) for(ll i = start; i >= 1; --i)
#define rep0(i, start) for(ll i = (start-1); i >= 0; --i)
#define ms(n, i) memset(n, i, sizeof(n))
#define casep(n) printf("Case %lld:", ++n)
#define pn printf("\n")
#define pf printf
#define EL '\n'
#define fastio std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

// === Debug macro starts here ===
#ifndef ONLINE_JUDGE
#define DEBUG
#define SYS_COL system("COLOR")
#endif

int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; SYS_COL; \
                cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":" \
                <<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}

template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value,
            Ostream&>::type operator<<(Ostream& os,  const Cont& v) {
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
#else
#define dbg(x)
#endif
// === Debug macro ends here ===

#define ff first
#define ss second

const ll sz = 22;
vector <int> g[sz], comp[sz];
int col[sz], vis[sz];

void comp_dfs(ll u, ll id)
{
    vis[u] = 1;
    comp[id].pb(u);

    for(int &v : g[u]) {
        if(!vis[v])
            comp_dfs(v, id);
    }
}

ll dfs(ll pos, ll id)
{
    if(pos == comp[id].size())
        return 1;
    ll u = comp[id][pos];

    set <int> exist;
    for(int &v : g[u])
        if(col[v])
            exist.insert(col[v]);

    ll ret = 0;
    for1(i, 3) {
        if(exist.find(i) != exist.end())
            continue;

        col[u] = i;
        ret += dfs(pos+1, id);
        col[u] = 0;
    }

    return ret;
}

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

    for1(i, m) {
        int u, v;
        si(u), si(v);

        g[u].pb(v);
        g[v].pb(u);
    }

    ll ans = 1, id = 0;

    for1(i, n) {
        if(vis[i])
            continue;

        comp_dfs(i, ++id);
    }

    for1(i, id)
        ans *= dfs(0, i);

    cout << ans << EL;

    return 0;
}

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,avx512f,avx512bw,avx512bitalg")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl

#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define lb lower_bound
#define ub upper_bound

#define rep(x,start,end) for(int x=start;x!=end;x++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug

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

int B,m;
bool bad[25][25];

int ind[1050000];

int ahat[21][1050000];
int bhat[21][1050000];
ll hat[21][1050000];

void conv(){
	for (int x=0;x<1048576;x++) {
		ahat[__builtin_popcount(x)][x]=ind[x];
		bhat[__builtin_popcount(x)][x]=ind[x];
	}

	rep(cnt,0,21){
		rep(bit,0,20){
			for (int a=0;a<1048576;a+=2<<bit){
				int b=a+(1<<bit);
				for (int x=0;x<(1<<bit);x++){
					ahat[cnt][b+x]+=ahat[cnt][a+x];
					bhat[cnt][b+x]+=bhat[cnt][a+x];
				}
			}
		}
	}

	rep(cnt,0,21){
		rep(cnt2,0,cnt+1){
			for (int x=0;x<1048576;x++){
				hat[cnt][x]+=(ll)ahat[cnt2][x]*bhat[cnt-cnt2][x];
			}
		}
	}

	rep(cnt,0,21){
		rep(bit,0,20){
			for (int a=0;a<1048576;a+=2<<bit){
				int b=a+(1<<bit);
				for (int x=0;x<(1<<bit);x++){
					hat[cnt][b+x]-=hat[cnt][a+x];
				}
			}
		}
	}

	ll ans=0;
    for (int x=0;x<(1<<B);x++){
    	ans+=ind[x^((1<<B)-1)]*hat[__builtin_popcount(x)][x];
	}
	cout<<ans<<endl;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);

	cin>>B>>m;

	int a,b;
	rep(x,0,m){
		cin>>a>>b;
		a--,b--;
		bad[a][b]=bad[b][a]=true;
	}

	ind[0]=1;
	rep(x,1,1<<B){
		int temp=__builtin_ctz(x);
		int nx=x^(1<<temp);

		ind[x]=ind[nx];

		rep(bit,0,B) if (nx&(1<<bit) && bad[temp][bit]){
			ind[x]=0;
		}
	}

	conv();
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i)
#define forrc(i,r,l) for (int i= (int)(r); i>= (int)(l); --i)

#define pb push_back
#define fi first
#define se second
#define mp make_pair

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()

#define tr(c,i) for(_typeof_((c)).begin() i = (c).begin(); i != (c).end(); i++)

#define present(c,x) ((c).find(x) != (c).end())

#define cpresent(c,x) (find(all(c),x) != (c).end())

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

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

using namespace std;
#define count1(x) __builtin_popcount(x)
#define count1ll(x) __builtin_popcountll(x)
#define leadzero(x) __builtin_clz(x)
#define trailzero(x) __builtin_ctz(x)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;
typedef long long ll;
typedef unsigned long long int ull;
/*
//unhackable unordered_map and gp_hash_table:-
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);
    }
};

*/

ll max(ll a,ll b){
    if(a>b) return a;
    else return b;
}

const int MOD=1000000007;
int no_of_bits(long long n)
{
    int count=0;
    while(n>0)
    {
        n=n>>1;
        count++;
    }
    return count;
}
long long gcd(long long a, long long b) {
  while (b > 0) {
    long long t = a % b;
    a = b;
    b = t;
  }
  return a;
}

void add_self(int &a, int b){
  a+=b;
  if(a>=MOD){
    a-=MOD;
  }
}

void sub_self(int &a, int b){
  a-=b;
  if(a<0){
    a+=MOD;
  }
}

int search(vi x,int n,int i){
  int l=0,h=n-1,mid;
  while(l<=h){
    mid=(l+h)/2;
    if(x[mid]<i){
      l=mid+1;
    }else{
      h=mid-1;
    }
  }
  return l;
}

const int INF=-2000;
const ll INF_=1e13;
ll minll(ll a,ll b){
    if(a>b) return b;
    else return a;
}
ll maxll(ll a,ll b){
    if(a<b) return b;
    else return a;
}
void solve(){
    ll ans=1;
    for(int i=1;i<=30;i++)
    {
        ans=i*ans/gcd(i,ans);
    }
    cout<<ans+1<<'\n';
}
int main(){

//  auto start = chrono::high_resolution_clock::now();

    // unsync the I/O of C and C++.
    // ios_base::sync_with_stdio(false);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  int t;
//   cin>>t;
t=1;
  while(t--){
      solve();
  }

    // auto end = chrono::high_resolution_clock::now();

    // Calculating total time taken by the program.
    // double time_taken =
    //   chrono::duration_cast<chrono::nanoseconds>(end - start).count();

    // time_taken *= 1e-9;

    // cout << "Time taken by program is : " << fixed
        //  << time_taken << setprecision(9);

}

#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD ((int)1e9 + 7)
#define atoi(x) ((x)-'0')
#define int ll
//#define double long double
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

ll n, ans = 1;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

signed main() {
	cin >> n;
	if (n == 1) {
		cout << 1;
	}
	else {
		for (int i = 1; i <= n; i++) ans = lcm(ans, i);
		cout << ans + 1;
	}
}


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

void printmat(const vector<vector<int>>& mat) {
    for (auto row : mat) {
        for (int elem : row)
            cout << elem << " ";
        cout << endl;
    }
}
void printv(const vector<long long>& v) {
    for (int elem : v)
        cout << elem << " ";
    cout << endl;
}
void printvp(const vector<pair<int, int>>& vp) {
    for (auto row : vp)
        cout << row.first << ", " << row.second << " ; ";
    cout << endl;
}

int main() {
    int T=1, caseIdx=0;
    //cin >> T;
    while (T--) {
        caseIdx++;
        string x, ans;
        cin >> x;
        auto it = x.find('.');
        ans = x.substr(0, it);

        cout << ans << endl;
        //cout << "Case #" << caseIdx << ": " << ans << endl;
    }
}

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

int main() {
    string inp;
    cin >> inp;
    string ans = "";
    for(int i = 0; i < inp.length(); i++){
        if(inp[i] == '.'){break;}
        else{ans = ans + inp[i];}
    }
cout << ans;
}


#include<bits/stdc++.h>
#define ll long long
#define mxn 200002
#define mod 1000000007ll
using namespace std;
ll mem[mxn][17][2], n, k;
char str[mxn];
ll dp1(int pos, int rem, bool f)
{
    if(pos==0)return (rem==0);
    ll ret= mem[pos][rem][f];
    if(ret!=-1)return ret;

    ret= 0;
    if(f)
    {
        ret= (k-rem)*dp1(pos-1, rem, f);
        if(rem)ret+= (16-(k-rem))*dp1(pos-1, rem-1, f);
    }
    else ret= 15ll*dp1(pos-1, rem-1, 1);

    return mem[pos][rem][f]= ret%mod;
}
ll dp2(int pos, int rem, bool f, int msk)
{
    if(rem==-1)return 0;
    if(pos==n)return (rem==0);
    ll ret= mem[pos][rem][f];
    if(ret!=-1)return ret;

    ret= 0;
    if(f)
    {
        ret= (k-rem)*dp2(pos+1, rem, f, 0);
        if(rem)ret+= (16-(k-rem))*dp2(pos+1, rem-1, f, 0);
    }
    else
    {
        int let;
        if(str[pos]>='A')let= 10+(str[pos]-'A');
        else let= (str[pos]-'0');

        if(msk&(1<<(let)))ret+= dp2(pos+1, rem, f, msk);
        else ret+= dp2(pos+1, rem-1, f, msk|(1<<(let)));

        for(int i=(pos==0); i<let; i++)
        {
            if(msk&(1<<(i)))ret+= dp2(pos+1, rem, 1, 0);
            else ret+= dp2(pos+1, rem-1, 1, 0);
        }
    }

    return mem[pos][rem][f]= ret%mod;
}
int main()
{
    scanf("%s %lld", str, &k);
    n= strlen(str);

    if(k>n)
    {
        puts("0");
        return 0;
    }

    memset(mem, -1, sizeof mem);

    ll res= 0;
    for(int i=k; i<n; i++)
    res+= dp1(i, k, 0), res%= mod;

    memset(mem, -1, sizeof mem);
    res+= dp2(0, k, 0, 0);
    res%= mod;

    printf("%lld\n", res);

    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <map>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

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

#define V vector<int>
#define P pair<int,int>
#define INF 1000000007
#define MOD	1000000007
typedef long long LL;

string N;
int K;
LL dp[200010][20];

int char_int(char c) {
	int res = 0;
	if ('0' <= c && c <= '9') {
		res = c - '0';
	}
	else {
		res = c - 'A' + 10;
	}
	return res;
}

void cal() {
	int kcnt = 0;
	bool used[16];
	REP(i, 16)	used[i] = false;
	REP(i, N.size()) {
		int c = char_int(N[i]);
		if (i == 0) {
			dp[i][1] = c - 1;
			used[c] = true;
			kcnt++;
			continue;
		}
		for (int j = 1; j <= K; j++) {
			dp[i][j] += dp[i - 1][j] * j;
			dp[i][j] += dp[i - 1][j - 1] * (16 - (j - 1));
			dp[i][j] %= MOD;
		}
		dp[i][1] += 15;

		for (int k = 0; k < c; k++) {
			if (used[k])	dp[i][kcnt]++;
			else dp[i][kcnt + 1]++;
		}
		if (!used[c]) {
			used[c] = true;
			kcnt++;
		}
	}
	dp[N.size()-1][kcnt]++;
}

int main() {
	cin >> N >> K;
	cal();
	cout << dp[N.size() - 1][K] % MOD << endl;
}


#include<bits/stdc++.h>
using namespace std;
using ll=int64_t;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}

void solve(){
    string s;
    cin>>s;
    if(s.length()==1){
        cout<<(s=="8"?"Yes":"No")<<'\n';
        return;
    }
    if(s.length()==2){
        if(atoi(s.c_str())%8==0){
            cout<<"Yes"<<'\n';
            return;
        }
        swap(s[0],s[1]);
        if(atoi(s.c_str())%8==0){
            cout<<"Yes"<<'\n';
            return;
        }
        cout<<"No"<<'\n';
        return;
    }
    int cnt[10]={};
    for(auto&c:s) ++cnt[c-'0'];
    for(int i{111};i<1000;++i){
        if(i%8) continue;
        int a=i%10,b=(i/10)%10,c=i/100;
        if(!a or !b or !c) continue;
        --cnt[a];--cnt[b];--cnt[c];
        bool f=true;
        for(int j{1};j<=(9);++j){
            if(cnt[j]<0) f=false;
        }
        ++cnt[a];++cnt[b];++cnt[c];
        if(f){
            cout<<"Yes"<<'\n';
            return;
        }
    }
    cout<<"No"<<'\n';
}

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

//#pragma GCC optimize ("Ofast")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops")
//#include <x86intrin.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define PI 3.141592653589793L
#define FAST ios::sync_with_stdio(false); cin.tie(NULL);
// Use for file I/O;
#define FIN string _fname = "input"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

#define FIN2 freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define RINIT mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define gsize(x) (int)((x).size())

using namespace std;
//using namespace __gnu_pbds;
//typedef gp_hash_table<int, int, hash<int>> ht;

const char nl = '\n';
const char Nl = '\n';

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

const ll inf = 1e9 + 10;
const ll inf2 = 1e18 + 99LL;
const ld inf3 = 1e14;
const ll mod = 1e9+7, mod2 = 998244353;
const ld eps = 1e-2;
const bool local = false;

const int logn = 8, maxn = 1000, maxm = 10001, maxn2 = 3;

int main() {
    FAST; //RINIT;

    int n;
    cin >> n;
    string s;
    cin >> s;

    if (s[0] != s[n - 1]) {
		cout << 1 << nl;
		return 0;
	}

	for (int i = 1; i + 2 < n; i++) {
		if (s[0] != s[i] && s[i + 1] != s[n - 1]) {
			cout << 2 << nl;
			return 0;
		}
	}

	cout << -1 << nl;
}

// © Benq
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
*/


#include <cstdio>
const int maxn = 1e6 + 100;
struct node
{
	int to,next,lab;
}E[maxn];
int n,m,head[maxn],tot,col[maxn];
inline void add(int x,int y,int lab) { E[++tot].next = head[x],E[tot].to = y,E[tot].lab = lab,head[x] = tot; }
void dfs(int u)
{
	for(int p = head[u],v;p;p=E[p].next)
	{
		if(col[v = E[p].to]) continue;
		col[v] = (E[p].lab == col[u] ? col[u] % n + 1 : E[p].lab),dfs(v);
	}
}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i = 1,a,b,c;i<=m;++i) scanf("%d %d %d",&a,&b,&c),add(a,b,c),add(b,a,c);
	col[1] = 1,dfs(1);
	for(int i = 1;i<=n;++i) printf("%d\n",col[i]);
	return 0;
}

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

#include<cstdio>
#include<cstring>

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

int N, M;
int to[400005], ne[400005], c[200005], he[100001];
int kotae[100001];

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
const int MAX = 1000;
class shuturyoku_unko {
public:
	char C[MAX * 4];
	constexpr shuturyoku_unko() : C() {
		rep(i, MAX) {
			int X = i;
			rep(j, 3) {
				C[i * 4 + 2 - j] = '0' + X % 10;
				X /= 10;
			}
			C[i * 4 + 3] = ' ';
		}
	}
};
constexpr shuturyoku_unko f;
const int dm = 1 << 17;
char* dn = cn, * di = dn, * owad = dn + dm - 20;
void putint(int A) {
	if (owad < di) {
		fwrite(dn, 1, di - dn, stdout);
		di = dn;
	}
	if (A >= 1000) {
		int dig = 1;
		if (A >= 100000) dig = 3;
		else if (A >= 10000) dig = 2;
		memcpy(di, f.C + A / 1000 * 4 + 3 - dig, dig);
		memcpy(di + dig, f.C + A % 1000 * 4, 4);
		di += dig + 4;
	}
	else {
		int dig = 1;
		if (A >= 100) dig = 3;
		else if (A >= 10) dig = 2;
		memcpy(di, f.C + A * 4 + 3 - dig, dig + 1);
		di += dig + 1;
	}
}

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

	N = getint();
	M = getint();

	int k = 2;
	rep1(i, M) {
		int u = getint(), v = getint();
		c[i] = getint();
		to[k] = v;
		ne[k] = he[u];
		he[u] = k++;
		to[k] = u;
		ne[k] = he[v];
		he[v] = k++;
	}

	int Q[100001], q = 0;
	Q[q++] = 1;
	kotae[1] = 1;
	while (q) {
		int tmp = Q[--q];
		int oya = kotae[tmp];
		for (int k = he[tmp]; k; k = ne[k]) {
			int t = to[k];
			if (!kotae[t]) {
				int e = c[k >> 1];
				kotae[t] = e + (oya == e);
				Q[q++] = t;
			}
		}
	}

	rep1(i, N) putint(kotae[i] - ((kotae[i] > N) << 1));
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}


#pragma GCC optimize("Ofast")

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

template<typename T>
class SegTree {
    int n;                       // 葉の数
    vector<T> data;              // データを格納するvector
    T def;                       // 初期値かつ単位元
    function<T(T, T)> operation; // 区間クエリで使う処理
    function<T(T, T)> update;    // 点更新で使う処理

    T _query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return def; // 交差しない
        if (a <= l && r <= b)
            return data[k]; // a,l,r,bの順で完全に含まれる
        else {
            T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子
            T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子
            return operation(c1, c2);
        }
    }

  public:
    SegTree(size_t _n, T _def, function<T(T, T)> _operation,
            function<T(T, T)> _update)
        : def(_def), operation(_operation), update(_update) {
        n = 1;
        while (n < _n) {
            n *= 2;
        }
        data = vector<T>(2 * n - 1, def);
    }

    void change(int i, T x) {
        i += n - 1;
        data[i] = update(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

    T operator[](int i) {
        return data[i + n - 1];
    }
};

bool solve()
{
    ll n,q,a,t,x,y;
    cin >> n >> q;
    SegTree<ll> st(n, 0,
        [](ll p, ll k){return p^k;},
        [](ll p, ll k){return p^k;});

    rep(i,n){
        cin >> a;
        st.change(i, a);
    }

    rep(i,q){
        cin >> t >> x >> y;
        x--;
        if(t==1){
            st.change(x, y);
        }
        else{
            cout << st.query(x, y) << endl;
        }
    }

    return true;
}

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

#pragma GCC target ("avx2")
//#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
#define mod 1000000007
using namespace std;
ll st[1200001];
umll m;
void build(ll a[],ll l,ll r,ll i)
{
    if(l==r)
    {
        st[i]=a[l];
        return;
    }
    ll mid=(r-l)/2+l;
    build(a,l,mid,2*i+1);
    build(a,mid+1,r,2*i+2);
    st[i]=(st[2*i+1]^st[2*i+2]);
}
void update(ll l,ll r,ll i,ll ind,ll v)
{
    if(ind<l||ind>r)
        return;
    else if(l==r&&ind==l)
    {
        st[i]=(st[i]^v);
        return;
    }
    ll mid=(r-l)/2+l;
    update(l,mid,2*i+1,ind,v);
    update(mid+1,r,2*i+2,ind,v);
    st[i]=(st[2*i+1]^st[2*i+2]);
}
ll que(ll l,ll r,ll low,ll high,ll i)
{
    if(high<l||low>r)
        return 0;
    else if(l>=low&&r<=high)
        return st[i];
    ll mid=(r-l)/2+l;
    return (que(l,mid,low,high,2*i+1)^que(mid+1,r,low,high,2*i+2));
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    for(ll i=0;i<=1200000;i++)
        st[i]=0;
    ll n,q,c,l,r,p;
    cin>>n>>q;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    build(a,0,n-1,0);
    //for(ll i=0;i<=10;i++)
      //  cout<<st[i]<< " ";
    //cout<< "\n";
    while(q--)
    {
            cin>>p>>l>>r;
            if(p==1)
            {
                l--;
                update(0,n-1,0,l,r);
            }
            else
            {
                l--;
                r--;
                ll ans=que(0,n-1,l,r,0);
                cout<<ans<< "\n";
            }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const double PI  = acos(-1.0);
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
using ll = long long;
#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//ax + by = gcd(a, b) �𖞂��� x, y ��Ԃ�
ll extgcd (ll a, ll b, ll& x, ll& y){
    ll d = a;
    if (b != 0){
        d = extgcd(b, a % b, y, x);
        y -= (a/b) * x;
    } else {
        x = 1; y = 0;
    }
    return d;
}
// ax == 1 (mod m)�𖞂��� x
ll mod_inverse(ll a, ll m){
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}
int main()
{
    ll A, B, C;
    ll M = 998244353;
    cin >> A >> B >> C;
    ll ans = mod_inverse(8, M);
    (ans *= A) %= M;
    (ans *= A + 1) %= M;
    (ans *= B) %= M;
    (ans *= B + 1) %= M;
    (ans *= C) %= M;
    (ans *= C + 1) %= M;
    cout << ans;
    return 0;
}

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

typedef pair<int,int>  pint;
typedef pair<ll,ll>    pll;
typedef vector<int>    vint;
typedef vector<ll>     vll;
typedef vector<string> vstr;
typedef vector<pint>   vpint;
typedef vector<pll>    vpll;

#define vint2(v,n,m,init) vector<vector<int>> v(n, vector<int>(m, init))
#define vll2(v,n,m,init)  vector<vector<ll>>  v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vint var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vstr var(n); rep(i,n){cin >> var[i];}
#define ALL(var)         (var).begin(), (var).end()
#define sortall(var)     sort(ALL(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());

#define prt(var)         cout << (var) << "\n"
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
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;}
//----------------------------------------------------------------------------
#define prt4(v1,v2,v3,v4) cout<<(v1)<<" "<<(v2)<<" "<<(v3)<<" "<<(v4)<<"\n";

ll power(ll a, ll p, ll mod){
    ll res = 1;
    ll x = a;
    while(p){
        if(p&1) res *= x, res %= mod;
        x *= x, x %= mod;
        p >>= 1;
    }
    return res;
}

int main(void) {
    ll n, m;
    cin >> n >> m;

    prt((power(10,n,m*m)/m)%m);
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define FORL(i,m,n) for(ll i=(m); i < (n); i += 1)
#define REPL(i,n) FORL(i,0,(n))

const ll INF = 1LL << 60;

struct UnionFind{
    vector<int> par,siz;

    UnionFind(int n) : par(n,-1),siz(n,1) {}

    int root(int x){
        if(par[x] == -1) return x;
        else return par[x] = root(par[x]);
    }

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

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

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

        par[y] = x;
        siz[x] += siz[y];
        return true;
    }
};

using Edge = pair<int, pair<int,int>>;

ll combination(ll n,ll k){
    if(n == 0) return 0;
    if(k == 0) return 1;
    ll x=1,y=1;
    REPL(i,k){
        x *= n;
        n--;
    }
    REPL(i,k-1){
        y *= k-i;
    }

    return x/y;
}

int combination(int n,int k){
    if(n == 0) return 0;
    if(k == 0) return 1;
    int x=1,y=1;
    REP(i,k){
        x *= n;
        n--;
    }
    REP(i,k-1){
        y *= k-i;
    }

    return x/y;
}

ll min(ll a, ll b){
    if(a > b){
        return b;
    }else if(a < b){
        return a;
    }else{
        return a;
    }
}

ll max(ll a, ll b){
    if(a > b){
        return a;
    }else if(a < b){
        return b;
    }else{
        return a;
    }
}

int fac(int n){
    if(n == 1) return 1;
    else return n * fac(n-1);
}

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

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

    ll a=INF,b=INF,c=INF;

    for(ll i=1,j=0; i<n; i*=2,j+=1){
        ll tmp_a = n / i;
        ll tmp_b = j;
        ll tmp_c = n % i;
        if(a+b+c > tmp_a+tmp_b+tmp_c){
            a = tmp_a;
            b = tmp_b;
            c = tmp_c;
        }
    }

    cout << a+b+c << endl;
}

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

#ifdef LOCAL
#include "debug.h"
#endif

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define rep(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repi(i, a, b) for (int i = (int)a; i >= (int)b; i--)
#define pb push_back
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define umin(a, x) a = min(a, x)
#define umax(a, x) a = max(a, x)

ll nxt() {
	ll x; cin >> x; return x;
}

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

set<pll> generate_box(int a, int b) {
	set<pll> ans;

	rep(i, -3, 4) {
		rep(j, -3, 4) {
			if (abs(i) + abs(j) <= 3) {
				int c = a - i, d = b - j;
				ans.insert({c, d});
			}
		}
	}
	return ans;
}

int ans = 0;

int reach_1(int a, int b, int c, int d) {
	//this is for 1
	auto x = generate_box(a, b);
	for (auto it = x.begin(); it != x.end(); it++) {
		if ((*it).fi == c && (*it).se == d) {
			ans = 1;
			return 1;
		}
	}
	if (a + b == c + d || a - b == c - d) {
		ans = 1; return 1;
	}

	return 0;
}

void solve() {
	int a, b, c, d; cin >> a >> b >> c >> d;

	//0
	if (a == c && b == d) {
		ans = 0;
		return;
	}

	//1
	if (reach_1(a, b, c, d)) return;

	//this for 2
	if (((a + b) % 2) % 2 == ((c + d) % 2) % 2) {
		ans = 2;
		return;
	}
	auto x = generate_box(a, b);
	auto y = generate_box(c, d);
	for (auto it = x.begin(); it != x.end(); it++) {
		int A = (*it).fi, B = (*it).se;
		if (reach_1(A, B, c, d)) {
			ans = 2;
			return;
		}
	}
	for (auto it = y.begin(); it != y.end(); it++) {
		int A = (*it).fi, B = (*it).se;
		if (reach_1(a, b, A, B)) {
			ans = 2;
			return;
		}
	}

	//3
	ans = 3;
	return;
}

int32_t main(){
	// setIO("trapped");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cout << fixed << setprecision(10);

	int T = 1;
	// cin >> T;

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

	cout << ans << endl;
}


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

const ll INF = 1e18;
const int MX = 2005;

int main() {
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    int l1 =s1.size();
    int l2 =s2.size();
    int l3 =s3.size();
    ll n1,n2,n3=-1;
    map<char,int>m;
    for(int i = 0; i < s1.size();i++){
        m[s1[i]] += 1;
        m[s1[0]] += 100;
    }
    for(int i = 0; i < s2.size();i++){
        m[s2[i]] += 1;
        m[s2[0]] += 100;
    }
    for(int i = 0; i < s3.size();i++){
        m[s3[i]] += 1;
        m[s3[0]] += 100;
    }
    if(m.size() > 10){
        cout << "UNSOLVABLE" << endl;
        return 0;
    }
    int array[]={0,1,2,3,4,5,6,7,8,9};
    do{
        ll a=0,b=0,c=0;
        map<int,int>ma;
        int cnt = 0;
        bool skip = false;
        for(auto &x:m){
            if(x.second >= 100 && array[cnt]==0){
                skip = true;
                break;
            }else{
                ma[x.first] = array[cnt];
            }
            cnt++;
        }
        if(!skip){
            for(int i = 0;i < l1;i++){
                a += pow(10,i) * ma[s1[l1-i-1]];
            }
            for(int i = 0;i < l2;i++){
                b += pow(10,i) * ma[s2[l2-i-1]];
            }
            for(int i = 0;i < l3;i++){
                c += pow(10,i) * ma[s3[l3-i-1]];
            }
            if(a + b == c){
                n1 = a;
                n2 = b;
                n3 = c;
                break;
            }
        }
    }while(next_permutation(array,array+10));
    if(n3 == -1){
        cout << "UNSOLVABLE" << endl;
    }else{
        cout << n1 << endl;
        cout << n2 << endl;
        cout << n3 << endl;
    }
}

#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>

using namespace std;
using ll = long long;
int n;
int st[10], val[256];
string a, b, c;
bool dfs(int i, int car);
bool search(char c, int i, int car) {
	for(int j = 0; j < 10; ++j) if(!st[j]) {
		st[j] = c;
		val[c] = j;
		if(dfs(i, car)) return true;
		st[j] = 0;
		val[c] = -1;
	}
	return false;
}
bool ok(string& x) {
	return val[x.back()];
}
bool dfs(int i, int car) {
	if(i >= c.size()) return !car && ok(a) && ok(b) && ok(c);

	if(i < a.size() && val[a[i]] == -1) return search(a[i], i, car);

	if(i < b.size() && val[b[i]] == -1) return search(b[i], i, car);
	int va = i >= a.size() ? 0 : val[a[i]];
	int vb = i >= b.size() ? 0 : val[b[i]];
	int res = va + vb + car;
//	printf("%d %d %d\n", va, vb, res);
	if(val[c[i]] == -1) {
		if(st[res%10]) return false;
		val[c[i]] = res % 10;
		st[res % 10] = c[i];
		if(dfs(i + 1, res/10)) return true;
		val[c[i]] = -1;
		st[res%10] = 0;
	}
	else {
		if(val[c[i]] != res % 10) return false;
		if(dfs(i + 1, res / 10)) return true;
	}
	return false;
}

void print(string& x){
	for(auto& c: x) printf("%d", val[c]);
	puts("");
}

int main(){
	cin >> a >> b >> c;
	memset(val, -1, sizeof val);
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	reverse(c.begin(), c.end());
	if(dfs(0, 0)) {
		reverse(a.begin(), a.end());
		reverse(b.begin(), b.end());
		reverse(c.begin(), c.end());
		print(a);
		print(b);
		print(c);
	}
	else puts("UNSOLVABLE");
}


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

ll nck[N][N];

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

	for (int i=0; i<N; i++) {
		nck[i][0] = 1;
		for (int j=1; j<=i; j++) {
			nck[i][j] = nck[i-1][j-1] + nck[i-1][j];
		}
	}

	ll a, b, k; cin>>a>>b>>k; --k;
	string s;

	while (a && b) {
		ll x = nck[a+b-1][a-1];
		// cout<<x<<' '<<k<<endl;
		if (x <= k) k -= x, s += 'b', --b;
		else s += 'a', --a;
	}

	while (a--) s += 'a';
	while (b--) s += 'b';

	cout<<s<<endl;
}

#include <bits/stdc++.h>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ld long double
#define ll long long
using namespace std;

#define MOD 1000000007

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

ll calc(ll n, ll a, ll b) {
    bool doneA[a + 1], doneB[b + 1];
    memset(doneA, false, sizeof(doneA));
    memset(doneB, false, sizeof(doneB));

    ll num = 1;
    for (ll i = 1; i <= n; i++) {
        num *= i;
        for (ll j = 1; j <= a; j++) {
            if (!doneA[j] && num % j == 0) {
                num /= j;
                doneA[j] = true;
            }
        }
        for (ll j = 1; j <= b; j++) {
            if (!doneB[j] && num % j == 0) {
                num /= j;
                doneB[j] = true;
            }
        }
    }
    return num;
}

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

    int a, b;
    ll k;
    cin >> a >> b >> k;

    string s;
    for (int i = 0; i < a; i++) s += 'a';
    for (int j = 0; j < b; j++) s += 'b';

    int pos = a;
    int n = a + b;
    k--;
    for (int i = 0; i < n; i++) {
        int cntA = 0, cntB = 0;
        for (int j = i + 1; j < n; j++) {
            if (s[j] == 'a') cntA++;
            else cntB++;
        }

        ll ans = calc(n - i - 1, cntA, cntB);
        if (k >= ans) {
            swap(s[i], s[pos]);
            k -= ans;
            pos++;
        }
    }

    cout << s << "\n";

}

/*
 cnt # a and b
 k -=
 perform the swap

 1: aabbb
 2: ababb
 3: abbab
 4: abbba
 5: baabb
 6: babab
 7: babba
 8: bbaab
 9: bbaba
 10: bbbaa

 */


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

int main(){
 long long n, k;
 cin >> n >> k;

 for(int i = 0; i < k; i++){
 if(n % 200 == 0){
     n = n / 200;
 }else{
     n = n * 1000 + 200;
 }
}

 cout << n << endl;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,X,i;
    cin >> N >> X;
    char c;
    for(i = 0;i < N;i++){
        cin >> c;
        if(c == 'o') X+=1;
        else X = max(0,X - 1);
    }
    cout << X << endl;
}


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

#define rep(i,a,b) for(int i=a; i<b; i++)
#define repe(i,a,b) for(int i=a; i<=b; i++)
#define ll long long
#define ui unsigned int
#define pb push_back
#define deb(x) cout << #x << '=' << x << endl
#define deb2(x,y) cout << #x << '=' << x << << #y << '=' << y << endl
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define endl "\n"
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define hcf(x,y)     __gcd(x,y)
#define lcm(x,y)     (x*y)/(__gcd(x,y))
#define CountOne(x)  __builtin_popcount(x)
#define parity(x)    __builtin_parity(x)           //Funtion return (true) if number of set bits is odd(odd parity) else false..
#define LeadZero(x)  __builtin_clz(x)             //Counts leading zero in binary representation of x ....
#define TrailZero(x) __builtin_ctz(x)

#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef map<int, int> mii;
typedef unordered_map<int, int> umap_ii;
typedef unordered_map<int, int> umap_ii;
typedef unordered_map<string, int> umap_si;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
//alt + ctrl + N

//===============================================================================//
ll power(ll x, ll y) {
ll v = 1; while (y > 0) { if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

bool isPowerOfTwo(ll x){
    return x && (!(x & (x-1)));     //check if the number is power of two or not
}
ll ceil(ll a,ll b){ return (a+b-1)/b; }
//===============================================================================//
bool cmp(pair<ll,ll> a, pair<ll,ll> b){
    if(2*a.ff+a.ss == 2*b.ff+b.ss) return (a.ff>b.ff);
    else return (2*a.ff+a.ss > 2*b.ff+b.ss);
}

int main(){
    fastIO;
srand(chrono::high_resolution_clock::now().time_since_epoch().count());

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

    ll test = 1;
    //cin >> test;
    while(test--){
        ll n;
        cin >> n;
        vector<pair<ll,ll>>a(n);
        ll voteT = 0,voteA = 0;
        rep(i,0,n){
        	ll x,y;
        	cin >> x >> y;
        	a[i].ff = x;
        	a[i].ss = y;
        	voteA += x;
        }
        sort(all(a),cmp);
        ll ans = 0;
        for(ll i=0;i<n;i++){
        	if(voteT > voteA){
        		break;
        	}
        	voteT += a[i].ff + a[i].ss;
        	voteA -= a[i].ff;
        	ans++;
        }
        cout << ans << endl;
    }
return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mod 1000000007
#define vll vector<ll>
#define inf 3e15 +7
#define pll pair<ll,ll>
#define ff first
#define ss second
#define PI acos(-1)
#define prm 998244353
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*
ll dx[4]={1,-1,0,0};
ll dy[4]={0,0,-1,1};
cout<<fixed<<setprecision(12)<<;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%prm;
    while(b>0){
        if(b&1){res=(res*a)%prm;b--;}
        a=(a*a)%prm;
        b>>=1;
    }
    return res;
}
ll inv(ll y){return power(y,prm-2);}
ll fact[300060];
ll nCr(ll n, ll r)
{
   if (r==0)
      return 1;
    return (fact[n]* inv(fact[r]) % prm *
            inv(fact[n-r]) % prm) % prm;
}

void init(ll n)
{
	fact[0]=1;
	for(ll i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%prm;
}
*/
/*
//cout<<"Case #"<<fff-T<<": ";
/*
ll spf[15000050];
void sieve()
{
	for(ll i=2;i*i<=15000030;i++){
		if(spf[i]==0){
			for(ll j=i+i;j<=15000030;j+=i){
				if(spf[j]==0){
					spf[j]=i;
				}
			}
		}
	}
}*/

int main()
{
    fastio;
	ll T=1;
	//cin>>T;
	//ll fff=T;
	while(T--)
	{
	     ll n;
	     cin>>n;
	     ll a[n+1];
	     for(ll i=1;i<=n;i++)cin>>a[i];
	     if(n==1)
	     {
	         cout<<a[1]<<endl;
	         return 0;
	     }
	     if(n==2)
	     {
	          cout<<(2*a[1])%mod<<endl;
	         return 0;
	     }
	     ll dp[n+3][2];
	     dp[0][0]=1;
	     dp[0][1]=0;
	     dp[1][0]=1;
	     dp[1][1]=0;
	     for(ll i=2;i<=n;i++)
	     {
	         dp[i][0]=(dp[i-1][0] + dp[i-1][1])%mod;
	         dp[i][1]=dp[i-1][0];
	     }
	     //cout<<dp[n][0]<<endl;
	     //cout<<dp[n][1]<<endl;
	     ll ans=0;
	     //ans+=;
	     for(ll i=1;i<=n;i++)
	     {
	        ll v=a[i]*((dp[i-1][0]+dp[i-1][1])%mod);
	        v=v%mod;
	        v=v*((dp[n-i+1][0] + dp[n-i+1][1])%mod);
	        v=v%mod;
	        ans=(ans+v)%mod;
	        if(i==1)continue;
	        ll x=a[i]*((dp[i-2][0]+dp[i-2][1])%mod);
	        x=x%mod;
	        x=x*((dp[n-i][0] + dp[n-i][1])%mod);
	        x=x%mod;

	        ans=(ans-x + mod)%mod;
	         //ans=(ans+(a[i]*((dp[i-1][0]+dp[i-1][1])%mod)*((dp[n-i+1][0] + dp[n-i+1][1])%mod))%mod)%mod;
	         //if(i>1)
	         //ans=(ans+mod-(a[i]*((dp[i-2][0]+dp[i-2][1])%mod)*((dp[n-i][0] + dp[n-i][1])%mod))%mod)%mod;

	       //cout<<ans<<endl;

	     }
	     cout<<ans<<endl;
	}
}
/*

*/


#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
const long long INF = (1LL<<62);

using Graph = vector<vector<int>>;
using LLPair = pair<LL, LL>;
using WeightedGraph = vector<vector<LLPair>>; //(対向頂点、コスト)
using PriorityQ = priority_queue<LLPair, vector<LLPair>, greater<LLPair>>;

void dijkstra(WeightedGraph &WG, vector<LL> &D, LL s){
	//D初期化
	for(int i=0; i<D.size(); i++){
		D[i] = INF;
	}
	D[s] = 0; //s->sはコスト0で確定

	//キューには(コスト, 頂点)を入れる。sから当該頂点には当該コストあれば行ける。
	//キューにはコストの昇順で入る。
	PriorityQ pq;
	pq.push(make_pair(0, s));
	while(!pq.empty()){
		LL pos = pq.top().second; pq.pop();
		for(auto nv : WG[pos]){
			LL to = nv.first; //頂点posからたどれる頂点
			LL cost = nv.second; //そのコスト
			if(D[to] > D[pos] + cost){
				//sからtoまではD[to]のコストがあれば行ける(最小ではない)
				D[to] = D[pos] + cost;
				pq.push(make_pair(D[to], to));
			}
		}
	}
	return;
}

//G[0]-G[25]はa-zの仮想頂点とする。
int H, W;
int getpos(int h, int w){ return (26 + (h*W) + w); }
const int dh[4] = {1, 0, -1, 0};
const int dw[4] = {0, 1, 0, -1};
int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> H >> W;
	WeightedGraph WG(26+(H*W));
	vector<char> V(26 + (H*W));
	int sh, sw, gh, gw;
	for(int i=0; i<H; i++){
		string s; cin >> s;
		for(int j=0; j<W; j++){
			int pos = getpos(i, j);
			char c = s[j];
			V[pos] = c;
			if(c >= 'a' && c <= 'z'){
				int p = c - 'a';
				WG[pos].push_back(make_pair(p, 1));
				WG[p].push_back(make_pair(pos, 0));
			}
			if(c == 'S'){ sh = i; sw = j; }
			if(c == 'G'){ gh = i; gw = j; }
		}
	}

	//各マスからグラフWGを作成する
	for(int h=0; h<H; h++){
		for(int w=0; w<W; w++){
			int pos = getpos(h, w);
			char c = V[pos];
			if(c == '#') continue;

			for(int i=0; i<4; i++){
				int nh = h + dh[i];
				int nw = w + dw[i];
				int npos = getpos(nh, nw);
				if(nh < 0 || nh >= H || nw < 0 || nw >= W) continue;

				char nc = V[npos];
				if(nc == '#') continue;
				if(nc == c && nc >= 'a' && nc <= 'z'){
					; //none
				}
				else{
					WG[pos].emplace_back(make_pair(npos, 1));
					WG[npos].emplace_back(make_pair(pos, 1));
				}
			}
		}
	}

	vector<LL> dist(26+(H*W));
	dijkstra(WG, dist, getpos(sh, sw));
	LL ans = dist[getpos(gh, gw)];
	if(ans == INF){ ans = -1; }
	printf("%lld\n", ans);
	return 0;
}

#include <algorithm>
#include <array>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;
#define int long long
#define ll long long
#define pii std::pair<int, int>
#define pdd std::pair<double, double>
#define INF (1LL << 33)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define SHOW(p) \
    if (test)   \
        cout << #p " : " << p << endl;
bool test = false;
template <class T>
[[maybe_unused]] bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
int H, W;
vector<string> a;
vector<vector<int>> dp;
pii s, g;
vector<vector<pii>> tele;
queue<pii> currentq, nextq;

void hoge(int x, int y)
{
    currentq.push({x, y});
    int nx, ny, time = 0;
    while (currentq.size() != 0) {
        pii place = currentq.front();
        currentq.pop();
        nx = place.first, ny = place.second;
        if (test)
            cout << place.first << ", " << place.second << " will be checked." << endl;

        if (chmin(dp.at(place.first).at(place.second), time)) {
            if (test)
                cout << "time updated." << endl;
            char tmp_cc = a.at(nx).at(ny);
            if (tmp_cc == '#') {
            } else {
                if (tmp_cc == '.' || tmp_cc == 'S' || tmp_cc == 'G') {
                } else if (tele.at(static_cast<int>(tmp_cc - 'a')).size() != 0) {
                    for (auto v : tele.at(static_cast<int>(tmp_cc - 'a'))) {
                        if (dp.at(v.first).at(v.second) > time + 1)
                            nextq.push(v);
                    }
                    tele.at(static_cast<int>(tmp_cc - 'a')).clear();
                }
                if (nx + 1 != H)
                    if (dp.at(nx + 1).at(ny) > time + 1)
                        nextq.push({nx + 1, ny});
                if (nx - 1 != -1)
                    if (dp.at(nx - 1).at(ny) > time + 1)
                        nextq.push({nx - 1, ny});
                if (ny + 1 != W)
                    if (dp.at(nx).at(ny + 1) > time + 1)
                        nextq.push({nx, ny + 1});
                if (ny - 1 != -1)
                    if (dp.at(nx).at(ny - 1) > time + 1)
                        nextq.push({nx, ny - 1});
            }
        }
        if (currentq.size() == 0) {
            currentq = nextq;
            while (!nextq.empty()) {
                if (test) {
                    auto next_p = nextq.front();
                    cout << next_p.first << ", " << next_p.second << endl;
                }
                nextq.pop();
            }
            if (test)
                cout << "time : " << time << " finished. next size " << currentq.size() << endl;
            time++;
        }
    }
}
signed main()
{
    //test = true;
    cin >> H >> W;
    a.resize(H);
    tele.resize(static_cast<int>('z' - 'a') + 1);
    REP(i, H)
    {
        cin >> a.at(i);
        REP(j, W)
        {
            char tmp_c = a.at(i).at(j);
            if (tmp_c == 'S') {
                s = {i, j};
            } else if (tmp_c == 'G') {
                g = {i, j};
            } else if (tmp_c != '#' && tmp_c != '.') {
                tele.at(static_cast<int>(tmp_c - 'a')).push_back({i, j});
            }
        }
    }
    dp.resize(H);
    REP(i, H)
    {
        dp.at(i).resize(W, INF);
    }
    hoge(s.first, s.second);
    if (test) {
        REP(i, H)
        {
            REP(j, W)
            {
                cout << dp.at(i).at(j) << " ";
            }
            cout << endl;
        }
    }
    if (dp.at(g.first).at(g.second) == INF) {
        cout << -1 << endl;
    } else {
        cout << dp.at(g.first).at(g.second) << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,srt,end) for(ll i = (srt); i < (ll)(end); i++)
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
//cout << std::fixed << std::setprecision(15) << y << endl;

// For debug
// Ref: https://qiita.com/ysuzuki19/items/d89057d65284ba1a16ac
#define dump(var)  do{std::cerr << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cerr << e << "\n";}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cerr << e << " "; } std::cerr << "\n";}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ std::cerr << "\n"; for(const auto& v : vv){ view(v); } }
template<typename T> void dump_cout(const T& v) { for(long long i = 0; i < v.size(); i++) std::cout << v[i] << (i == v.size()-1 ? "\n" : " "); }

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

    double ans;
    double cnt = double(n);
    rep(i,0,n){
        ans += (1 / ( cnt / double(n) ));
        cnt -= 1.0;
    }
    // eliminate probability of choosing initial position
    ans -= 1.0;
    printf("%.11f\n", ans);
    return 0;
}

// Problem: D - Staircase Sequences
// Contest: AtCoder - AtCoder Beginner Contest 190
// URL: https://atcoder.jp/contests/abc190/tasks/abc190_d
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define deb(x) cout<< #x <<" is "<<x<<endl;

vector<int>f;
void factorize(int n){
	for(int i=1;i*i<=n;i++){
	  if(n % i == 0){
	  f.emplace_back(i);
    if(i != n/i)f.emplace_back(n/i);
    }
	}
}

bool check(int n,int C){
  return ( C % n && (n-1)%2 );
}

void solve(){
  int n;
  cin>>n;
  factorize(2 * n);
  int cnt = 0;
  // cout<<f.size()<<endl;
  for(int i=0;i<f.size();i++){
    // deb(f[i])
    if(check(f[i] , n))cnt++;
    // else cout<<f[i]<<endl;
  }
  cout<<cnt * 2<<endl;

}

signed main(){
	solve();
}


/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip> //setprecision
#include <map> // map
#include <unordered_map> //unordered_map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#include <numeric> //accumulate,,,
#include <sstream>
//#define endl "\n";
using namespace std;

using PLL = pair<long long,long long>;
typedef tuple<long long,long long,long long> TUP;
using P = pair<int,int>;
const long long INF = 4000000000000000001;
const int inf = 1001001001;
const long long MOD = 1000000007;

// dp[i][j][k]: i番目までj個(0≤j≤cnt)選んでmod cntでkとなる時の必要魔力の最小値
vector<vector<vector<long long>>> dp(105,vector<vector<long long>>(105,vector<long long>(105)));

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

    int N;cin >> N;
    long long X;cin >> X;
    vector<long long> a(N);
    for(int i = 0;i<N;i++) cin >> a.at(i);
    // sum(a) ≤ X
    //for(int i = 0;i<101;i++) for(int j = 0;j<101;j++) for(int k = 0;k<101;k++) dp[i][j][k] = INF;

    long long ans = INF;
    for(int cnt = 1;cnt<=N;cnt++){
        for(int i = 0;i<105;i++) for(int j = 0;j<105;j++) for(int k = 0;k<105;k++) dp[i][j][k] = -1;
        dp[0][0][0] = 0;

        for(int i = 0;i<N;i++){
            for(int j = 0;j<N;j++){
                for(int k = 0;k<cnt;k++){
                    // i個目を選ぶ
                    int nextMOD = (k + a.at(i))%cnt;
                    if(dp[i][j][k] != -1)dp[i+1][j+1][nextMOD] = max(dp[i+1][j+1][nextMOD] , dp[i][j][k]+a.at(i));
                    // i個目を選ばない
                    dp[i+1][j][k] = max(dp[i+1][j][k] , dp[i][j][k]);
                    //cout << cnt << " " << nextMOD << " " << dp[i+1][j+1][nextMOD] << endl;
                }
            }
        }
        // cnt個選んで、k+(cnt*?)=Xにならないといけない
        long long res = dp[N][cnt][X%cnt];
        if(res == -1) continue;
        //cout << cnt << " " << res << " " << " " << X%cnt << " " << ((X-res)/cnt)*cnt + res << endl;

        ans = min(ans,((X-res)/cnt));
    }

    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int mod=998244353;
int n,m,K;
char s[10];
int d[5010][5010],dp[5010][5010];
void update(int &x,int y) {
	x+=y; if (x>=mod) x-=mod;
}
int iv[5],tmp;
int ksm(int x,int y) {
	int res=1;
	while (y) {
		if (y&1) res=(ll)res*x%mod;
		x=(ll)x*x%mod; y>>=1;
	} return res;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n),read(m),read(K); int x,y;
	for (int i=1;i<=K;i++) {
		read(x),read(y); scanf("%s",s+1);
		if (s[1]=='R') d[x][y]=1;
		else if (s[1]=='D') d[x][y]=2;
		else d[x][y]=3;
	}
	iv[0]=iv[1]=1; for (int i=2;i<=3;i++) iv[i]=(ll)(mod-mod/i)*iv[mod%i]%mod;
	dp[1][1]=1;
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=m;j++) {
			if (i==n&&j==m) { printf("%lld\n",(ll)dp[n][m]*ksm(3,n*m-K)%mod); return 0; }
			for (int k=1;k<=3;k++) {
				if (d[i][j]&&d[i][j]!=k) continue;
				if (!d[i][j]) tmp=iv[3]; else tmp=1;
				if (k!=2) update(dp[i][j+1],(ll)dp[i][j]*tmp%mod);
				if (k!=1) update(dp[i+1][j],(ll)dp[i][j]*tmp%mod);
			}
		}
	}
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Integer overflow?

  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?

  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?

  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
#define FOR(i, a, b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(ll i = (ll)(a - 1); i >= (ll)(b); i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

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

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

long long mod_pow(long long x, long long y, long long M){
    if(y == 0){
        return 1;
    }
    if(y & 1){
        return mod_pow(x, y - 1, M) * x % M;
    }
    long long t = mod_pow(x, y / 2, M);
    return t * t % M;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H,W,K;
    cin >> H >> W >> K;
    vvc C(H,vc(W,'O'));
    rep(i,K){
        int h,w;
        char c;
        cin >> h >> w >> c;
        h--;w--;
        C[h][w]=c;
    }
    vvl dp(H+1,vl(W+1,0));
    dp[0][0]=mod_pow(3,H*W-K,MOD2);
    ll i3=mod_pow(3,MOD2-2,MOD2);
    rep(i,H){
        rep(j,W){
            if(C[i][j]=='O'){
                dp[i][j+1]+=2*i3*dp[i][j];
                dp[i+1][j]+=2*i3*dp[i][j];
            }
            else if(C[i][j]=='X'){
                dp[i][j+1]+=dp[i][j];
                dp[i+1][j]+=dp[i][j];
            }
            else if(C[i][j]=='D'){
                dp[i+1][j]+=dp[i][j];
            }
            else if(C[i][j]=='R'){
                dp[i][j+1]+=dp[i][j];
            }
            dp[i+1][j]%=MOD2;
            dp[i][j+1]%=MOD2;
        }
    }
    cout << dp[H-1][W-1] << endl;
}


#include<iostream>
using namespace std;

int main() {
	int n;
	cin >> n;
	double x[n], y[n];
	for (int i = 0;i < n;i++) {
		cin >> x[i] >> y[i];
	}
	int flag = 0;
	for (int i = 0;i < n - 2;i++) {
		for (int j = i + 1;j < n - 1;j++) {
			for (int k = j + 1;k < n;k++) {
				if (x[i] == x[j]) {
					if (x[i] == x[k]) {
						flag = 1;
						goto ans;
					}
				}
				else {
					double dx, dy, b;
					dx = x[i] - x[j];
					dy = y[i] - y[j];
					b = y[i] - dy * x[i] / dx;
					double right, left;
					left = y[k];
					right = dy * x[k] / dx + b;
					if (abs(left - right) < 0.00001) {
						flag = 1;
						goto ans;
					}
				}
			}
		}
	}
	goto ans;
ans:
	if (flag==1) cout << "Yes" << endl;
	else cout << "No" << endl;
}

//clear adj and visited vector declared globally after each test case
//check for long long overflow
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Incase of close mle change language to c++17 or c++14
/**#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops”)**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007ll //998244353ll
#define lld long double
#define mii map<int, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int a[n][n];
    int r[n];
    rep(i,0,n)
    {
        r[i]=1e9;
        rep(j,0,n)
        {
            cin>>a[i][j];
            r[i]=min(r[i], a[i][j]);
        }
    }
    int c[n], f=0;
    rep(i,0,n)
    {
        c[i]=a[0][i]-r[0];
    }
    rep(i,0,n)
    {
        rep(j,0,n)
        {
            if(r[i]+c[j]!=a[i][j])
            {
                cout<<"No";
                return 0;
            }
        }
    }
    cout<<"Yes\n";
    rep(i,0,n)
    cout<<r[i]<<" ";cout<<"\n";
    rep(i,0,n)
    cout<<c[i]<<" ";
}


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

void hoge(int a, int b) {
  if (a>b) {
    cout << ">" << endl;
  } else if (a<b) {
    cout << "<" << endl;
  } else {
    cout << "=" << endl;
  }
  return;
}

int main() {

  int A, B, C;
  cin >> A >> B >> C;

  // cout << pow(A,C) << endl;
  // cout << pow(B,C) << endl;

  if (A>=0 && B>=0) {
    hoge(A,B);
  } else {
    if (C % 2==0) {
      hoge(abs(A),abs(B));
    } else {
      hoge(A, B);
    }
  }
  // if (pow(A,C)<pow(B,C)) {
  //   cout << "<" << endl;
  // } else if (pow(A,C)>pow(B,C)) {
  //   cout << ">" << endl;
  // } else {
  //   cout << "=" << endl;
  // }
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vcc = vector<vc>;
using Pii = pair<int,int>;
using ld = long double;

#define rep(i,n) for(int i = 0; i<(int)n; i++)
#define per(i,n) for(int i = n-1; i>=0; i--)
#define mysort(V) sort(V.begin(),V.end())
#define myreverse(V) reverse(V.begin(),V.end())
#define myunique(V) V.erase( unique(V.begin(), V.end()), V.end() );
#define print(s) cout << s << endl;

const ld PI = 3.14159265358979;
const long long INF = 1234567890987654321;

long long powll(long long x, long long n){
    if(n == 0) return 1;
    else       return powll(x,n-1)*x;
}

long long gcd(long long a, long long b){
    if(a%b==0) return b;
    else return gcd(b,a%b);
}

long long nCr(long long n, long long r){
    if(r<0 || n<r) return 0;
    long long ans = 1;
    for(int i =1; i<=r; i++){
        ans *= n-i+1;
        ans /= i;
    }
    return ans;
}

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ok;
    //偶数
    if(c%2==0){
        if(abs(a)>abs(b)){
            ok = 1;
        }
        else if(abs(a)==abs(b)){
            ok = 0;
        }
        else{
            ok = -1;
        }
    }
    else{
        if(a<0 && b<0){
            ok = a-b;
        }
        else if(a<0){
            ok = -1;
        }
        else if(b<0){
            ok = 1;
        }
        else{
            ok = a-b;
        }
    }
    if(ok>0) cout << ">" << endl;
    else if(ok==0) cout << "=" << endl;
    else cout << "<" << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vl;
typedef vector<vector<ll>> vll;
typedef vector<bool> vb;
typedef set<int> si;
typedef queue<int> qi;
typedef stack<int> sti;
typedef priority_queue<int> pqi;
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
//#define __builtin_popcountll bitCountLL
//#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
//std::uniform_int_distribution<long long> rg(1,1e18);
#define maxn 100005
#define Mod 1000000007
const int INF = 2e9;
const ll ML = 4e18;
vii perm;
int n, m;
void dfs(int i, vector<int>& rs, int state) {
    if(i == n) {
        perm.push_back(rs);
        return;
    }
    for(int j = 0; j < n; j++) {
        if(state & (1 << j) ){
            rs.push_back(j + 1);
            dfs(i + 1, rs, state ^ (1 << j) );
            rs.pop_back();
        }
    }
}
int ans;
void helper(vi& w, vi& p, vi& b, vi& ma) {
    vi a(n);
    fori(i,0,n) a[i] = w[p[i] - 1];
    vi sum(n);
    sum[0] = a[0];
    fori(i,1,n) sum[i] = a[i] + sum[i - 1];
    int rs = 0;
    vii dp(n, vi(n, 0));
    fori(i,0,n) {
        rep(j, i - 1, 0) {
            int dw = (j == 0 ? sum[i] : sum[i] - sum[j - 1]);
            int idx = lower_bound(all(b), dw) - b.begin();
            dp[j][i] = (idx == 0 ? 0 : ma[idx -1]);
            rep(k,i-1, j) {
                dp[j][i] = max(dp[j][i], dp[k][i] + dp[j][k]);
            }
        }
    }
    ans = min(ans, dp[0][ n -1]);
}

void solve() {
    cin >> n >> m;
    vi w(n);
    vector<pii> bridge(m);
    fori(i,0,n) {
        cin >> w[i];
    }
    fori(i,0,m) cin >> bridge[i].second >> bridge[i].first;
    sort(all(bridge));
    fori(i,0,n) {
        if(w[i] > bridge[0].first) {
            cout << -1 << endl;
            return;
        }
    }
    vi mx(m);
    mx[0] = bridge[0].second;
    fori(i,1,m) mx[i] = max(mx[i-1], bridge[i].second);
    vi rs;
    dfs(0,rs,(1 << n) - 1);
    ans =  INF;
    vi b(m);
    fori(i,0,m) b[i] = bridge[i].first;
    fori(i, 0 , perm.size()) helper(w, perm[i], b, mx);
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
//	freopen("D:\\data_in.txt", "r", stdin);

    solve();

    /*
    clock_t start,finish;
    start = clock();

    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/

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

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 solve() {
  int n, m;
  cin >> n >> m;
  vector<ll> w(n);
  ll maxW = 0;
  rep(i, n) {
    cin >> w[i];
    chmax(maxW, w[i]);
  }
  vector<ll> l(m), v(m);
  rep(i, m) {
    cin >> l[i] >> v[i];
    if (v[i] < maxW) return -1;
  }

  // 前処理
  vector<ll> dist(1 << n, 0);
  for (int bit = 0; bit < (1 << n); ++bit) {
    ll W = 0;
    rep(i, n) {
      if (bit & (1 << i)) W += w[i];
    }
    rep(i, m) {
      if (v[i] < W) {
        chmax(dist[bit], l[i]);
      }
    }
  }

  // DP
  ll res = 1LL << 60;
  vector<int> ids(n);
  iota(ids.begin(), ids.end(), 0);
  do {
    vector<ll> dp(n, 0);
    for (int i = 1; i < n; ++i) {
      int bit = (1 << ids[i]);
      for (int j = i - 1; j >= 0; --j) {
        bit |= (1 << ids[j]);
        chmax(dp[i], dp[j] + dist[bit]);
      }
    }
    chmin(res, dp[n - 1]);
  } while (next_permutation(ids.begin(), ids.end()));

  return res;
}

int main() { cout << solve() << endl; }


/*
 /+===================================================+\
//+---------------------------------------------------+\\
|.|\\...>>>>>>> Hollwo_Pelw's 2nd template<<<<<<<...//|.|
\\+---------------------------------------------------+//
 \+===================================================+/
*/
#include <bits/stdc++.h>
using namespace std;
// type
typedef long long ll;
typedef long double ld;
// pair
#define F                   first
#define S                   second
#define pii                 pair<int, int>
#define pll                 pair<ll, ll>
#define pdd                 pair<ld, ld>
// vector & !!?(string)
#define eb                  emplace_back
#define pb                  push_back
#define all(a)              a.begin(), a.end()
#define rall(a)             a.rbegin(), a.rend()
#define sz(a)               a.size()
// I/O
#define setpre(n)           fixed << setprecision(n)
#define Ptest(x)            return cout << x << endl, (void) 0;
bool endline = false;
template<class T>
istream& operator >> (istream& inp, vector<T>& v){
    for (auto& it : v) inp >> it;
    return inp;
}
template<class T>
ostream& operator << (ostream& out, vector<T>& v){
    for (auto& it : v) out << it << (endline ? "\n" : " ");
    return out;
}
template<class T, class U>
istream& operator >> (istream& inp, pair<T, U>& v){
    inp >> v.F >> v.S;
    return inp;
}
template<class T, class U>
ostream& operator << (ostream& out, pair<T, U>& v){
    out << v.F << ' ' << v.S;
    return out;
}
// geometry calculate
#define pi                  acos(-1.0)
#define g_sin(a)            sin(a*pi/180)
#define g_cos(a)            cos(a*pi/180)
#define g_tan(a)            tan(a*pi/180)
// set val
#define ms0(a)              memset(a,        0, sizeof(a));
#define ms1(a)              memset(a,        1, sizeof(a));
#define msn1(a)             memset(a,       -1, sizeof(a));
#define msinf(a)            memset(a, 0x3f3f3f, sizeof(a));

void FAST_IO(string filein, string fileout);
void Hollwo_Pelw();

signed main(){
    FAST_IO("input.inp", "output.out");
    int testcases = 1;
    // cin >> testcases;
    for (int test = 1; test <= testcases; test++){
        // cout << "Case #" << test << ": ";
        Hollwo_Pelw();
    }
    return 0;
}

void FAST_IO(string filein = "", string fileout = ""){
    if (fopen(filein.c_str(), "r")){
        freopen(filein.c_str(), "r", stdin);
        freopen(fileout.c_str(), "w", stdout);
    }
    cin.tie(0), cout.tie(0) -> sync_with_stdio(0);
}

// constant
const int allmod[3] = {(int) 1e9 + 7, 998244353, (int) 1e9 + 9};
const int mod = allmod[1];
const int MAXN = 2e5 + 6;
const int inf = 2e9;
const ll linf = 1e18;
#define int long long

int n, m;

void Hollwo_Pelw() {
    cin >> n >> m;
    if (m % n) cout << "No";
    else cout << "Yes";
}

/*

./-=====>>><<<-------- DEBUG -------->>><<<=====-\.
/.................................................\
+====================== INP ======================+

+====================== OUT ======================+

+======================*****======================+
\................................................./
.\-=====>>><<<--------= END =-------->>><<<=====-/.

*/

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

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

  if(h % n == 0)
    cout << "Yes";
  else
    cout <<"No";
}


#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = (1<<30)-1;
const ll linf = 1LL<<61;
const int MAX = 510000;
int dy[8] = {0,1,0,-1,1,-1,-1,1};
int dx[8] = {-1,0,1,0,1,-1,1,-1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    int sz = a.size();
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr;
        sz--;
        if(sz) cout << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

map<ll,ll> mp;
vl B(80,0);
vl v({2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71});
ll dp[2][1<<20];

int main(){
    ll a,b; cin >> a >> b;
    for(ll i=a; i<=b; i++){
        rep(j,20){
            if(i % v[j] == 0) B[i-a] |= 1<<j;
        }
    }
    dp[0][0] = 1;
    int bit = 1<<20;
    for(ll i=a; i<=b; i++){
        rep(j,bit) dp[1][j] = 0;
        rep(j,bit){
            dp[1][j] += dp[0][j];
            if((j & B[i-a]) == 0) dp[1][j+B[i-a]] += dp[0][j];
        }
        swap(dp[0],dp[1]);
    }
    ll ans = 0;
    rep(i,bit) ans += dp[0][i];
    cout << ans << "\n";
}

#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxX = 72, maxPrimes = 20;
bool notPrime[maxX + 1];
vector<lli> primes;

const int maxN = 72;
lli a, b; int n;
int primesMask[maxN + 1];
lli memo[maxN + 1][1LL << maxPrimes];
lli solve(int i = 0, int mask = 0)
{
  if (i == n + 1)
    return 1;
  lli &ans = memo[i][mask];
  if (ans != -1)
    return ans;

  ans = solve(i + 1, mask);
  if (!(mask & primesMask[i]))
    ans += solve(i + 1, mask | primesMask[i]);
  return ans;
}

int main()
{
  notPrime[0] = notPrime[1] = true;
  for (int i = 2; i <= maxX; i ++)
  {
    if (!notPrime[i]) primes.push_back(i);
    for (int j = 0; i*primes[j] <= maxX; j ++)
    {
      notPrime[i*primes[j]] = true;
      if (i % primes[j] == 0) break;
    }
  }

  while (~scanf("%lld %lld", &a, &b))
  {
    n = b - a;
    for (lli i = a; i <= b; i++)
    {
      primesMask[i - a] = 0;
      for (int j = 0; j < primes.size(); j++)
      {
        int p = primes[j];
        if (i % p == 0)
          primesMask[i - a] |= (1LL << j);
      }
    }

    memset(memo, -1, sizeof(memo));
    lli ans = solve();
    printf("%lld\n", ans);
  }
  return 0;
}


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

int main(){
  int N; cin >> N;
  vector<int> A(N); rep(i,N) cin >> A[i];
  ll res = 1;
  vector<int> p={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
  ll ans = 1e18;
  rep(i,(1<<15)){
    ll x=1;
    rep(j,15) if((i>>j)&1) x*=p[j];
    if(x==1) continue;
    int ok = 1;
    rep(j,N){
      if(gcd(x,A[j])==1) ok=0;
    }
    if(ok) chmin(ans, x);
  }
  cout << ans << endl;
  return 0;
}

// clang-format off
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifndef godfather
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

#define int long long
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef gp_hash_table<int, int> umap;
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> oset;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pii> vii;

#define INF 1000000000000000000
#define inf 1000000000
#define MOD  1000000007
#define PI 3.1415926535897932385

#define pb push_back
#define bitc __builtin_popcountll
#define mp make_pair
#define all(ar) ar.begin(), ar.end()

#define fr(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define rep(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define frr(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
#define foreach(it, ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fil(ar, val) memset(ar, val, sizeof(ar))  // 0x3f for inf, 0x80 for -INF can also use with pairs

#ifdef godfather
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T>
void __p(std::vector<T> a) { cout << "{ "; for (auto p : a) __p(p); cout << "}"; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.first); __p(a.second); cout << "}"; }
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) { __p(a1); __p(a...); }
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cout<<name<<" : ";__p(arg1);cout<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    int bracket=0,i=0;
    for(; ;i++)
        if(names[i]==','&&bracket==0)
            break;
        else if(names[i]=='(')
            bracket++;
        else if(names[i]==')')
            bracket--;
    const char *comma=names+i;
    cout.write(names,comma-names)<<" : ";
    __p(arg1);
    cout<<"| ";
    __f(comma+1,args...);
}
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define end_routine()
#endif

mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l, r) uniform_int_distribution<int>(l, r)(rng32)
inline bool equals(double a, double b) { return fabs(a - b) < 1e-9; }
ll modpow(ll b, ll e, ll mod=MOD) {
    ll ans=1; for(;e;b=b*b%mod,e/=2) if(e&1) ans=ans*b%mod; return ans; }

ld modp(ld b, ll e) {
    ld ans=1; for(;e;b=b*b,e/=2) if(e&1) ans=ans*b; return ans; }

void solve()
{
    // START
    ll n;
    cin>>n;
    set<ll>primes={2,3,5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
    ll pro=1;
    vi arr(n);
    rep(i,n){
        cin>>arr[i];
        if(primes.count(arr[i]))pro*=arr[i];
    }
    ll ans=pro;
    for(;true;ans+=pro){
        bool ok=true;
        for(auto k:arr){
            if(__gcd(k, ans)==1){
                ok=false;break;
            }
        }
        if(ok){
            cout<<ans<<"\n";
            break;
        }
    }
    // END
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(15);   cout<<fixed;
    #ifdef godfather
        cin.exceptions(cin.failbit);
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    fr(i,1,t)
    {
        // cout<<"Case #"<<i<<":"<<" ";
        solve();
    }
    end_routine();
}


#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
// #pragma GCC target("avx2")
// 293206GT
#include <array>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>
#include <limits>
#include <set>
#include <map>
#include <queue>
//#include <unordered_map>
//#include <unordered_set>
//#include <unordered_set>
//#include <stack>
#include <string>
#include <algorithm>
#include <random>
#include <bitset>
#include <chrono>
//#include <cstdlib>
//#include <cstring>

// #include <bits/extc++.h>
// using namespace __gnu_pbds;
//template<class T>
//using OrderedSet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
#define int ll
// #define int long long
using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) ((x) * (x))
typedef pair<int, int> pii;
typedef long double ld;
typedef pair<ld, ld> pld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
#define ts to_string
#define sts string ts

sts(string s) { return s; }

sts(bool b) { return b ? "true" : "false"; }

sts(char c) { return string(1, c); }

sts(const char *s) { return (string) s; }

template<class A, class B>
sts(pair<A, B>);

template<class T>
sts(T v) {
    string s = "{", sep = "";
    for (auto x : v) {
        s += sep;
        sep = ", ";
        s += ts(x);
    }
    return s + "}";
}

template<class A, class B>
sts(pair<A, B> p) { return "(" + ts(p.first) + ", " + ts(p.second) + ")"; }

void dbgPrint() { cerr << endl; }

template<class A, class... B>
void dbgPrint(A a, B... b) {
    cerr << ' ' << ts(a);
    dbgPrint(b...);
}

#ifdef LOCAL
#define dbg(...) cerr << "line #" << __LINE__ << " [" << #__VA_ARGS__ << "]:", dbgPrint(__VA_ARGS__)
#else
#define dbg(...)
#endif

#define sz(a) (int) (a).size()
#define len(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define eb emplace_back
#define rep(x, y, a) for (int x = (y); x < (int)(a); ++x)
#define asd(n) rep(i, 0, n)
#define jkl(n) rep(j, 0, n)
#define UB upper_bound
#define LB lower_bound
#define mp make_pair
namespace IO {

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a);

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a);

    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a) {
        for (pair<A, B> x : a)
            out << x.first << " " << x.second << '\n';
        return out;
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a) {
        for (A x : a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x : a) in >> x;
        return in;
    }
}  // namespace IO

template<class A, class B>
inline int chkmax(A &a, B b) {
    if (a < (A) b) {
        a = (A) b;
        return 1;
    }
    return 0;
}

template<class A, class B>
inline int chkmin(A &a, B b) {
    if (a > (A) b) {
        a = (A) b;
        return 1;
    }
    return 0;
}

using namespace IO;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve();

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(41);
    int q = 1;
    // cin >> q;
    while (q--) solve();
}

void solve() {
    int n;
    cin >> n;
    vi a(n);
    cin >> a;
    sort(all(a));
    int f = 1;
    asd(n) if (a[i] != i + 1) f = 0;
    if (f) put("Yes");
    else put("No");
}

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

int main() {
	string s;
	cin >> s;
	deque<char>deq;
	int rc = 0;
	rep(i, 0, s.size()) {
		if (s[i] == 'R') rc++;
		else {
			if (rc % 2 == 0) deq.push_back(s[i]);
			else deq.push_front(s[i]);
		}
	}
	stack<char>st;
	while(!deq.empty()) {
		char v = deq.front();
		deq.pop_front();
		if(!st.empty() && v == st.top()) st.pop();
		else st.push(v);
	}
	string ans;
	while (!st.empty()) {
		char a = st.top();
		ans.push_back(a);
		st.pop();
	}
	if (rc % 2 == 0) reverse(ans.begin(), ans.end());
	cout << ans << endl;
}


// Template
#include "bits/stdc++.h"
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003LL;
template <typename T>
inline bool chmin(T &x, const T &y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T>
inline bool chmax(T &x, const T &y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}
struct IOSET {
    IOSET() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
    }
} ioset;

// Main
int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
        if (a[i] > 0) --a[i];
        if (b[i] > 0) --b[i];
    }

    vector<int> v(2 * n, -1);
    rep(i, n) {
        if (a[i] != -1) v[a[i]] = i;
        if (b[i] != -1) v[b[i]] = i + n;
    }

    int cnt = 0;
    rep(i, n) if (a[i] == -1 && b[i] == -1) ++cnt;
    auto dfs = [&](auto f, int now) -> void {
        // cout << now << "\n";
        if (now == 2 * n) {
            cout << "Yes\n";
            exit(0);
        }
        rep(i, 1, n + 1) {
            if (now + i * 2 > 2 * n) break;
            bool flag = true;
            int c = 0;
            rep(j, now, now + i) {
                if (v[j] >= n || (v[j + i] != -1 && v[j + i] < n)) {
                    flag = false;
                    break;
                }
                if (v[j] != -1) {
                    if (b[v[j]] != -1 && b[v[j]] != j + i) {
                        flag = false;
                        break;
                    }
                }
                if (v[j + i] != -1) {
                    if (a[v[j + i] - n] != -1 && a[v[j + i] - n] != j) {
                        flag = false;
                        break;
                    }
                }
                if (v[j] == -1 && v[i + j] == -1) ++c;
            }
            if (c > cnt) flag = false;
            if (!flag) continue;
            cnt -= c;
            f(f, now + 2 * i);
            cnt += c;
        }
    };
    dfs(dfs, 0);
    cout << "No\n";
}

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

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

int main(){
  int N;cin>>N;
  vector<long> x,y,z;
  for(int i=0;i<2*N;i++){
    long a;char c;cin>>a>>c;
    if(c=='R') x.push_back(a);
    if(c=='G') y.push_back(a);
    if(c=='B') z.push_back(a);
  }
  int l,m,n,cnt;
  long X,Y,Z;X=Y=Z=(1L<<60);
  if(!(x.size()&1) && !(y.size()&1) && !(z.size()&1)){
    cout<<0<<endl;
    return 0;
  }

  if(!(x.size()&1)) swap(x,z);
  if(!(y.size()&1)) swap(y,z);

  //if((x.size()&1) && (y.size()&1)){
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
  sort(z.begin(),z.end());
    //if(x.size()>y.size()) swap(x,y);
    l=x.size();m=y.size();n=z.size();
    cnt=0;
    for(int i=0;i<l;i++){
      if(X==0) break;
      for(int j=cnt;j<m;j++){
        if(j==m-1){
          chmin(X,abs(x[i]-y[j]));
          break;
        }
        if(y[j]==x[i]){
          X=0;
          break;
        }
        if(y[j+1]<=x[i]){
          cnt++;
          continue;
        }
        chmin(X,abs(x[i]-y[j]));
        chmin(X,abs(x[i]-y[j+1]));
        break;
      }
    }
  cnt=0;
  for(int i=0;i<m;i++){
    if(Y==0) break;
      for(int j=cnt;j<n;j++){
        if(j==n-1){
          chmin(Y,abs(y[i]-z[j]));
          break;
        }
        if(z[j]==y[i]){
          Y=0;
          break;
        }
        if(z[j+1]<=y[i]){
          cnt++;
          continue;
        }
        chmin(Y,abs(y[i]-z[j]));
        chmin(Y,abs(y[i]-z[j+1]));
        break;
      }
    }
  cnt=0;
  for(int i=0;i<n;i++){
    if(Z==0) break;
      for(int j=cnt;j<l;j++){
        if(j==l-1){
          chmin(Z,abs(z[i]-x[j]));
          break;
        }
        if(x[j]==z[i]){
          Z=0;
          break;
        }
        if(x[j+1]<=z[i]){
          cnt++;
          continue;
        }
        chmin(Z,abs(z[i]-x[j]));
        chmin(Z,abs(z[i]-x[j+1]));
        break;
      }
    }
  cout<<min(X,Y+Z)<<endl;
}