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

int main(){
    int n,l;
    cin >> n >> l;
    if(l>=0)cout << (2*l+n-1)*n/2-l << endl;
    else if(n+l>0){
        cout << (2*l+n-1)*n/2 << endl;
    }
    else {
        cout << (2*l+n-1)*n/2-(l+n-1) << endl;
    }
    return 0;
}

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

int main(){
  int n, l;
  cin >> n >> l;
  int ans = 0;
  for(int i=l; i<l+n; ++i){
    if(l+n-1 < 0 && i == l+n-1) continue;
    if(l > 0 && i == l) continue;
    ans += i;
  }
  cout << ans << endl;
}


#include<stdio.h>
#include<math.h>
int main(){
    double x1, x2;
    double y1, y2;
    double L, l;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    L = pow(x2-x1, 2.0) + pow(y2-y1, 2.0);
    l = sqrt(L);
    printf("%f", l);
    return 0;
}

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string>
using namespace std;

int main() {
	double x1, y1, x2, y2, num, ans = 0, dou = 1, xx;
	cin >> x1 >> y1 >> x2 >> y2;
	num = (x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1);
	while (dou < num) {
		dou *= 10;
	}
	xx = dou;
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < i; j++) {
			dou *= 0.1;
		}
		if (dou < 0.000001)break;
		for (int j = 0; j < 10; j++) {
			ans += dou;
			//cout << ans << " " << j << " " << dou << endl;
			if (ans*ans > num) {
				ans -= dou;
				break;
			}
		}
		dou = xx;
	}
	printf("%f\n", ans);
	//cout << ans;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}

int main(int argc,char* argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG=1;}
  dprint("start");

  ll N; cin>>N;
  ll a[N]; CINA(a,N); reverse(a,a+N);
  vector<ll> v;
  v.push_back(a[0]);
  for(int i=1;i<N;++i){
    int m = v.size();
    if(a[i]>=v[m-1]){
      v.push_back(a[i]);
    }else{
      auto x = upper_bound(ALL(v),a[i]);
      while(*x==a[i]){
        ++x;
      }
      *x = a[i];
    }
  }
  if(DEBUG){ for(auto x:v){ cout << x << " ";} cout << "\n"; }
  cout << v.size() << "\n";
}

#include <bits/stdc++.h>
#include<math.h>
#include<algorithm>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007

int main () {
    int n, q ;
    string s ;
    cin >> n >> q ;
    cin >> s ;
    vector<int> l (q), r(q) ;
    rep(i, q){
        cin >> l[i] >> r[i] ;
        l[i]-- ;
        r[i]-- ;
    }
    vector<int> num (n) ;
    rep(i, n - 1){
        if(s[i] == 'A' && s[i + 1] == 'C'){
            num[i + 1]++ ;
        }
    }
    for(int i = 1 ; i < n ; i++){
        num[i] += num[i - 1] ;
    }
    vector<int> ans ;
    rep(i, q){
        ans.push_back(num[r[i]] - num[l[i]]) ;
    }
    rep(i, q){
        cout << ans[i] << endl ;
    }
}


#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

int main(){
    int h,w;
    cin>>h>>w;
    vector<string> s(h);
    for(int i=0;i<h;i++) cin>>s[i];

    int res = max(h,w);
    vector<vector<int>> b(h-1,vector<int>(w-1));
    auto judge=[&](int i,int j){
        return (int)(s[i][j]=='#');
    };
    for(int i=0;i+1<h;i++){
        for(int j=0;j+1<w;j++){
            int cnt = judge(i,j) + judge(i+1,j) +judge(i,j+1) + judge(i+1,j+1);
            b[i][j] = (cnt%2==0);
        }
    }

    vector<vector<int>> sum(h,vector<int>(w));
    for(int i=0;i<h-1;i++){
        for(int j=0;j<w-1;j++){
            if(b[i][j]) sum[i+1][j] = sum[i][j]+1;
        }
    }

    for(int i=0;i<h-1;i++){
        int x = i+1;
        stack<pair<int,int>> lh;
        lh.push({-1,0});
        for(int y=0;y<w;y++){
            while(sum[x][y]<lh.top().second){
                auto tmp = lh.top(); lh.pop();
                int height = tmp.second;
                int width = y-lh.top().first;
                res = max(res,width*(height+1));
            }
            lh.push({y,sum[x][y]});
        }
    }
    cout<<res<<endl;

    return 0;
}

#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// 2*2の正方形のうち黒の個数と白の個数がどちらも偶数のものは全部黒にできる
// どちらも奇数のものはできない(白黒反転は可)
// そういう正方形を内側に含まないような最大の長方形を求める

int h, w, ng[2020][2020], x[2020], res;
string s[2020];

signed main() {
	cin >> h >> w;
	res = max(h,w);
	rep(i,h) cin >> s[i];
	rep(i,h) {
		rep(j,w-1) {
			if (i && !(s[i-1][j]^s[i-1][j+1]^s[i][j]^s[i][j+1])) x[j]++;
			else x[j] = 1;
		}
		stack<int> s;
		rep(r,w) {
			while (!s.empty() && x[s.top()]>=x[r]) {
				int t = s.top(); s.pop();
				int l = (s.empty() ? -1 : s.top());
				chmax(res, x[t]*(r-l));
			}
			s.push(r);
		}
	}
	cout << res << endl;
}


//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}

	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 607;
int n;
struct G {
	int d, c[N][N];
	vector<pi> p;
	inline bool pd(int x, int y) {
		return x >= 0 && x < n * 2 && y >= 0 && y < n * 2 && !~c[x][y];
	}
	void dfs(int x, int y, int z) {
		c[x][y] = z;
		for (pi o : p) {
			int X = x + o.fi, Y = y + o.se;
			if (pd(X, Y)) dfs(X, Y, z ^ 1);
		}
	}
	inline void main() {
		rd(d);
		for (int i = 0; i < n * 2; i++)
			for (int j = 0; j < n * 2; j++)
				c[i][j] = -1;
		for (int i = 1 - n * 2; i < n * 2; i++)
			for (int j = 1 - n * 2; j < n * 2; j++)
				if (i * i + j * j == d) p.pb(mp(i, j));
		for (int i = 0; i < n * 2; i++)
			for (int j = 0; j < n * 2; j++)
				if (pd(i, j)) dfs(i, j, 0);
	}
} g[2];
vector<pi> p[4];

int main() {
	rd(n), g[0].main(), g[1].main();
	for (int i = 0; i < n * 2; i++)
		for (int j = 0; j < n * 2; j++)
			p[g[1].c[i][j]*2+g[0].c[i][j]].pb(mp(i, j));
	int o = 0;
	for (int i = 1; i < 4; i++)
		if (p[i].size() > p[o].size()) o = i;
	while ((int)p[o].size() > n * n) p[o].pop_back();
	for (pi x : p[o]) print(x.fi, x.se);
	return 0;
}


#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;

int N, K;
const ll MOD = 998244353;
ll F[4002], F_inv[4002];

ll modpow(ll a, ll b) {
	ll rtn = 1, kakeru = a;
	while (b > 0) {
		if (b & 1)rtn *= kakeru;
		kakeru *= kakeru;
		kakeru %= MOD;
		rtn %= MOD;
		b >>= 1;
	}
	return rtn;
}

void calc_fac() {
	F[0] = 1, F[1] = 1;
	for (int i = 2; i <= 4001; i++) {
		F[i] = F[i - 1] * i;
		F[i] %= MOD;
	}

	F_inv[4001] = modpow(F[4001], MOD - 2);
	for (int j = 4000; j >= 0; j--) {
		F_inv[j] = F_inv[j + 1] * (j + 1);
		F_inv[j] %= MOD;
	}

}

ll comb(ll a, ll b) {
	if (a < 0)return 0;
	if (b < 0)return 0;
	if (b > a)return 0;
	ll ans = (F[a] * F_inv[b])%MOD * F_inv[a - b];
	return ans % MOD;
}

ll hcomb(ll a, ll b) {
	return comb(a + b - 1, b);
}

int main() {

	calc_fac();

	cin >> K >> N;

	for (int i = 2; i <= 2 * K; i++) {
		if (i % 2 == 1) {
			ll cnt = 0;
			int A = min((i - 1) / 2, (2 * (K + 1) - i) / 2);
			for (int j = 0; j <= A; j++) {
				ll tmp = 1;
				tmp *= (modpow(2, j) * comb(A, j)) % MOD;
				tmp *= hcomb(K - 2 * A + j, N - j);
				tmp %= MOD;
				cnt += tmp;
				cnt %= MOD;
			}
			cout << cnt << endl;
		}
		else {
			ll cnt = 0;
			int A = min((i) / 2, (2 * (K + 1) - i) / 2) - 1;
			for (int j = 0; j <= A; j++) {
				ll tmp = 1;
				tmp *= (modpow(2, j) * comb(A, j)) % MOD;
				ll a = hcomb(K - 2 * A + j - 1, N - j) + hcomb(K - 2 * A + j - 1, N - j - 1);
				a %= MOD;
				tmp *= a;
				tmp %= MOD;
				cnt += tmp;
				cnt %= MOD;
			}
			cout << cnt << endl;
		}
	}

	return 0;
}

