#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>
#include <numeric>
#include <chrono>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 998244353;

int dp[3022][6044];

int solve2(int n,int k) {
    if(k > n) return 0;
    if(k == n) return 1;
    if(k == 0) return 0;

    if(dp[n][k] != 0) return dp[n][k];
    return dp[n][k] = (solve2(n-1, k-1) + 0LL + solve2(n, 2*k))%mod;
}

void solve() {
  int n,k;cin>>n>>k;
  cout << solve2(n,k) << endl;
}

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);
 // cout << fixed << setprecision(15);
 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 int t=1;//cin>>t;
 while (t--) {
   solve();
 }

 return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (ll i = ((n) - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

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

template <typename T>
void print(vector<T>& x) {
    int N = x.size();
    REP(i, N) {
        if (i > 0) cout << " ";
        cout << x[i];
    }
    cout << "\n";
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

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

    vector<vector<Pll>> xyz(n + 1);
    REP(i, m) {
        ll _x, _y, _z;
        cin >> _x >> _y >> _z;
        xyz[_x].eb(make_pair(_y, _z));
    }

    vector<ll> dp(1LL << n, 0);
    dp[0] = 1;

    REP(i, n) {
        REVREP(j, 1LL << n) {
            if (bcnt(j) != i || dp[j] == 0) continue;

            REP(k, n) {
                if (j >> k & 1) continue;
                ll sn = j | (1LL << k);
                bool f = true;
                for (auto [y, z]: xyz[i + 1]) {
                    ll mask = (1LL << y) - 1;
                    if (bcnt(sn & mask) > z) {
                        f = false;
                        break;
                    }
                }

                if (f) dp[sn] += dp[j];
            }
        }
    }

    print(dp[(1LL << n) - 1]);
}


#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

  int n;
  cin>>n;
  vector<pair<ll,int>> X(n),Y(n);
  rep(i,n){
    ll x,y;
    cin>>x>>y;
    X[i]={x,i};
    Y[i]={y,i};
  }
  sort(ALL(X));
  sort(ALL(Y));

  vector<pair<ll,pair<int,int>>> A;
  A.push_back({X[n-1].first-X[0].first,{X[n-1].second,X[0].second}});
  A.push_back({X[n-1].first-X[1].first,{X[n-1].second,X[1].second}});
  A.push_back({X[n-2].first-X[0].first,{X[n-2].second,X[0].second}});
  A.push_back({Y[n-1].first-Y[0].first,{Y[n-1].second,Y[0].second}});
  A.push_back({Y[n-1].first-Y[1].first,{Y[n-1].second,Y[1].second}});
  A.push_back({Y[n-2].first-Y[0].first,{Y[n-2].second,Y[0].second}});

  sort(ALL(A));
  reverse(ALL(A));

  ll ma=A[0].first;
  ll tma0=A[0].second.first,tma1=A[0].second.second;
  if(tma1>tma0) swap(tma1,tma0);

  ll sma0=A[1].second.first,sma1=A[1].second.second;
  if(sma1>sma0) swap(sma1,sma0);

  if(tma1==sma1 && tma0==sma0){
    cout<<A[2].first<<endl;
  }
  else cout<<A[1].first<<endl;

  return 0;
}

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

pair<int,int> solve(int x,int y) {
    if(x > y) {
        swap(x,y);
    }
    return {x,y};
}

int main() {
    int N;
    cin >> N;
    vector<pair<pair<int,int>,int>>tmp(N);
    for(int i = 0; i < N; i++) {
        cin >> tmp[i].first.first >> tmp[i].first.second;
        tmp[i].second = i;
    }
    sort(tmp.begin(),tmp.end());
    vector<pair<int,pair<int,int>>>tmp2;
    tmp2.push_back({tmp[N-1].first.first-tmp[0].first.first,solve(tmp[N-1].second,tmp[0].second)});
    tmp2.push_back({tmp[N-1].first.first-tmp[1].first.first,solve(tmp[N-1].second,tmp[1].second)});
    tmp2.push_back({tmp[N-2].first.first-tmp[0].first.first,solve(tmp[N-2].second,tmp[0].second)});
    for(int i = 0; i < N; i++) {
        swap(tmp[i].first.first,tmp[i].first.second);
    }
    sort(tmp.begin(),tmp.end());
    tmp2.push_back({tmp[N-1].first.first-tmp[0].first.first,solve(tmp[N-1].second,tmp[0].second)});
    tmp2.push_back({tmp[N-1].first.first-tmp[1].first.first,solve(tmp[N-1].second,tmp[1].second)});
    tmp2.push_back({tmp[N-2].first.first-tmp[0].first.first,solve(tmp[N-2].second,tmp[0].second)});
    sort(tmp2.rbegin(),tmp2.rend());
    for(int i = 1; i < tmp2.size(); i++) {
        if(tmp2[i].second != tmp2[i-1].second) {
            cout << tmp2[i].first << endl;
            return 0;
        }
    }
}


#include <bits/stdc++.h>
using i64 = long long;
using u32 = unsigned;
using u64 = unsigned long long;
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    i64 n;
    std::cin >> n;
    std::string s, t;
    std::cin >> s;
    std::cin >> t;
    std::vector<int> a, b;
    for (int i = 0; i < n; i++) {
        if (s[i] == '0') {
            a.push_back(i);
        }
        if (t[i] == '0') {
            b.push_back(i);
        }
    }
    if (a.size() != b.size()) {
        std::cout << "-1\n";
        return 0;
    }
    int ans = 0;
    for (int i = 0; i < int(a.size()); i++) {
        ans += (a[i] != b[i]);
    }
    std::cout << ans << "\n";
    return 0;
}

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
using ll=long long int;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

bitset<7> dp[201010];

int main(){
   int n;
   cin>>n;
   string s,t;
   cin>>s>>t;

   dp[n]=1;
   for(int i=n-1;i>=0;i--){
      if(t[i]=='A'){
         rep(x,0,7)dp[i][x]=1;
         rep(x,0,7){
            if(!dp[i+1][(10*x+(s[i]-'0'))%7]){
               dp[i][x]=0;
            }
            if(!dp[i+1][(10*x)%7]){
               dp[i][x]=0;
            }
         }
      }
      else{
         rep(x,0,7){
            if(dp[i+1][(10*x+(s[i]-'0'))%7]){
               dp[i][x]=1;
            }
            if(dp[i+1][(10*x)%7]){
               dp[i][x]=1;
            }
         }
      }
   }
   if(dp[0][0])puts("Takahashi");
   else puts("Aoki");
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, j, n) for (int i = (j); i < (n); ++i)
#define mp make_pair
using ll = long long;
using ld = long double;
typedef pair<int, int> P;
typedef pair<P, int> COST;
#define repl(i, n) for (ll i = 0; i < (n); ++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using vll = vector<char>;
using GrafPair = vector<vector<P>>;
using Graf = vector<vll>;
#define MAX int(1e9) + 7
#define DOUBLE fixed << setprecision(15)

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n), b(n);
    rep(i,n)cin >> a[i] >> b[i];
    map<ll,ll> money;
    rep(i,n){
        money[a[i]]=0;
    }
    money[0]= k;
    rep(i,n){
        money[a[i]]+=b[i];
    }
    vector<ll> c(n+1);
    c[0]=0;
    rep(i,n)c[i+1]=a[i];
    sort(c.begin(),c.end());
    c.erase(unique(c.begin(),c.end()),c.end());
    ll sum=0;
    ll last=0;
    rep(i,c.size()){
        if(sum>=(c[i]-last)){
            sum-=(c[i]-last);
            sum+=money[c[i]];
            last=c[i];
        }else{
            if(i==0)sum+=k;

            cout << last+sum << endl;
            return 0;
        }
    }
    cout << c[c.size()-1]+sum << endl;

}

#include <bits/stdc++.h>

#define ll long long int

using namespace std;

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, K, r, m, n;
  cin >> N >> K;
  N--;
  ll sum = N * 3, zero = 0, one = 1, tmp = 0;
  for (r = 0; r <= sum; r++){
    tmp = 0;
    if (r <= N)
      tmp = (r + 1) * (r + 1) - (r + 1) * r / 2;
    else if (r > N && r <= 2 * N)
      tmp = (r - N + 1) * (2 * N - r + 1) + (r - N + 1) * (r - N) / 2
	+ (2 * N - r) * (r + 1) - (2 * N - r) * (r + 1) / 2;
    else
      tmp = (3 * N - r + 1) * (2 * N - r + 1) + (3 * N - r + 1) * (r - N) / 2;
    if (K > tmp)
      K -= tmp;
    else
      break;
  }
  for (m = max(r - 2 * N, zero); m <= min(r, N); m++){
    tmp = (min(N, r - m) - max(r - m - N, zero) + 1);
    if (K > tmp)
      K -= tmp;
    else
      break;
  }
  for (n = max(r - m - N, zero); n <= min(N, r - m); n++){
    if (K > 1)
      K--;
    else
      break;
  }
  cout << m + 1 << ' ' << n + 1 << ' ' << r - m - n + 1 << '\n';
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN 200005
#define lowbit(x) (x&-x)
#define reg register
#define mkpr make_pair
#define fir first
#define sec second
typedef long long LL;
typedef unsigned long long uLL;
const int INF=0x3f3f3f3f;
const int mo=998244353;
const LL jzm=2333;
const int iv2=499122177;
const double Pi=acos(-1.0);
typedef pair<int,int> pii;
const double PI=acos(-1.0);
template<typename _T>
_T Fabs(_T x){return x<0?-x:x;}
template<typename _T>
void read(_T &x){
	_T f=1;x=0;char s=getchar();
	while(s>'9'||s<'0'){if(s=='-')f=-1;s=getchar();}
	while('0'<=s&&s<='9'){x=(x<<3)+(x<<1)+(s^48);s=getchar();}
	x*=f;
}
template<typename _T>
void print(_T x){if(x<0){x=(~x)+1;putchar('-');}if(x>9)print(x/10);putchar(x%10+'0');}
int n,a[MAXN],pow2[MAXN],inv2[MAXN],suf[MAXN],ans;
int add(int x,int y){return x+y<mo?x+y:x+y-mo;}
signed main(){
	read(n);for(int i=1;i<=n;i++)read(a[i]);sort(a+1,a+n+1);
	pow2[0]=1;for(int i=1;i<=n;i++)pow2[i]=add(pow2[i-1],pow2[i-1]);
	inv2[0]=1;for(int i=1;i<=n;i++)inv2[i]=1ll*inv2[i-1]*iv2%mo;
	for(int i=n;i>0;i--)suf[i]=add(suf[i+1],1ll*a[i]*pow2[i-1]%mo);
	for(int i=1;i<=n;i++)ans=add(ans,1ll*suf[i+1]*inv2[i]%mo*a[i]%mo);
	for(int i=1;i<=n;i++)ans=add(ans,1ll*a[i]*a[i]%mo);printf("%d\n",ans);
	return 0;
}

