#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for (int i=0; i < (n); i++)
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int MOD = 1000000007;
const double pi = 3.141592653589;

int main() {
    int n, l;
    cin >> n >> l;
    int taste = 0;
    int ate = INF;
    rep(i,n){
        taste += l + i;
        if(abs(ate) > abs(l+i)) ate = l+i;
    };
    cout << taste - ate << endl;
    return 0;
}

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

int main()
{
  int a,b;
  cin >> a >> b;

  int ans = 0;
  for(int i = a; i <= b; i++){
    string s = to_string(i);
    string t = s;
    reverse(t.begin(),t.end());
    if(s == t){
      ans++;
    }
  }

  cout << ans << endl;

}


#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int i,a[4],b,c,sum;
	for(i=0;i<4;i++){
		scanf("%d",&a[i]);
	}
	scanf("%d %d",&b,&c);
	sort(a,a+4,greater<int>());
	for(i=0;i<3;i++){
		sum+=a[i];
	}
	if(b>c){
		sum+=b;
	}
	else{
		sum+=c;
	}
	printf("%d\n",sum);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main() {
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  int dx=abs(sx-tx);
  int dy=abs(sy-ty);
  cout<<string(dx,'R')<<string(dy,'U');
  cout<<string(dx,'L')<<string(dy,'D');
  cout<<'L'<<string(dy+1,'U')<<string(dx+1,'R')<<'D';
  cout<<'R'<<string(dy+1,'D')<<string(dx+1,'L')<<'U';
  cout<<endl;
  return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    string A, B, C;

    cin >> N;
    cin >> A;
    cin >> B;
    cin >> C;

    ll count = 0;
    REP(i, N){
        if((A[i] != B[i]) && (B[i] != C[i]) && (C[i] != A[i])){
            count += 2;
            continue;
        }
        if((A[i] == B[i]) && (B[i] != C[i]) && (C[i] != A[i])){
            count++;
            continue;
        }
        if((A[i] != B[i]) && (B[i] == C[i]) && (C[i] != A[i])){
            count++;
            continue;
        }
        if((A[i] != B[i]) && (B[i] != C[i]) && (C[i] == A[i])){
            count++;
            continue;
        }
    }

    cout << count << endl;
    return 0;
}

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

void solve(){
  int N; cin >> N;
  string A, B, C; cin >> A >> B >> C;
  int ans = 0;
  rep(i,N){
    set<char> st;
    st.insert(A[i]);
    st.insert(B[i]);
    st.insert(C[i]);
    ans += st.size()-1;
  }
  cout << ans << endl;
}

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


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const ll  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1000000007;

/*vll adj[MAXN];ll visit[MAXN]={};
ll dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/
// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m,k,d,w;
string s,t;
//vll a,b;
// <------------- Implement Functions Here ----------> //

// <------------- Start of main() -------------------> //

void MAIN(ll _) {
	vll a(3);
	cin>>a[0]>>a[1]>>a[2];
	sort(all(a));
	cin>>k;
	cout<<(a[0]+a[1]+((ll)pow(2,k))*a[2]);
}

int main() {
	fastio;randomINT;
	//cin>>T;
	for(ll i=1;i<=T;i++) {
		MAIN(i);
	}
	return 0;
}


#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	for(ll i = m/n; i >= 1; --i){
		ll r = m - i * n;
		if(r < 0) continue;
		if(r%i == 0){
			cout << i << endl;
			return 0;
		}
	}
	cout << 1 << endl;
	return 0;
}

#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)
const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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

vector<long long> enum_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);
            if (N / i != i)
                res.push_back(N / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}
int main()
{
    ll N, M;
    cin >> N >> M;
    ll ans = 1;
    auto div = enum_divisors(M);

    for (int i = M / N; i >= 1;i--)
    {
        for (int j = 0; j < div.size();j++)
        {
            if(div[j] == i){
                ans = i;
                break;
            }
            //cout << i << " " <<div[j] << endl;
        }
        if (ans != 1)
        {
            break;
        }
    }
    cout << ans << endl;
}


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

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

int N;
int D[100010];
int mod = 998244353;

signed main()
{
    cin >> N;
    rep(i, N)
    {
        int d;
        cin >> d;
        D[d]++;
        if(i == 0 && d != 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }

    int ans = 1;
    rep(i, N)
    {
        if(i == 0 && D[i] != 1)
        {
            cout << 0 << endl;
            return 0;
        }
        int tmp = 1;
        if(i != 0)
            rep(j, D[i])tmp = tmp * D[i - 1] % mod;
        ans = ans * tmp % mod;
    }

    cout << ans << endl;

    return 0;
}

#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

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

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for(int i=0;i<n;i++) cin >> A[i];
    sort(A.begin(),A.end());
    ll h=0,v=0;
    for(int i=n-1;i>0;i--){
        if(h==0){
            if(A[i]==A[i-1]){
                h=A[i];
                i--;
            }
        }else{
            if(A[i]==A[i-1]){
                v=A[i];
                break;
            }
        }
    }
    ll ans=h*v;
    cout << ans << endl;
}


#include<stdio.h>
#include<math.h>
#include<algorithm>
#define reg register
#define ri reg int
#define rep(i, x, y) for(ri i = x; i <= y; ++i)
#define nrep(i, x, y) for(ri i = x; i >= y; --i)
#define DEBUG 1
#define ll long long
#define max(i, j) (i) > (j) ? (i) : (j)
#define min(i, j) (i) < (j) ? (i) : (j)
struct IO {
	#define MAXSIZE (1 << 20)
	#define isdigit(x) (x >= '0' && x <= '9')
	char buf[MAXSIZE], *p1, *p2;
	char pbuf[MAXSIZE], *pp;
	#if DEBUG
	#else
		IO() : p1(buf), p2(buf), pp(pbuf) {}
		~IO() {
			fwrite(pbuf, 1, pp - pbuf, stdout);
		}
	#endif
	inline char gc() {
		#if DEBUG
    		return getchar();
		#endif
    	if(p1 == p2)
			p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin);
    	return p1 == p2 ? ' ' : *p1++;
	}
	inline bool blank(char ch) {
    	return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
	}
	template <class T>
	inline void read(T &x) {
    	register double tmp = 1;
    	register bool sign = 0;
    	x = 0;
    	register char ch = gc();
    	for(; !isdigit(ch); ch = gc())
    		if(ch == '-') sign = 1;
    	for(; isdigit(ch); ch = gc())
			x = x * 10 + (ch - '0');
    	if(ch == '.')
			for(ch = gc(); isdigit(ch); ch = gc())
        		tmp /= 10.0, x += tmp * (ch - '0');
    	if(sign) x = -x;
	}
	inline void read(char *s) {
		register char ch = gc();
		for(; blank(ch); ch = gc());
		for(; !blank(ch); ch = gc())
			*s++ = ch;
    	*s = 0;
	}
	inline void read(char &c) {
    	for(c = gc(); blank(c); c = gc());
	}
	inline void push(const char &c) {
		#if DEBUG
    		putchar(c);
		#else
    		if(pp - pbuf == MAXSIZE) {
				fwrite(pbuf, 1, MAXSIZE, stdout);
				pp = pbuf;
			}
    		*pp++ = c;
		#endif
	}
	template <class T>
	inline void write(T x) {
    	if(x < 0) {
			x = -x;
			push('-');
		}
    	static T sta[35];
    	T top = 0;
    	do{
			sta[top++] = x % 10;
			x /= 10;
    	}while(x);
    	while(top)
			push(sta[--top] + '0');
	}
	template <class T>
	inline void write(T x, char lastChar) {
    	write(x);
		push(lastChar);
	}
} io;
int aa[1000010], cnt[1000010], belong[1000010];
int n, m, size, bnum, now, ans[1000010];
struct query { /*询问*/
	int l, r, id;
} q[1000010];