#include<bits/stdc++.h>
using namespace std ;
#define Next( i, x ) for( register int i = head[x]; i; i = e[i].next )
#define rep( i, s, t ) for( register int i = (s); i <= (t); ++ i )
#define drep( i, s, t ) for( register int i = (t); i >= (s); -- i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 4000 + 5 ;
const int P = 998244353 ;
int maxn, n, K, C[N][N], Ans[N] ;
signed main()
{
	K = gi(), n = gi(), maxn = n + K ;
	C[0][0] = 1 ;
	rep( i, 1, maxn ) rep( j, 0, maxn ) C[i][j] = (!j) ? 1 : ( C[i - 1][j - 1] + C[i - 1][j] ) % P ;
	for( re int i = 2; i <= 2 * K; ++ i ) {
		int u = 0, v = 0 ;
		rep( j, 1, K )
			if( ((i - j) != j) && ( (i - j) <= K ) && ( (i - j) >= 1 ) ) ++ u ;
			else if( (i - j) != j ) ++ v ;
		u /= 2, v += u ;
		if( i % 2 == 0 ) ++ u ;
		for( re int j = 0; j <= n; ++ j ) {
			Ans[i] = ( Ans[i] + C[u][j] * C[(n - j) + v - 1][(n - j)] % P ) % P ;
		}
	}
	rep( i, 2, 2 * K ) printf("%lld\n", Ans[i] ) ;
	return 0 ;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#define ll long long
using namespace std;

int main()
{
    double n;
    cin >> n;
    double ave=0;
    vector<double> a(n);
    for (ll i =0; i < n;i++){
        cin >> a[i];
        ave += a[i];
    }
    ave /= n;
    //cout << ave << endl;
    ll ans = n - 1;
    for (ll i = n - 1; i >= 0; i--)
    {
        if(abs(a[ans]-ave)>=abs(a[i]-ave)){
            ans = i;
        }
    }
    cout << ans << endl;
}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    double average = (double)accumulate(a.begin(), a.end(), 0)/n;
    int ans = 0;
    double minv=100100100;
    rep(i, n) {
        if (abs(average-(double)a[i])< minv) {
            ans = i;
            minv = abs(average-(double)a[i]);
        }
    }
    cout << ans << endl;
    //cout << a[ans] << endl;
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 100000000;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
ll n;
string s;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> s;
    map<pair<string,string>,ll> count;
    rep(bit,1<<n){
        string s1,t1;
        rep(i,n){
            if (bit&(1<<i)){
                s1 += s[i+n];
            }
            else{
                t1 += s[i+n];
            }
        }
        reverse(all(t1));
        count[make_pair(t1,s1)]++;
    }
    ll ans = 0;
    rep(bit,1<<n){
        string s1,t1;
        rep(i,n){
            if (bit&(1<<i)){
                s1 += s[i];
            }
            else{
                t1 += s[i];
            }
        }
        reverse(all(t1));
        ans += count[make_pair(s1,t1)];
    }
    PRINT(ans);
}

#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const int mod = (int)1e9 + 7;
const int mod2 = 998244353;

ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}

ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}
ll fact[(int)2e5+5];
ll komb(ll a, ll b){
	return fact[a+b] * exp(fact[a]*fact[b], mod-2) % mod;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	fact[0] = 1;
	for(int i = 1; i <= 2e5; i++) fact[i] = (fact[i-1]*i) % mod;
	int n, m; cin>>n>>m;
	unordered_map<int, int> cnt;
	for(int i = 2; i*i <= m; i++){
		while(m % i == 0){
			m /= i;
			cnt[i]++;
		}
	}
	if(m > 1) cnt[m]++;
	ll ans = 1;
	for(auto x: cnt){
		ans = (ans * komb(n-1, x.second)) % mod;
	}
	cout<<ans<<endl;
}


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

int main(){
  int X,Y;
  cin >> X >> Y;

  int ans=0;
  vector<int> a={0,300000,200000,100000};
  if(X<=3)  ans+=a.at(X);
  if(Y<=3)  ans+=a.at(Y);
  if(X==1 && Y==1)  ans+=400000;
  cout << ans << endl;

  return 0;
}

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

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

  int x, y;
  cin >> x >> y;
  --x, --y;

  int c[] = { 300000, 200000, 100000, 0 };
  cout << c[min(x, 3)] + c[min(y, 3)] + (!x && !y ? 400000 : 0) << endl;

  return (0);
}


#define scanf_s scanf
//#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 101
#define MIN -100001
#define _MAX 8

int main(void)
{
	char roman[102];
	char fig[8] = { "IVXLCDM" };
	int value[7] = { 1,5,10,50,100,500,1000 };
	int  sum = 0, b = _MAX;
	while (scanf_s("%s", &roman, MAX) != EOF) {
		for (int i = 0; roman[i] != '\0'; ++i) {
			for (int j = 0; j < 8; ++j) {
				if (roman[i] == fig[j]) {
					if (b >= j) sum += value[j];
					else { sum -= value[b]; sum += value[j] - value[b]; }
					b = j;
				}
			}
		}
		printf("%d\n", sum);
		sum = 0; b = _MAX;
	}
}

#include <iostream>
using namespace std;

int convert( char c )
{
    switch ( c )
    {
    case 'I':   return 1;
    case 'V':   return 5;
    case 'X':   return 10;
    case 'L':   return 50;
    case 'C':   return 100;
    case 'D':   return 500;
    case 'M':   return 1000;
    }
}

int main( void )
{
    string input;
    int answer, prev;
    while ( cin >> input )
    {
        answer = 0;
        prev = 0;

        for ( string ::reverse_iterator it = input.rbegin(); it != input.rend(); it++ )
        {
            int next = convert( *it );
            if ( prev <= next )
            {
                answer += next;
            }
            else
            {
                answer -= next;
            }
            prev = next;
        }

        cout << answer << endl;
    }
    return 0;
}


#include<iostream>
#include<string>

using namespace std;
int main(){
    string a,b,c;
    int ca=0,cb=0,cc=0,flag=0,ans=0;
    cin>>a>>b>>c;

    for(int i=0;i<a.size()+b.size()+c.size();i++){
        if(flag==0){
             if(ca==a.size()){
                ans=1;
                break;
            }

            if(a[ca]=='a')flag=0;
            if(a[ca]=='b')flag=1;
            if(a[ca]=='c')flag=2;

            ca++;
        }

        else if(flag==1){
             if(cb==b.size()){
                ans=2;
                break;
            }

            if(b[cb]=='a')flag=0;
            if(b[cb]=='b')flag=1;
            if(b[cb]=='c')flag=2;

            cb++;
        }

        else if(flag==2){
            if(cc==c.size()){
                ans=3;
                break;
            }

            if(c[cc]=='a')flag=0;
            if(c[cc]=='b')flag=1;
            if(c[cc]=='c')flag=2;

            cc++;
        }
    }

    if(ans==1)cout<<"A"<<endl;
    if(ans==2)cout<<"B"<<endl;
    if(ans==3)cout<<"C"<<endl;

    return 0;
}

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

int main() {

  vector<queue<char>> v(3);
  string s;

  rep(i, 0, 3) {
    cin >> s;
    for (char c : s) {
      v[i].push(c);
    }
  }

  int tmp, x = 0;

  while (true) {
    if (v[x].empty()) {
      break;
    }
    tmp = x;
    x = v[x].front() - 'a';
    v[tmp].pop();
  }

  cout << char(x + 'A') << endl;
  getchar();
}


#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
LL pw[87];

LL dfs(int i, LL d, int fg) {
   if (i == 0) return d == 0 ? 1 : 0;
   if (i == 1) return d == 0 ? 10 : 0;
   LL D = (10 - (d % 10)) % 10;
   //printf("i = %d d = %lld D = %lld\n", i, d, D);
   LL c = 9 - D + 1 - fg;
   d = d - pw[i - 1] * D + D;
   return c * dfs(i - 2, abs(d) / 10, 0);
}