#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;
#define PI 3.141592653589793
//#include <atcoder/all>
//using namespace atcoder;
//using Mint = modint;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n, ll p){
	if(n==0) return 1;
	if(n%2) return (a*modpow(a, n-1, p))%p;
	if(!(n%2)){
		ll t=modpow(a, n/2, p);
		return (t*t)%p;
	}
}

int main(){
  int n, m; cin >> n >> m; ll igai = 0; ll iga = 0, ig = 0;
  if(n==1){
    cout << m << endl; return 0;
  }
  ll dp[m+1][n+1] = {};
  rep(i, m+1){
    rep(j, n+1){
      if(j==0) dp[i][j] = 1;
      else dp[i][j] = dp[i][j-1]*i%mod;
    }
  }
  ll minv[m+1];
  rep(i, m+1){
    minv[i] = modinv(i, mod);
  }
  for(int i=1; i<=n-1; i++){
    for(int j=1; j<=m; j++){
      ll now = dp[m][n-1] - dp[m][i-1]*dp[m-j][n-i]%mod;
      if(now<0) now+=mod;
      now%=mod;
      now*=minv[j];
      iga+=now; iga%=mod;
    }
  }
  //cout << (modpow(m, n, mod)*n%mod-igai+mod)%mod << endl;
  ll all = modpow(m, n, mod)*n%mod;
  all-=iga;
  if(all<0) all+=mod; all%=mod;
  cout << all << endl;
}


#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <list>
#include <cmath>
#include <algorithm>
#include <assert.h>

using namespace std;

template <typename input_type>
input_type input() {
    input_type inp;
    cin >> inp;

    return inp;
}

const int max_vrtx = 4e5 + 5;

bool cycle, mark[max_vrtx];
int nm, sz;
vector <int> graph[max_vrtx];

void DFS(int vrtx, int par = -1) {
    int useless = 0;
    mark[vrtx] = true;
    sz++;

    for (auto ngh: graph[vrtx]) {
        if (not mark[ngh]) {
            DFS(ngh, vrtx);
        } else if ((ngh != par) or useless) {
            cycle = true;
        } else {
            useless++;
        }
    }
}

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

    nm = input<int>();
    for (int i = 0; i < nm; i++) {
        pair <int, int> color = {input<int>(), input<int>()};

        graph[color.first].push_back(color.second);
        graph[color.second].push_back(color.first);
    }

    int ans = 0;
    for (int i = 0; i < max_vrtx; i++) {
        if ((not mark[i]) and (not graph[i].empty())) {
            DFS(i);
            if (cycle) {
                ans += sz;
            } else {
                ans += (sz - 1);
            }

            sz = 0;
            cycle = false;
        }
    }

    cout << ans;
    return 0;
}


#include <bits/stdc++.h>
#pragma GCC diagnostic warning "-std=c++11"

#define ll long long
#define pb  push_back
#define pi  acos(-1.0)
#define maxn  1000009
#define sorted(s)  sort(s.begin(),s.end())
#define sl(n)  scanf("%lld", &n)
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()

using namespace std;

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

	ll n;
	cin>>n;
	string t;
	cin>>t;

	ll x = 1e10;
	if(t=="11" or t=="0" or t=="110"){
		cout << x << "\n";
		return 0;
	}
	if(t=="1"){
		cout << 2*x << endl;
		return 0;
	}

	string s = "110";

	bool flag = false;
	ll fst;
	for(ll i=0;i<3;i++){
		ll st = i, j;
		for(j=0;j<n;j++){ //loop whole t.
			ll ind = (i+j)%3;
			char ch = s[ind];
			if(t[j] != ch){
				break;
			}
		}
		if(j==n){
			flag = true;
			fst = i;
			break;
		}
	}
	if(flag==false){
		cout << 0 << "\n";
		return 0;
	}
	// cout << fst << endl;
	ll tot = 3*1e10;
	// cout << tot << endl;
	// cout << (tot-fst)/n << endl;

	tot-=n;
	ll ans = (tot-fst)/3;
	ans++;
	cout << ans << "\n";
	return 0;
}

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  //b
  int n;
  cin >> n;
  string t;
  cin >> t;
  string s = "";
  while ((int) s.size() <= n) {
    s += "110";
  }
  s += s;
  const int long long SN = 3e10;
  long long ans = 0;

  // first
  {
    if (s.substr(0, n) == t) {
      long long st = SN - n;
      ans += st / 3 + 1;
    }
  }
  // second
  {
    if (s.substr(1, n) == t) {
      long long st = SN - n;
      st--;
      ans += st / 3 + 1;
    }
  }
  // third
  {
    if (s.substr(2, n) == t) {
      long long st = SN - n;
      st -= 2;
      ans += st / 3 + 1;
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }

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

  long long m = 998244353;

  vector<long long> min_sum(n);
  min_sum.at(0) = a.at(0);
  if (n > 1) {
    for (int i = 1; i < n; i++) {
      min_sum.at(i) = (min_sum.at(i-1)*2-a.at(i-1)+a.at(i))%m;
    }
  }

  long long res = 0;
  for (int i = 0; i < n; i++) {
    res = (res+a.at(i)*min_sum.at(i)%m)%m;
  }

  cout << res << endl;
}

#include <bits/stdc++.h>

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

using namespace std;

// #define endl '\n'
#define int long long int
#define rep(i, a, b) for (int i = a; i < b; i++)
#define revrep(i, a, b) for (int i = a; i >= b; i--)
#define pb push_back
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))

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

ostream &operator<<( ostream &output, const pii &p ) { output << p.first << " " << p.second;return output; }
istream &operator>>( istream &input, pii &p ) { input >> p.first >> p.second;return input; }
template<typename T>
void inline println(vector<T> args){ for(T i: args)cout<<i<<" ";cout<<endl; }
void amax(int& a, int b) { a = max(a, b); }
void amin(int& a, int b) { a = min(a, b); }
int ceilInt(int a, int b) {
    if(!b) return 0;
    if(a%b) return a/b + 1;
    return a/b;
}

int INF = 1e18;
int MOD = 998244353;

static int mod_inv(int a, int m = MOD) {
    int g = m, r = a, x = 0, y = 1;
    while (r != 0) {
        int q = g / r;
        g %= r; swap(g, r);
        x -= q * y; swap(x, y);
    }
    return x < 0 ? x + m : x;
}

void solve()
{
    int n; cin>>n;
    int arr[n];
    rep(i, 0, n) cin>>arr[i];
    vi two(n+1, 1), twoInv(n+1, 1);
    int inv = mod_inv(2);
    rep(i, 1, n+1) {
        twoInv[i] = (inv*twoInv[i-1])%MOD;
        two[i] = (2*two[i-1])%MOD;
    }
    auto f = [&](int i) {
        return (twoInv[i]*arr[i])%MOD;
    };
    sort(arr, arr+n);
    int ans = 0;
    int pre = 0;
    rep(i, 0, n) {
        if(i-1 >= 0)
            ans += (((pre*two[i-1])%MOD)*arr[i])%MOD;
        ans += (arr[i]*arr[i])%MOD;
        ans %= MOD;
        pre += f(i);
        pre %= MOD;
    }
    cout<<ans<<endl;
}

signed main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin>>t;
    rep(i, 0, t)
    {
        // cout<<"Case #"<<i+1<<": ";
        solve();
    }
    return 0;
}


#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(__int128_t &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(__int128_t x){
  int s=0;
  int m=0;
  char f[40];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