int cmp(query a, query b) {
	return (belong[a.l] ^ belong[b.l]) ? belong[a.l] < belong[b.l] : ((belong[a.l] & 1) ? a.r < b.r : a.r > b.r); /*奇偶优化后的排序*/
}
int main() {
	io.read(n), io.read(m);
	size = sqrt(n);
	bnum = ceil((double)n / size);
	rep(i, 1, bnum)
		rep(j, (i - 1) * size + 1, i * size) {
			belong[j] = i; /*依旧不知道所以然的离散化*/
		}
	rep(i, 1, n) io.read(aa[i]);
	rep(i, 1, m) {
		io.read(q[i].l), io.read(q[i].r);
		q[i].id = i; /*读入每一个询问*/
	}
	std::sort(q + 1, q + m + 1, cmp);
	int l = 1, r = 0;
	rep(i, 1, m) {
		int ql = q[i].l, qr = q[i].r; /*莫队主体*/
		while(l < ql) now -= !--cnt[aa[l++]]; /*需要移动就移,在移的过程中更新答案*/
		while(l > ql) now += !cnt[aa[--l]]++;
		while(r < qr) now += !cnt[aa[++r]]++;
		while(r > qr) now -= !--cnt[aa[r--]];
		ans[q[i].id] = now;
	}
	rep(i, 1, m) io.write(ans[i], '\n');
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
    // que[R] = {L, index_of_query};
    // um is map such that um[element] = last index the element was seen
    // s - a set that contains the last index as mentioned above
    // code assumes 0 indexed
    // complexity - O(n*log(n))

    unordered_map<int, int>um;
    pbds s;
    int n; cin >> n;
     int q; cin >> q;
    vector<int>a(n);
    for (auto &it : a)
        cin >> it;

    vector<int>ans(q);
    vector<vector<pair<int, int>>>que(n);
    for (int i = 0; i < q; i++)
    {
        int L, R; cin >> L >> R;
        L --;
        R--;
        que[R].push_back({L, i});
    }
    for (int i = 0; i < n; i++)
    {
        if (um.count(a[i]))
            s.erase(um[a[i]]);
        um[a[i]] = i;
        s.insert(i);
        for (auto it : que[i])
            ans[it.second] = s.size() - s.order_of_key(it.first);
    }
    for (int i = 0; i < q; i++)
        cout << ans[i] << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vl a(n);
    vl cnt(n);
    cin >> a;

    ll ans = 1;
    rep(i, n) {
        if (a[i] == 0) ans *= (3 - cnt[a[i]]);
        else ans *= (cnt[a[i] - 1] - cnt[a[i]]);
        ans %= mod;
        cnt[a[i]]++;
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


///\/\/\/

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, ll>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    nvarep(n,v);
    map<int,int>fm,bm;
    rep(i,0,n){
        if(i%2==0)fm[v[i]]++;
        else bm[v[i]]++;
    }
    vector<p>f,b;
    irep(i,fm){
        f.pb(mp(i->second,i->first));
    }
    irep(i,bm){
        b.pb(mp(i->second,i->first));
    }
    f.pb(mp(0,0));
    b.pb(mp(0,0));
    sort(range(f));
    reverse(range(f));
    sort(range(b));
    reverse(range(b));
    if(f[0].second==b[0].second){
        cout<<n-max(f[0].first+b[1].first,f[1].first+b[0].first)<<nnn;
    }else{
        cout<<n-f[0].first-b[0].first<<nnn;
    }
    return 0;
}

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<int> even(1e5+1, 0);
  vector<int> odd(1e5+1, 0);
  rep(i,n) {
    int v;
    cin >> v;
    if (i%2) {
      odd[v]++;
    } else {
      even[v]++;
    }
  }
  pair<int, int> mx_odd = make_pair(0, 0);
  pair<int, int> mx_even = make_pair(0, 0);
  pair<int, int> mx_odd_2 = make_pair(0, 0);
  pair<int, int> mx_even_2 = make_pair(0, 0);

  rep(i, 1e5+1) {
    if (odd[i] > mx_odd.second) {
      mx_odd_2 = mx_odd;
      mx_odd = make_pair(i, odd[i]);
    } else {
      if (odd[i] > mx_odd_2.second) mx_odd_2 = make_pair(i, odd[i]);
    }
    if (even[i] > mx_even.second) {
      mx_even_2 = mx_even;
      mx_even = make_pair(i, even[i]);
    } else {
      if (even[i] > mx_even_2.second) mx_even_2 = make_pair(i, even[i]);
    }
  }
  int h = n/2;
  int odd_diff = (n/2 - mx_odd.second);
  int even_diff = (n/2 - mx_even.second);
  int ans = 0;
  if (mx_even.first == mx_odd.first) {
    int a = (h - mx_even.second) + (h - mx_odd_2.second);
    int b = (h - mx_odd.second) + (h - mx_even_2.second);
    ans = min(a, b);
  } else {
    ans = (h - mx_odd.second) + (h - mx_even.second);
  }
  cout << ans << endl;

  return 0;
}


#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using Vi = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    int n;
    cin>>n;
    vector<string> s(3);
    rep(i,3){
        cin>>s[i];
    }
    ll ans=0;
    rep(i,n){
        ll memo=0;
        if(s[0][i]!=s[1][i]) memo++;
        if(s[0][i]!=s[2][i]) memo++;
        if(s[2][i]!=s[1][i]) memo++;
        ans+=max((ll)0,memo-1);
    }
    cout<<ans<<endl;

}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,su=0;
    string a,s,d;
    cin>>n>>a>>s>>d;
    set<char>se;
    for(i=0;i<n;i++)
    {
        se.insert(a[i]);
        se.insert(s[i]);
        se.insert(d[i]);
        su+=se.size()-1;
        se.clear();
    }
    cout<<su<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, u, v;
  cin >> n >> u >> v;
  u--, v--;
  vector<vl> g(n);
  rep(i, n - 1) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<vl> d(2, vl(n, -1));
  rep(k, 2) {
    queue<ll> q;
    q.push(u);
    d[k][u] = 0;
    while(!q.empty()) {
      int i = q.front();
      q.pop();
      for(auto v : g[i]) {
        if(d[k][v] != -1) continue;
        d[k][v] = d[k][i] + 1;
        q.push(v);
      }
    }
    swap(u, v);
  }
  ll mx = 0;
  rep(i, n) if(d[0][i] < d[1][i]) mx = max(mx, d[1][i]);
  cout << mx - 1 << endl;
}

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
wGraph InputWGraph(ll N,ll M){
    wGraph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        G[a].push_back(make_pair(b,c));
        G[b].push_back(make_pair(a,c));
    }
    return G;
}
wGraph InputDWGraph(ll N, ll M){
    wGraph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        G[a].push_back(make_pair(b,c));
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}

void OutputGraph(wGraph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j].first <<"/" << G[i][j].second << ",";
        }
        cout << endl;
    }
}

void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    string N;
    cin >> N;
    ll digit = N.size();
    vector<vector<ll>>memo(2);
    for (int yi = 0; yi < 2; ++yi) {
        memo[yi] = vector<ll>(digit);
        for (int xi = 0; xi < digit; ++xi) {
            memo[yi][xi] = (1ll << 50);
        }
    }
    ll first = N[0] - '0';
    memo[0][0] = min(11 - first,first);
    memo[1][0] = min(11 - first - 1,first + 1);

    for (int i = 1; i < digit; ++i) {
        ll num = N[i] - '0';
        memo[0][i] = min(memo[0][i-1] + num,memo[1][i-1] + (10 - num));
        memo[1][i] = min(memo[0][i-1] + num + 1,memo[1][i-1] + (10 - num - 1));
    }
    cout << (memo[0][digit-1]) << endl;
}


#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	int n, k; cin >> n >> k;
	cout << (n % k == 0 ? 0 : 1) << endl;
	return 0;
}

#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

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

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int a, b;
  cin >> a >> b;

  cout << max(max(a + b, a * 2 - 1), b * 2 - 1);
}
#endif


#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
/*!* [intutil] *!*/
/*+* 整数演算いろいろ *+*/
i64 divceil(i64 a, i64 b) {
    return a / b + (a > 0 && a % b ? 1 : 0);
}
i64 logceil(i64 a, i64 b) {
    for(i64 i = 0, x = 1; a >= 2; x *= a, i++) if(x <= b) return i; return 0;
}
i64 gcd(i64 a, i64 b) {
    for (i64 c; a;) c = a, a = b % a, b = c; return b;
}
i64 lcm(i64 a, i64 b) {
    return (a / gcd(a, b) * b);
}
int main() {
    int N;
    cin >> N;
    vector<i64> A(N);
    for(i64 &a : A) cin >> a;
    bool ans;
    // i : ターン数 (0 mod 2 で自分のターン)
    for(int i = 0; true; i++) {
        i64 g = A[0];
        for(i64 a : A) g = gcd(g, a);
        for(i64 &a : A) a /= g;

        int even_num = 0;
        for(i64 a : A) even_num += (a % 2 == 0);
        if(even_num % 2) { // 偶数が奇数個
            ans = i % 2 == 0;
            break;
        } else { // 偶数が偶数個
            i64 odd = 0;
            for(i64 a : A) if(a % 2 == 1) odd = a;
            if(N - even_num == 1 && odd > 2) { // 奇数が一つだけで、それは1でない
                for(i64 &a : A) if(a % 2 == 1) a--;
                continue;
            } else {
                ans = i % 2 == 1;
                break;
            }
        }
    }
    cout << (ans ? "First" : "Second") << endl;
    return 0;
}

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