int main() {
    LL D;
    while (~scanf("%lld", &D)) {
          LL ans = 0;
          pw[0] = 1;
          for (int i = 1; i <= 18; i++) {
              pw[i] = pw[i - 1] * 10;
          }
          for (int i = 1; i <= 18; i++) {
              ans += dfs(i, D, 1);
          }
          printf("%lld\n", ans);
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
ll d;
map < ll, ll > mp[20];
ll pw10[20];
ll coef[20];
ll gc[20];
int LEN = 0;
int val[25];
int val0[25];
ll solve(int where, ll need) {
    //cout << where << " " << need << endl;
    if (where == LEN) {
        return (need == 0);
    }
    if (gc[where] != 0 && need % gc[where] != 0) return 0;
    //if (need % gc[where] != 0) return 0;
    if (coef[where] == 0) {
        if (need == 0) return 10;
        else return 0;
    }
    if (mp[where].find(need) != mp[where].end()) {
        return mp[where][need];
    }
    ll tot = 0;
    for (int i = -9; i <= 9; i++) {
        if (where) tot += solve(where + 1, need - i * coef[where]) * val[i + 9];
        else {
            tot += solve(where + 1, need - i * coef[where]) * val0[i + 9];
        }
    }
    return mp[where][need] = tot;
}
ll solve(int len) {
    LEN = (len + 1) / 2;
    for (int i = 0; i <= LEN; i++) mp[i].clear();
    for (int i = 0; i < (len + 1) / 2; i++) {
         coef[i] = pw10[len - 1 - i] - pw10[i];
         coef[i] /= 9;
    }
    gc[LEN] = 0;
    for (int i = LEN - 1; i >= 0; i--) gc[i] = __gcd(coef[i], gc[i + 1]);
    return solve(0, d);
}
int main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    for (int i = 0; i <= 9; i++) {
        for (int j = 0; j <= 9; j++) {
            val[i - j + 9]++;
            if (j) val0[i - j + 9]++;
        }
    }
    pw10[0] = 1;
    for (int i = 1; i <= 18; i++) pw10[i] = 10 * pw10[i - 1];
    cin >> d;
    if (d % 9 != 0) {
        cout << 0;
        return 0;
    }
    d /= 9;
    ll f = 0;
    for (int len = 2; len <= 18; len++) {
        f += solve(len);
    }
    cout << f << endl;

    return 0;
}


#include <iostream>
using namespace std;

const int MAX_N = 100005;

int n, A[MAX_N], B[MAX_N], C[MAX_N], pos[3 * MAX_N], rev[3 * MAX_N];

void wypisz() {
    cout << "----------------------\n";
    for(int i = 1; i <= n; i++) cout << A[i] << " ";
    cout << endl;
    for(int i = 1; i <= n; i++) cout << B[i] << " ";
    cout << endl;
    for(int i = 1; i <= n; i++) cout << C[i] << " ";
    cout << endl;
}

void swapColumn(int i) {
    swap(A[i], C[i]);
}

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> A[i];
    for(int i = 1; i <= n; i++) cin >> B[i];
    for(int i = 1; i <= n; i++) cin >> C[i];

    for(int i = 1; i <= n; i++) {
        if((B[i] % 3 != 2) || (((B[i] - 2) / 3) % 2 == i % 2)) {
            cout << "No";
            return 0;
        }
        int a = (A[i] - 1) / 3;
        int b = (B[i] - 1) / 3;
        int c = (C[i] - 1) / 3;
        if(a != b || a != c || b != c) {
            cout << "No";
            return 0;
        }
    }
    for(int i = 1; i <= n; i++) {
        pos[B[i]] = i;
    }
    for(int i = 1; i <= n; i++) {
        if(B[i] == 3 * i - 1) {
            continue;
        }
        int j = pos[3 * i - 1];
        int x = B[i];
        int y = B[j];
        B[i] = y;
        B[j] = x;
        swap(A[i], A[j]);
        swap(C[i], C[j]);
        pos[x] = j;
        pos[y] = i;

        if((i - j) % 4 != 0) {
            swapColumn(i);
            swapColumn(j);
        }
        swap(A[i + 1], C[i + 1]);
//         wypisz();
    }

    int odd = 0, even = 0;
    for(int i = 1; i <= n; i++) {
//         if(rev[B[i]]) swap(A[i], C[i]);
        if(A[i] > C[i]) {
            if(i % 2 == 1) odd++;
            else even++;
//             cout << "No3";
//             return 0;
        }
    }

    if(odd % 2 == 1 || even % 2 == 1) {
        cout << "No";
        return 0;
    }

    cout << "Yes";
    return 0;
}

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

#define fastio                  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define input_output            freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

#define ll                      long long
#define read1(x)                 cin>>x
#define read2(x,y)               cin>>x>>y
#define print(x)                cout<<x<<endl
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define umap                    unordered_map
#define uset                    unordered_set
#define clr(a,b)                memset(a,b,sizeof a)
#define all(ds)                 ds.begin(), ds.end()
#define rev(ds)                 ds.rbegin(), ds.rend()
#define asc(A)                  sort(A.begin(), A.end())
#define dsc(A)                  sort(A.begin(), A.end(), greater<int>())
#define gcd(x,y)                __gcd(x,y)
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(int i=0; i<n;++i)
#define fr1(i, n)               for(int i=1; i<=n; ++i)
#define rfr(i, n)               for(int i=n-1; i>=0; --i)
#define printVector(v)          for(int i= 0;i<v.size();i++) {cout<<v[i]<<" ";} cout<<endl;
#define precise(x)              cout<<fixed<<setprecision(x)
#define inf                     10000000000000

ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }
ll power(ll x, ll y, ll m) { if(!y) return 1; ll p=power(x, y>>1, m)%m; p=p*p%m; return (y&1)?(x*p)%m:p;}
ll modInverse(ll a, ll m){ return power(a, m-2, m); }
bool isPrime(ll num){bool flag=true;for(ll i =2;i<=num/2;i++){if(num%i==0) {flag=false; break;} }return flag;}
ll sumofdigits(ll n){ll c=0;while(n>0){c++;n/=10;}return c;}
bool sortinrev(const pair<int,int>&a,const pair<int,int>&b) {return a.first > b.first; }
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) {return a.second < b.second; }

//const double PI= 2*acos(0.0);
const long long MOD= 1000000007;

void solve(){
    int n; cin>>n;
    vi v;
    fr(i, n){
        int x; cin>>x;
        v.push_back(x);
    }
    sort(all(v));
    if(v.size() <= 2){
        print(0);
        return;
    }
    int count = 0;
    for(int i = 0; i < n-2; ++i){
        for(int j = i+1; j < n-1; ++j){
            if(v[i] == v[j])continue;
            for(int k = j+1; k < n; ++k){
                if(v[i] == v[k] || v[j] == v[k])continue;
                if(v[i] + v[j] > v[k])count++;
            }
        }
    }
    cout<<count<<endl;

}
int main()
{
#ifndef ONLINE_JUDGE
    input_output
#else
    fastio
#endif

    int t =1 ;
    // cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


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

int dp[305][305][305];
string s;

int my(int l,int r,int k)
{
	if (dp[l][r][k]!=0)
	{
		return dp[l][r][k];
	}
	else if (l==r)
	{
		dp[l][r][k]=1;
		return 1;
	}
	else if (l+1==r)
	{
		if (s[l]==s[r]||k>0)
		{
			dp[l][r][k]=2;
			return 2;
		}
		else
		{
			dp[l][r][k]=1;
			return 1;
		}
	}
	int ans=max(my(l+1,r,k),my(l,r-1,k));
	if (s[l]==s[r])
	{
		ans=max(ans,my(l+1,r-1,k)+2);
	}
	else if (k>0)
	{
		ans=max(ans,my(l+1,r-1,k-1)+2);
	}
	dp[l][r][k]=ans;
	return ans;
}

int main(int argc, char const *argv[])
{
	int k;
	cin>>s>>k;
	cout<<my(0,s.size()-1,k)<<endl;
	return 0;
}

#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

ll Mod = 998244353;
const int N = 2e3 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

ll mul(ll a, ll b){
	return (a * b) % Mod;
}

ll dp[3 * N][N];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n >> Mod;

	dp[0][0] = 1;
	for(int i = 1; i <= 3*n; i++){
		for(int j = 0; j <= n; j++){
			dp[i][j] = dp[i - 1][j];
			if(j){
				if(2 <= i) dp[i][j] += mul(i - 1, dp[i - 2][j - 1]);
				if(3 <= i) dp[i][j] += mul(mul(i - 2, i - 1), dp[i - 3][j - 1]);
			}
			dp[i][j] %= Mod;
		}
	}

	ll ans = 0;
	for(int i = 0; i <= n; i++) ans += dp[3 * n][i];
	cout << ans % Mod << '\n';
	return 0;
}


// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,ko;
    ll x,y,w,z;
    char hoge,fuga;
    cin>>a>>b>>c>>d;
    if(a+b>c+d) cout<<"Left"<<endl;
    if(a+b==c+d) cout<<"Balanced"<<endl;
    if(a+b<c+d) cout<<"Right"<<endl;

    return 0;
}

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

int main() {
   string S;
   cin >> S;
   string T = S.substr(2, S.size()-3);
   int count = 0;
   rep(i, T.size()) if( T[i] == 'C' ) count++;
   int o = 0;
   rep(i, S.size()) if( S[i] < 'a' || S[i] > 'z' ) o++;
   if( S.substr(0,1) == "A" && count == 1 && o == 2 ) cout << "AC" << endl;
   else cout << "WA" << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef long double ld;

int main() {
    ll A, B;
    cin >> A >> B;
    vector<ll> num_A;
    vector<ll> num_B;
    vector<ll> num;
    num_A.push_back(1);
    num_B.push_back(1);
    for(int i = 2; i <= sqrt(A); i++){
        if(A % i == 0){
            while(A % i == 0){
                A = A / i;
            }
            num_A.push_back(i);
        }
    }
    num_A.push_back(A);
    sort(num_A.begin(),num_A.end());
    num_A.erase(unique(num_A.begin(), num_A.end()), num_A.end());

    for(int i = 2; i <= sqrt(B); i++){
        if(B % i == 0){
            while(B % i == 0){
                B = B / i;
            }
            num_B.push_back(i);
        }
    }
    num_B.push_back(B);
    sort(num_B.begin(),num_B.end());
    num_B.erase(unique(num_B.begin(), num_B.end()), num_B.end());

    for(int i = 0; i < num_A.size(); i++){
        for(int j = 0; j < num_B.size(); j++){
            if(num_A[i] == num_B[j]){
                num.push_back(num_A[i]);
            }
        }
    }

    cout << num.size() << endl;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()

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

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> x >> y;
	ll ans=1;
	n=x;
	for(i=2;i*i<=x;i++)
	{
		if(n%i==0 && y%i==0)
			ans++;
		while(n%i==0)
			n/=i;
	}
	if(n>1 && y%n==0)
		ans++;

	cout<<ans<<endl;
}


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

int main(void) {
	int X, Y;
	scanf("%d %d", &X, &Y);
	int award[] = {300000, 200000, 100000, 0};
	if (X == 1 && Y == 1) printf("1000000\n");
	else printf("%d\n", award[min(3, X - 1)] + award[min(3, Y - 1)]);
	return 0;
}


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

void getResult(const uint actCount, uint *cookie1, uint *cookie2){
  uint *first = cookie1;
  uint *second = cookie2;
  for(uint i = 0; i < actCount; i++){
    if(*first % 2 != 0){
      (*first)--;
    }
    uint half = *first / 2;
    *first = half;
    *second += half;

    uint *tmp = first;
    first = second;
    second = tmp;
  }
}

int main(){
  uint A, B, K;
  cin >> A >> B >> K;

  getResult(K, &A, &B);
  cout << A << " " << B;
  return 0;
}

#include <iostream>
#include <iomanip>
#include <cmath>

int main(int argc, char const* argv[])
{
	double x1, y1, x2, y2;
	std::cin >> x1 >> y1 >> x2 >> y2;

	double x = std::abs( x1 - x2 );
	double y = std::abs( y1 - y2 );

	std::cout << std::setprecision(20) << std::sqrt( x * x + y * y ) << std::endl;

	return 0;
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <atcoder/all>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace atcoder;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 3000000;
const int K = 100000;
const int mod = 1e9 + 7;
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, q;
    cin >> n >> q;
    fenwick_tree<int> f(n);
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        f.add(i, x);
    }
    while(q--){
        int t, l, r;
        cin >> t >> l >> r;
        if (t == 0){
            f.add(l, r);
        } else{
            cout << f.sum(l, r) << endl;
        }
    }
}