template<class T> inline T pow2_L(T a){
  return a*a;
}
int main(){
  __int128_t R;
  rd(R);
  __int128_t X;
  rd(X);
  __int128_t Y;
  rd(Y);
  __int128_t res;
  if((pow2_L(X))+(pow2_L(Y))==(pow2_L(R))){
    wt_L(1);
    wt_L('\n');
    return 0;
  }
  __int128_t Lj4PdHRW;
  __int128_t KL2GvlyY;
  __int128_t Q5VJL1cS;
  Lj4PdHRW = 0;
  KL2GvlyY = 1000000;
  while(Lj4PdHRW < KL2GvlyY){
    if((Lj4PdHRW + KL2GvlyY)%2==0){
      Q5VJL1cS = (Lj4PdHRW + KL2GvlyY) / 2;
    }
    else{
      Q5VJL1cS = (Lj4PdHRW + KL2GvlyY - 1) / 2;
    }
    if((pow2_L(X))+(pow2_L(Y))<=(pow2_L((Q5VJL1cS*R)))){
      KL2GvlyY = Q5VJL1cS;
    }
    else{
      Lj4PdHRW = Q5VJL1cS + 1;
    }
  }
  res =KL2GvlyY;
  if(res==1){
    res = 2;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay version 20210405-1

// --- original code ---
// {
//   __int128_t @R, @X, @Y, res;
//   if(X**2 + Y**2 == R**2) wt(1), return 0;
//   res = bsearch_min[__int128_t,c,0,1d6](X**2+Y**2 <= (c*R)**2);
//   if(res==1) res = 2;
//   wt(res);
// }

#include <stdio.h>
#include <algorithm>
#include <vector>
#define MN 100000

int n;
std::vector<int> e[MN+5];

void add(int u,int v){
	e[u].push_back(v);
}

struct state{
	int c,f,s;
}s[MN+5];

void dfs(int u){
	s[u].c = 1;
	s[u].f = 1;
	s[u].s = 0;
	std::vector<int> ve[2];
	for(auto v:e[u]){
		dfs(v);
		s[u].c += s[v].c;
		if(s[v].c&1){
			ve[1].push_back(v);
		}else{
			if(s[v].s>=s[v].f){
				s[u].s += s[v].s;
				s[u].f += s[v].f;
			}else{
				ve[0].push_back(v);
			}
		}
	}
	std::sort(ve[1].begin(),ve[1].end(),[](int a,int b)->bool{
		return s[a].s-s[a].f>s[b].s-s[b].f;
	});
	for(int i=0;i<(int)ve[1].size();i++){
		int v = ve[1][i];
		if(i&1){
			s[u].f += s[v].s;
			s[u].s += s[v].f;
		}else{
			s[u].s += s[v].s;
			s[u].f += s[v].f;
		}
	}
	if(ve[1].size()&1){
		for(auto v:ve[0]){
			s[u].f += s[v].s;
			s[u].s += s[v].f;
		}
	}else{
		for(auto v:ve[0]){
			s[u].s += s[v].s;
			s[u].f += s[v].f;
		}
	}
}

int main(){
	scanf("%d",&n);
	for(int i=2,f;i<=n;i++){
		scanf("%d",&f);
		add(f,i);
	}
	dfs(1);
	printf("%d\n",s[1].f);
}


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

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,s,e) for(int i=s ; i < e ; i++)
#define rrep(i,s,e) for(int i=s ; i > e ; i--)
#define srep(i,s,e,j) for(int i=s ; i < e ; i+=j)
#define tr(i,x) for(auto i : x)
#define inp(a) for(int i=0 ; i<a.size() ; i++)cin>>a[i]
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vb vector<bool>
#define vpi vector<pii>
#define maxpqi priority_queue<int>
#define minpqi priority_queue <int, vector<int>, greater<int> >
#define pii pair<int,int>
#define F first
#define S second
#define mk make_pair
#define pb push_back
#define pf push_front
#define endl '\n'
#define br printf("\n")
#define inf 1000000
#define imap map<int,int>
#define uimap unordered_map<int,int>
#define gcd(a,b) __gcd(a,b)
#define mod 1000000007
#define clr(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define lb lower_bound
#define ub upper_bound
#define npos string::npos
#define all(x) x.begin(),x.end()
#define descen greater<int>()

string yes="YES",no="NO";

const int hi = 1e4;

vi must;
vi wrong;

bool ok(int n){
    vi pre;
    if(n == 0)pre.pb(0);
    while(n > 0){
        pre.pb(n%10);
        n = n/10;
    }
    while(pre.size() < 4)pre.pb(0);
    sort(all(pre));
    bool ans;
    tr(i,must){
        ans = false;
        tr(j,pre){
            if(i == j){
                ans = true;
                break;
            }
        }
        if(!ans)return false;
    }
    tr(i,wrong){
        tr(j,pre){
            if(i == j){
                return false;
            }
        }
    }
    // bool ans = true;
    // tr(i,must){
    //     ans = false;
    //     // tr(j,pre){
    //     //     if(i == j){
    //     //         pre.erase(find(all(pre),j));
    //     //         ans = true;
    //     //         break;
    //     //     }
    //     // }
    //     rep(j,0,pre.size()){
    //         if(i == pre[j]){
    //             pre.erase(find(all(pre),pre[j]));
    //             ans = true;
    //             break;
    //         }
    //     }
    //     if(!ans)return false;
    // }
    // tr(i,wrong){
    //     tr(j,pre){
    //         if(i == j)return false;
    //     }
    // }
    return true;
}

void solve(){
    string s;cin>>s;
    int o = count(all(s),'o');
    if(o > 4){
        cout << 0 << endl;
        return;
    }
    rep(i,0,10){
        if(s[i] == 'o')must.pb(i);
        if(s[i] == 'x')wrong.pb(i);
    }
    // cout << "must : ";
    // tr(i,must)cout << i << " ";
    // cout<<endl;
    // cout << "wrong : ";
    // tr(i,wrong)cout << i << " ";
    // cout<<endl;
    int ans = 0;
    int tmp;
    rep(i,0,hi){
        tmp = ok(i);
        // if(tmp){
        //     cout << "- " << i << endl;
        // }
        ans += tmp;
    }
    cout << ans << endl;
    // int q;cin>>q;
    // while(q--){
    //     int n;cin>>n;
    //     cout << (ok(n) ? yes : no ) << endl;
    // }
}

int32_t main()
{
    // fastio
    // ios::sync_with_stdio(false);
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    solve();
    return 0;
}

/*
// Sort the array in descending order
    sort(arr, arr + n, greater<int>());
*/

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
inline int read() {
	int x=0,f=1;char c=getchar();
	while(c<48||c>57){if(c=='-')f=-1;c=getchar();}
	while(c>=48&&c<=57)x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
using namespace std;
typedef long long ll;
ll k;
int n;
ll div(ll x){
	if(x>=3)return x*(x-2)-x*(x-1)/2+1;
	return 0;
}
ll que(ll x){
	// 将x分成3个正整数方案数
	return div(x)-3*div(x-n)+3*div(x-2*n)-div(x-3*n);
}
ll D(ll x){
	if(x>=2)return x-1;
	return 0;
}
ll q2(ll x){
	return D(x)-2*D(x-n)+D(x-2*n);
}
int main() {
	n=read(),scanf("%lld",&k);
	int pos=-1;
	rep(i,3,3e6){
		if(que(i)>=k){pos=i;break;}
		else k-=que(i);
	}
	rep(i,1,pos-2){
		ll rst=q2(pos-i);
		if(rst>=k){
			int u=max(1,pos-i-n);
			printf("%d %lld %lld\n",i,u+k-1,pos-i-(u+k-1));
			return 0;
		}else k-=rst;
	}
	return 0;
}


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

    int a[505][505],b[505][505];

    void solve(){
      int r,c;
      cin>>r>>c;
      rep(i,r){
        rep(j,c-1){
          cin>>a[i][j];
        }
      }
      rep(i,r-1){
        rep(j,c){
          cin>>b[i][j];
        }
      }
      priority_queue<P,vector<P>,greater<P>>q;
      vector<int>dist(r*c*2,INF);

      auto push=[&](int i,int j,int k,int nd){
        int v=i*c*2+j*2+k;
        if(dist[v]<=nd){return;}
        dist[v]=nd;
        q.emplace(nd,v);
      };
      push(0,0,0,0);
      while(!q.empty()){
        auto t=q.top();q.pop();
        int d=t.first,v=t.second;
        if(dist[v]!=d){continue;}
        int i=v/(2*c),j=v/2%c,k=v%2;
        if(k==0){
          if(j+1<c){push(i,j+1,k,d+a[i][j]);}
          if(j-1>=0){push(i,j-1,k,d+a[i][j-1]);}
          if(i+1<r){push(i+1,j,k,d+b[i][j]);}
          push(i,j,1,d+1);
        }
        else{
          if(i-1>=0){push(i-1,j,1,d+1);}
          push(i,j,0,d);
        }
      }
      cout<<dist[r*c*2-2]<<endl;
    }
    int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      solve();
      return 0;
    }

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <limits>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
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(a > b){ a = b; return 1; } return 0; }
template<class T> inline int  sz(T &a) { return a.size(); }
using ll = long long; using ld = long double;
using pi = pair<int,int>; using pl = pair<ll,ll>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
const int inf = numeric_limits<int>::max();
const ll infll = numeric_limits<ll>::max();
int main()
{
  int a,b; cin >> a >> b;
  printf("%.10Lf\n", (ld)(a-b)/a*100);
  return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>
#include <cassert>
#include <random>
#include <chrono>

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

void debug_out(){ cout << "\n"; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = 1000000007;
/* const ll MOD = 998244353; */
const ll INF = 1ll<<60;
const double PI = acos(-1);

struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

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

  N *= 2;

  int ans = 0;
  vector<int> v;
  for(int i = 1; i*i <= N; i++){
    if(N%i == 0){
      if(i*i != N) v.emplace_back(N/i);
      v.emplace_back(i);
    }
  }
  N /= 2;

  for(auto x : v){
    if((x+1)%2 == 0){
      if(N%x == 0) ans++;
    }else{
      if((N+x/2)%x == 0) ans++;
      /* cout << N << " " << x/2 << "  " << N+x/2 << " " << x << "\n"; */
    }
  }

  cout << ans << "\n";

  return 0;
}

#include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;
ll n, f[200111];

ll ck[200111], step[200111];
ll dfs(ll x, ll color, ll curstep = 1) {
	ck[x] = color;
	step[x] = curstep;

	ll nx = f[x];
	if (ck[nx] == 0) {
		return dfs(nx, color, curstep + 1);
	}
	if (ck[nx] == color) {
		return curstep + 1 - step[nx];
	}
	return 0;
}

int main(void) {
	scanf("%lld", &n);
	for (ll i = 1; i <= n; i++) {
		scanf("%lld", &f[i]);
	}

	ll t = 0;
	for (ll i = 1; i <= n; i++) {
		if (!ck[i]) {
			ll cycle = dfs(i, i);
			if (cycle) {
				t++;
			}
		}
	}

	ll p = 998244353;
	ll ans = 1;
	for (ll i = 0; i < t; i++) {
		ans *= 2;
		ans %= p;
	}

	printf("%lld\n", ans - 1);
}


#include <bits/stdc++.h>
#define ss second
#define ll long long
#define mod 1000000007
#define ff first
#define pb push_back
#define pll pair<ll,ll>
#define w(x) ll x; cin>>x; while(x--)
#define ps(x,y) fixed<<setprecision(y)<<x;
#define fo(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define re(i, j) fo(i, 0, j, 1)
#define pi acos(-1)
#define all(cont) cont.begin(), cont.end()
#define countbit(x) __builtin_popcount(x)
#define de(n) ll n;cin>>n;
#define def(a,n) ll n;cin>>n;ll a[n];re(i,n){cin>>a[i];}
#define defi(a,n,k) ll n;cin>>n; ll k;cin>>k;ll a[n];re(i,n){cin>>a[i];}
#define deb(x) cout<<#x<<"="<<x<<endl;
#define tr(it,a) for(auto it=a.begin();it!=a.end();it++)
#define nl cout<<endl;
using namespace std;
//18-1326D1 1208B 845C 912B 1009B 1350C 20C 1333C 1234D 1327C 1305B 1304B (or in matrix) 1216-C(26) 21
void cp()
{
    ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
ll powermod(ll x, ll y,ll p)
{
    int res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;

        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
int main()
{
    //cp();
	de(n);
	de(p);
	if(p==2)
	{
		if(n==1)
		cout<<"1";
		else{
			cout<<"0";
		}
	}
	else
	{
		ll ans=powermod(p-2,n-1,mod);
		ans=((ans%mod)*((p-1)%mod))%mod;
		cout<<ans;
	}
}

// Problem: E - Train
// Contest: AtCoder - AtCoder Beginner Contest 192
// URL: https://atcoder.jp/contests/abc192/tasks/abc192_e
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define mod 1000000007

// templates
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define sz(x) (int)x.size()
#define po(x, y) fixed << setprecision(y) << x
#define ss(s) scanf(" %[^\n]%*c", s)
#define sc(n) scanf("%d", &n)
#define sl(n) scanf("%lld", &n)
#define ps(s) printf("%s\n", s)
#define pr(n) printf("%d\n", n)
#define pl(n) printf("%lld\n", n)
#define prs(n) printf("%d ", n)
#define pls(n) printf("%lld ", n)
using namespace std;

const ll inf = (ll)1e16 + 10;
const int N = (int)1e5 + 10;
int a[N], b[N];
vector<array<ll, 3>> adj[N];  // u->v,t,k
vector<ll> dist(N);
ll n, m, x, y;
void bfs() {
  set<array<ll, 2>> s;  // time,node
  s.insert({0, x});
  for (int i = 0; i <= n; i++) {
    dist[i] = inf;
  }
  dist[x] = 0;
  while (sz(s)) {
    auto temp = *s.begin();
    s.erase(s.begin());
    ll node = temp[1], kete = temp[0];
    for (auto c : adj[node]) {
      ll add = 0;
      if (kete < c[2] && kete != 0) {
        add = (c[2] - kete);
      } else if (kete != 0) {
        if (kete % c[2]) {
          add = c[2] - (kete % c[2]);
        }
      }
      ll curr = c[1] + add + kete;
      // printf("node-> %lld curr-> %lld\n", node, curr);
      if (dist[c[0]] > curr) {
        s.erase({dist[c[0]], c[0]});
        dist[c[0]] = curr;
        s.insert({curr, c[0]});
      }
    }
  }
  if (dist[y] == inf) {
    dist[y] = -1;
  }
  pl(dist[y]);
}
void solve() {
  sl(n), sl(m), sl(x), sl(y);
  for (int i = 1; i <= m; i++) {
    ll u, v, t, k;
    sl(u), sl(v), sl(t), sl(k);
    adj[u].push_back({v, t, k});
    adj[v].push_back({u, t, k});
  }
  bfs();
}

int main() {
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  // #endif
  int t = 1;
  // sc(t);
  while (t--) {
    solve();
  }
  // cerr << (float)clock() / CLOCKS_PER_SEC * 1000 << " ms" << endl;
  return 0;
}


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

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

#define FastIO()            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define read()              freopen("in.txt","r",stdin)
#define write()             freopen("out.txt","w",stdout)

typedef long long           ll;
typedef unsigned long long  ull;
typedef double              dbl;
typedef float               flt;

typedef pair<int, int>      pii;
typedef pair<ll, ll>        pl;

typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef vector<pii>         vpii;
typedef vector<pl>          vpl;

#define pie                 acos(-1)

#define mp                  make_pair
#define pb                  push_back
#define ff                  first
#define ss                  second

#define MAX                 300005
#define MOD                 1000000007
#define INF                 1000000100

#define for0(i, n)          for(ll i=0; i<n; i++)
#define for1(i, n)          for(ll i=1; i<=n; i++)
#define forab(i, a, b)      for(ll i=a; i<=b; i++)
#define forabx(i, a, b, x)  for(ll i=a; i<=b; i+=x)
#define forinv(i, a, b)     for(ll i=a; i>=b; i--)

#define clr0(a)             memset(a, 0, sizeof(a))
#define ceil(x, y)          (x+y-1) / (y)
#define max3(a, b, c)       max(a, max(b, c))
#define min3(a, b, c)       min(a, min(b, c))
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a * b) / __gcd(a, b))
#define sort1(a)            sort(a+1, a+n+1)
#define debug(x)            cout << "DEBUG " << x << endl;

#define Y()                 cout << "YES" << endl;
#define N()                 cout << "NO" << endl;
#define inArr(a, x, y)      forab(i, x, y) { cin >> a[i]; }
#define outArr(a, x, y)     forab(i, x, y) { cout << a[i] << " "; } cout << endl;

void solve() {
    int n;
    cin >> n;
    int now = 3;
    cout << 6 << " " << 10 << " " << 15 << " ";
    for(int i=16; ; i+=1) {
        if (i==6 || i==10 || i==15) {
            continue;
        }
        ll dv = 0;
        if (__gcd(i, 6)>1) {
            dv++;
        }
        if (__gcd(i, 10)>1) {
            dv++;
        }
        if (__gcd(i, 15)>1) {
            dv++;
        }
        if (dv>2) {
            cout << i << " ";
            now++;
        }
        if (now==n) {
            break;
        }
    }
    cout << endl;
}

void testcase() {
    ll t;
    cin >> t;
    while (t--) {
        solve();
    }
}

int main () {
    FastIO()

    //testcase();
    solve();

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<int> good = {6, 10, 15}, ans;
	for(int i = 1; i <= 10000; i++){
		int g = 0;
		for(int v : good) if((i % v) == 0) g = 1;
		if(g)
			ans.push_back(i);
	}
	swap(ans[2], ans[3]);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
		cout << ans[i] << ' ';
	return 0;
}


#define LOCAL
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;

#define rep(i,s,n) for (int i = (ll)s; i < (ll)n; i++)
#define rrep(i,n,e) for (int i = (ll)n; i > (ll)e; i--)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
// #define M_PI 3.14159265358979323846 // CF
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) cout << fixed << setprecision(10) << x << endl; // print Decimal number 10 Rank
#define endl "\n"
#define Case(x) printf("Case #%d: ", x); // gcj

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<char> vch;
typedef vector<vector<char>> vvch;