namespace IO {
    template <typename _T>
    inline bool read (_T& x) {
        x = 0;
        _T y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-') y = -1;
            c = getchar();
        }
        if (c == EOF) return false;
        while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
        x *= y;
        return true;
    }

    template <typename _T>
    inline _T input () {
        _T x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-') y = -1;
            c = getchar();
        }
        if (c == EOF) return 0;
        while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
        x *= y;
        return x;
    }
};
using namespace IO;

namespace modular {
    const int MOD = 1000000007;

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

    inline void inc (int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }

    inline int mul (int x, int y) { return 1LL * x * y % MOD; }

    inline int qpow (int x, int y) {
        int ans = 1;
        for (; y; y >>= 1, x = mul(x, x)) if (y & 1) ans = mul(ans, x);
        return ans;
    }
};

#define reg register
#define MAX_N 200007
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for(int i = l; i <= r; ++i)
#define lep(i, l, r) for(int i = l; i < r; ++i)
#define irep(i, r, l) for(int i = r; i >= l; --i)
#define ilep(i, r, l) for(int i = r; i > l; --i)
typedef long long ll;

int N;
int a[MAX_N];

inline void print (bool k, bool p) { puts(k ^ p ? "First" : "Second"); exit(0); }

void dfs (int p) {
    int cnt[2] = {0, 0};
    rep (i, 1, N) cnt[a[i] & 1]++;
    rep (i, 1, N) if (a[i] == 1) print(cnt[0] & 1, p);
    if (cnt[0] & 1) print(1, p);
    else if (cnt[1] > 1) print(0, p);
    rep (i, 1, N) if (a[i] != 1 && (a[i] & 1)) a[i]--;
    int d = a[1];
    rep (i, 2, N) d = std::__gcd(d, a[i]);
    rep (i, 1, N) a[i] /= d;
    dfs(p ^ 1);
}

int main () {
#ifdef LOCAL
    FIN("in");
#endif
    read(N);
    rep (i, 1, N) read(a[i]);
    dfs(0);
    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  while (K--) {
    vector<int> V(N);
    for (int i = 0; i < N; i++) {
      V.at(max(0, i - A.at(i)))++;
      if (i + A.at(i) + 1 < N) V.at(i + A.at(i) + 1)--;
    }
    for (int i = 1; i < N; i++) V.at(i) += V.at(i - 1);
    if (A == V) break;
    A = V;
  }
  for (auto a : A) cout << a << "\n";
}

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

ll n, k;
array<ll, N> old, nw;
bitset<N> used;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    vector<ll> a(n);
    for (auto& i : a) cin >> i;

    for (int i = 0; i < n; ++i) {
        old[max(0ll, i - a[i])]++;
        old[min(n, i + a[i] + 1)]--;
    }

    for (int i = 1; i < k; ++i) {
        ll psum = 0;
        used.reset();
        for (int j = 0; j < n; ++j) {
            if (i % 2) {
                psum += old[j];
                // cout << i << ' ' << j << ' ' << psum << '\n';
                ll mn = max(0ll, j - psum), mx = min(n, j + psum + 1);
                if (!used[j]) {
                    used[j] = 1;
                    nw[j] = 0;
                }
                if (!used[mn]) {
                    used[mn] = 1;
                    nw[mn] = 0;
                }
                if (!used[mx]) {
                    used[mx] = 1;
                    nw[mx] = 0;
                }

                // cout << j << ' ' << mn << ' ' << mx << '\n';
                nw[mn]++;
                nw[mx]--;
            } else {
                psum += nw[j];
                // cout << i << ' ' << j << ' ' << psum << '\n';
                ll mn = max(0ll, j - psum), mx = min(n, j + psum + 1);
                if (!used[j]) {
                    used[j] = 1;
                    old[j] = 0;
                }
                if (!used[mn]) {
                    used[mn] = 1;
                    old[mn] = 0;
                }
                if (!used[mx]) {
                    used[mx] = 1;
                    old[mx] = 0;
                }

                // cout << j << ' ' << mn << ' ' << mx << '\n';
                // cout << old[mn] << ' ' << old[mx] << '\n';
                old[mn]++;
                old[mx]--;
            }
        }

        if (nw == old) break;
    }

    if (k % 2) {
        ll psum = 0;
        for (int i = 0; i < n; ++i) {
            psum += old[i];
            cout << psum << ' ';
        }
    } else {
        ll psum = 0;
        for (int i = 0; i < n; ++i) {
            psum += nw[i];
            cout << psum << ' ';
        }
    }
}


#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define REP(i,n) for(long long i(0);(i)<(n);(i)++)

void solve(long long N){
    cout << (N-2)*180 << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}

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

using namespace std;

int main(){
	double n;
	cin >> n;
	cout << n*(180-(360/n)) << endl;
	return 0;
}


#include <iostream>
using namespace std;
#define MOD 1000000007

int main(int argc, const char * argv[]) {
    int N;
    cin>>N;
    int *A=new int[N];
    long long s=0,s2=0;
    for(int i=0;i<N;++i){
        cin>>A[i];
        s+=A[i];
        s%=MOD;
        s2+=(long long)A[i]*A[i];
        s2%=MOD;
    }
    s*=s;
    s%=MOD;
    s-=s2;
    s%=MOD;
    if(s<0){
        s+=MOD;
    }
    if(s%2==0){
        cout<<(s/2)<<endl;
    }else{
        cout<<((s+MOD)/2)<<endl;
    }

    delete[] A;
    return 0;
}

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

const int max_n = 8100;
bool pos_x[max_n][max_n*2];
bool pos_y[max_n][max_n*2];
signed main()
{
    gearup;
    int n; cin >> n;
    vl a(n);
    rep(i,n)cin>>a[i];
    if(a[0] != 0){
        out(-1);
        return 0;
    }

    ll res = 0;
    rep(i,n-1){
        if(a[i+1] > i+1){
            out(-1);
            return 0;
        }
        if(a[i] + 1 == a[i+1])res++;
        else if(a[i] >= a[i+1])res += a[i+1];
        else {
            out(-1);
            return 0;
        }
    }
    out(res);
}


#include <bits/stdc++.h>
#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 repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll N, A, B;
  cin >> N >> A >> B;
  if (N == 1) {
    COUT("Hello World");
  } else {
    COUT(A + B);
  }
  return 0;
}

#include <iostream>
using namespace std;

int main()
{
  int n;
  cin >> n;
  if(n - 1)
  {
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
  }
  else
  {
    cout << "Hello World" << endl;
  }
  return 0;
}


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

int main() {

    int k; cin >> k;
    string s; cin >> s;
    string ans;
    if (s.size() <= k) ans = s;
    else {
        ans = s.substr(0, k);
        ans += "...";
    }
    cout << ans << endl;
    return 0;
}

//abc168

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

int main() {
  int k;
  string s;
  cin >> k >> s;

  if(s.size() <= k){
    cout << s;
  }else{
    cout << s.substr(0,k) << "..." << endl;
  }

}


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

#define ll long long
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

// debug templates
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";

void solve(){
	int minn = inf, maxx = 0;
	FOR(5){
		int x; cin >> x;
		minn = min(minn,x);
		maxx = max(maxx,x);
	}
	int k; cin >> k;
	cout << (maxx - minn > k ? ":(" : "Yay!");
}

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

	solve();
	return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
int a[5],k;
for(int i=0;i<5;i++)
{
cin>>a[i];
}
cin>>k;
sort(a,a+5);
string ans="Yay!";
if(a[4]-a[0]>k)
{
ans=":(";
}
cout<<ans<<endl;
}


#include "bits/stdc++.h"

typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++)
#define REP(i,n) for(int i = 0;i < (n) ; i++)
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
#define N 1010
int MOD = 1000000007;
int fac[N+1];
int inv[N+1];
ll bitpow(ll x,ll n){
    ll ans = 1;
    while(n > 0){
        if(n%2 == 1) ans = ans * x % MOD;
        x = x * x %MOD;
        n = n >> 1;
    }
    return ans;
}
ll COM(ll n,ll k){
    return fac[n]*inv[k]%MOD*inv[n-k]%MOD;
}
int dp[1010][1010] = {0};
signed main(){
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    fac[0] = 1;
    inv[0] = 1;
    for(int i = 1;i <= N;i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = bitpow(fac[i],MOD-2)%MOD;
    }
    dp[a-1][0] = 1;
    for(int i = a;i <= b;i++){
        for(int j = 0;j <= n;j++){
            dp[i][j] = dp[i-1][j];
            for(int k = c;k <= d;k++){
                if(j-i*k < 0 || i*k > n)break;
                dp[i][j] += dp[i-1][j-i*k] * fac[n-(j-i*k)] %MOD * inv[n-(j-i*k) - i*k] %MOD * inv[k]%MOD * bitpow(inv[i],k)%MOD;
                dp[i][j] %= MOD;
                // if(i == 3){
                //     //cerr << "j : dp[i-1][j-i*k] : fac[n-(j-i*k)] : inv[n-i*k] : inv[k] : bitpow(inv[i],k)" << endl;
                //     //cerr << j << " " << dp[i-1][j-i*k] <<  " : " << fac[n-(j-i*k)]<<  " : "<< inv[n-i*k] <<  " : "<<  inv[k] <<  " : "<<  bitpow(inv[i],k);
                //     //cerr << endl;
                //  }
            }
        }
    }
    cout << dp[b][n] << endl;

    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d
// rm -r -f test;oj dl http://arc067.contest.atcoder.jp/tasks/arc067_c

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

template <typename T> inline void read (T &x) {bool b = 0; char c; while (!isdigit (c = getchar()) && c != '-');
if (c == '-') c = getchar(), b = 1; x = c - 48; while (isdigit(c = getchar())) x = (x<<3) + (x<<1) + c - 48; if (b)x=-x;}
template <typename T> inline void wrip(T x) {if (x > 9) wrip(x / 10); putchar(x%10 + 48); }

template <typename T> inline void write(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar(' ');}
template <typename T> inline void writeln(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar('\n');}
inline char readch() {char c; do c = getchar(); while (c == '\n' || c == ' '); return c;}
inline void reads(string &s) {char c; while((c=getchar())==' '||c =='\n'); s=c; while((c=getchar())!=' '&&c!='\n') s+=c;}
inline void getlines(string &s) {char c; while((c=getchar())=='\n'); s=c; while((c=getchar())!='\n') s+=c;}
typedef const int csint;

#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair <int, int> ii;
typedef vector <int> vi;

const ld pi = acos(-1);
const ll inf = 1e9,
mod = 1e9 + 7,
N = 1011;

int n, a, b, c, d;
ll f[N][N], cb[N][N], g[N][N];
ll fac[N], inv[N];
void Inc(ll &a, ll b) {
    a += b;
    if (a >= mod)
        a -= mod;
}
ll pw(ll a, ll b) {
    if (b == 0)
        return 1;
    ll t = pw(a, b / 2);
    t = t * t % mod;
    if (b % 2)
        return t * a % mod;
    return t;
}
int res, dx[111], pa[111];
void Try(int x) {
    if (x > n) {
        int cnt[21], num[21];
        memset(cnt, 0, sizeof(cnt));
        memset(num, 0, sizeof(num));
        for (int i = 1; i <= n; i++)
            cnt[pa[i]]++;
        for (int i = 1; i <= n; i++) {
            if (!cnt[i])
                continue;
            if (cnt[i] < a || cnt[i] > b)
                return;
            num[cnt[i]]++;
        }
        for (int i = 1; i <= n; i++) {
            if (!num[i])
                continue;
            if (num[i] > d || num[i] < c)
                return;
        }
        res++;
        return;
    }
    for (int i = 1; i <= x; i++) {
        if (dx[i])
            continue;
        dx[x] = i != x;
        pa[x] = i;
        Try(x + 1);
        dx[x] = 0;
    }
}
int main() {
    #ifdef makacha
        freopen("m.inp", "r", stdin);
        freopen("m.out", "w", stdout);
    #endif // makacha
    read(n);
    read(a);
    read(b);
    read(c);
    read(d);
//    Try(1);
//    cout << res << '\n';
    cb[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        cb[i][0] = 1;
        for (int j = 1; j <= i; j++)
            cb[i][j] = (cb[i - 1][j] + cb[i - 1][j - 1]) % mod;
    }
    g[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        g[i][0] = 1;
        for (int j = i; j <= n; j += i)
            g[i][j] = (ll) cb[j][j / i] * g[i - 1][j - j / i] % mod;
    }
    fac[0] = 1;
    for (int i = 1; i <= n; i++)
        fac[i] = (ll)fac[i - 1] * i % mod;
    inv[n] = pw(fac[n], mod - 2);
    for (int i = n; i >= 1; i--)
        inv[i - 1] = (ll)inv[i] * i % mod;
    for (int i = 1; i <= n; i++)
        for (int j = i; j <= n; j += i)
            g[i][j] = (ll)g[i][j] * inv[i] % mod;
    f[a - 1][0] = 1;
    for (int i = a; i <= b; i++) {
        int lim = min(d * i, n);
        int im = i - 1;
        for (int j = i * c, grs = c; j <= lim; j += i, grs++)
            for (int k = j, rem = n, kk = k - j; k <= n; k++, rem--, kk++) {
                ll tmp = f[im][kk];
                tmp = tmp * cb[rem][j] % mod;
                tmp = tmp * g[grs][j] % mod;
                Inc(f[i][k], tmp);
            }
        for (int j = 0; j <= n; j++)
            Inc(f[i][j], f[im][j]);
    }
    cout << f[b][n];
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define txt freopen("ip.txt", "r", stdin); freopen("op.txt", "w", stdout)
#define a3 INT_MAX
#define i3 INT_MIN
#define a6 INT64_MAX
#define i6 INT64_MIN
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define div2(a) (!(a&1))
#define deb(x) cout<<(#x)<<" "<<(x)<<"\n";
#define newl cout<<"\n"
#define all(s) s.begin(),s.end()
#define pi 3.14159265358979323846
#define fp(x) fixed<<setprecision(x)<<
template<class T>
T mod(T a){
    if(a < 0){
        a += 1000000007;
    }
    return a%1000000007;
}
template<class T>
T addmod(T a, T b){
    return (mod(a) + mod(b)) % 1000000007;
}
template<class T>
T prodmod(T a, T b){
    return (mod(a) * mod(b)) % 1000000007;
}
template<class T>
T bin_exp(T a, T b)
{
    T res = 1;
    T temp = 1;
    if (b <= 1)
        return a;
    if (b %2 == 0)
        res = bin_exp(a * a, b / 2);
    else
    {
        res *= a;
        temp = bin_exp(a, --b);
    }
    return res * temp;
}
template<class T>
T bin_expmod(T a, T b)
{
    T res = 1;
    T temp = 1;
    if (b <= 1)
        return a;
    if (b %2 == 0)
        res = bin_expmod(prodmod(a,a), b / 2);
    else
    {
        res = prodmod(a,res);
        temp = bin_exp(a, --b);
    }
    return prodmod(res , temp);
}

template<class T>
int digit(T a)
{
    vector<long long> dig = {
        0,
        9,
        99,
        999,
        9999,
        99999,
        999999,
        9999999,
        99999999,
        999999999,
        9999999999,
        99999999999,
        999999999999,
        9999999999999,
        99999999999999,
        999999999999999,
        9999999999999999,
        99999999999999999,
        999999999999999999,
        INT64_MAX};
    auto it = lower_bound(dig.begin(), dig.end(), a);
    int idx = (it - dig.begin());
    return idx;
}
template<class T>
int sumAllInts(T n){
    int a = 1;
    int su = 0;
    while(n){
        su += n%10;
        n/=10;
    }
    return su;
}
template<class T>
void split(char c,T s){
    int n = s.size();
    int i = 0;
    while ((cout<<s[i],i+=1) && (i<n) && (cout<<c<<' '));
}

void solve(){
  long long int N,T;
  cin>>N>>T;
  vector<int> A(N);
  for(unsigned int i=0;i<A.size();i++) cin>>A[i];
  long long int total=T;
  for(unsigned int i=1;i<A.size();i++)
  {
      if(A[i]-A[i-1]>T)
      total+=T;
      else
      {
          total+=(A[i]-A[i-1]);
      }

  }
  cout<<total;
}
int main(){
    quickie;
    //txt;
    int t=1;
    while(t--){
        solve();
        newl;
    }
    return 0;
}

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

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

#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);

int main() {
    ll h, w; cin >> h >> w;
    vector<vector<bool>> b(h+2, vector<bool>(w+2, true)); // trueで黒
    queue<P> que;
    vector<vector<ll>> dist(h+2, vector<ll>(w+2, 0));
    rep(i, h) {
        string s; cin >> s;
        rep(j, w) {
            if(s[j] == '.') {
                b[i+1][j+1] = false;
            }
            else {
                que.push(make_pair(i+1, j+1));
            }
        }
    }
    while(!que.empty()) {
        P t = que.front(); que.pop();
        ll x = t.first, y = t.second;
        if(!b[x-1][y]) {
            dist[x-1][y] = dist[x][y]+1;
            b[x-1][y] = true;
            que.push(make_pair(x-1, y));
        }
        if(!b[x+1][y]) {
            dist[x+1][y] = dist[x][y]+1;
            b[x+1][y] = true;
            que.push(make_pair(x+1, y));
        }
        if(!b[x][y-1]) {
            dist[x][y-1] = dist[x][y]+1;
            b[x][y-1] = true;
            que.push(make_pair(x, y-1));
        }
        if(!b[x][y+1]) {
            dist[x][y+1] = dist[x][y]+1;
            b[x][y+1] = true;
            que.push(make_pair(x, y+1));
        }
    }

    ll ans = 0;
    rep(i, h) {
        rep(j, w) {
            if(ans < dist[i+1][j+1]) {
                ans = dist[i+1][j+1];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) {
    if(n == 0) return 1;

    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


// 2020-07-04 23:45:06
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

int dp[105][55][55], v[55];
int rec(int k, int l, int r) {
  if(dp[k][l][r] >= 0) return dp[k][l][r];
  chmax(dp[k][l][r], 0);
  if(k == 0) return dp[k][l][r];
  if(l == r) return dp[k][l][r];
  chmax(dp[k][l][r], rec(k-1, l+1, r) + v[l]);
  chmax(dp[k][l][r], rec(k-1, l, r-1) + v[r-1]);
  if(k >= 2) {
    if(v[l] < 0) chmax(dp[k][l][r], rec(k-2, l+1, r));
    if(v[r-1] < 0) chmax(dp[k][l][r], rec(k-2, l, r-1));
  }
  return dp[k][l][r];
}
void answer() {
  int n, k;
  cin >> n >> k;
  repc(ki, k) repc(li, n) repc(ri, n) dp[ki][li][ri] = -1;
  rep(i, n) cin >> v[i];
  cout << max(0, rec(k, 0, n)) << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

#include <bits/stdc++.h>

#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

vector<vector<ll>> g(100010);
vector<ll> dist(100010);

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

    vector<ll> v(n);
    rep(i, n)cin >> v[i];

    ll ans = 0;
    rep(i, min(n, k) + 1)rep(j, min(n, k) + 1 - i){
        vector<ll> tmp = v;
        tmp.erase(tmp.begin()+i, tmp.end()-j);

        sort(ALL(tmp));

        rep(l, k - (i+j) && !tmp.empty()){
            if(tmp.front() < 0)tmp.erase(tmp.begin());
        }

        ll res = 0;
        rep(l, tmp.size())res += tmp[l];

        ans = max(ans, res);
    }

    cout << ans << endl;
}


#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion

int main()
{
	int l, r; cin >> l >> r;
	if (r - l + 1 >= 2019 || l == 0)cout << 0 << endl;
	else
	{
		int res = 1e7;
		for (int i = l; i < r; ++i)
		{
			for (int j = i + 1; j <= r; ++j)
			{
				chmin(res, ((i % 2019)*(j % 2019)) % 2019);
			}
		}
		cout << res << endl;
	}
}

#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{

    ll l, r;
    cin >> l >> r;

    ll mi = 2019;
    for (ll i = l; i < l + 2019; i++) {
        for (ll j = i + 1; j <= min(r, i + 2020); j++) {
            mi = min(mi, ((i % 2019) * (j % 2019)) % 2019);
        }
    }

    put(mi)

    return 0;
}


#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef vector <int> vi;

int main(void){
	map <char, int> m;
	vi x;
	int num[] = {1,5,10,50,100,500,1000};
	for (int i=0; i<7; i++)
		m["IVXLCDM"[i]] = num[i];

	while (true){
		string roman;
		cin>>roman;
		if (cin.eof()) break;

		int tmp, tmp2= m[roman[0]];
		for (int i=0; i<(int)roman.size(); i++){
			tmp = m[roman[i]];
			if (i!=0 && tmp2<tmp)
				x[i-1] = -tmp2;
			x.push_back(tmp);
			tmp2 = tmp;
		}

		int s=0;
		for (int i=0; i<(int)x.size(); i++)
			s += x[i];
		cout<<s<<endl;
		x.clear();
	}
}

#include<iostream>
#include<string>
using namespace std;
int main(){
long i,l,m,n,y;
string s;
while(cin>>s){
l=s.size();
y=0;m=1001;
for(i=0;i<l;i++){
if(s[i]=='I')n=1;
else if(s[i]=='V')n=5;
else if(s[i]=='X')n=10;
else if(s[i]=='L')n=50;
else if(s[i]=='C')n=100;
else if(s[i]=='D')n=500;
else if(s[i]=='M')n=1000;
if(m<n)y-=m*2;
y+=n;
m=n;
}
cout<<y<<endl;
}
return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define TTF template<typename T, typename F>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline void Out(T&x){cout<<x;}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline int ubnd(T&v,ET(T)&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T)&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF inline void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF inline void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
#undef TT
#undef TTF
#undef ET

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}

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

struct Edge {
  int f, t, c;
  Edge(int f, int t, int c) : f(f), t(t), c(c) {}
  bool operator<(const Edge& e) const { return c != e.c ? c > e.c : (f != e.f ? f < e.f : t < e.t); }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int dijkstra(const Graph& g, int s, int t){
  int vis[128];
  fill(begin(vis), end(vis), 0);
  priority_queue<Edge> pq;
  for (pq.push(Edge(-2, s, 0)); !pq.empty(); pq.pop()){
    Edge e = pq.top();
    if (vis[e.t]++) continue;
    if (e.t == t) return e.c;
    for (const auto& ee : g[e.t]){
      pq.push(Edge(e.f, ee.t, e.c + ee.c));
    }
  }
  return -1;
}

int main()
{
  int n, k;
  while (cin >> n >> k, n || k){
  Graph g(n + 1);
  for (int i = 0; i < k; i++){
    int t = in();
    if (t){
      int a, b, c;
      cin >> a >> b >> c;
      g[a].push_back(Edge(a, b, c));
      g[b].push_back(Edge(b, a, c));
    }
    else {
      int a, b;
      cin >> a >> b;
      cout << dijkstra(g, a, b) << endl;
    }
  }
  }
  return (0);
}

// priority_queue queue deque front stringstream max_element min_element insert count make_tuple

#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
const int INF = 1e9;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;

int cost[100][100];
int main()
{
	int N, M;
	while (cin>>N>>M, N) {
		rep(i, N) rep(j, N) cost[i][j] = (i==j?0:INF);

		rep(i, M) {
			int q; cin>>q;
			if (q==0) {
				int a, b;
				cin>>a>>b; a--, b--;

				cout << (cost[a][b] < INF ? cost[a][b] : -1) << endl;
			} else {
				int a, b, c;
				cin>>a>>b>>c; a--, b--;

				for (int i=0; i<N; i++) {
					for (int j=0; j<N; j++) {
						cost[i][j] = min({cost[i][j], cost[i][a] + cost[j][b] + c, cost[i][b]+ cost[j][a] + c});
					}
				}
			}
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
int partition(int* A,int p,int r){
  int x=A[r];
  int i=p-1;
  for(int j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i+1;
}
signed main(){
  int n;
  cin>>n;
  int A[n];
  for(int i=0;i<n;i++) cin>>A[i];
  int k=partition(A,0,n-1);
  for(int i=0;i<n;i++){
    if(i) cout<<" ";
    if(i==k) cout<<"[";
    cout<<A[i];
    if(i==k) cout<<"]";
  }
  cout<<endl;
  return 0;
}

#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

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

const int mod = INF+7;
int main(){
    int n;cin>>n;
    string a,b,c;cin>>a>>b>>c;
    int res = 0;
    rep(i,n){
        int cnt = 1;
        if(a[i]==b[i])cnt++;
        if(b[i]==c[i])cnt++;
        if(c[i]==a[i])cnt++;
        if(cnt>3)cnt--;
        res += 3-cnt;
    }
    cout<<res<<endl;
}


#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define BITF(n, i) (((n) >> i) & 1)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z) cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair<int, int>
#define ld long double
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T> void print2(const T &x, const T &y) { cout << x << " " << y << "\n"; }
template <class T> void print3(const T &x, const T &y, const T &z) { cout << x << " " << y << " " << z << "\n"; }
const int MOD = 998244353, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int binpow(int a, int b, int mo) {
  int ans = 1;
  do {
    if (b & 1) ans = 1ll * ans * a % mo;
    a = 1ll * a * a % mo;
  } while (b >>= 1);
  return ans;
}
const int FACTSIZE = 100100;
int fact[FACTSIZE];
int revfact[FACTSIZE];

int ncr(int n, int r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  int rs = fact[n] * revfact[r];
  if (rs >= MOD) rs %= MOD;
  rs *= revfact[n - r];
  if (rs >= MOD) rs %= MOD;
  return rs;
}
void init() {
  fact[0] = 1, revfact[0] = 1;
  for (int i = 1; i < FACTSIZE; ++i) {
    fact[i] = fact[i - 1] * i % MOD;
    revfact[i] = binpow(fact[i], MOD - 2, MOD);
  }
}
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  init();
  int K, N;
  cin >> K >> N;
  vec<int> res(2 * K - 1, -1);
  FORS(i, 2, K + 1) {
    int ans = 0;
    if (i % 2 == 1) {
      int even = (i - 1) / 2;
      FORS(j, 0, even) {
        int val = N - j * 2;
        int tmp = ncr(even, j) * ncr(val + (K - 1), val);
        ans += j % 2 == 0 ? tmp : -tmp;
        ans %= MOD;
      }
      // DEBUG2(i, ans);
    } else {
      int even = i / 2 - 1;
      FORS(j, 0, even) {
        int val = N - 1 - j * 2;
        // DEBUG2(val, K - 2);
        int tmp = ncr(even, j) * ncr(val + (K - 2), val);
        ans += j % 2 == 0 ? tmp : -tmp;
        ans %= MOD;
      }
      FORS(j, 0, even) {
        int val = N - j * 2;
        int tmp = ncr(even, j) * ncr(val + (K - 2), val);
        ans += j % 2 == 0 ? tmp : -tmp;
        ans %= MOD;
      }
      //      int even = i / 2;
    }
    ans %= MOD;
    ans += MOD;
    ans %= MOD;
    res[i - 2] = ans;
    res[(2 * K - 2) - (i - 2)] = ans;
  }
  REP(i, 2 * K - 1) print(res[i]);
}

#include <bits/stdc++.h>

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

int n, m, v, p, a[100005];
long long pre[100005];

int main() {
	read(n), read(m), read(v), read(p);
	for (int i = 1; i <= n; ++i) {
		read(a[i]);
	}
	std::sort(a + 1, a + 1 + n, std::greater<int>());
	long long sum = a[p];
	int ans = p;
	for (int i = p + 1; i <= n; ++i) {
		if (a[i] + m >= a[p] && 1ll * (a[i] + m) * (i - p) - sum >= 1ll * m * (v - n + i - p)) {
			++ans;
		}
		sum += a[i];
	}
	print(ans);
}


#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

/*
正面衝突の場合 U-D, L-R
斜め衝突の場合 U-L, L-D, D-R, R-U

*/

int x_in[200050], y_in[200050];
char c_in[200050];
vector<pair<int, char>> ur[400020];
vector<pair<int, char>> ud[400020];

int n;

int solve_UD(){
    rep(i, 400020){
        ud[i].clear();
    }
    rep(i, n){
        if (c_in[i] != 'U' && c_in[i] != 'D') continue;
        ud[x_in[i]].push_back(make_pair(y_in[i], c_in[i]));
    }
    int tmin = 2000001;
    rep(i, 400020){
        sort(ud[i].begin(), ud[i].end());
        rep(j, ud[i].size()-1){
            if (ud[i][j].second == 'U' && ud[i][j+1].second == 'D'){
                tmin = min(tmin, ud[i][j+1].first - ud[i][j].first);
            }
        }
    }
    return tmin * 5;
}

int solve_UR(){
    rep(i, 400020){
        ur[i].clear();
    }
    rep(i, n){
        if (c_in[i] != 'U' && c_in[i] != 'R') continue;
        ur[x_in[i]+y_in[i]].push_back(make_pair(x_in[i], c_in[i]));
    }
    int tmin = 2000001;
    rep(i, 400020){
        sort(ur[i].begin(), ur[i].end());
        rep(j, ur[i].size()-1){
            if (ur[i][j+1].second == 'U' && ur[i][j].second == 'R')
            tmin = min(tmin, ur[i][j+1].first - ur[i][j].first);
        }
    }
    return tmin*10;
}

void rotate(){
    int tmp;
    rep(i, n){
        tmp = x_in[i];
        x_in[i] = 200000-y_in[i];
        y_in[i] = tmp;
        if (c_in[i] == 'U') c_in[i] = 'L';
        else if (c_in[i] == 'L') c_in[i] = 'D';
        else if (c_in[i] == 'D') c_in[i] = 'R';
        else c_in[i] = 'U';
    }

}

int main()
{
    cin >> n;
    rep(i, n){
        cin >> x_in[i] >> y_in[i] >> c_in[i];
    }

    int t_time = 2000001;
    rep(t, 4){
        t_time = min(t_time, solve_UD());
        t_time = min(t_time, solve_UR());
        rotate();
    }

    if (t_time == 2000001) cout << "SAFE" << endl;
    else cout << t_time << endl;

}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

lli ans = INF;
const lli ssize = 400100;

void calc(vector<set<lli>> &lef,vector<set<lli>> &rig){
    REP(i,0,ssize){
        if(rig.size()==0)continue;
        for(auto e:lef[i]){
            auto itr = rig[i].upper_bound(e);
            if(itr==rig[i].end())break;
            LOG3(ans,(*itr),e);
            chmin(ans,(*itr)-e);
        }
    }
}

void func(long long N, std::vector<long long> X, std::vector<long long> Y, std::vector<std::string> U){

    {
    //LR combination
        vector<set<lli>> lef(ssize),rig(ssize);
        REP(i,0,N){
            if(U[i]=="R")lef[Y[i]].insert(X[i]);
            else if(U[i]=="L")rig[Y[i]].insert(X[i]);
        }
        calc(lef,rig);
    }

    {
    //UD combination
        vector<set<lli>> lef(ssize),rig(ssize);
        REP(i,0,N){
            if(U[i]=="U")lef[X[i]].insert(Y[i]);
            else if(U[i]=="D")rig[X[i]].insert(Y[i]);
        }
        calc(lef,rig);
    }

    {
        //y=x+b
        {
        //LU combination
            vector<set<lli>> lef(ssize),rig(ssize);
            REP(i,0,N){
                if(U[i]=="U")lef[X[i]-Y[i]+ssize/2].insert(X[i]*2);
                else if(U[i]=="L")rig[X[i]-Y[i]+ssize/2].insert(X[i]*2);
            }
            calc(lef,rig);
        }

        {
        //RD combination
            vector<set<lli>> lef(ssize),rig(ssize);
            REP(i,0,N){
                if(U[i]=="R")lef[X[i]-Y[i]+ssize/2].insert(X[i]*2);
                else if(U[i]=="D")rig[X[i]-Y[i]+ssize/2].insert(X[i]*2);
            }
            calc(lef,rig);
        }
    }

    {
        //y=-x+b
        {
        //LD combination
            vector<set<lli>> lef(ssize),rig(ssize);
            REP(i,0,N){
                if(U[i]=="D")lef[X[i]+Y[i]].insert(X[i]*2);
                else if(U[i]=="L")rig[X[i]+Y[i]].insert(X[i]*2);
            }
            calc(lef,rig);
        }

        {
        //RU combination
            vector<set<lli>> lef(ssize),rig(ssize);
            REP(i,0,N){
                if(U[i]=="R")lef[X[i]+Y[i]].insert(X[i]*2);
                else if(U[i]=="U")rig[X[i]+Y[i]].insert(X[i]*2);
            }
            calc(lef,rig);
        }
    }

    if(ans==INF){
        cout<<"SAFE"<<endl;
    }
    else{
        cout<<ans*5<<endl;
    }

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    std::vector<long long> Y(N);
    std::vector<std::string> U(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&Y[i]);
        std::cin >> U[i];
    }
    func(N, std::move(X), std::move(Y), std::move(U));
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define fi first
#define se second
typedef pair<int, int> ii;

const int N = 5e3 + 5;
int n, sum;
vector< pair<int, ii> > vec;
priority_queue<int> pq;

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        int h, p; cin >> h >> p;
        vec.pb( { h + p, { h, p } } );
    }
    sort(vec.begin(), vec.end() );
    for (auto i : vec) {
        if(sum <= i.se.fi) {
            pq.push(i.se.se);
            sum += i.se.se;
        }
        else {
            if(i.se.se < pq.top() ) {
                sum -= pq.top(); pq.pop();
                sum += i.se.se; pq.push(i.se.se);
            }
        }
    }

    cout << pq.size();

    return 0;
}


#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<algorithm>
#include<stdio.h>
using namespace std;
int n, m;
struct Node {
	//int id;
	list<int> next;
};
Node graph[100005];
int prenum[100005];
int parent[100005];
int lowest[100005];
set<int> answer;
int rootCount;
void dfs(int curNodeId,int step) {
	int low = prenum[curNodeId];
	list<int>::iterator it = graph[curNodeId].next.begin();
	list<int>::iterator end = graph[curNodeId].next.end();
	for (it; it != end; it++) {
		int id = *it;
		if (prenum[id] == 0) {
			parent[id] = curNodeId;
			prenum[id] = step + 1;
			dfs(id, step + 1);
			low = min(low, lowest[id]);
			if (step == 1) {
				rootCount++;
			}
		}
		else {
			low = min(low, prenum[id]);
		}
	}
	lowest[curNodeId] = low;
}
void findArticulationPoint() {
	if (rootCount >= 2) {
		answer.insert(0);
	}
	int p;
	for (int i = 1; i < n; i++) {
		p = parent[i];
		if (p == 0) {
			continue;
		}
		if (prenum[p] <= lowest[i]) {
			answer.insert(p);
		}
	}
	vector<int> ans;
	for (set<int>::iterator it = answer.begin(); it != answer.end(); it++) {
		ans.push_back(*it);
	}

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

	for (vector<int>::iterator it = ans.begin(); it != ans.end(); it++) {
		printf("%d\n", *it);
	}
}
int main() {
	scanf("%d %d", &n,&m);
	int a, b;
	for (int i = 0; i < m; i++) {
		scanf("%d %d", &a,&b);
		graph[a].next.push_back(b);
		graph[b].next.push_back(a);
	}

	prenum[0] = 1;
	dfs(0,1);

	findArticulationPoint();

	/*for (int i = 0; i < n; i++) {
		cout << i << " " << prenum[i] << " " << parent[i] << " " << lowest[i] << endl;
	}*/
}

#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

struct node {int to,cost; };

typedef vector< vector<node> > G;

inline void add_edge(G& g,int from,int to,int cost=1){
	node in; in.to=to; in.cost=cost;
	g[from].pb(in);
}

inline void add_both_edge(G& g,int from,int to,int cost=1){
	add_edge(g,from,to,cost);
	add_edge(g,to,from,cost);
}

void dfs(const G& g,int cur,int prev,int &k,vi& order, vi& low,vi& parent) {
	order[cur]=k++;
	low[cur]=order[cur];

	rep(i,g[cur].size()){
		int to=g[cur][i].to;
		if(order[to]==-1){
			parent[to]=cur;
			dfs(g,to,cur,k,order,low,parent);
			low[cur]=min(low[cur],low[to]);
		}else if(to!=prev)
			low[cur]=min(low[cur],order[to]);
	}
	return;
}

void Lowlink(const G& g, vi& order,vi& low,vi& parent) {
	int v=g.size();
	order.assign(v,-1);
	low.resize(v);
	parent.resize(v);
	int k=0;
	parent[0]=-1;
	dfs(g,0,-1,k,order,low,parent);
	return ;
}

int main(void){
	int n,m;
	cin >> n >> m;
	G graph(n);
	rep(i,m){
		int a,b;
		cin >> a >> b;
		add_both_edge(graph,a,b);
	}
	vi order,low,parent;
	Lowlink(graph,order,low,parent);

	rep(i,n){
		if(i){
			bool ok=false;
			rep(j,graph[i].size()){
				int to=graph[i][j].to;
				if(i==parent[to]&&order[i]<=low[to])
					ok=true;
			}
			if(ok) cout << i << endl;
		}else{
			int d=0;
			rep(j,n) if(parent[j]==0) d++;
			if(d>=2) cout << i << endl;
		}
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long D[201][100001], MOD=1000000007;

int main()
{
    int n, x, a;
    cin >> n >> x;
    vector <int> A;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(),A.end());
    for (int i = 0; i <= x; i++)
    {
        for (int y = 1; y <= n; y++)
        {
            D[y][i] = 0;
        }
        D[0][i] = i;
    }
    for (int i = 0; i < n; i++)
    {
        for (int y = 0; y <= x; y++)
        {
            D[i+1][y] += D[i][y] * i;
            D[i+1][y] %= MOD;
            D[i+1][y] += D[i][y % A[i]];
            D[i+1][y] %= MOD;
        }
    }
    cout << D[n][x];
    return 0;
}


    #include<iostream>
    #include<cstdio>
    #include<vector>
    #include<cmath>
    #include<cstring>
    #include<fstream>
    #include<algorithm>
    using namespace std;
    typedef long long LL;
    const int INF=0x3f3f3f3f;
    const int MAXN=1e5+5;
    int tot,head[MAXN];
    LL dist[MAXN];
    bool vis[MAXN];

    struct Edge
    {
        int from,to,nxt;
        LL cost;
    }e[MAXN*2];

    void addedge(int u,int v,int w)
    {
        e[tot].from=u;
        e[tot].to=v;
        e[tot].cost=w;
        e[tot].nxt=head[u];
        head[u]=tot++;
    }

    void dfs(int u,int fa)
    {
        for(int i=head[u];i!=-1;i=e[i].nxt)
        {
            int to=e[i].to;
            if(to==fa) continue;
            dist[to]=dist[u]+e[i].cost;
            dfs(to,u);
        }
    }

    int main()
    {
        int n;
        while(scanf("%d",&n)!=EOF)
        {
            tot=0;
            memset(head,-1,sizeof(head));
            memset(dist,0,sizeof(dist));
            int u,v;
            LL w;
            for(int i=1;i<=n-1;i++)
            {
                scanf("%d%d%lld",&u,&v,&w);
                addedge(u,v,w);
                addedge(v,u,w);
            }
            int q,k;
            scanf("%d%d",&q,&k);
            dfs(k,-1);
    //        for(int i=1;i<=n;i++)
    //            cout<<dist[i]<<" ";
    //        cout<<endl;
            int x,y;
            for(int i=1;i<=q;i++)
            {
                scanf("%d%d",&x,&y);
                printf("%lld\n",dist[x]+dist[y]);
            }
        }
        return 0;
    }

#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define SIZE 100005

struct Edge{
	Edge(int arg_to,ll arg_dist){
		to = arg_to;
		dist = arg_dist;
	}
	int to;
	ll dist;
};

vector<Edge> G[SIZE]; //グラフの隣接リスト表現
int N; //ノードの個数
int root; //根ノードの番号
int MAX_LOG_V = 17;
int POW[18];

int parent[18][SIZE];
int depth[SIZE];
ll DIST[SIZE];

//parentとdepthを再帰的に設定
void dfs(int node_id,int parent_id,int d){
	parent[0][node_id] = parent_id;
	depth[node_id] = d;
	for(int i = 0; i < G[node_id].size(); i++){
		if(G[node_id][i].to != parent_id){
			DIST[G[node_id][i].to] = DIST[node_id]+G[node_id][i].dist;
			dfs(G[node_id][i].to,node_id,d+1);
		}
	}
}

//初期化
void init(){
	//parent[0]とdepthを初期化する
	dfs(root,-1,0);
	//parentを初期化する
	for(int k = 0; k + 1 < MAX_LOG_V; k++){
		for(int node_id = 0; node_id < N; node_id++){
			if(parent[k][node_id] < 0)parent[k+1][node_id] = -1; //node_idの2^k上のノードがルートノードより上なら、2^(k+1)上も同様とする
			else{
				parent[k+1][node_id] = parent[k][parent[k][node_id]];
			}
		}
	}
}

//leftとrightのLCAを求める
int lca(int left,int right){
	//leftとrightの深さが同じになるまで親を辿る
	if(depth[left] > depth[right])swap(left,right); //rightの方が深い所にいる

	for(int k = MAX_LOG_V-1; k >= 0; k--){
		if(depth[right]-depth[left] >= POW[k]){ //たとえば深さの差が39なら、32+4+2+1のように、ノードを上方に移動させる
			right = parent[k][right];
		}
	}

	if(left == right)return left;

	for(int k = MAX_LOG_V-1; k >= 0; k--){
		if(parent[k][left] == parent[k][right]){
			//Do nothing
		}else{
			left = parent[k][left];
			right = parent[k][right];
		}
	}
	return parent[0][left]; //最後は、leftの親とrightの親が必ず一致している
}

ll calc_dist(int a,int b){

	return DIST[a]+DIST[b]-2*DIST[lca(a,b)];
}

int main(){

	POW[0] = 1;
	for(int i = 1; i <= 17; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%d",&N);

	int from,to;
	ll dist;

	for(int i = 0; i < N-1; i++){
		scanf("%d %d %lld",&from,&to,&dist);
		from--;
		to--;
		G[from].push_back(Edge(to,dist));
		G[to].push_back(Edge(from,dist));
	}

	root = 0;
	DIST[root] = 0;
	init();

	int num_query,K;
	int x,y;

	scanf("%d %d",&num_query,&K);
	K--;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d %d",&x,&y);
		x--,y--;
		printf("%lld\n",calc_dist(x,K)+calc_dist(K,y));
	}

	return 0;
}


/**
 *    author:  otera
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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 n, m;
vector<vector<int>> a;

void solve() {
	cin >> n >> m;
    a.assign(n, vector<int>(m));
    rep(i, n) {
        rep(j, m) {
            cin >> a[i][j];
            -- a[i][j];
        }
    }
    vector<int> used(n, 0), check(m, 1);
    int ans = n;
    int cnt = 0;
    while(true) {
        map<int, int> mp;
        rep(i, n) {
            while(used[i] < m && !check[a[i][used[i]]]) {
                used[i] ++;
            }
            mp[a[i][used[i]]] ++;
        }
        set<int> se; int ma = 0;
        for(auto p: mp) {
            if(ma == p.sc) {
                se.insert(p.fr);
            } else if(ma < p.sc) {
                se.clear();
                ma = p.sc;
                se.insert(p.fr);
            }
        }
        chmin(ans, ma);
        for(auto j: se) {
            check[j] = 0;
            ++ cnt;
        }
        if(cnt == m) break;
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
	int a[5000];
	int left[5000], right[5000];
	int n;

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

		bool existsPos = false;
		for (int i=0; i<n; i++) {
			cin >> a[i];
			if (a[i] > 0) existsPos = true;
		}

		int maximum;

		if (existsPos) {
			int left_max = a[0];
			int left_max_pos = 0;
			left[0] = a[0];
			for (int i=1; i<n; i++) {
				left[i] = left[i-1] + a[i];
				if (left[i] > left_max) {
					left_max = left[i]; left_max_pos = i;
				}
			}
			int right_max = a[n-1];
			int right_max_pos = n-1;
			right[n-1] = a[n-1];
			for (int i=n-2; i>=0; i--) {
				right[i] = right[i+1] + a[i];
				if (right[i] > right_max) {
					right_max = right[i]; right_max_pos = i;
				}
			}

			maximum = 0;
			for (int i = right_max_pos; i <= left_max_pos; i++) maximum += a[i];
		}
		else {
			maximum = -100000;
			for (int i=0; i<n; i++) {
				if (a[i] > maximum) maximum = a[i];
			}
		}

		cout << maximum << endl;
	}

	return 0;
}

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<map>

using namespace std;

int main(){
	int sum;
	string st;
	map <char,int> code;
	code['I']=1;
	code['V']=5;
	code['X']=10;
	code['L']=50;
	code['C']=100;
	code['D']=500;
	code['M']=1000;

	while(cin>>st){
		sum=0;
		for(int i=0;i<st.size()-1;i++){
			if(code[st[i]]<code[st[i+1]])
			sum-=code[st[i]];
			else
			sum+=code[st[i]];
		}
		printf("%d\n",sum+code[st[st.size()-1]]);
	}
}


#include<bits/stdc++.h>

using namespace std;
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF 2000000000
#define int long long
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
int a[100000];

int partition(int p,int r){
	int x=a[r];
	int i=p-1;
	lps(j,p,r){
		if(a[j]<=x){
			i++;
			swap(a[i],a[j]);
		}
	}
	swap(a[i+1],a[r]);
return i+1;
}

signed main(){
	int n;
	cin>>n;
	lp(i,n) cin>>a[i];
	int p=partition(0,n-1);
	lp(i,n){
		if(i) cout<<" ";
		if(i==p) cout<<"["<<a[i]<<"]";
		else cout<<a[i];
	}
	cout<<endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int h1=read(),m1=read(),h2=read(),m2=read(),k=read();
	cout<<(h2-h1)*60+m2-m1-k<<endl;
}


#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int n, k;
  cin >> n >> k;
  // n = 200000;
  // k = 100000;
  if (n <= k + 1)
  {
    for(int i = 0; i < n; ++i) cout << n << " ";
    return;
  }

  vector<int> a(n + 1, 0);
  for(int i = 0; i < n; ++i)
  {
    // a[i] = 1;
    cin >> a[i];
  }

  for(int i = 0; i < k; ++i)
  {
    vector<int> next_a(n + 1, 0);
    for(int j = 0; j < n; ++j)
    {
      next_a[ max(0, j - a[j]) ]++;
      next_a[ min(n, j + a[j] + 1) ]--;
      // cout << "add " << max(0, j - a[j]) << ", " << min(n, j + a[j] + 1) << endl;
    }
    int max_cd_num = 0;
    for(int j = 0; j < n; ++j)
    {
      next_a[j + 1] += next_a[j];
      max_cd_num += (next_a[j] == n);
    }
    a = next_a;
    if (max_cd_num >= n) break;
  }

  for(int i = 0; i < n; ++i) cout << a[i] << " ";

}

int main()
{
  fastio;
  solve();

  return 0;
}


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

bool p[101000];

void prime() {
  fill(p, p+101000, true);
  p[0] = false;
  p[1] = false;
  for(int i = 2; i < 101000; i++) {
    if(p[i]) {
      for(int j = 2; i*j < 101000; j++) {
	p[i*j] = false;
      }
    }
  }
}

int main() {
  int n;
  prime();
  while(cin >> n, n) {
    int ans;
    for(int i = 0; i <= n; i++) {
      if(p[i] && p[i-2]) ans = i;
    }
    cout << ans-2 << ' ' << ans << endl;
  }
}

#include<stdio.h>
int isprime(int n){
  for(int i = 2; i * i <= n; i++){
    if(n % i == 0)return 0;
  }
  return 1;
}
int main(){
  int v;
  while(scanf("%d", &v) != EOF) {
    if(v == 0){
      break;
    }
    while(1){
      if(isprime(v) == 1 && isprime(v - 2) == 1){
        printf("%d %d\n", v - 2, v);
        break;
      }else{
        v--;
      }
    }
  }
  return 0;
}


#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

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

	vector<bool> seen(1'000'000'000);
	bool ans = true;
	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;
		if (seen[a])
			ans = false;
		seen[a] = true;
	}
	cout << (ans ? "YES" : "NO") << endl;
}

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

int main()
{
    int a,b,ans=0,cnt=0;
    string s;
    cin>>a>>b;
    cin>>s;
    for(int i=0; i<a; i++)
    {
        if(s[i]-'0'<0||s[i]-'0'>9)
        {
            cout<<"No";
                return 0;
        }
    }
    if(s[a]!='-')
    {
        cout<<"No";
            return 0;
    }
    for(int i= a+1 ; i <a+b+1 ; i++)
    {
        if(s[i]-'0'<0||s[i]-'0'>9)
        {
            cout<<"No";
                return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


//Now you are making me a boy with luvv...
//I don't want to do this but I'm being forced to ....pls help!!
#include <bits/stdc++.h>
using namespace std;
#define loop(x,n) for(int x = 0; x < n; ++x)
#define ed end()
#define bg begin()
# define ld long double
#define ll long long
#define ub(v,a) upper_bound(all(v),a)
#define lb(v,a) lower_bound(all(v),a)
#define sz(a) (int)(a.size())
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define tr(v,it) for(auto it=v.begin();it!=v.end();it++)
#define present(v,x) (v.find(x)!=v.end()) //set/map etc.
#define vpresent(v,x) (find(all(v),x)!=v.end()) // vector
typedef vector< int > vi;
typedef vector< long long > vll;
typedef vector<pair<ll,ll>> vp;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
const long long max_sz = 1e5 + 1;
const long long mod = 1e9 + 7;
const long long MAXN = 4e18 + 1;
char flip(char k){ if(k=='0') return '1'; return '0'; }
ll sum_digit(ll n){ ll a=0,i; for(i=n;i>0;i=i/10){ a+=(i%10);} return a; }
ll gcd(ll a, ll b){
	if(b == 0) return a;
	return gcd(b, a%b);
}
int main(){
                   // ios_base::sync_with_stdio(false);
                    //cin.tie(NULL);
                    //cout.tie(NULL);

                     ll t;
                    // cin >> t;
                     t=1;
                     while (t--){
                             ll h1,m1,h2,m2,k;cin>>h1>>m1>>h2>>m2>>k;
                             if(m2>m1){
                                 ll diff=(h2-h1)*60 + m2-m1;
                                 cout<<diff-k<<endl;
                             }
                             else{
                                 ll diff=(h2-h1)*60 +m2-m1;
                                 cout<<diff -k<<endl;
                             }
                     }
                    cerr << endl
                                  << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
                      return 0;
}


#include <stdio.h>
int main(){
	int X,Y,Z;
	int *px,*py,*pz;
	scanf("%d",&X);
	scanf("%d",&Y);
	scanf("%d",&Z);
	px = &Z;
	py = &X;
	pz = &Y;
	printf("%d %d %d",*px,*py,*pz);
}

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

int main(){
  int x,y,z;
  cin>>x>>y>>z;
  int temp = x;
  x = y;
  y = temp;
  int temp2 = x;
  x = z;
  z = temp2;
  cout<<x<<" "<<y<<" "<<z;
  return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main(){
int a,b,c,i,d;
cin>>a>>b>>c;
i=c;
d=b;
while(a>b){
	b=b+d;
    c=c+i;
    }
	cout<<c;
}

#include <bits/stdc++.h>

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

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

using ll = long long;

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

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n + x - 1) / x * t << endl;

    return 0;
}