#include <bits/stdc++.h>

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

using namespace std;
using lint=long long;

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

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

	Fenwick_tree<lint> F(a);
	rep(_,q){
		int t,l,r; scanf("%d%d%d",&t,&l,&r);
		if(t==0) F.add(l,r);
		else     printf("%lld\n",F.sum(l,r));
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
int H, W, ans=1; cin >> H >> W; string A[H];
REP(i, H){ cin >> A[i]; }
int B[H][W]={}; vector< pair<int, int> > C;
REP(i, H){ REP(j, W){
  if(A[i][j]=='#'){  B[i][j]=1; C.push_back(make_pair(i, j)); }
} }
REP(i, H*W){
if((int)C.size()==H*W){ cout << ans-1 << "\n"; return 0; }
int a=C[i].first, b=C[i].second, c=B[a][b]+1;
if(a>0&&!B[a-1][b]){ B[a-1][b]=c; C.push_back(make_pair(a-1, b)); }
if(b>0&&!B[a][b-1]){ B[a][b-1]=c; C.push_back(make_pair(a, b-1)); }
if(a<H-1&&!B[a+1][b]){ B[a+1][b]=c; C.push_back(make_pair(a+1, b)); }
if(b<W-1&&!B[a][b+1]){ B[a][b+1]=c; C.push_back(make_pair(a, b+1)); }
ans=c;
}
}

#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
char str[1005];
const int DR[4] = {0, 1, 0, -1};
const int DC[4] = {1, 0, -1, 0};
int sp[1005][1005];
int main() {
	int h, w;
	scanf("%d%d", &h, &w);
	memset(sp, -1, sizeof(sp));
	queue<pair<int, int>> Q;
	for (int i = 0; i < h; ++i) {
		scanf("%s", str);
		for (int j = 0; j < w; ++j) {
			if (str[j] == '#') {
				sp[i][j] = 0;
				Q.push({i, j});
			}
		}
	}
	int ans = 0;
	while (!Q.empty()) {
		auto x = Q.front();
		Q.pop();
		ans = sp[x.first][x.second];
		for (int d = 0; d < 4; ++d) {
			int nr = x.first + DR[d];
			int nc = x.second + DC[d];
			if (nr < 0 || nc < 0 || nr >= h || nc >= w) continue;
			if (sp[nr][nc] != -1) continue;
			sp[nr][nc] = sp[x.first][x.second] + 1;
			Q.push({nr, nc});
		}
	}
	printf("%d\n", ans);
}


/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

vector<pair<ll,ll>> factor_arr;

void myfactor(ll num){
    ll count = 0;
    while (!(num % 2)) {
        num >>= 1; count++;
    }
    if (count) factor_arr.push_back({2,count});
    for (auto i = 3; i <= sqrt(num); i += 2) {
        count = 0;
        while (num % i == 0) {
            count++;
            num /= i;
        }
        if (count) factor_arr.push_back({i,count});
    }
    if (num > 2) factor_arr.push_back({num,1});
}

void virus(){
        ll a,b,c;
        cin>>a>>b>>c;
        cout<<min({a+b,b+c,a+c});
}

int32_t main(){
    ios_base::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 t=1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

//om namah shivaay
//faith over fear
//no one wants to die,yet death is the destination we all share

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
    ll a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout<<(a[0]+a[1]);

}


#include<iostream>
#include<queue>
#include<cstdio>
using namespace std;

int main(){
	priority_queue<int,vector<int>,greater<int> > que;
	string ss;
	int c[5];
	while(scanf("%d,%d,%d,%d,%d",&c[0],&c[1],&c[2],&c[3],&c[4])!=EOF){
		int dt[14];
		for(int i=0;i<14;i++){
			dt[i]=0;
		}
		for(int i=0;i<5;i++){
			que.push(c[i]);
		}
		while(!que.empty()){
			for(int i=1;i<=13;i++){
				if(que.top()==i)dt[i]++;
			}
			que.pop();
		}
		int onepair=0,threecard=0,straight=0,fourcard=0;
		for(int i=1;i<14;i++){
			if(dt[i]==2)onepair++;
			if(dt[i]==3)threecard++;
			if(dt[i]==4)fourcard++;
		}
		for(int i=5;i<14;i++){
			if(dt[i-4]==1 && dt[i-3]==1 && dt[i-2]==1 && dt[i-1]==1 &&dt[i]==1)straight++;
			if(i==13){
				if(dt[10]==1 && dt[11]==1 && dt[12]==1 && dt[13]==1 &&dt[1]==1)straight++;
			}
		}
		if(onepair==1){
			if(threecard==1)cout<<"full house"<<endl;
			else cout<<"one pair"<<endl;
		}
		else if(onepair==2)cout<<"two pair"<<endl;
		else if(threecard==1){
			if(onepair==1)cout<<"full house"<<endl;
			else cout<<"three card"<<endl;
		}
		else if(fourcard==1)cout<<"four card"<<endl;
		else if(straight==1)cout<<"straight"<<endl;
		else cout<<"null"<<endl;
	}
	return 0;
}

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,no-stack-protector,fast-math")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 4 * N + 5;

int head[N], nxt[M], to[M], typ[M], ne, n;

void init(){
    ne = 0;
    memset(head, -1, n * sizeof head[0]);
}

void addEdge(int f, int t, int ty){
    to[ne] = t;
    typ[ne] = ty;
    nxt[ne] = head[f];
    head[f] = ne++;
}

void addBiEdge(int a, int b, int ty){
    addEdge(a, b, ty);
    addEdge(b, a, ty);
}

struct state{
    int dis;
    set<int> typs;
};

state node[N];

bool inQ[N];

int dij(){
    priority_queue<pair<int, int> , vector<pair<int, int>>, greater<pair<int, int>>> pq;
    pq.emplace(0, 0);

    for(int i = 0 ; i < n ; ++i)
        node[i].dis = (int)1e9;

    node[0].dis = 0;
    inQ[0] = true;

    int cst, v;

    while(pq.size()){
        auto top = pq.top();
        pq.pop();

        int u = top.second;
        int d = top.first;
        inQ[u] = false;

        if(node[u].dis < d)continue;

        for(int e = head[u] ; ~e ; e = nxt[e]){
            v = to[e];
            cst = (node[u].typs.find(typ[e]) == node[u].typs.end());

            if(node[u].dis + cst < node[v].dis){
                inQ[v] = true;
                node[v] = {node[u].dis + cst, {typ[e]}};
                pq.emplace(node[v].dis, v);
            }

            else if(node[u].dis + cst == node[v].dis){
                if(node[v].typs.find(typ[e]) != node[v].typs.end())continue;
                node[v].typs.emplace(typ[e]);
                if(!inQ[v])
                    pq.emplace(node[v].dis, v), inQ[v] = true;
            }
        }

    }

    if(node[n - 1].dis > n)
        node[n - 1].dis = -1;
    return node[n - 1].dis;
}

int main(){
    IO;
    int m;
    scanf("%d %d", &n, &m);
    init();
    while(m--){
        int u, v, ty;
        scanf("%d %d %d", &u, &v, &ty);
        addBiEdge(--u, --v, ty);
    }
    printf("%d\n", dij());
}


#include <map>
#include <string>
#include <iostream>
using namespace std;
int main(){
	int i,r;
	string s;
	map<char,int>m;
	for(m['I']=1,m['V']=5,m['X']=10,m['L']=50,m['C']=100,m['D']=500,m['M']=1000;getline(cin,s);cout<<r<<endl)for(i=r=0;i<s.size();i++)r+=m[s[i]]*(m[s[i]]<m[s[i+1]]?-1:1);
}

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

int Roman_to_Arabia(char c){
	if (c == 'I')return 1;
	else if (c == 'V')return 5;
	else if (c == 'X')return 10;
	else if (c == 'L')return 50;
	else if (c == 'C')return 100;
	else if (c == 'D')return 500;
	else if (c == 'M')return 1000;
	else return 0;
}