constexpr ll LINF = 1001002003004005006ll;
constexpr int INF = 1002003004;
constexpr int n_max = 2e5+10;

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

template<class T, class U>
T POW(T x, U n) {T ret=1; while (n>0) {if (n&1) {ret*=x;} x*=x; n>>=1;} return ret;};

// debug
template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';};
string to_string(const char c) {return to_string((string) &c);};
string to_string(bool b) {return (b ? "true" : "false");};
template <size_t N>
string to_string(bitset<N> v){
  string res = "";
  for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
  return res;
};
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for(const auto &x : v) {
    if(!first) res += ", ";
    first = false; res += to_string(x);
  }
  res += "}";
  return res;
};
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;};
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); };

void LINE_OUT() {
  cout << "--------------" << endl;
};

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define LINE LINE_OUT();
#else
#define debug(...) 71
#define LINE 71;
#endif

void print() { cout << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
};

template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
};

template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
    print(vec);
  }
};

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

  int N; cin >> N;
  vector<ll> X(N);
  rep(i, 0, N) cin >> X[i];
  ll m = 0;
  ld y = 0.0;
  ll c = 0;
  rep(i, 0, N) {
    m += abs(X[i]);
    chmax(c, abs(X[i]));
    y += (ld)abs(X[i]) * (ld)abs(X[i]);
  }

  y = sqrt(y);
  cout << m << endl;
  Decimal(y);
  cout << c << endl;

  return 0;
};

#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; debug_print(__VA_ARGS__); } while(false)
template<typename T, typename... Ts> void debug_print(const T &t, const Ts &...ts) { cerr << t; ((cerr << ", " << ts), ...); cerr << endl; }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, const T& b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, const T& b) { if (a < b) {a = b; return true; } return false; }
template<typename T, typename... Ts> void print(const T& t, const Ts&... ts) { cout << t; ((cout << ' ' << ts), ...); cout << '\n'; }
template<typename... Ts> void input(Ts&... ts) { (cin >> ... >> ts); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    input(n, m);
    vector<vector<int>> graph(n);
    rep(i, 0, m) {
        int a, b;
        input(a, b);
        graph[a - 1].push_back(b - 1);
    }
    vector<bool> used(n, false);
    auto dfs = [&](auto &f, int v) -> void {
        if (used[v]) return;
        used[v] = true;
        for (auto nv : graph[v]) {
            f(f, nv);
        }
    };
    int ans = 0;
    rep(i, 0, n) {
        used.assign(n, false);
        dfs(dfs, i);
        rep(j, 0, n) {
            ans += used[j];
        }
    }
    print(ans);

    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <array>
using namespace std;

string s, t;

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

	int n; cin >> n >> s >> t;
	vector<array<int, 7>> dp(n + 1);
	for (int i = 0; i < 7; i++) dp[n][i] = (i != 0);
	for(int i = n - 1; i >= 0; i--)
		for (int j = 0; j < 7; j++) {
			if (t[i] == 'A') {
				if (dp[i + 1][(j * 10) % 7]) { dp[i][j] = 1; continue; }
				if (dp[i + 1][(j * 10 + s[i] - '0') % 7]) { dp[i][j] = 1; continue; }
				dp[i][j] = 0;
			}
			else {
				if (!dp[i + 1][(j * 10) % 7]) { dp[i][j] = 0; continue; }
				if (!dp[i + 1][(j * 10 + s[i] - '0') % 7]) { dp[i][j] = 0; continue; }
				dp[i][j] = 1;
			}
		}
	cout << (dp[0][0] ? "Aoki" : "Takahashi") << '\n';
	cin.ignore(2); return 0;
}

#include <bits/stdc++.h>
#ifdef LILY
#include "./Debug.h"
#else
#define var(...) (0)
#define dbg(...) (0)
#endif
using int32 = int;
using int64 = long long;
using namespace std;

class Solution
{
#define int int32
#define sfor(i, n) for (int i = 1; i <= (n); ++i)
#define tfor(i, n) for (int i = 0; i < (n); ++i)

    int n;
    string s, x;
    // dp[i] is a set including the numbers which Takahashi wants the remainder of the current number divided by 7 to be after the appending i digits.
    vector<int> dp;

    void SHURU()
    {
        cin >> n;
        cin >> s >> x;
        dp = vector<int>(n + 1, 0);
        dp[n] = 1;
    }

    void SHUCHU()
    {
        cout << ((dp[0] & 1) ? "Takahashi\n" : "Aoki\n");
    }

    int Tmove(int ap, int tars)
    {
        dbg(var(ap));
        int ret = 0, d, e;
        for (int i = 0; i < 10; ++i)
        {
            d = (3 * i + ap) % 7;
            e = (3 * i) % 7;
            if ((tars & (1 << d)) || (tars & (1 << e)))
            {
                ret |= (1 << i);
                dbg(var(d), var(tars));
            }
        }
        return ret;
    }

    int Amove(int ap, int tars)
    {
        dbg(var(ap));
        int ret = 0, d, e;
        for (int i = 0; i < 10; ++i)
        {
            d = (3 * i + ap) % 7;
            e = (3 * i) % 7;
            if ((tars & (1 << d)) && (tars & (1 << e)))
            {
                ret |= (1 << i);
                dbg(var(d), var(e), var(tars));
            }
        }
        return ret;
    }