int main(){
	string roman;
	int num;

	while (cin >> roman){
		num = 0;

		for (int i = 0; i < roman.size(); ++i){

			if (Roman_to_Arabia(roman[i]) < Roman_to_Arabia(roman[i + 1]))
				num -= Roman_to_Arabia(roman[i]);
			else
				num += Roman_to_Arabia(roman[i]);
		}
		cout << num << endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define Rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)

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

//cout << fixed << setprecision(10);//
//最小公倍数//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//べき//
ll squ(ll n, ll p, ll m){
	if(p==0) return 1;
	if(p%2==0){
		ll t=squ(n, p/2, m);
		return t*t%m;
	}
	return n*squ(n,p-1,m);

}

//逆元mod(mを法とするaの逆元)//
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;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nが大

ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}

	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1);
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}

	return k;
}

////////////////////////////////////////////////////////////////////

ll a[100005];

int judge(int n){
	ll y;
ll b[100005];
ll ch=0;

for(int i=1;i<=n;i++){
	if(i==1){y=a[1];
	if(y%2){y--;
	ch=1;
	}
	}
else{
	if(a[i]%2){
		ch++;
		y=gcd(y,a[i]-1);
	}
	else{
		y=gcd(y,a[i]);
	}

}

if(a[i]==1){return 0;}
if(ch>=2){return 0;}

}

if(ch==0){return 0;}
if(y==1||y%2==1){return 0;}
ll sum=0;
for(int i=1;i<=n;i++){
	if(a[i]%2==0){
	b[i]=a[i]/y;}
	else{
		b[i]=(a[i]-1)/y;
	}
if((a[i]-b[i])%2)sum++;
}
if(sum%2){return 0;}
for(int i=1;i<=n;i++){
	a[i]=b[i];
}

return 1;

}

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

ll sum=0;
rep(i, n){
	cin>>a[i];
	sum+=a[i];
}

if(n%2==0){
	if(sum%2==0){
		cout<<"Second"<<endl;
	}
	else{
		cout<<"First"<<endl;
	}
	return 0;
}

if(sum%2==0){cout<<"First"<<endl;
return 0;}

ll inv=0;
for(int u=1;u<=50;u++){
if(judge(n)==1){
	inv++;
}
else{
	break;
}
}

if(inv%2){cout<<"First"<<endl;}
else{cout<<"Second"<<endl;}
return 0;

}

#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
int n,a[100005];
bool work(){
	int num1=0,num2=0;
	for(int i=1;i<=n;i++)
		if(a[i]>1){
			if(a[i]&1)
				num1++;
			else
				num2++;
		}
	if(!num1&&!num2)
		return false;
	if(num2&1)
		return true;
	if(num1>1||!num1)
		return false;
	for(int i=1;i<=n;i++)
		if(a[i]>1&&a[i]&1){
			a[i]--;
			break;
		}
	int d=a[1];
	for(int i=2;i<=n;i++)
		d=__gcd(d,a[i]);
	for(int i=1;i<=n;i++)
		a[i]/=d;
	return !work();
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	puts(work()?"First":"Second");
	return 0;
}


#include <cstdio>
#include <cstring>
using namespace std;

int main(void)
{
	int n;
	char str[10000],c;
	char *t;

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

	for(int i = 0; i < n; i++){
		gets(str);

		while(t=strstr(str, "Hoshino"),t){
			t[6]  = 'a';
		}
		printf("%s\n", str);
	}
	return 0;
}

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