    void CHULI()
    {
        for (int i = n - 1; i >= 0; i--)
        {
            switch (x[i])
            {
            case 'T':
                dp[i] = Tmove(s[i] - 48, dp[i + 1]);
                break;
            case 'A':
                dp[i] = Amove(s[i] - 48, dp[i + 1]);
                break;
            default: dbg("WTF, ", var(x[i]));
                break;
            }
            dbg(var(i), var(dp[i]));
        }
    }

public:
    Solution()
    {
        SHURU();
        CHULI();
        SHUCHU();
    }
#undef int
#undef tfor
#undef sfor
};

int32 main()
#ifndef LILY
{
    Solution();
}
#endif


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

vector<vector<int>> pass;
vector<vector<int>> tour;
vector<pair<int, int>>inout;
int depth = 0;
int pcount = 0;
void dfs(int now){
  inout[now].first = pcount;
  tour[depth].emplace_back(pcount);
  depth ++;
  pcount ++;
  for(int ver: pass[now]){
    dfs(ver);
  }
  depth --;
  pcount ++;
  inout[now].second = pcount;
}
signed main() {
  int n;
  cin >> n;
  pass.resize(n);
  tour.resize(n);
  inout.resize(n);
  int p;
  for(int i = 1; i < n; i++){
    cin >> p;
    p--;
    pass[p].emplace_back(i);
  }
  dfs(0);
  REP(i, n){
    sort(tour[i].begin(), tour[i].end());
  }

  int q;
  cin >> q;
  int u, d;
  REP(i, q){
    cin >> u >> d;
    u--;
    auto in = lower_bound(tour[d].begin(), tour[d].end(), inout[u].first);
    auto out = lower_bound(tour[d].begin(), tour[d].end(), inout[u].second);
    cout << out - in <<endl;
  }

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
int add(int a,int b) {return a+b>=mod?a+b-mod:a+b;}
int dec(int a,int b) {return a<b?a+mod-b:a-b;}
int mul(int a,int b) {return 1ll*a*b%mod;}
void Add(int &a,int b) {(a+=b)>=mod?a-=mod:0;}
void Dec(int &a,int b) {(a-=b)<0?a+=mod:0;}
void Mul(int &a,int b) {a=1ll*a*b%mod;}
int pw2[303];
int c[303][303];
int f[303],g[303];
int a[200503];
int re(){
	int i=0,f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) i=(i<<3)+(i<<1)+c-'0';
	return i*f;
}
int main(){
	c[0][0]=1;
	for(int i=1;i<=300;++i){
		c[i][0]=1;
		for(int j=1;j<=i;++j) c[i][j]=add(c[i-1][j-1],c[i-1][j]);
	}
	pw2[0]=1;
	for(int i=1;i<=300;++i) pw2[i]=add(pw2[i-1],pw2[i-1]);
	int n=re(),m=re();
	for(int i=1;i<=n;++i) a[i]=re();
	int inv2=mod-mod/2;
	for(int i=1;i<=n;++i){
		int buf=1;
		for(int j=0;j<=m;++j){
			Add(f[j],buf);
			Mul(buf,a[i]);
		}
	}
	for(int i=1;i<=m;++i){
		for(int j=0;j<=i;++j){
			Add(g[i],mul(mul(f[j],f[i-j]),c[i][j]));
		}
		Dec(g[i],mul(f[i],pw2[i]));
		Mul(g[i],inv2);
		cout<<g[i]<<endl;
	}
}


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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//main
//------------------------------------------
int vector_finder(std::vector<lint> vec, lint number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main(){
    lint t,n;
    cin >> t >> n;
    n--; // 0から数えるため
    vector<lint> x,y;
    for(lint i=1;i<=100+t;i++){
        lint tmp = i*(100+t);
             tmp /=100;
        x.push_back(tmp);
    }

    for(lint i=1;i<=100+t;i++){
        if( !vector_finder(x,i)){
             y.push_back(i);
        }
    }

    lint n_t = n/y.size();
    lint cnt   = (100 + t) * n_t +  y[n%y.size()];

    cout << cnt << endl;
}

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")

//#include <immintrin.h>
//#include <emmintrin.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,h,t) for (int i=h;i<=t;i++)
#define dep(i,t,h) for (int i=t;i>=h;i--)
#define ll long long
#define me(x) memset(x,0,sizeof(x))
#define IL inline
#define rint register int
inline ll rd(){
	ll x=0;char c=getchar();bool f=0;
	while(!isdigit(c)){if(c=='-')f=1;c=getchar();}
	while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	return f?-x:x;
}
char ss[1<<24],*A=ss,*B=ss;
IL char gc()
{
	return A==B&&(B=(A=ss)+fread(ss,1,1<<24,stdin),A==B)?EOF:*A++;
}
template<class T>void maxa(T &x,T y)
{
	if (y>x) x=y;
}
template<class T>void mina(T &x,T y)
{
	if (y<x) x=y;
}
template<class T>void read(T &x)
{
	int f=1,c; while (c=gc(),c<48||c>57) if (c=='-') f=-1; x=(c^48);
	while(c=gc(),c>47&&c<58) x=x*10+(c^48); x*=f;
}
const int mo=1e9+7;
ll fsp(int x,int y)
{
	if (y==1) return x;
	ll ans=fsp(x,y/2);
	ans=ans*ans%mo;
	if (y%2==1) ans=ans*x%mo;
	return ans;
}
struct cp {
	ll x,y;
	cp operator +(cp B)
	{
		return (cp){x+B.x,y+B.y};
	}
	cp operator -(cp B)
	{
		return (cp){x-B.x,y-B.y};
	}
	ll operator *(cp B)
	{
		return x*B.y-y*B.x;
    }
    int half() { return y < 0 || (y == 0 && x < 0); }
};
struct re{
	int a,b,c;
};
const int N=6e5;
char s[N],t[N];
vector<int> v1,v2;
int main()
{
//   freopen("1.in","r",stdin);
//   freopen("1.out","w",stdout);
   ios::sync_with_stdio(false);
   int n;
   cin>>n;
   cin>>(s+1)>>(t+1);
   rep(i,1,n)
     if (s[i]-'0'==0) v1.push_back(i);
   rep(i,1,n)
     if (t[i]-'0'==0) v2.push_back(i);
   if (v1.size()!=v2.size())
   {
   	cout<<-1<<endl; return 0;
   }
   int m=v1.size();
   int cnt=0;
   rep(i,1,m) if (v1[i-1]!=v2[i-1]) cnt++;
   cout<<cnt<<endl;
   return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;typedef double db;
typedef pair<int, int> pii;typedef pair<ll, ll> pll;
typedef pair<int,ll> pil;typedef pair<ll,int> pli;
#define Fi first
#define Se second
#define _Out(a)	cerr<<#a<<" = "<<(a)<<endl
const int INF = 0x3f3f3f3f, MAXN = 1e2 + 3,MAXV=1e3+4;
const ll LINF = 0x3f3f3f3f3f3f3f3f;ll MOD = 998244353;
const db Pi = acos(-1), EPS = 1e-6;
void test(){cerr << "\n";}template<typename T,typename...Args>void test(T x,Args...args){cerr<<x<<" ";test(args...);}
inline ll qpow(ll a, ll b){return b?((b&1)?a*qpow(a*a%MOD,b>>1)%MOD:qpow(a*a%MOD,b>>1))%MOD:1;}
inline ll qpow(ll a, ll b,ll c){return b?((b&1)?a*qpow(a*a%c,b>>1,c)%c:qpow(a*a%c,b>>1,c)) %c:1;}
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll cede(ll a,ll b){if(b<0)return cede(-a,-b);if(a<0)return a/b;return (a+b-1)/b;}
inline ll flde(ll a,ll b){if(b<0)return flde(-a,-b);if(a<0)return (a-b+1)/b;return a/b;}
inline int sign(db x){return x<-EPS ? -1:x>EPS;}
inline int dbcmp(db l,db r){return sign(l - r);}
namespace Fast_IO{ //orz laofu
    const int MAXL((1 << 18) + 1);int iof, iotp;
    char ioif[MAXL], *ioiS, *ioiT, ioof[MAXL],*iooS=ioof,*iooT=ioof+MAXL-1,ioc,iost[55];
    char Getchar(){
        if (ioiS == ioiT){
            ioiS=ioif;ioiT=ioiS+fread(ioif,1,MAXL,stdin);return (ioiS == ioiT ? EOF : *ioiS++);
        }else return (*ioiS++);
    }
    void Write(){fwrite(ioof,1,iooS-ioof,stdout);iooS=ioof;}
    void Putchar(char x){*iooS++ = x;if (iooS == iooT)Write();}
    inline int read(){
        int x=0;for(iof=1,ioc=Getchar();(ioc<'0'||ioc>'9')&&ioc!=EOF;)iof=ioc=='-'?-1:1,ioc=Getchar();
        if(ioc==EOF)Write(),exit(0);
        for(x=0;ioc<='9'&&ioc>='0';ioc=Getchar())x=(x<<3)+(x<<1)+(ioc^48);return x*iof;
    }
    inline long long read_ll(){
        long long x=0;for(iof=1,ioc=Getchar();(ioc<'0'||ioc>'9')&&ioc!=EOF;)iof=ioc=='-'?-1:1,ioc=Getchar();
        if(ioc==EOF)Write(),exit(0);
        for(x=0;ioc<='9'&&ioc>='0';ioc=Getchar())x=(x<<3)+(x<<1)+(ioc^48);return x*iof;
    }
    void Getstr(char *s, int &l){
        for(ioc=Getchar();ioc==' '||ioc=='\n'||ioc=='\t';)ioc=Getchar();
        if(ioc==EOF)Write(),exit(0);
        for(l=0;!(ioc==' '||ioc=='\n'||ioc=='\t'||ioc==EOF);ioc=Getchar())s[l++]=ioc;s[l] = 0;
    }
    template <class Int>void Print(Int x, char ch = '\0'){
        if(!x)Putchar('0');if(x<0)Putchar('-'),x=-x;while(x)iost[++iotp]=x%10+'0',x/=10;
        while(iotp)Putchar(iost[iotp--]);if (ch)Putchar(ch);
    }
    void Putstr(const char *s){for(int i=0,n=strlen(s);i<n;++i)Putchar(s[i]);}
} // namespace Fast_IO
using namespace Fast_IO;

int dp[MAXN][MAXN*MAXN*MAXN];

void work()
{
    int n=read(),k=read();MOD=read();
    dp[0][0]=1;int UPD=n*(n+1)/2*k;
    for(int i=1;i<=n;i++)
    {

        for(int j=0;j<i;j++)
        {
            ll sum=0;
            for(int now=j;now<=UPD;now+=i)
            {
                sum=(sum+dp[i-1][now])%MOD;
                if(now>=i*(k+1))sum=(sum-dp[i-1][now-i*(k+1)]+MOD)%MOD;
                dp[i][now]=sum;
            }
        }
    }
    for(int x=1;x<=n;x++)
    {
        ll ans=0;
        for(int i=0;i<=UPD;i++)ans=(ans+1ll*dp[x-1][i]*dp[n-x][i]%MOD*(k+1)%MOD)%MOD;
        printf("%lld\n",(ans-1+MOD)%MOD);
    }
}
int main()
{

    //std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //int T=read();for(int cas=1;cas<=T;cas++)
    //int T;scanf("%d",&T);for(int i=1;i<=T;i++)
    work();
    // Write();
}

/**
4
-1 1
-1 -1
-1 -1
-1 -1

4
3 5
-1 -1
-1 -1
-1 -1
-1 -1

4
1 -1
2 -1
6 -1
-1 7

3
2 -1
-1 3
5 6

*/

#include <bits/stdc++.h>

#define ll long long
#define ld long double
using namespace std;

const int N = 100 + 5;

int mod, k, dp[N][N], a[N];
string s;

int add(int a, int b){
    return (a + b) % mod;
}

int mul(int a, int b){
    return 1ll * a * b % mod;
}

int fp(int b, int p){
    if(p == 0) return 1;
    int ret = fp(b, p >> 1);
    ret = mul(ret, ret);
    if(p & 1) ret = mul(ret, b);
    return ret;
}

int beats(int a, int b){
    if(a == b) return a;
    if((a + 1) % 3 == b) return b;
    return a;
}

int solve(int idx, int k){
    if(k == 0) return a[idx];
    if(dp[idx][k] != -1) return dp[idx][k];

    int l = solve(idx, k - 1);
    int r = solve(add(idx, fp(2, k - 1)), k - 1);

    return dp[idx][k] = beats(l, r);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> mod >> k >> s;
    for(int i = 0; i < mod; i++){
        if(s[i] == 'P') a[i] = 1;
        else if(s[i] == 'S') a[i] = 2;
    }
    memset(dp, -1, sizeof dp);
    int ans = solve(0, k);
    if(ans == 0) cout << 'R';
    else if(ans == 1) cout << 'P';
    else cout << 'S';

    return 0;
}


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

int
main()
{
  double A, B; cin >> A >> B;
  cout << (A / 100) * B << endl;

}

#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll>
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++)
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
    ll x, y, a, b;
    cin>>x>>y>>a>>b;
    // check when it's optimal to use b instead of a
    // when b>=x
    ll ans=0;
    while(x<b/a)
    {
    	ans++;
    	x*=a;
    	if(x>=y)
    	{
    		cout<<ans-1<<endl;
    		return;
    	}
    }
    //x/=a;
    //ans--;
    ll rem=max((ll)0, y-x);
    ans+=((rem/b));
    if(rem%b==0)
    	ans--;
    cout<<ans<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//#include <atcoder/all>
using namespace std;
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a; i > -1; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a; i > b; --i)
#define repl(i, a) for (ll i = (ll)0; i < (ll)a; ++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
#define fi first
#define se second
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll mod_998244353 = 998244353;
constexpr ll INF = 1LL << 60;

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