int main(){
	int n,pos;
	string s;
	while(cin>>n&&n){
		getline(cin,s);
		while(n--){
			getline(cin,s);
			while((pos=s.find("Hoshino",0))!=string::npos)
				s.replace(pos,7,"Hoshina");
			cout<<s<<endl;
		}
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
template<class T>using vv = vector<vector<T>>;
using vvi = vv<int>;
using vvl = vv<long long>;

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define repi(i,a,b) for(int i=(a),_i=(b);i<_i;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif

int N;
vv<int> A;
ll dp[1<<16][16];
const ll INF = 1e15;
ll dfs(int used, int i) {
  if (i == N)
    return 0;

  if (dp[used][i] != INF)
    return dp[used][i];

  if (used & (1 << i))
    return dfs(used, i+1);

  ll ans = 0;

  vi notUsed;
  rep(j, N)
    if (!(used & (1 << j))) {
      if (j < i)
        return -INF;
      notUsed.push_back(j);
    }

  rep(bit, 1 << (notUsed.size())) {
    ll tmp = 0;
    int used2 = 0;
    rep(j, notUsed.size()) {
      if (bit & (1 << j)) {
        used2 |= 1 << notUsed[j];
        rep(k, j+1, notUsed.size()) {
          if (bit & (1 << k))
            tmp += A[notUsed[j]][notUsed[k]];
        }
      }
    }
    ans = max(ans, tmp + dfs(used | used2, i+1));
  }
  return dp[used][i] = ans;
}
int main() {
  in(N);
  A.resize(N, vector<int>(N, 0));

  rep(i, 1<<16) rep(j, 16) dp[i][j] = INF;
  rep(i, N) rep(j, N) {
    cin >> A[i][j];
  }
  cout << dfs(0, 0) << endl;

  return 0;
}

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

void chmax(ll &a, ll b){ if(a < b) a = b; return; }
ll n, a[16][16], dp[1<<16];

int main(){
    cin >> n;
    rep(i,n) rep(j,n) cin >> a[i][j];
    loop(i,1,1<<n){
        rep(j,n) rep(k,j) if(i>>j & i>>k & 1) dp[i] += a[j][k];
        for(int j = i; j > 0; j = (j-1)&i) chmax(dp[i], dp[j]+dp[i^j]);
    }
    cout << dp[(1<<n)-1] << endl;
    return 0;
}


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

int main(){
	int N, K;
	cin >> N >> K;
	int ans = 0;
	for(int i = 1; i <= N - K + 1; ++i) {
		ans++;
	}
	cout << ans << endl;
}

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>

using namespace std;

typedef long long ll;
const int maxn=1e5+7;

int main()
{
//    freopen("input.txt","r",stdin);

    int n,k;
    cin>>n>>k;
	cout<<n-(k-1)<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

void solve()
{
    string s;cin>>s;
    if(s=="MON")
    cout<<6<<endl;
    else if(s=="TUE")
    cout<<5<<endl;
    else if(s=="WED")
    cout<<4<<endl;
    else if(s=="THU")
    cout<<3<<endl;
    else if(s=="FRI")
    cout<<2<<endl;
    else if(s=="SAT")
    cout<<1<<endl;
    else
    cout<<7<<endl;

}
int32_t main()
{
    rapido;
    int t;
    //cin>>t;
      t=1;
    while(t--)
    solve();
}

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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<vector<int> > ivve;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pb         push_back
#define mp         make_pair
#define GCD(x,y)   __gcd(x,y)
#define lb         lower_bound
#define up         upper_bound
#define setp       setprecision
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define spc(x)     cout<<fixed<<setp(x)

const   long long  inf = 1e18;
const   long long  cs =  200005;
const   long long  mod = 1000000007;
const   double     PI =  2 * acos(0.0);
void solve()
{
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0,cnt1=0;
    bool flag = false;

    string s;
    vector<string>v{"SUN","MON","TUE","WED","THU","FRI","SAT"};
    cin>>s;
    vector<string>::iterator it;
    it=find(all(v),s);
    x=distance(v.begin(),it);
    cout<<7-x<<endl;

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

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

    // int32_t tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}

int main(){
    ll k; cin>>k;
    vector<ll> ans;
    rep(i,51) if(i!=50-k%50) ans.push_back(k/50+i);
    cout<<50<<endl;
    puti(ans);
	return 0;
}

#include <iostream>
#define INF 1e9
using namespace std;
long long cnt;

void merge(int A[],int L,int M,int R){
  int n1=M-L;
  int n2=R-M;
  int a[500000],b[500000];
  for(int i=0;i<n1;i++)a[i]=A[L+i];
  for(int i=0;i<n2;i++)b[i]=A[M+i];
  a[n1]=INF,b[n2]=INF;
  int i=0,j=0;

  for(int k=L;k<R;k++){
    if(a[i]<=b[j]) A[k]=a[i++];
    else A[k]=b[j++],cnt+=(n1-i);
  }
}

void mergeSort(int A[],int L,int R){
  if(L+1<R){
    int M=(L+R)/2;
    mergeSort(A,L,M);
    mergeSort(A,M,R);
    merge(A,L,M,R);
  }
}

int main(){
  int n, a[500000];
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  mergeSort(a,0,n);

  cout <<cnt<<endl;
  return 0;
}


#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    string s;
    cin >> s;
    rep(i, s.size()-1){
        if (s[i] == 'A' && s[i+1] == 'C'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int r;
	cin >> r;
	if (r < 1200) cout << "ABC" << endl;
	else if (r < 2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
inline void read(long long &x) {
    char ch;
    bool flag = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;
    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x = flag ? -x : x;
}
inline void write(long long x) {
    static const long long maxlen = 100;
    static char s[maxlen];
    if (x < 0) {   putchar('-'); x = -x;}
    if (!x) { putchar('0'); return; }
    long long len = 0; for (; x; x /= 10) s[len++] = x % 10 + '0';
    for (long long i = len - 1; i >= 0; --i) putchar(s[i]);
}

inline void read(int &x){
    char ch;
    bool flag = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;
    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x = flag ? -x : x;
}

const long long MAXN =1001000;

long long n;
struct kt{
long long x,y;
long long id;
}a[ MAXN ];

long long fa[ MAXN ];

struct edge{
long long x,y,val;
}E[ MAXN*2 ];

bool cmp_x(kt A,kt B){
return A.x<B.x;
}

bool cmp_y(kt A,kt B){
return A.y<B.y;
}

bool cmp_e(edge A,edge B){
return A.val<B.val;
}

long long get_fa(long long x){
return (fa[x]==x)?(x):(fa[x]=get_fa(fa[x]));
}

int main(){
    read(n);
    for (long long i=1;i<=n;i++)
    {
        a[i].id=i;
        read(a[i].x);read(a[i].y);
    }
    sort(a+1,a+n+1,cmp_x);
    long long cnt=0;
    for (long long i=1;i<n;i++)
        {
            ++cnt;
            E[cnt].x=a[i].id;
            E[cnt].y=a[i+1].id;
            E[cnt].val=a[i+1].x-a[i].x;
        }

    sort(a+1,a+n+1,cmp_y);
    for (long long i=1;i<n;i++)
        {
            ++cnt;
            E[cnt].x=a[i].id;
            E[cnt].y=a[i+1].id;
            E[cnt].val=a[i+1].y-a[i].y;
        }
    for (long long i=1;i<=n;i++)
        fa[i]=i;

    sort(E+1,E+cnt+1,cmp_e);
    long long ans=0;
    for (long long i=1;i<=cnt;i++)
        {
            long long a=E[i].x,b=E[i].y;
            long long x=get_fa(a),y=get_fa(b);
            if ( x!=y )
                {
                    ans+=E[i].val;
                    fa[x]=y;
                }
        }
    cout<<ans<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793
template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
/*
 * UnionFind。O(ｱｯｶｰﾏﾝ)
 */
struct UnionFind{
	vi p;
	UnionFind(int s):p(s,-1){}
	void unite(int a,int b){
		a=root(a);b=root(b);
		if(a!=b){
			if(p[b]<p[a])swap(a,b);
			p[a]+=p[b];p[b]=a;
		}
	}
	bool same(int a,int b){return root(a)==root(b);}
	int root(int a){return p[a]<0?a:p[a]=root(p[a]);}
};

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n;
   	cin>>n;
   	using D=tuple<int,int,int>;
   	vector<D> data;

   	rep(i,n){
   	    int x,y;
   	    cin>>x>>y;
   	    data.emplace_back(i,x,y);
   	}
   	vector<D> edge;
   	sort(all(data),[](D a,D b){return get<1>(a)<get<1>(b);});
   	rep(i,n-1){
   	    int a0,a1,a2,b0,b1,b2;
   	    tie(a0,a1,a2)=data[i];
   	    tie(b0,b1,b2)=data[i+1];
   	    edge.emplace_back(b1-a1,a0,b0);
   	}
   	sort(all(data),[](D a,D b){return get<2>(a)<get<2>(b);});
   	rep(i,n-1){
   	    int a0,a1,a2,b0,b1,b2;
   	    tie(a0,a1,a2)=data[i];
   	    tie(b0,b1,b2)=data[i+1];
   	    edge.emplace_back(b2-a2,a0,b0);
   	}
   	int ans=0;
   	UnionFind uf(n);
   	sort(all(edge),[](D a,D b){return get<0>(a)<get<0>(b);});
   	for(auto&e:edge){
   	    int c,a,b;
   	    tie(c,a,b)=e;
   	    if(uf.same(a,b))continue;
   	    uf.unite(a,b);
   	    ans+=c;
   	}
   	cout<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
#define scl(n) scanf("%lld", &n)
#define pcl(n) printf("%lld\n", n)
#define pcl1(n) printf("%lld ", n)
#define nln printf("\n")
#define dev(x) cout << #x << " " << x << " ";
#define PTT pair<ll, ll>

map<ll, ll> mp, mp1;
map<ll, ll>::iterator itr;

int main()
{
    ll t, n, x;
    scl(n);
    ll mn = 1e10, d;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            d = max(i, n / i);
            ll cnt = 0;
            while (d >= 1)
            {
                d /= 10;
                cnt++;
            }
            mn = min(cnt, mn);
        }
    }
    pcl(mn);
    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <math.h>
#include <cmath>
#include <ctime>
#include <stdlib.h>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
typedef pair<int, int> P;

const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 1000000021;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	return lower_bound(all(vec), xx) - vec.begin();
}
template<typename T>void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>void vecin(vector<TT>& vec) {
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % 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;
}
long long modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

bool chmax(int& xx, int yy) {
	if (xx < yy) {
		xx = yy;
		return true;
	}
	return false;
}
bool chmin(int& xx, int yy) {
	if (xx > yy) {
		xx = yy;
		return true;
	}
	return false;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx <= 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}

signed main() {
	int n,mi=INF,ans=1;
	cin >> n;
	for (int i = 1; i*i <= n; i++) {
		if (n % i == 0) {
			chmin(mi,n / i);
		}
	}
	if (mi == INF)mi = n;
	while (mi >= 10) {
		mi /= 10;
		ans++;
	}
	cout << ans << endl;
}


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

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

  int64_t ans = 0;
  vector<int> a(n);
  for(int i=0; i<n; i++) {
    cin >> a[i];
    if(i>=1) {
      ans += max(0, a[i-1]-a[i]);
      if(a[i-1]-a[i]>0) a[i] = a[i-1];
    }
  }

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

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

struct UnionFind{
  vector<int> p;
  UnionFind(int n){
    p.resize(n);
    for(int i=0; i<n; i++)  p[i] = i;
  }
  int find(int x){
    if(p[x] == x)  return x;
    return p[x] = find(p[x]);
  }
  void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y)  return;
    p[x] = y;
  }
};

int main(){
  int n;  cin >> n;
  vector<tuple<int, int, int>> xyn(n);  // 0:x  1:y  2:idenfi.. number
  for(int i=0; i<n; i++){
    cin >> get<0>(xyn[i]) >> get<1>(xyn[i]);
    get<2>(xyn[i]) = i;
  }

  vector<tuple<int, int, int>> edge;  // 0:cost  1:from  2:to
  // x でソート
  sort(xyn.begin(), xyn.end(), [](auto &a, auto &b){ return get<0>(a) < get<0>(b); });
  for(int i=1; i<n; i++)  // 隣接する2頂点を cost : x座標差で辺として格納
    edge.push_back({get<0>(xyn[i])-get<0>(xyn[i-1]), get<2>(xyn[i-1]), get<2>(xyn[i])});

  // y でソート
  sort(xyn.begin(), xyn.end(), [](auto &a, auto &b){return get<1>(a) < get<1>(b); });
  for(int i=1; i<n; i++)  // 隣接する2頂点を cost : y座標差で辺として格納
    edge.push_back({get<1>(xyn[i])-get<1>(xyn[i-1]), get<2>(xyn[i-1]), get<2>(xyn[i])});

  sort(edge.begin(), edge.end());  // 辺たちをコストで昇順
  long ans = 0;

  // クラスカル法
  UnionFind uf(n);
  for(auto nowe : edge){
    if(uf.find(get<1>(nowe)) == uf.find(get<2>(nowe)))  continue;
    uf.unite(get<1>(nowe), get<2>(nowe));
    ans += get<0>(nowe);
  }

  cout << ans << endl;

  return 0;
}


#include <iostream>
using namespace std;

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

    // 答えを格納するための変数
    int ares = -1, bres = -1, cres = -1;

    // 全探索
    for (int a = 0; a <= N; ++a) {
        // a + b が N 以下の範囲で
        for (int b = 0; a + b <= N; ++b) {
            int c = N - a - b;
            if (10000 * a + 5000 * b + 1000 * c == Y) {
                ares = a;
                bres = b;
                cres = c;
            }
        }
    }
    cout << ares << " " << bres << " " << cres << endl;
}

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

void input(int& rnTrgSu, int& rnTrgKin)
{
  cin >> rnTrgSu >> rnTrgKin;
}

void searchMoney(int nTrgSu, int nTrgKin)
{
  vector<int> cnvnMoney{10000, 5000, 1000};

  int nCalKin;
  int i, j;
  for (i = 0; i <= nTrgSu; i++)
  {
    for (j = 0; j <= (nTrgSu - i); j++)
    {
      nCalKin = nTrgKin;

      nCalKin -= cnvnMoney[0] * i;
      nCalKin -= cnvnMoney[1] * j;
      nCalKin -= cnvnMoney[2] * (nTrgSu - i - j);
      if ( !nCalKin )
        break;
    }
    if ( !nCalKin )
      break;
  }
  if ( !nCalKin )
    cout << i << " " << j << " " << (nTrgSu - i - j) << endl;
  else
    cout << -1 << " " << -1 << " " << -1 << endl;
}

int main()
{
  int nTrgSu, nTrgKin;

  input(nTrgSu, nTrgKin);
  searchMoney(nTrgSu, nTrgKin);

  return 0;
}


#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
string make_string(T N)
{
    string ret;
    T now = N;
    while (now > 0)
    {
        T x = now % 10;
        ret += (char)('0' + x);
        now /= 10;
    }
    reverse(all(ret));
    return ret;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}

template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));
const string minf = "-";
void chmax(string &s, string t)
{
    if (s == minf)
    {
        s = t;
        return;
    }
    if (s.size() < t.size())
    {
        s = t;
        return;
    }
    if (s.size() == t.size() && s < t)
    {
        s = t;
        return;
    }
    return;
}
//cost[i]:iを作るのに必要なコスト
const ll cost[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int main()
{
    cout << fixed << setprecision(30);
    ll N, M;
    cin >> N >> M;
    vector<ll> A(M);
    loop(i, M) cin >> A[i];
    vector<string> dp(11000, "-");
    dp[0] = "";
    loop(i, 10010)
    {
        if (dp[i] == minf)
            continue;
        loop(j, M)
        {
            ll nownum = cost[A[j]];
            chmax(dp[i + nownum], dp[i] + (char)('0' + A[j]));
        }
    }
    putout(dp[N]);
    return 0;
}

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

const int x[10] = {-1,2,5,5,4,5,6,3,7,6};
void chmax(int &a, const int &b) { if (a < b) a = b; return; }

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

    vector<int> data(m);
    for (int i = 0; i < m; i++) cin >> data[i];
    sort(data.begin(),data.end(),greater<int>());

    vector<int> keta(n+1,-1); keta[0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < m; j++) {
            if (i - x[data[j]] >= 0) chmax(keta[i], keta[i - x[data[j]]] + 1);
        }
    }

    while (n > 0) {
        for (int i = 0; i < m; i++) {
            if (n - x[data[i]] >= 0 && keta[n] == keta[n - x[data[i]]] + 1) {
                cout << data[i];
                n -= x[data[i]];
                break;
            }
        }
    }
    return 0;
}


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

int main(){
    int n,m;
    int P[1010],Q[1000000];

    while(true){
	cin >> n >> m;
	if(n==0&&m==0) break;

	P[0]=0;
	for(int i=1;i<=n;i++) scanf("%d",&P[i]);

	int num=0;
	for(int i=0;i<=n;i++){
	    for(int j=i;j<=n;j++){
		Q[num++]=P[i]+P[j];
	    }
	}

	sort(Q,Q+num);

	int key,index,ans=0;
	int *pos;
	for(int i=0;i<num;i++){
	    key=m-Q[i];
	    if(key<0) break;

	    pos=lower_bound(Q,Q+num,key);
	    index=distance(Q,pos)-1;

	    ans=max(ans,Q[i]+Q[index]);
	}
 	cout << ans << endl;

    }
    return 0;
}

#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

int N, M;

int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M;
	while (N) {
		int num[1001];
		int ans = 0;
		set<int>F;
		set<int>S;
		for (int i = 0; i < N; i++)cin >> num[i];
		F.insert(0);
		for (int i = 0; i < N/2; i++) {
			F.insert(num[i]);
			for (int j = 0; j < N/2; j++) {
				F.insert(num[i] + num[j]);
			}
		}
		S.insert(0);
		for (int i = N/2; i < N; i++) {
			S.insert(num[i]);
			for (int j = N/2; j < N; j++) {
				S.insert(num[i] + num[j]);
			}
		}
		set<int>::reverse_iterator ritr = S.rbegin();
		for (auto i : F) {
			if (ritr == S.rend())break;
			while ((i + *ritr) > M) {
				++ritr;
				if (ritr ==S.rend())break;
			}
			if(ritr!=S.rend())	ans = max(ans, i + *ritr);
		}
		cout << ans << endl;
		cin >> N >> M;
	}
	return 0;
}