// using lll=boost::multiprecision::cpp_int;
// using
// Double=boost::multiprecision::number<boost::multiprecision::cpp_dec_float<128>>;//仮数部が1024桁
template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}

ll mypow(ll x, ll n, const ll &p = -1)
{ // x^nをmodで割った余り

  if (p != -1)
  {
    x = (x % p + p) % p;
  }
  ll ret = 1;
  while (n > 0)
  {
    if (n & 1)
    {
      if (p != -1)
        ret = (ret * x) % p;
      else
        ret *= x;
    }
    if (p != -1)
      x = (x * x) % p;
    else
      x *= x;
    n >>= 1;
  }
  return ret;
}

struct myrand{
  random_device seed;
  mt19937 mt;
  myrand():mt(seed()){}
  int operator()(int a,int b){//[a,b)
    uniform_int_distribution<int>dist(a,b-1);
    return dist(mt);
  }
};

// using namespace atcoder;

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

using P=pair<int,int>;
void solve()
{
  int n,m;
  cin>>n>>m;
  vector<int>x(m),y(m);
  map<int,int>mp;
  rep(i,m){
    cin>>x[i]>>y[i];
    if(!mp.count(x[i])){
      mp[x[i]]=mp.size();
    }
  }
  vector<set<int>>row(mp.size()+5);
  rep(i,m){
    row[mp[x[i]]].emplace(y[i]);
  }
  unordered_set<int>ans;
  ans.emplace(n);
  for(auto &e:mp){
    set<int>add,sub;
    for(auto &ee:row[e.se]){
      if(ans.count(ee-1)||ans.count(ee+1)){
        add.emplace(ee);
      }else if(ans.count(ee)){
        sub.emplace(ee);
      }
    }
    for(auto &ee:sub)ans.erase(ee);
    for(auto &ee:add)ans.emplace(ee);
  }
  cout<<ans.size()<<"\n";
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);
  solve();
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e6+5,inf=1e18,mod=1e9+7;
#define test ll testcases;cin>>testcases; while(testcases--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll>
#define ppll pair<ll,pair<ll,ll>>
#define pld pair<ld,ld>
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))
const ld pi=3.141592653589793238;

bool check_prime(ll n)
{
	ll flag=0,i;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			flag=1;
			break;
		}
	}
	if(n==1)
	{
		return false;
	}
	else if(flag==0 || n==2 || n==3)
	{
		return true;
	}
	else
	{
		return false;
	}
}

ll fastexpo(ll a,ll b,ll MOD)
{
	ll result=1;
	while(b>0)
	{
		if(b%2==1)
		{
			result=(result*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return result;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,i;
    cin>>n>>x;
    char str[n+1]={'\0'};
    cin>>str;
    for(i=0;i<strlen(str);i++)
    {
    	if(str[i]=='o')
    	{
    		x++;
    	}
    	else
    	{
    		if(x!=0)
    		{
    			x--;
    		}
    	}
    }
    cout<<x<<"\n";
	return 0;
}


#include <sys/time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
using ll = int64_t;
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) FOR(i, 0, n)
template <class T, class U>
bool chmax(T &a, const U &b) {
    return a < b ? a = b, true : false;
}
template <class T, class U>
bool chmin(T &a, const U &b) {
    return b < a ? a = b, true : false;
}
constexpr int INF = 1000000003;
constexpr ll LINF = 1000000000000000003;

constexpr int BEAM_SIZE = 10000;
constexpr int N = 50;
int tile[50][50];
int board[50][50];
int dirx[4] = {1, -1, 0, 0}, diry[4] = {0, 0, 1, -1};
char op[4] = {'D', 'U', 'R', 'L'};

inline bool in_board(int x, int y) {
    return x >= 0 && x < N && y >= 0 && y < N;
}

struct beam_search {
    struct State {
        int px, py;
        int score;
        bitset<2048> is_used;
        string ops;

        State(int _px, int _py) : px(_px), py(_py), score(), is_used() {
            score += board[px][py];
            is_used.set(tile[px][py]);
        }

        bool operator<(const State &rhs) const { return eval() < rhs.eval(); }
        bool operator>(const State &rhs) const { return rhs < *this; }

        int eval() const { return score; }

        void update_score(int row) {}

        void _place(int dir) {
            px += dirx[dir];
            py += diry[dir];
            score += board[px][py];
            is_used.set(tile[px][py]);
            ops.push_back(op[dir]);
        }

        State place(int dir) {
            State res(*this);
            res._place(dir);
            return res;
        }

        bool is_place(int dir) {
            int x = px + dirx[dir];
            int y = py + diry[dir];
            return in_board(x, y) && !is_used[tile[x][y]];
        }

        string answer() const {
            return ops;
        }
    };

    string solve(int sx, int sy) {
        priority_queue<State> cur, nxt;
        cur.push(State(sx, sy));
        State res(sx, sy);
        while (!cur.empty() && (double)clock() / CLOCKS_PER_SEC < 1.95) {
            while (!nxt.empty()) nxt.pop();
            while (!cur.empty()) {
                State now = cur.top();
                cur.pop();
                if (cur.empty()) chmax(res, now);
                for (int dir = 0; dir < 4; ++dir) {
                    if (!now.is_place(dir))
                        continue;
                    State s = now.place(dir);
                    if (nxt.size() < BEAM_SIZE || s.eval() > nxt.top().eval())
                        nxt.push(s);
                    if (nxt.size() > BEAM_SIZE) nxt.pop();
                }
            }
            swap(cur, nxt);
        }

        cerr << res.eval() << endl;
        return res.answer();
    }
};

int main(void) {
    int sx, sy;
    cin >> sx >> sy;
    rep(i, N) {
        rep(j, N) cin >> tile[i][j];
    }
    rep(i, N) {
        rep(j, N) cin >> board[i][j];
    }

    beam_search solver;
    cout << solver.solve(sx, sy) <<endl;

    return 0;
}

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
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; }

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

    int n = N-1;
    ll res = -1;
    for (int bit = 0; bit < (1<<n); ++bit) {
        ll xxor = 0;
        queue<ll> oor;
        oor.push(A[0]);
        for (int ii = 0; ii < n; ++ii) {
            if (bit & (1 << ii)) {
                ll o = 0;
                while(!oor.empty()){
                    o |= oor.front();
                    oor.pop();
                }
                xxor ^= o;
            }
            oor.push(A[ii+1]);
        }
        ll o = 0;
        while(!oor.empty()){
            o |= oor.front();
            oor.pop();
        }
        xxor ^= o;
        if(res == -1) res = xxor;
        else chmin(res, xxor);
    }
    cout << res << endl;
}


#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <iomanip>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define repi(i, ini, N) for(int i = ini; i < N; i++)
#define chmax(i, j) i = max(i, j)
#define chmin(i, j) i = min(i, j)
typedef long long ll;

ll N;
ll K;

int main() {
    cin >> N >> K;
    vector<pair<ll, ll> > A;
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        A.push_back(make_pair(a,b));
    }
    sort(A.begin(), A.end());
    ll now = 0;
    rep(i, N) {
        if (A[i].first > now+K) {
            cout << now+K << endl;
            return 0;
        }
        K = K - (A[i].first-now);
        now = A[i].first;
        K += A[i].second;
    }
    cout << now + K << endl;

}

#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> used(2 * N);
  auto out = []() {
    cout << "No" << endl;
    exit(0);
  };
  REP(i, N) {
    int A, B;
    cin >> A >> B;
    if (A != -1 && B != -1 && A >= B) out();
    if (A != -1) {
      if (used[A - 1] != 0) out();
      used[A - 1] = i + 1;
    }
    if (B != -1) {
      if (used[B - 1] != 0) out();
      used[B - 1] = -(i + 1);
    }
  }
  vector<bool> dp(N + 1);
  dp[0] = 1;
  FOR(i, 1, N + 1) {
    REP(j, i)
    if (dp[j]) {
      bool ng = 0;
      REP(k, i - j) {
        int a = used[2 * j + k], b = used[2 * j + k + i - j];
        ng |= (a < 0) || (b > 0) || (a > 0 && b < 0 && b != -a);
      }
      if (!ng) {
        dp[i] = 1;
        break;
      }
    }
  }
  cout << (dp[N] ? "Yes" : "No") << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
const double pi = acos(-1);
ll mod = 1000000007;

//
struct Edge {
    int to;
    long long w;
    Edge(int to, long long w) : to(to), w(w) {}
};

// Union find
struct dsu {
    vector<int> d;
    dsu(int n = 0): d(n,-1) {}
    int findRoot(int x) {
        if(d[x] < 0) return x;
        return d[x] = findRoot(d[x]);
    }
    bool unite(int x,int y) {
        x = findRoot(x); y = findRoot(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) { return findRoot(x) == findRoot(y);}
    int size(int x) {return -d[findRoot(x)];}
};

#include <iostream>
using namespace std;

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

/*
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
*/

template <typename T>
T my_lower_bound(vector<T> a, T lb, T ub, T k) {
    while(ub - lb > 1) {
        T mid = (lb + ub) / 2;
        if(a[mid] >= k) {
            ub = mid;
        }else{
            lb = mid;
        }
    }
    return ub;
}

//change a large letter into a small letter
char chupper(char a) {
    a += ('A' - 'a');
    return a;
}

//change a small letter into a large letter
char chlower(char a) {
    a += ('a' - 'A');
    return a;
}

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

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

int main() {
    ll n; int m;
    cin >> n >> m;
    cout << modpow(10,n,m * m) / m % m << endl;
    return 0;
}

/*
* @Author: kabbo
* @Date:   2020-06-24 08:40:07
* @Last Modified by:   kabbo
* @Last Modified time: 2020-06-24 08:49:58
*/
#include<bits/stdc++.h>
using namespace std;
#define pii pair<long long,long long>
#define endl '\n'
#define ull unsigned long long
#define ll int64_t
#define ar array
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0200r0.html
template<class Fun>
class y_combinator_result {
	Fun fun_;
public:
	template<class T>
	explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}

	template<class ...Args>
	decltype(auto) operator()(Args &&...args) {
		return fun_(std::ref(*this), std::forward<Args>(args)...);
	}
};

template<class Fun>
decltype(auto) y_combinator(Fun &&fun) {
	return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}
const int mod = 1e9 + 7;
using u64 = uint64_t;
using u128 = __uint128_t;
#define sc1(x) scanf("%lld",&(x));
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
int dp[1005][1005];
vector<int>a,b;
int sol(int i,int j){
    	if (i == -1 and j == -1)return 0;
		if (i == -1)return j + 1;
		if (j == -1)return i + 1;
		int &ret = dp[i][j];
		if (ret != -1)return ret;
		int op1 = sol(i - 1, j) + 1;
		int op2 = sol(i, j - 1) + 1;
		int op3 = sol(i - 1, j - 1) + (a[i] != b[j]);
		return ret = min({op1, op2, op3});
}
void solve() {
	int n, m;
	cin >> n >> m;
	a.resize(n),b.resize(m);
	for (auto& x : a)cin >> x;
	for (auto& x : b)cin >> x;

	memset(dp, -1, sizeof(dp));
	cout<<sol(n-1,m-1)<<endl;
// 	auto res = y_combinator([&](auto sol, int i, int j)->int {
//
// 	})(n-1,m-1);
//      cout<<res<<endl;

}
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	/*int t;
	cin >> t;
	for (int i(1); i <= t; ++i) {
		printf("Case %d:\n", i);*/
	solve();
	//}
	return 0;
}


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

int main(){
    char s, t;
    cin >> s >> t;

    if(s == 'Y'){
        if(t == 'a'){
            cout << "A";
        }else if(t == 'b'){
            cout << "B";
        }else{
            cout << "C";
        }
    }else{
        cout << t;
    }
}

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

int main() {
  string S,T;
  cin>>S>>T;
  if(S=="Y"){
    if(T=="a"){
      T = "A";
    }
    if(T=="b"){
      T = "B";
    }
    if(T=="c"){
      T = "C";
    }
  }
  cout<<T<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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; }

int main(){
    int m,h; cin >> m >> h;
    if(h % m == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
  int m,h;
  cin >> m >> h;
  if (h%m==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


//#include<bits/stdc++.h>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
#include<string>
#include<set>
//#include<unordered_map>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,b,a) for(int i=b;i>=a;i--)
#define m_p make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define pi acos(-1)
#define IO ios::sync_with_stdio(false);cin.tie(0)
#define io ios::sync_with_stdio(false)
typedef  long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const double  eps=1e-9;
inline int gcd(int a,int b){return b?gcd(b,a%b):a;}
inline int lcm(int a,int b){return a*b/gcd(a,b);}
inline int rd()
{
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar();}
while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
return x*f;
}
const int maxn=1e5+50;
void run()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << 21 - a - b - c << endl;
}

int main()
{
   run();
   return 0;
}
/*
start time:
over time:
*/

#include<bits/stdc++.h>
using namespace std;
//#include<atcoder/all>
//using namespace atcoder;
using ll = long long;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a) (a).begin(),(a).end()
struct edge{
    int to;
    char c;
};
void Main(){
    int n, m;
    cin >> n >> m;
    vector<vector<edge>> graph(n);
    For(i,0,m){
        int a, b;
        char c;
        cin >> a >> b >> c;
        a--;
        b--;
        graph[a].push_back({b, c});
        if(a != b) graph[b].push_back({a, c});
    }
    vector<vector<int>> exGraph(n * n);
    For(i,0,n){
        For(j,0,n){
            for(auto [to1, c1]: graph[i]){
                for(auto [to2, c2]: graph[j]){
                    if(c1 == c2){
                        exGraph[i * n + j].push_back(to1 * n + to2);
                    }
                }
            }
        }
    }
    vector<int> dist(n * n, 1e9);
    dist[n - 1] = 0;
    queue<int> que;
    que.push(n - 1);
    while(!que.empty()){
        auto now = que.front();
        que.pop();
        for(auto to: exGraph[now]){
            if(dist[to] > dist[now] + 1){
                dist[to] = dist[now] + 1;
                que.push(to);
            }
        }
    }
    int ans = 1e9;
    For(i,0,n){
        ans = min(ans, dist[i * n + i] * 2);
        for(auto [to, c]: graph[i]){
            ans = min(ans, dist[i * n + to] * 2 + 1);
        }
    }
    if(ans == 1e9) ans = -1;
    cout << ans << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(40)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll N;
ll A[200005];
ll T[200005];

ll func(ll value, ll index) {
    if (T[index] == 1) {
        return value + A[index];
    }
    else if (T[index] == 2) {
        return std::max(value, A[index]);
    }
    return std::min(value, A[index]);
}

ll calc(ll value) {
    REP(i, N) {
        value = func(value, i);
    }
    return value;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) {
        cin >> A[i] >> T[i];
    }

    ll low = calc(-INF);
    ll heigh = calc(INF);
    ll sum = 0;
    REP(i, N) {
        if (T[i] == 1)
            sum += A[i];
    }

    ll Q;
    cin >> Q;
    REP(i, Q) {
        ll x;
        cin >> x;
        if (x < low - sum)
            cout << low << endl;
        else if (heigh - sum < x)
            cout << heigh << endl;
        else
            cout << x + sum << endl;
    }
    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <math.h>
#include <map>
#include <queue>
#include <set>

#define say(s) cout << s << endl
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define vec vector

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

int main() {
  int a1, a2, a3;
  int a[3] = {0};
  rep(i, 3) {
    int b;
    cin >> b;
    a[i] = b;
  }

  for(int i=0; i<3; i++) {
    for(int j=0; j<3; j++) {
      for(int k=0; k<3; k++) {
        if(i!=j && i!=k && j!=k) {
          if(a[k]-a[j] == a[j] - a[i]) {
            say("Yes");
            return 0;
          }
        }
      }
    }
  }
  say("No");

  return 0;
}


#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = long long; const ll INF = 9e18;
void print() { cout << endl; }
template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);}
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<head;print0(tail...);}
// clang-format on

int main() {
  int n;
  string s;
  cin >> n;
  vector<char> atcoder={'a','t','c','o','d','e','r'};
  for (int i = 0; i < n; i++) {
    cin >> s;
    int lg = -1;
    int gta = 4000;
    int gtt = 4000;
    for (int j = 0; j < s.length(); j++) {
      if (j<=6 && lg==-1 && s.at(j)>atcoder.at(j) ) lg = 1;
      if (j<=6 && lg==-1 && s.at(j)<atcoder.at(j) ) lg = 0;
	  if (j>=7 && lg==-1) lg = 1;
      if (s.at(j)>'a') gta=min(gta,j);
      if (s.at(j)>'t') gtt=min(gtt,j);
    }
    if(lg==1){
      print(0);
    }else if (gtt<4000){
      print(min(gtt-1,gta));
    }else if (gta<4000){
      print(gta);
    }else{
      print(-1);
    }
  }
}

#include <bits/stdc++.h>
#include <bits/extc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define td(v) v.begin(),v.end()
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define re(v) {for(auto &_re : v) cin >> _re;}
#define pr(v) {for(auto _pr : v) cout << _pr << " "; cout << endl;}
#define sz(x) (int)(x).size()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define eb emplace_back
using namespace std;
const ll M = 1e9 + 7;
const ll mod = 998244353;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll binpow(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b&1) res = res * a % M;
		a = a * a % M;
		b>>=1;
	}
	return res;
}
//#define double long double
//#define int long long
string t = "atcoder";
void solve(){
	string s;
	cin >> s;
	bool ok = false;
	for(char c : s) if(c!='a') ok = true;
	if(!ok){
		cout << -1 << endl;
		return;
	}
	if(t < s){
		cout << 0 << endl;
		return;
	}
	int eq = 1;
	for(int i=0;i<min((int)s.size(), 7);i++){
		if(s[i] == t[i]){
			eq++;
		}
	}
	int ans = 1e9;
	for(int i=0;i<s.size();i++){
		for(int j=0;j<eq; j++){
			if(s[i] > t[j]){
				ans = min(ans, abs(i-j));
			}
		}
	}
	cout << ans << endl;
}
int32_t main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  //freopen("jump.in", "r", stdin);
	//freopen("equal.out", "w", stdout);
	int t = 1;
	cin >> t;
	while(t--){
		solve();
	}
}