#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200010

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli;
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N;
double pi=2.0*acos(0.0);
vector<pair<pair<double,double>,int> > data;
vi ans;
double calcvec(pair<double,double> hoge1,pair<double,double> hoge2){
	double x=hoge2.first,y=hoge2.second;
	x-=hoge1.first,y-=hoge1.second;
	double ret=acos(x/sqrt(x*x+y*y));
	if(y<0)ret=2.0*pi-ret;
	return ret;
}
double calckaku(double a,double b){
	double ret=b-a;
	if(ret<0)ret+=2.0*pi;
	return ret;
}
int main(){
	cin>>N;
	int lef=0;
	for(int i=0;i<N;i++){
		double x,y;
		cin>>x>>y;
		data.pb(mp(mp(x,y),i));
	}
	sort(data.begin(),data.end());
	reverse(data.begin(),data.end());
	int num=0,nxnum;
	double kakub=acos(0.0);
	while(1){
		nxnum=0;
		double mi=2.0*pi,kakumemo;
		for(int i=0;i<N;i++){
			if(i!=num){
				double kaku=calcvec(data[num].first,data[i].first);
				double kakuc=calckaku(kakub,kaku);
				if(kakuc<mi){
					mi=kakuc,nxnum=i,kakumemo=kaku;
				}
			}
		}
		ans.pb(num);
		kakub=kakumemo;
		if(nxnum==0)break;
		num=nxnum;
	}
	double ans2[105]={0.0};
	int n=ans.size();
	for(int i=0;i<n;i++){
		int n1=ans[i],n2=ans[((i+1)%n)],n0=ans[((i+n-1)%n)];
		double ka1=calcvec(data[n1].first,data[n2].first);
		double ka2=calcvec(data[n0].first,data[n1].first);
		double ka=calckaku(ka2,ka1);
		ans2[data[ans[i]].second]=ka/(2.0*pi);
	}
	for(int i=0;i<N;i++)printf("%.7lf\n",ans2[i]);
}

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

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

	vector<int> X(N), Y(N);
	vector<char> U(N);

	map<char, int> conv;
	char conv_table[5] = "URDL";
	REP(i, 4) conv[conv_table[i]] = i;

	REP(i, N) {
		char c;
		scanf("%d %d %c", &X[i], &Y[i], &c);
		U[i] = c;
	}

	map<int, vector<pii>> lr, ud, ru, rd;
	REP(i, N) {
		lr[Y[i]].emplace_back(X[i], U[i]);
		ud[X[i]].emplace_back(Y[i], U[i]);
		ru[X[i] - Y[i]].emplace_back(X[i], U[i]);
		rd[X[i] + Y[i]].emplace_back(X[i], U[i]);
	}

	int ans = INF;
	for (auto &it : lr) {
		vector<pii> v = it.se;
		vector<int> ord(v.size());
		iota(ALL(ord), 0);
		sort(ALL(ord), [&](int i, int j) {
			return v[i].fi < v[j].fi;
		});
		int last = -INF;
		for (int i : ord) {
			if (v[i].se == 'R') last = v[i].fi;
			else if (v[i].se == 'L' && last != -INF) chmin(ans, (v[i].fi - last) * 5);
		}
	}
	for (auto &it : ud) {
		vector<pii> v = it.se;
		vector<int> ord(v.size());
		iota(ALL(ord), 0);
		sort(ALL(ord), [&](int i, int j) {
			return v[i].fi < v[j].fi;
		});
		int last = -INF;
		for (int i : ord) {
			if (v[i].se == 'U') last = v[i].fi;
			else if (v[i].se == 'D' && last != -INF) chmin(ans, (v[i].fi - last) * 5);
		}
	}
	for (auto &it : ru) {
		vector<pii> v = it.se;
		vector<int> ord(v.size());
		iota(ALL(ord), 0);
		sort(ALL(ord), [&](int i, int j) {
			return v[i].fi < v[j].fi;
		});
		int lastu = -INF, lastr = -INF;
		for (int i : ord) {
			if (v[i].se == 'U') lastu = v[i].fi;
			else if (v[i].se == 'R') lastr = v[i].fi;
			else if (v[i].se == 'D' && lastr != -INF) chmin(ans, (v[i].fi - lastr) * 10);
			else if (v[i].se == 'L' && lastu != -INF) chmin(ans, (v[i].fi - lastu) * 10);
		}
	}
	for (auto &it : rd) {
		vector<pii> v = it.se;
		vector<int> ord(v.size());
		iota(ALL(ord), 0);
		sort(ALL(ord), [&](int i, int j) {
			return v[i].fi < v[j].fi;
		});
		int lastr = -INF, lastd = -INF;
		for (int i : ord) {
			if (v[i].se == 'R') lastr = v[i].fi;
			else if (v[i].se == 'D') lastd = v[i].fi;
			else if (v[i].se == 'U' && lastr != -INF) chmin(ans, (v[i].fi - lastr) * 10);
			else if (v[i].se == 'L' && lastd != -INF) chmin(ans, (v[i].fi - lastd) * 10);
		}
	}

	if (ans == INF) puts("SAFE");
	else cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  vector<int> scinence = {a,b,c,d};
  vector<int> sorcial = {e,f};
  sort(scinence.begin(), scinence.end());
  int ans = 0;
  for(int i = 3; i > 0;--i) ans += scinence.at(i);
  ans += max(e,f);
  cout << ans << endl;
}

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <limits>
typedef long long ll;
#define REP(i,n)   for(int i=0; i<(int)(n); ++i)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); ++i)

#define in cin
#define out cout
#define pb push_back
using namespace std;

int main(){
	int a[4], b[2], mi = 999, sum=0;
	REP(i, 4) {
		in >> a[i];
		sum += a[i];
		mi = min(mi, a[i]);
	}
	in >> b[0];
	in >> b[1];
	int bb = max(b[0], b[1]);
	sum -= mi;

	out << sum+bb << endl;
	return 0;

}


#include <bits/stdc++.h>

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    double n,m,d;cin >>n>>m>>d;
    double p;
    if(d==0){
        p=1/n;
    }
    else {
        p=2*(n-d)/(n*n);
    }
//    cout <<p<<endl;
    p*=(m-1);
    cout <<setprecision(20)<<p<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14 100兆
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll n, m, d;
  cin >> n >> m >> d;
  long double x = 0;
  if(2 * d >= n){
    x += n - d;
    x += n - d;
    x /= n * n;
  }
  else if(d == 0){
    x += n;
    x /= n * n;
  }
  else{
    x += d;
    x += 2 * (n - 2 * d);
    x += d;
    x /= n * n;
  }
  cout << fixed << setprecision(10);
  cout << x * (m - 1) << endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  vector<int64_t>B(1+N);
  map<int64_t,int64_t>M;
  M[1]=A.at(0);
  for(int i=2;i<=N;i++)
    if(i%2==1)
      M[i]=M.at(i-2)+A.at(i-1);
  B.at(0)=0;
  B.at(0)=0;
  B.at(2)=max(A.at(0),A.at(1));
  for(int i=3;i<=N;i++){
  if(i%2==0)
    B.at(i)=max(A.at(i-1)+B.at(i-2),A.at(i-2)+M.at(i-3));
    else
      B.at(i)=max(A.at(i-1)+B.at(i-2),A.at(i-2)+B.at(i-3));

  }cout<<B.at(N)<<endl;
   return 0;
}

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

int main(void) {
    int i, j, n, cnt=0;
    cin >> n;
    int A[n];

    for (i = 0; i < n; i++) cin >> A[i];

    for (i = 0; i < n; i++) {
        for (j = n - 1; j > i; j--) {
            if (A[j] < A[j-1]) {
                swap(A[j], A[j-1]);
                cnt++;
            }
        }
    }

    for (i = 0; i < n; i++) {
        cout << A[i];
        if (i == n - 1) cout << endl;
        else cout << ' ';
    }
    cout << cnt << endl;
    return 0;
}


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

typedef long long LL;

int n;

void into(){
  scanf("%d",&n);
}

void work(){
}

void outo(){
  printf("%d\n",(n-2)*180);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl "\n"
typedef long long ll;
const double pi=3.14159265358979323846;
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}
vector<long long> divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;

    /*long long N;
    cin >> N;
    vector<long long> res = divisors(N);
    for (int i = 0; i < res.size(); ++i) {
        cout << res[i] << " ";
    }
    cout << endl;*/
}
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}
void sayYes(bool f) {
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void sayYES(bool f) {
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int main() {
  int n;
  cin >> n;
  cout << (n-2)*180 << endl;
}


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

using namespace std;

int main(){
	int n[102], tn=0,ni=0,all = 0, i = 0,h=0;
	int data[1024][10];
	int tdata[10] = { 0 };

	//input
	while (1){
		cin >> n[ni];
		if (n[ni] == 0)break;
		tn += n[ni];

		for (; i < tn; i++){
			for (int j = 0; j < n[ni]; j++){
				cin >> data[i][j];
			}
		}
		ni++;
	}

	//output
	for (int k = 0; k < ni; k++){
		for (int i=0; i < n[k]; i++, all = 0,h++){
			for (int j = 0; j < n[k]; j++){
				printf("%5d", data[h][j]);
				all += data[h][j];
				tdata[j] += data[h][j];
			}
			printf("%5d\n", all);
		}

		all = 0;
		for (int i = 0; i < n[k]; i++){
			printf("%5d", tdata[i]);
			all += tdata[i];
		}
		printf("%5d\n", all);

		for (int i = 0; i < n[k]; i++){
			tdata[i] = 0;
		}
		all = 0;
	}
	return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

int main(){

	int N,Q,M,Date[101],i,l,k;

	while(0<=scanf("%d%d",&N,&Q)){
		for(i=0;i<101;i++){
			Date[i]=0;
		}

		if((N==0) && (Q==0)){
			break;
		}

		for(k=0;k<N;k++){
			scanf("%d",&M);
			if(M==0){
				continue;
			}else{
				for(i=0;i<M;i++){
					scanf("%d",&l);
					++Date[l];
				}
			}
		}
		l=0;
		i=0;
		for(k=0;k<100;k++){
			if(i<Date[k] && Date[k]>=Q){
				i=Date[k];
				l=k;
			}
		}

		printf("%d\n",l);
	}

	return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

bool f(vector<ll> &a) {
  int N = (int)a.size();
  if (*max_element(ALL(a)) < N)
    return false;
  REP(i, N) a[i]++;
  *max_element(ALL(a)) -= (N+1);
  return true;
}

void rev(vector<ll> &a) {
  int N = (int)a.size();
  REP(i, N) a[i]--;
  *min_element(ALL(a)) += (N+1);
}

void print(const vector<ll> &a) {
  int N = (int)a.size();
  cout << N << endl;
  REP(i, N) {
    if (i > 0) cout << " ";
    cout << a[i];
  }
  cout << endl;
}

int main2() {
  ll K; cin >> K;
  int N = 50;
  vector<ll> a(N, N-1);
  REP(i, N) a[i] += K/N;
  REP(_, K % N) {
    rev(a);
  }

  print(a);

  // if (K <= 100) {
    // ll count = 0;
    // while (f(a)) {
      // count++;
      // print(a);
    // }
    // cout << "check=" << count << endl;
  // }

  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}

# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

class node {
public:
	int key;
	node *parent, *lch, *rch;
};

node *NIL, *root;

void insert(int v) {
	node *y = NIL, *x = root, *z = new node;
	z->key = v; z->lch = z->rch = NIL;
	while (x != NIL) {
		y = x;
		if (z->key < x->key)x = x->lch;
		else x = x->rch;
	}
	z->parent = y;
	if (y == NIL)root = z;
	else if (z->key < y->key)y->lch = z;
	else y->rch = z;
	return;
}

node* find(int k) {
	node *x = root;
	while (x != NIL&&k != x->key) {
		if (k < x->key)x = x->lch;
		else x = x->rch;
	}
	return x;
}

node* next(node *z) {
	node *x, *y;
	if (z->rch != NIL) {
		x = z->rch;
		while (x->lch != NIL)x = x->lch;
		return x;
	}

	y = z->parent;
	while (y != NIL&&x == y->rch) {
		x = y;
		y = y->parent;
	}
	return y;
}

void remove(node *z) {
	node *y, *x;
	if (z->lch == NIL || z->rch == NIL)y = z;
	else y = next(z);

	if (y->lch != NIL)x = y->lch;
	else x = y->rch;

	if (x != NIL)x->parent = y->parent;

	if (y->parent == NIL)root = x;
	else if (y == y->parent->lch)y->parent->lch = x;
	else y->parent->rch = x;

	if (y != z)z->key = y->key;
	delete(y);
	return;
}

void ino(node *u) {
	if (u == NIL)return;
	ino(u->lch);
	cout << " " << u->key;
	ino(u->rch);
	return;
}

void preo(node *u) {
	if (u == NIL)return;
	cout << " " << u->key;
	preo(u->lch);
	preo(u->rch);
	return;
}

void print() {
	ino(root);
	cout << endl;
	preo(root);
	cout << endl;
	return;
}

int main() {
	int n; cin >> n;
	string s; node *a;
	while (cin >> s) {
		if (s == "insert") {
			cin >> n;
			insert(n);
		}
		else if (s == "find") {
			cin >> n;
			a = find(n);
			if (a != NIL)cout << "yes" << endl;
			else cout << "no" << endl;
		}
		else if (s == "delete") {
			cin >> n;
			remove(find(n));
		}
		else if (s == "print")print();
	}
	return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (long long i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int n,m;
vector<int> v[501];
set<int> st,ss;

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

    while(true) {
	cin>>n>>m;
	if(n==0&m==0) break;
	REP(i,501) v[i].clear();
	st.clear();ss.clear();
	REP(i,m) {
		int a,b;
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	st.insert(1);
	REP(i,v[1].size()) {
		st.insert(v[1][i]);
	}
	for(auto x:st) {
		REP(i,v[x].size()) {
			ss.insert(v[x][i]);
		}
	}
	for(auto x:st) {
		ss.insert(x);
	}
	cout<<ss.size()-1<<endl;
    }

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
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; }

int main(){
    int n, ans = 0;
    cin >> n;
    vector<int> a(n);
    vector<vector<int> > x(n), y(n);
    rep(i, n){
        cin >> a[i];
        rep(j, a[i]){
            int X, Y;
            cin >> X >> Y;
            X--;
            x[i].push_back(X);
            y[i].push_back(Y);
        }
    }
    rep(bit, 1<<n){
        bitset<16> tmp(bit);
        if((int)tmp.count() < ans) continue;
        bool ok = true;
        rep(i, n) {
            // 正直な人
            if(tmp.test(i)){
                rep(j, a[i]) {
                    // x[i][j]は正直者だと正直者が言っているのに実際には正直者ではない
                    if(tmp.test(x[i][j]) && y[i][j] == 0) {
                        ok = false;
                        break;
                    }
                    if(!tmp.test(x[i][j]) && y[i][j] == 1) {
                        ok = false;
                        break;
                    }
                }
            }
        }
        if(ok) chmax(ans, (int)tmp.count());
    }
    cout << ans << endl;
}


#include <iostream>

using namespace std;

int main() {
  string s;
  cin >> s;
  cout << "2018/01/" << s.substr(s.size() - 2) << endl;
  return 0;
}

#include <stdio.h>

int main(){
    int year;
    int month;
    int day;
    scanf("%d/%d/%d", &year, &month, &day);
    printf("2018/%02d/%02d\n", month, day);

    return 0;

}