#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <ctype.h>
#include <climits>
#include <queue>
#include <iostream>
#include <string>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
// using ll = long long;
//using P = pair<int,int>;

int main () {
    int n;
    cin >> n;
    vector<string> s(n);
    set<string> s_set;
    rep(i,n) {
        cin >> s[i];
        s_set.insert(s[i]);
    }

    rep(i,n) {
        if(s_set.count("!" + s[i])) {
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << "satisfiable" << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define int long long int
#define popcount(x) __builtin_popcountll(x)
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define fr first
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define ld long double
const int INF = __LONG_LONG_MAX__;
#define rall(a) (a).rbegin(),(a).rend()
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroint-loops")

int power(int a,int b,int m)
{
  int res=1;
  while(b)
  {
    if(b&1) res=((res%m)*(a%m))%m;
    a=((a%m)*(a%m))%m;
    b>>=1;
  }
  return res;
}

int power(int a,int b)
{
  int res=1;
  while(b)
  {
    if(b&1) res*=a;
    a*=a;
    b>>=1;
  }
  return res;
}

bool isPowerOfTwo(int x)
{
    // x will check if x == 0 and !(x & (x - 1)) wiint check if x is a power of 2 or not
  return (x && !(x & (x - 1)));
}

void solve()
{
  int n;
  cin>>n;
  int ans=1;
  for(int i=2;i<=n;i++)
  {
    ans=(ans*i)/__gcd(i,ans);
  }
  ans++;
  cout<<ans;
}

signed main()
{
  fastio
  int tt=1;
  // cin>>tt;
  //  freopen("input.txt", "r" , stdin);
  // freopen("output.txt", "w", stdout);
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
  return 0;
}


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

int main(){
    ll N,W;
    cin >> N >> W;
    vector<ll> S(N), T(N), P(N), A(200001);
    rep(i,N){
        cin >> S[i] >> T[i] >> P[i];
        A[S[i]] += P[i];
        A[T[i]] -= P[i];
    }
    rep(i,200000){
        A[i+1] += A[i];
    }
    ll M = -1;
    rep(i,200001){
        cmax(M,A[i]);
    }
    string ans = "No";
    if(M <= W){
        ans = "Yes";
    }
    cout << ans << endl;
}

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

int main() {
  int a,b,c,f=0;
  string g="Yes";
  cin>>a>>b>>c;
  int h=a;
  vector<int> d(b),e(b);
  for(int i=0;i<b;i++){
    cin>>d.at(i)>>e.at(i);
  }
  for(int i=0;i<b;i++){
    a-=d.at(i)-f;
    f=d.at(i);
    if(a<=0)g="No";
    a+=e.at(i)-f;
    if(h<a)a=h;
    f=e.at(i);
  }
  a-=c-f;
  if(a<=0)g="No";
  cout<<g<<endl;
}


#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long ll;
string intToA(int n,int radix){
    string ans="";
    do{
        int t=n%radix;
        if(t>=0&&t<=9)ans+=t+'0';
        else ans+=t-10+'a';
        n/=radix;
    }while(n!=0);
    reverse(ans.begin(),ans.end());
    return ans;
}
const int maxn = 1e3 + 5;
int res[100086] = {0};
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	res[1] = 1;
	for(int i = 2;i<=100000;i++){
		string w1 = intToA(i,10);
		string w2 = intToA(i,8);
		//cout << w1 << w2 <<endl;
		if(w1.find('7')!=w1.npos || w2.find('7')!=w2.npos){
			res[i] = res[i-1];
		}else{
			res[i] = res[i-1]+1;
		}
	}
	int k;
	cin >> k;
	cout << res[k] << endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto &e: a) cin >> e;
    int ans = INT_MAX;
    for(int i = 0; i < 1 << n; i++){
        int xored = 0, ored = 0;
        for(int j = 0; j < n; j++){
            ored |= a[j];
            if(j == n - 1 || (i >> j) & 1){
                xored ^= ored;
                ored = 0;
            }
        }
        ans = min(ans, xored);
    }

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


#include <bits/stdc++.h>

using namespace std;

const int N = 101;

int dp[N][N * N * N], cnt[N];
int n, k, mod;

void upd(int & var, int val) {
  var += val;
  if (var >= mod)
    var -= mod;
}

int main() {
  scanf("%d %d %d", &n, &k, &mod);
  dp[0][0] = 1;
  int sum = 0;
  for (int x = 1; x <= n; ++x) {
    memset(cnt, 0, sizeof cnt);
    sum += k * x;
    int full = k * x;
    for (int j = 0, z = 0; j <= sum; ++j) {
      int now = dp[x-1][j];
      upd(cnt[z], now);
      dp[x][j] = cnt[z];
      if (j >= full) {
        upd(cnt[z], mod - dp[x-1][j-full]);
      }
      ++z;
      if (z >= x)
        z -= x;
    }
  }
  for (int i = 1; i <= n; ++i) {
    int lef = i - 1, rig = n - i;
    long long ans = 0;
    for (int j = 0; j <= sum; ++j) {
      ans = (ans + 1LL * dp[lef][j] * dp[rig][j]) % mod;
    }
    ans = (ans * (k+1) - 1) % mod;
    if (ans < 0)
      ans += mod;
    printf("%lld\n", ans);
  }
  return 0;
}

// Author: Muhesh Kumar

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

using ll  = long long;
using db = long double;
using str = string;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;

using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;

using vvi = vector<vi>;
using vvl = vector<vl>;

using si = set<int>;
using sl = set<ll>;
using ss = set<str>;

ll mod = 1000000007;
ll inf = 1e18 + 1;

#define fr first
#define sc second

#define sz(x) (x).size()
#define bg(x) begin(x)
#define all(x) bg(x), end(x)

#define ft front()
#define bk back()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define nl '\n'

#define rev(v) reverse(all(v))
#define sor(v) sort(all(v))
#define lb lower_bound
#define ub upper_bound

#define amax(a, b) a = max(a, b)
#define amin(a, b) a = min(a, b)
#define mxele(v) *max_element(all(v))
#define mnele(v) *min_element(all(v))

#define rep(i, a, b) for(int i = a; i < b; i++)
#define repeq(i, a, b) for (int i = a; i <= b; i++)
#define reprev(i, b, a) for (int i = b - 1; i >= a; i--)
#define repeach(a, b) for (auto& a: b)

int main() {

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

    int n, a, b; cin >> n >> a >> b;
    cout << n - a + b;

    return 0;
}


#include <bits/stdc++.h>

#define LL long long
#define ull unsigned long long
#define F(i, j, k) for (int i = j; i <= k; ++i)
#define DF(i, j, k) for (int i = j; i >= k; --i)

using namespace std;

template <typename T> inline void read(T &n) {
    T w = 1;
    n = 0;
    char ch = getchar();
    while (!isdigit(ch) && ch != EOF) {
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (isdigit(ch) && ch != EOF) {
        n = (n << 3) + (n << 1) + (ch & 15);
        ch = getchar();
    }
    n *= w;
}

template <typename T> inline void write(T x) {
    T l = 0;
    ull y = 0;
    if (!x) { putchar(48); return; }
    if (x < 0) { x = -x; putchar('-'); }
    while (x) { y = y * 10 + x % 10; x /= 10; ++l; }
    while (l) { putchar(y % 10 + 48); y /= 10; --l; }
}

template <typename T> inline void writes(T x) {
    write(x);
    putchar(' ');
}

template <typename T> inline void writeln(T x) {
    write(x);
    puts("");
}

template <typename T> inline void checkmax(T &a, T b) { a = a > b ? a : b; }

template <typename T> inline void checkmin(T &a, T b) { a = a < b ? a : b; }

const int N = 5000, MOD = 998244353;

int cm[N + 10][N + 10], ans;

inline int add(int x, int y) { x += y; return x >= MOD ? x - MOD : x; }

inline int dec(int x, int y) { x -= y; return x < 0 ? x + MOD : x; }

int main() {
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    int n, m;
    read(n);
    read(m);
    F(i, 1, N) {
        cm[i][0] = 1;
        F(j, 1, N) cm[i][j] = (LL)cm[i][j - 1] * i % MOD;
    }
    F(v, 1, m) {
        F(len, 1, n) {
            if (len + 2 <= n) ans = add(ans, (LL)dec(cm[m - v + 1][len], cm[m - v][len]) * (v - 1) % MOD * (v - 1) % MOD * cm[m][n - len - 2] % MOD * (n - len - 1) % MOD);
            if (len + 1 <= n) ans = add(ans, 2LL * dec(cm[m - v + 1][len], cm[m - v][len]) % MOD * (v - 1) % MOD * cm[m][n - len - 1] % MOD);
            if (len == n) ans = add(ans, dec(cm[m - v + 1][len], cm[m - v][len]));
        }
    }
    writeln(ans);
    return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
ll n;
ll b=0,c=0;
//vector<ll> B(2e5,0),C(2e5,0);
vector<bool> used(2e5,false);
vector<vector<pair<ll,ll>>> t(2e5);
//vector<ll> a(2e5,0);
ll res=0,tmp=1;
void dfs(ll x,int k){
    if(k==1){
        res=(res+(b*tmp)%mod)%mod;
        c++;
    }else{
        res=(res+(c*tmp)%mod)%mod;
        b++;
    }
    rep(i,t[x].size()){
        ll y=t[x][i].first,w=t[x][i].second%2;
        if(used[y])continue;
        used[y]=true;
        int nk=k^w;
        dfs(y,nk);
        t[x][i].second/=2;
    }
}
int main(void){
    cin>>n;
    rep(i,n-1){
        ll u,v,w;cin>>u>>v>>w;u--;v--;
        t[u].push_back({v,w});
        t[v].push_back({u,w});
    }
    rep(i,60){
        rep(j,n)used[j]=false;
        b=0,c=0;
        used[0]=true;
        dfs(0,0);
        tmp=(tmp*2)%mod;
        //cout<<res<<endl;
    }
    cout<<res<<endl;
}