import std.bigint,std.container,std.array,std.algorithm,std.conv,std.bitmanip,std.functional,std.math,std.numeric,std.string,std.range,std.uni,std.complex,
std.typecons,std.regex,std.complex,std.random;
import core.stdc.stdio:freopen;
import std.stdio;
//import core.stdc.stdio;
alias RedBlackTree set;
alias redBlackTree rbt;
alias BigInt big;
alias pair!(int,int) pii;
alias pair!(long,long) pll;
alias BoyerMooreFinder strfind;
immutable int mod=1000000007;
pure nothrow X binpow(X,Y)(X base,Y exp)
if(!is(Y==float) && !is(Y==real) && !is(Y==double))
{
	if(exp<0)return X(0);
	X res=X(1);
	while(exp>0)
	{
		if(exp&1)res*=base;
		base*=base;
		exp>>=1;
	}
	return res;
}
pure nothrow auto binpow(X,Y,Z)(X base,Y exp,in Z mm)
if(!is(Y==float) && !is(Y==real) && !is(Y==double))
{
	if(mm==0) return binpow(base,exp);
	if(exp<0)return X(0);
	auto res=X(1)%mm;
	while(exp>0)
	{
		if(exp&1)res=(res*base)%mm;
		base*=base;
		base%=mm;
		exp>>=1;
	}
	return res;
}
@property void putarr(X)(X a,in char ch=' '){foreach(const ref i;a)write(i,ch);}
void putarr(X)(X a,in int n,in int m)
{
	foreach(i;0..n)
	{
		foreach(j;0..m)write(a[i][j],' ');
		writeln;
	}
}
void getarr(X)(X a,in int n){foreach(ref i;a[0..n])input(&i);}
bool input(T...)(T ptrs) if (ptrs.length > 0) {return readf(replicate(" %s", ptrs.length), ptrs)==ptrs.length;}
struct pair(X,Y)
{
	X fi;
	Y se;
	this(X a_,Y b_){
		fi=a_;
		se=b_;
		}
	this(this){fi=fi;se=se;}
	int opCmp(ref const pair!(X,Y) s_) const pure nothrow
	{
		int cmp=0-(fi<s_.fi)+(fi>s_.fi);
		if(cmp!=0)return cmp;
		else return (0-(se<s_.se)+(se>s_.se));
	}
};
pair!(X,Y) mp(X,Y)(X x_,Y y_) pure nothrow
{
	pair!(X,Y) pp;
	pp.fi=x_;
	pp.se=y_;
	return pp;
}
X sqr(X)(X a_) pure nothrow @property @nogc {return a_*a_;}
X cub(X)(X a_) pure nothrow @property @nogc {return a_*a_*a_;}
nothrow @nogc @system void inf(in char* name) {freopen(name,"r",core.stdc.stdio.stdin);}
nothrow @nogc @system void ouf(in char* name) {freopen(name,"w",core.stdc.stdio.stdout);}
auto arread(T)(){return readln.split.map!(to!(T)).array;}
nothrow pure size_t lowb(T,X)(T a,X g) if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
{
	size_t l=0,r=a.length;
	while(r-l>1)
	{
		auto m=(l+r)>>1;
		if(!(a[m]<g))r=m;
		else l=m;
	}
	return (!(a[l]<g))?l:r;
}
pure nothrow size_t upb(T,X)(T a,X g) if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
{
	size_t l=0,r=a.length;
	while(r-l>1)
	{
		auto m=(l+r)>>1;
		if(g<a[m])r=m;
		else l=m;
	}
	return (g<a[l])?l:r;
}
pure nothrow size_t binf(T,X)(T a,X g) if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
{
	size_t l=0,r=a.length;
	while(r-l>1)
	{
		auto m=(l+r)>>1;
		if(!(a[m]<g))r=m;
		else l=m;
	}
	return (g==a[l])?l:a.length;
}
pure nothrow bool binary_search(T,X)(T a,X g) if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
{
	return binf(a,g)!=a.length;
}
//split strip isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin cumulativeFold schwartzSort multiSort partialSort heapify join
//---------------------------------------------------------------program beginning-----------------------------------------------------------

void main()
{
	int n;
	while(input(&n))
	{
		writeln(binpow(1378,n,10));
	}
}

import std.stdio;
import std.bigint;
import std.container;
import std.array;
import std.algorithm;
import std.conv;
import std.bitmanip;
import std.functional;
import std.math;
import std.numeric;
import std.string;
import std.range;
import std.uni;
import std.complex;
import std.typecons;
import core.stdc.stdio:freopen;
import std.regex;
import std.complex;
alias RedBlackTree Rbt;
alias redBlackTree rbt;
alias BigInt big;
alias pair!(int,int) pii;
alias pair!(long,long) pll;
alias BoyerMooreFinder strfind;
immutable int mod=1000000007;
pure nothrow @safe X binpow(X,Y)(X base,Y exp)
if(!is(Y==float) && !is(Y==real) && !is(Y==double))
{
	if(exp<0)return X(0);
	X res=X(1);
	while(exp>0)
	{
		if(exp&1)res*=base;
		base*=base;
		exp>>=1;
	}
	return res;
}
pure nothrow @safe auto binpow(X,Y,Z)(X base,Y exp,in Z mm)
if(!is(Y==float) && !is(Y==real) && !is(Y==double))
{
	if(mm==0) return binpow(base,exp);
	if(exp<0)return X(0);
	auto res=X(1)%mm;
	while(exp>0)
	{
		if(exp&1)res=(res*base)%mm;
		base*=base;
		base%=mm;
		exp>>=1;
	}
	return res;
}
@safe @property void putarr(X)(X a,in char ch=' '){foreach(const ref i;a)write(i,ch);}
/*@safe @property void putarr(X)(X[][] a)
{
	foreach(i;0..a.length)
	{
		foreach(j;0..a[i].length)write(a[i][j],' ');
		writeln;
	}
}*/
void getarr(X)(X a,in int n){foreach(ref i;a[0..n])input(&i);}
bool input(T...)(T ptrs) if (ptrs.length > 0) {return readf(replicate(" %s", ptrs.length), ptrs)==ptrs.length;}
struct pair(X,Y)
{
	X fi;
	Y se;
	this(X a_,Y b_){
		fi=a_;
		se=b_;
		}
	this(this){fi=fi;se=se;}
	int opCmp(ref const pair!(X,Y) s_) const pure nothrow
	{
		int cmp=0-(fi<s_.fi)+(fi>s_.fi);
		if(cmp!=0)return cmp;
		else return (0-(se<s_.se)+(se>s_.se));
	}
};
pair!(X,Y) mp(X,Y)(X x_,Y y_) pure nothrow
{
	pair!(X,Y) pp;
	pp.fi=x_;
	pp.se=y_;
	return pp;
}
X sqr(X)(X a_) pure nothrow @safe @property @nogc {return a_*a_;}
X cub(X)(X a_) pure nothrow @safe @property @nogc {return a_*a_*a_;}
nothrow @nogc @system void inf(in char* name) {freopen(name,"r",core.stdc.stdio.stdin);}
nothrow @nogc @system void ouf(in char* name) {freopen(name,"w",core.stdc.stdio.stdout);}
auto arread(T)(){return readln.split.map!(to!(T)).array;}
//split strip isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin cumulativeFold schwartzSort multiSort partialSort heapify join
//---------------------------------------------------------------program beginning-----------------------------------------------------------

void main()
{
	int n;
	input(&n);
	writeln(binpow(1378,n,10));
}


import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	auto tests = readln.strip.to !(int);
multitest_loop:
	foreach (test; 0..tests)
	{
		auto s = readln.strip;
		int res = 0;
		foreach (d; 1..10)
		{
			foreach (k; 1..5)
			{
				auto t = repeat (cast (char) (d + '0'), k);
				res += k;
				if (equal (s, t))
				{
					writeln (res);
					continue multitest_loop;
				}
			}
		}
		assert (false);
	}
}

import std.stdio;
import std.conv;
import std.string;

int[string] precalc;

void main()
{
    {
        int strokes = 0;
        for (int i = 1; i <= 9; ++i) {
            string key = "";
            for (int j = 1; j <= 4; ++j) {
                key ~= i.to!string;
                strokes += j;
                precalc[key] = strokes;
            }
        }
    }

    auto t = readln.strip.to!int;
    while (t-- > 0) {
        writeln(precalc[readln.strip]);
    }
}

// Cheese-Cracker: cheese-cracker.github.io

void play(){
    int n;
    n = rd!int;
    int dig = n % 10;
    int tim = 0;
    while(n > 0){
        n /= 10;
        ++tim;
    }
    int res = 10*(dig - 1) + (tim*(tim+1))/2;
    writeln(res);
}

int main(){
    long t = 1;
    t = rd;        // Toggle!
    while(t--) play();  // Let's play!
    stdout.flush;
    return 0;
}

/**********It's A Me Mario!**********/
import std.stdio, std.conv, std.functional, std.string, std.algorithm;
import std.container, std.range, std.typecons, std.numeric, std.math, std.random;
static string[] inp;
T rd(T = long)(){while(!inp.length) inp = readln.chomp.split; string a = inp[0]; inp.popFront; return a.to!T;}
T[] rdarr(T = long)(){ auto r = readln.chomp.split.to!(T[]); return r; }
void show(A...)(A a) { debug{ a.each!(w => write(w, "| ")); writeln; } }
alias ll = long;
alias rbt = redBlackTree;
alias tup = Tuple!(long, long);
T max(T = long)(T a, T b){ return (a > b) ? a : b; }
T min(T = long)(T a, T b){ return (a < b) ? a : b; }

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto t = RD!int;
	auto ans = new long[](t);
	foreach (ti; 0..t)
	{
		auto x = RD!string;

		auto len = x.length;
		ans[ti] = (cast(long)(x[0]-'0')-1)*10 + (len*(len+1)/2);
	}

	foreach (e; ans)
		writeln(e);
	stdout.flush;
	debug readln;
}


import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

immutable int mod = 998_244_353;
immutable int limit = 504;

void main ()
{
	auto c = new int [] [] (limit, limit);
	foreach (i; 0..limit)
	{
		c[i][0] = 1 % mod;
		foreach (j; 1..i + 1)
		{
			c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
		}
	}

	auto p = new int [] [] (limit, limit);
	foreach (i; 1..limit)
	{
		p[i][0] = 1;
		foreach (j; 1..limit)
		{
			p[i][j] = (p[i][j - 1] * 1L * i) % mod;
		}
	}

	auto f = new int [] [] (limit, limit);
	foreach (x; 0..limit)
	{
		f[0][x] = 1;
	}
	foreach (n; 2..limit)
	{
		foreach (x; 1..limit)
		{
			int delta = min (n - 1, x);
			int y = x - delta;
			foreach (k; 0..n + 1)
			{
				f[n][x] = (f[n][x] + f[k][y] * 1L *
				    (c[n][k] * 1L * p[delta][n - k] %
				    mod)) % mod;
			}
			debug {writefln !("f[%s][%s] = %s") (n, x, f[n][x]);}
		}
	}

	int n, x;
	while (readf !(" %s %s") (n, x) > 0)
	{
		writeln (f[n][x]);
	}
}

immutable multi = false;

int n, x;
immutable long p = 998244353;
alias Zp = Z!p;
Zp[][] ways, prePow;

Zp getWays(int size, int range)
{
	pragma(inline, true);
	assert(size >= 0);
	if (range >= 0) return ways[size][range];
	else return Zp(size == 0);
}

Zp[][] C = new Zp[][](501, 501);
static this()
{
	C[0][0] = Zp(1);
	foreach(size; 1 .. 501)
	{
		C[size][0] = Zp(1);
		foreach(subsize; 1 .. size + 1)
		{
			C[size][subsize] = C[size-1][subsize-1] + C[size-1][subsize];
		}
	}
}

Zp calcWays(int size, int range)
{
	pragma(inline, true);
	if (size == 0) return Zp(1);
	if (size == 1) return Zp(0);
	if (range == 0) return Zp(0);
	Zp ans = Zp(0);
	foreach(noDies; 0 .. size + 1)
	{
		Zp noWaysDies = prePow[min(range, size - 1)][noDies];
		noWaysDies = noWaysDies * C[size][noDies];
		noWaysDies = noWaysDies * getWays(size - noDies, range - (size - 1));
		ans = ans + noWaysDies;
	}
	return ans;
}

void solve(int tc)
{
	n = readInt!int;
	x = readInt!int;
	Zp.makeFactorials(2 * n);
	ways = new Zp[][](n+1, x+1);
	prePow = new Zp[][](501, 501);
	foreach(b; 0 .. 501) prePow[b][0] = Zp(1);
	foreach(b; 0 .. 501)
	{
		foreach(ex; 1 .. 501)
			prePow[b][ex] = prePow[b][ex-1] * Zp(b);
	}
	foreach(size; 0 .. n + 1)
		foreach(range; 0 .. x + 1)
			ways[size][range] = calcWays(size, range);
	debug
	{
		foreach(size; 0 .. n + 1)
			ways[size].writeln;
	}
	ways[n][x].rep.writeln;
}

// modular {{{
struct Z(immutable long m)
{
	long rep;
	static immutable bool primeModulus = isPrime(m);
	static Z!m[] fact;
	static if (primeModulus) { static Z!m[] invFact; }
	static makeFactorials(int n)
	{
		fact = new Z!m[](n + 1);
		fact[0] = Z!m(1);
		foreach(i; 1 .. n + 1) fact[i] = Z!m(i) * fact[i - 1];
		static if (primeModulus)
		{
			invFact = new Z!m[](n + 1);
			invFact[n] = fact[n].inv;
			foreach_reverse(i; 0 .. n) invFact[i] = Z!m(i + 1) * invFact[i + 1];
		}
	}

	this(long num)
	{
		rep = num;
	}

	Z!m opBinary(string operator)(Z!m rhs)
	{
		static if (operator == "+")
		{
			long result = rhs.rep + this.rep;
			if (result >= m)
				result -= m;
			return Z!m(result);
		}
		else static if (operator == "-")
		{
			long result = this.rep - rhs.rep;
			if (result < 0)
				result += m;
			return Z!m(result);
		}
		else static if (operator == "*")
		{
			long result = this.rep * rhs.rep;
			if (result >= m)
				result %= m;
			return Z!m(result);
		}
		else static if (operator == "/" && primeModulus)
		{
			assert(rhs != Z!m(0));
			return this * rhs.inv;
		}
		else
		{
			static assert(text("Operator ", operator, " not supported"));
		}
	}

	Z!m opBinary(string operator)(long exponent) if (operator == "^^")
	{
		assert(exponent >= 0);
		Z!m base = this;
		Z!m result = 1;
		while (exponent)
		{
			if (exponent & 1)
				result = result * base;
			base = base * base;
			exponent >>= 1;
		}
		return result;
	}

	static if (primeModulus)
	{
		Z!m inv()
		{
			return this^^(m - 2);
		}
		static Z!m C(int n, int k)
		{
			if (k < 0 || k > n) return Z!m(0);
			return fact[n] * invFact[k] * invFact[n - k];
		}
	}

	invariant
	{
		assert(rep >= 0 && rep < m);
	}
}
bool isPrime(long n)
{
	for(long d = 2; d * d <= n; d++)
		if (n % d == 0) return false;
	return true;
}
unittest
{
	alias Zp = Z!23;
	static assert(Zp.primeModulus);
	foreach(i; 1 .. 23) assert(Zp(i) * Zp(i).inv == Zp(1));
	Zp.makeFactorials(22);
	foreach(i; 0 .. 23) assert(Zp.fact[i] * Zp.invFact[i] == Zp(1));
	assert(Zp.C(3, 2) == Zp(3));
	assert(Zp.C(4, 2) == Zp(6));
}
// }}}

//{{{
void main()
{
	auto t = multi? readInt!int : 1;
	foreach(tc; 0 .. t) solve(tc);
}
//}}}
// input {{{
int currChar;
static this()
{
	currChar = ' ';
}

char topChar()
{
	return cast(char) currChar;
}

void popChar()
{
	import core.stdc.stdio;
	currChar = getchar();
}

auto readInt(T)()
{
	T num = 0;
	int sgn = 0;
	while (topChar.isWhite)
	{
		popChar;
	}
	while (topChar == '-' || topChar == '+')
	{
		sgn ^= (topChar == '-');
		popChar;
	}
	while (topChar.isDigit)
	{
		num *= 10;
		num += (topChar - '0');
		popChar;
	}
	if (sgn)
		return -num;
	return num;
}

string readString()
{
	string res = "";
	while (topChar.isWhite)
		popChar;
	while (!topChar.isWhite)
	{
		res ~= topChar;
		popChar;
	}
	return res;
}
void writes(T...)(T t)
{
	static foreach(i, ti; t)
	{
		static if (isIterable!(T[i]))
		{
			foreach(e; ti)
			{
				write(e, " ");
			}
		}
	}
}
auto ra(V)()
{
	int n = readInt!int;
	return ma(n, readInt!V);
}
auto rt(V)()
{
	int n = readInt!int;
	int m = readInt!int;
	return ma(n, ma(m, readInt!V));
}
auto rbg()
{
	int n = readInt!int;
	int m = readInt!int;
	auto adj = new int[][](n);
	foreach(i; 0 .. m)
	{
		auto u = readInt!int - 1;
		auto v = readInt!int - 1;
		adj[u] ~= v;
		adj[v] ~= u;
	}
	return adj;
}
auto ma(V)(size_t n, lazy V v)
{
	auto arr = new V[](n);
	foreach(ref ai; arr) ai = v;
	return arr;
}
// }}}
// imports {{{
import std.stdio;
import std.algorithm;
import std.typecons;
import std.math;
import std.numeric;
import std.container;
import std.range;
import std.array;
import std.ascii;
// }}}

immutable multi = true;

void solve(int tc)
{
	auto n = readInt!int;
	auto m = readInt!int;
	auto a = ma(n, ma(m, readInt!int));
	auto minmaxL = new Tuple!(int, int)[][](n);
	auto minmaxR = new Tuple!(int, int)[][](n);
	foreach(i, ref ai; a)
	{
		minmaxL[i] = ai.cumulativeFold!(min, max).array;
		minmaxR[i] = ai.retro.cumulativeFold!(min, max).array.retro.array;
	}
	char[] getConfiguration(int k)
	{
		debug writeln("for k = ", k);
		struct Row
		{
			Tuple!(int, int) left, right;
		}
		Row[] rows = new Row[](n);
		foreach(i, ref rowi; rows)
		{
			rowi = Row(minmaxL[i][k], minmaxR[i][k+1]);
		}
		debug writeln("rows = ", rows);
		auto events = new Tuple!(int, int, int)[](2 * n);
		int evlen = 0;
		foreach(i, row; rows)
		{
			events[evlen++] = tuple(row.left[0], +1, cast(int)i);
			events[evlen++] = tuple(row.left[1] + 1, -1, cast(int)i);
		}
		int pfMinPrev = int.max;
		int sfMaxPrev = int.min;
		auto pfMin = new int[](2 * n);
		auto sfMax = new int[](2 * n);
		sort(events);
		debug writeln("events = ", events);
		debug writeln("evlen = ", evlen);
		foreach(i, evi; events)
		{
			if (evi[1] == +1)
			{
				pfMinPrev = min(pfMinPrev, rows[evi[2]].right[0]);
			}
			pfMin[i] = pfMinPrev;
		}

		foreach_reverse(i, evi; events)
		{
			if (evi[1] == +1)
			{
				sfMaxPrev = max(sfMaxPrev, rows[evi[2]].right[1]);
			}
			sfMax[i] = sfMaxPrev;
		}
		debug writeln("pfMin = ", pfMin);
		debug writeln("sfMax = ", sfMax);
		int open = 0;
		int cut = -1;
		auto color = new char[](n);
		color[] = 'R';
		foreach(i, evi; events)
		{
			open += evi[1];
			if (i+1 < events.length && open == 0)
			{
				debug writeln("found a cut at i = ", i);
				if (pfMin[i] > sfMax[i])
				{
					debug writeln("it's a good cut!");
					foreach(j; 0 .. i)
					{
						if (events[j][1] > 0)
						{
							color[events[j][2]] = 'B';
						}
					}
					return color;
				}
			}
		}
		return null;
	}
	foreach(k; 0 .. m - 1)
	{
		auto config = getConfiguration(k);
		if (config !is null)
		{
			writeln("YES");
			config.write(" ");
			return writeln(k+1);
		}
	}
	return writeln("NO");
}

//{{{
void main()
{
	auto t = multi? readInt!int : 1;
	foreach(tc; 0 .. t) solve(tc);
}
//}}}
// input {{{
int currChar;
static this()
{
	currChar = ' ';
}

char topChar()
{
	return cast(char) currChar;
}

void popChar()
{
	import core.stdc.stdio;
	currChar = getchar();
}

auto readInt(T)()
{
	T num = 0;
	int sgn = 0;
	while (topChar.isWhite)
	{
		popChar;
	}
	while (topChar == '-' || topChar == '+')
	{
		sgn ^= (topChar == '-');
		popChar;
	}
	while (topChar.isDigit)
	{
		num *= 10;
		num += (topChar - '0');
		popChar;
	}
	if (sgn)
		return -num;
	return num;
}

string readString()
{
	string res = "";
	while (topChar.isWhite)
		popChar;
	while (!topChar.isWhite)
	{
		res ~= topChar;
		popChar;
	}
	return res;
}
void writes(T...)(T t)
{
	static foreach(i, ti; t)
	{
		static if (isIterable!(T[i]))
		{
			foreach(e; ti)
			{
				write(e, " ");
			}
		}
	}
}
auto ra(V)()
{
	int n = readInt!int;
	return ma(n, readInt!V);
}
auto rt(V)()
{
	int n = readInt!int;
	int m = readInt!int;
	return ma(n, ma(m, readInt!V));
}
auto rbg()
{
	int n = readInt!int;
	int m = readInt!int;
	auto adj = new int[][](n);
	foreach(i; 0 .. m)
	{
		auto u = readInt!int - 1;
		auto v = readInt!int - 1;
		adj[u] ~= v;
		adj[v] ~= u;
	}
	return adj;
}
auto ma(V)(size_t n, lazy V v)
{
	auto arr = new V[](n);
	foreach(ref ai; arr) ai = v;
	return arr;
}
// }}}
// imports {{{
import std.stdio;
import std.algorithm;
import std.typecons;
import std.math;
import std.numeric;
import std.container;
import std.range;
import std.array;
import std.ascii;
// }}}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

immutable int mod = 998_244_353;
immutable int limit = 504;

void main ()
{
	auto c = new int [] [] (limit, limit);
	foreach (i; 0..limit)
	{
		c[i][0] = 1 % mod;
		foreach (j; 1..i + 1)
		{
			c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
		}
	}

	auto p = new int [] [] (limit, limit);
	foreach (i; 1..limit)
	{
		p[i][0] = 1;
		foreach (j; 1..limit)
		{
			p[i][j] = (p[i][j - 1] * 1L * i) % mod;
		}
	}

	auto f = new int [] [] (limit, limit);
	foreach (x; 0..limit)
	{
		f[0][x] = 1;
	}
	foreach (n; 2..limit)
	{
		foreach (x; 1..limit)
		{
			int delta = min (n - 1, x);
			int y = x - delta;
			foreach (k; 0..n + 1)
			{
				f[n][x] = (f[n][x] + f[k][y] * 1L *
				    (c[n][k] * 1L * p[delta][n - k]) %
				    mod) % mod;
			}
			debug {writefln !("f[%s][%s] = %s") (n, x, f[n][x]);}
		}
	}

	int n, x;
	while (readf !(" %s %s") (n, x) > 0)
	{
		writeln (f[n][x]);
	}
}


import std.algorithm, std.array, std.conv, std.stdio, std.string;

void main ()
{
	string s;
	while ((s = readln.strip) != "")
	{
		auto a = s.splitter.map !(to !(long)).array;
		auto n = a.length;
		long res = 0;
		foreach (i; 0..n)
		{
			auto q = a[i] / n;
			auto r = a[i] % n;
			auto b = a.dup;
			b[i] = 0;
			foreach (j; 0..n)
			{
				b[(i + j + 1) % n] += q + (j < r);
			}
			auto cur = b.filter !(x => x % 2 == 0).sum;
			res = max (res, cur);
		}
		writeln (res);
	}
}

import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  long[] a; readA(14, a);

  auto ans = 0L;
  foreach (i; 0..14) {
    auto b = a.dup;
    b[i] = 0;
    foreach (j; 0..14)
      b[(i+j+1)%14] += a[i]/14 + (j < a[i]%14);

    auto r = 0L;
    foreach (j; 0..14)
      if (b[j]%2 == 0) r += b[j];
    ans = max(ans, r);
  }

  writeln(ans);
}

import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;

void main()
{
	enum N = 14;
	long[] a = readln.chomp.split.map!(to!long).array;
	long ans = 0;
	foreach (i, v; a) {
		// simulate
		long[] b = a.dup;
		b[i] = 0;
		foreach (j; 0..N) {
			b[cast(uint)((i + j + 1) % N)] += v / N;
		}
		foreach (j; 0 .. v % N) {
			++b[cast(uint)((i + j + 1) % N)];
		}
		long sub = 0;
		foreach (w; b) {
			if (w % 2 == 0) {
				sub += w;
			}
		}
		ans = max(ans, sub);
	}
	ans.writeln;
}

void tie(R, Args...)(R arr, ref Args args)
		if (isRandomAccessRange!R || isArray!R)
in
{
	assert (arr.length == args.length);
}
body
{
	foreach (i, ref v; args) {
		alias T = typeof(v);
		v = arr[i].to!T;
	}
}

void verbose(Args...)(in ref Args args)
{
	stderr.write("[");
	foreach (i, ref v; args) {
		if (i) stderr.write(", ");
		stderr.write(v);
	}
	stderr.writeln("]");
}

void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n=14;
  auto a=readln.split.to!(long[]);
  long ret=0;
  foreach(i; 0..n)if(a[i]>0){
    auto b=a.dup;
    long k=b[i];
    b[i]=0;
    foreach(j; 0..n) b[j]+=k/n;
    for(int j=1; j<=(k%n).to!(int); j++) b[(i+j)%n]+=1;
    long score=0;
    foreach(e; b)if(e%2==0) score+=e;
    ret=max(ret, score);
  }
  writeln(ret);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}

import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
    auto a = readln.splitter.map!(to!int).array;
    a ~= a;
    long ans = 0;
    foreach (i; 0..14) {
        auto now = a[i+1..i+1+14].dup;

        debug { writeln(now); }

        now[$-1] = 0;

        auto curVal = (int j, long e) => e + a[i] / 14 + (a[i] % 14 >= j);
        auto vals = now.enumerate(1).map!(x => curVal(x.index, x.value));

        debug { writeln(vals); }

        ans = max (ans, vals.filter!(x => x % 2 == 0).sum);
    }

    writeln (ans);
}

import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
    auto a = readln.splitter.map!(to!int).array;
    a ~= a;
    long ans = 0;
    foreach (i; 0..14) {
        auto now = a[i+1..i+1+14].dup;

        debug { writeln(now); }

        now[$-1] = 0;

        auto curVal = (int j, int e) => e + a[i] / 14 + (a[i] % 14 >= j);
        auto vals = now.enumerate(1).map!(x => curVal(x.index, x.value));

        debug { writeln(vals); }

        ans = max (ans, vals.filter!(x => x % 2 == 0).sum);
    }

    writeln (ans);
}

import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
    auto a = readln.splitter.map!(to!int).array;
    a ~= a;
    int ans = 0;
    foreach (i; 0..14) {
        auto now = a[i+1..i+1+14].dup;

        debug { writeln(now); }

        now[$-1] = 0;

        auto curVal = (int j, int e) => e + a[i] / 14 + (a[i] % 14 >= j);
        auto vals = now.enumerate(1).map!(x => curVal(x.index, x.value));

        debug { writeln(vals); }

        ans = max (ans, vals.filter!(x => x % 2 == 0).sum);
    }

    writeln (ans);
}

void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n=14;
  auto a=readln.split.to!(long[]);
  long ret=0;
  foreach(i; 0..n)if(a[i]>0){
    auto b=a.dup;
    long k=b[i];
    b[i]=0;
    foreach(j; 0..n) b[j]+=k/n;
    for(int j=1; j<=(k%n).to!(int); j++) b[j%n]+=1;
    long score=reduce!((r, e)=>(r+(e%2==0 ? e : 0L)))(0L, b);
    ret=max(ret, score);
  }
  writeln(ret);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
import std.array;
import std.range;

void main()
{
    auto nm = readln.split.map!(to!int);
    auto ts = readln.split.map!(to!int);
    auto count = 0;
    auto d = nm[1]-ts[0];
    foreach(t; ts.dropOne) {
        if (d<0) {
            writeln(-1);
            return;
        } else {
            d-=10;
            count+=2;
        }
        //writef("d=%d c=%d ",d,count);
        d-=t;
    }
    if (d<0) {
        writeln(-1);
        return;
    }
    while (d>=10) {
        d-=10;
        count+=2;
    }
    if (d>=5) { count++;}
    writeln(count);
}

import core.thread;
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex;

//	Input
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { tokens = readln.split; if (stdin.eof) throw new EOFException; } auto token = tokens[0]; tokens.popFront; return token; }
int readInt() { return to!int(readToken); }
long readLong() { return to!long(readToken); }
real readReal() { return to!real(readToken); }

//	chmin/chmax
void chmin(T)(ref T t, in T f) { if (t > f) t = f; }
void chmax(T)(ref T t, in T f) { if (t < f) t = f; }

//	Pair
struct Pair(S, T) {
	S x; T y;
	int opCmp(    const Pair p) const { return (x < p.x) ? -1 : (x > p.x) ? +1 : (y < p.y) ? -1 : (y > p.y) ? +1 : 0; }
	int opCmp(ref const Pair p) const { return (x < p.x) ? -1 : (x > p.x) ? +1 : (y < p.y) ? -1 : (y > p.y) ? +1 : 0; }
	string toString() const { return "(" ~ to!string(x) ~ ", " ~ to!string(y) ~ ")"; }
}
auto pair(S, T)(inout(S) x, inout(T) y) { return Pair!(S, T)(x, y); }

//	Array
int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = as.length; for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) { return (a <  val); }); }
int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) { return (a <= val); }); }
T[] unique(T)(in T[] as) { T[] bs; foreach (a; as) if (bs.empty || bs[$ - 1] != a) bs ~= a; return bs; }

int N, D;
int[] A;

void main(string[] args) {
	try {
	for (; ; ) {
		N = readInt;
		D = readInt;
		A = new int[N];
		foreach (i; 0 .. N) {
			A[i] = readInt;
		}

		const x = D - reduce!"a + b"(0, A) - 10 * (N - 1);
		if (x < 0) {
			writeln(-1);
		} else {
			writeln(x / 5 + 2 * (N - 1));
		}
	}
	} catch (EOFException) {}
}

import std.stdio;
import std.string;
import std.algorithm;
import std.conv;

void main()
{
    auto nm = readln.split.map!(to!int);
    auto ts = readln.split.map!(to!int);
    auto count = 0;
    auto d = nm[1];
    foreach(t; ts) {
        d-=t;
        if (d<0) {
            writeln(-1);
            return;
        } else {
            d-=10;
            count+=2;
        }
    }
    if (d>5) { count++;}
    writeln(count);
}


import std.stdio;
void main()
{
	auto q=["monday" : 1,"tuesday" : 2,"wednesday" : 3,"thursday" : 4,"friday" : 5,"saturday" : 6 ,"sunday" : 7];
	string a,b;
	readf("%s\n%s\n",&a,&b);
	//writeln(a);
	int x=q[a],y=q[b];
	int p;
	if(x>y) p=7+y-x;
	else p=y-x;
	if(p <4 && p!=1)writeln("YES");
	else writeln("NO");
}

import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

enum DOWS = [
"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"
];

void main() {
  try {
    for (; ; ) {
      const S = readToken();
      const T = readToken();

      const s = DOWS.countUntil(S);
      const t = DOWS.countUntil(T);
      bool ans;
      foreach (n; [28, 30, 31]) {
        if ((s + n - t) % 7 == 0) {
          debug {
            writeln("ok ", n);
          }
          ans = true;
        }
      }
      writeln(ans ? "YES" : "NO");
    }
  } catch (EOFException e) {
  }
}

import std.stdio;
import std.math;
import std.algorithm;
import std.range;
import std.random;
import std.regex;
import std.string;
import std.numeric;
import std.functional;
import std.bigint;
import std.bitmanip;
import std.conv;
import std.container;
alias redBlackTree rbt;
alias BigInt big;
//writeln readf readln string wstring dstring delegate function static length
//double float real foreach immutable assert unittest continue break

void main()
{
	int[string] q=["monday" : 1,"tuesday" : 2,"wednesday" : 3,"thursday" : 4,"friday" : 5,"saturday" : 6 ,"sunday" : 7];
	string a=readln,b=readln;
    a=a[0..$-1];
    b=b[0..$-1];
    int x=q[a],y=q[b];
	int p;
	if(x>y) p=7+y-x;
	else p=y-x;
	if(p <4 && p!=1)writeln("YES");
	else writeln("NO");
}

import std.stdio;
import std.math;
import std.algorithm;
import std.range;
import std.random;
import std.regex;
import std.string;
import std.numeric;
import std.functional;
import std.bigint;
import std.bitmanip;
import std.conv;
import std.container;
alias redBlackTree rbt;
alias BigInt big;
//writeln readf readln string wstring dstring delegate function static length
//double float real foreach immutable assert unittest continue break

void main()
{
	auto q=["monday" : 1,"tuesday" : 2,"wednesday" : 3,"thursday" : 4,"friday" : 5,"saturday" : 6 ,"sunday" : 7];
	string a,b;
	readf("%s\n%s\n",&a,&b);
	//writeln(a);
	int x=q[a],y=q[b];
	int p;
	if(x>y) p=7+y-x;
	else p=y-x;
	if(p <4 && p!=1)writeln("YES");
	else writeln("NO");
}


import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto n = RD;
	long[] p;
	for (long i = 2; i*i <= n; ++i)
	{
		if (n % i == 0)
		{
			p ~= i;
			p ~= n/i;
		}
	}
	long ans = n;
	foreach (e; p)
	{
		ans = gcd(ans, e);
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

int root(int[] uf, int u) {
  return (uf[u] < 0) ? u : (uf[u] = uf.root(uf[u]));
}
bool connect(int[] uf, int u, int v) {
  u = uf.root(u);
  v = uf.root(v);
  if (u == v) return false;
  if (uf[u] > uf[v]) swap(u, v);
  uf[u] += uf[v];
  uf[v] = u;
  return true;
}

void main() {
  try {
    for (; ; ) {
      const N = readLong();

      long[] ds;
      for (long d = 1; d * d <= N; ++d) {
        if (N % d == 0) {
          ds ~= d;
          if (d != N / d) {
            ds ~= N / d;
          }
        }
      }
      ds.sort();
      const dsLen = cast(int)(ds.length);
      debug {
        writeln("ds = ", ds);
      }
      if (dsLen <= 2) {
        writeln(N);
      } else {
        const V = cast(int)(ds[1]);
        auto uf = new int[V];
        uf[] = -1;
        foreach (j; 2 .. dsLen) {
          for (int u = 0, v = cast(int)(ds[j] % V); u < V; ++u, ++v %= V) {
            uf.connect(u, v);
          }
        }
        int ans;
        foreach (u; 0 .. V) {
          if (uf[u] < 0) {
            ++ans;
          }
        }
        writeln(ans);
      }
    }
  } catch (EOFException e) {
  }
}

import std.algorithm;
import std.conv;
import std.numeric;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	long n;
	while (readf (" %s", &n) > 0)
	{
		long res = n;
		for (long d = 2; d * d <= n; d++)
		{
			if (n % d == 0)
			{
				res = gcd (res, d);
				res = gcd (res, n / d);
			}
		}
		writeln (res);
	}
}

import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0;
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;

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

void solve(){
	long n = rlong;

	long[] ds = [n];
	for(long i = 2 ; i * i <= n; i ++){
		if(n % i == 0) ds ~= i, ds ~= n / i;
	}
	ds.sort();

	foreach(d; ds[1 .. $]){
		if(d % ds[0] != 0){
			1.writeln;
			return;
		}
	}
	ds[0].writeln;
	return;
}

import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

int root(int[] uf, int u) {
  return (uf[u] < 0) ? u : (uf[u] = uf.root(uf[u]));
}
bool connect(int[] uf, int u, int v) {
  u = uf.root(u);
  v = uf.root(v);
  if (u == v) return false;
  if (uf[u] > uf[v]) swap(u, v);
  uf[u] += uf[v];
  uf[v] = u;
  return true;
}

void main() {
  try {
    for (; ; ) {
      const N = readLong();

      long[] ds;
      for (long d = 1; d * d <= N; ++d) {
        if (N % d == 0) {
          ds ~= d;
          if (d != N / d) {
            ds ~= d;
          }
        }
      }
      ds.sort();
      const dsLen = cast(int)(ds.length);
      if (dsLen <= 2) {
        writeln(N);
      } else {
        const V = cast(int)(ds[1]);
        auto uf = new int[V];
        uf[] = -1;
        foreach (j; 2 .. dsLen) {
          for (int u = 0, v = cast(int)(ds[j] % V); u < V; ++u, ++v %= V) {
            uf.connect(u, v);
          }
        }
        int ans;
        foreach (u; 0 .. V) {
          if (uf[u] < 0) {
            ++ans;
          }
        }
        writeln(ans);
      }
    }
  } catch (EOFException e) {
  }
}


import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main () {
	auto n = readln.strip.to!int, a = readln.split.map !(to!int).array;
	foreach (d; 0..101) foreach (b; 0..101) if (a.all !(x => [b - d, b, b + d].canFind (x))) {d.write; return;}
	write (-1);
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;

immutable int limit = 101;

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		readln;
		auto a = readln.splitter.map !(to !(int)).array;
		int res = limit;
		foreach (base; 0..limit)
		{
			foreach (diff; 0..limit)
			{
				if (a.all !(x => x == base ||
				    x == base - diff || x == base + diff))
				{
					res = min (res, diff);
				}
			}
		}
		if (res == limit)
		{
			res = -1;
		}
		writeln (res);
	}
}

import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int DEBUG_LEVEL = 0;
void print()(){ writeln(""); }
void print(T, A ...)(T t, lazy A a){ write(t), print(a); }
void print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }

const long mod = 1_000_000_007;

void main(string[] args){
	if(args.length > 1 && args[1] == "-debug"){
		if(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;
		else DEBUG_LEVEL = 1;
	}

	int n = read.to!int;
	int[] as = readln.chomp.split.map!(to!int).array;

	bool[int] aset;
	foreach(a; as) aset[a] = 1;

	int ans;

	int[] ks = aset.keys;
	ks.sort();
	if(ks.length == 1) ans = 0;
	else if(ks.length == 2){
		ans = ks[1] - ks[0];
		if(ans % 2 == 0) ans /= 2;
	}
	else if(ks.length == 3){
		if(ks[1] - ks[0] == ks[2] - ks[1]) ans = ks[1] - ks[0];
		else ans = -1;
	}
	else ans = -1;

	ans.writeln;

}
/*

How many different a do they have?
If more than 4, impossible.
If 3, possible if and only if it is like 1-4-7.
If 2 or 1, always possible.

*/

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto a = RDR.ARR;
	a = a.sort().uniq.array;

	if (a.length == 1)
	{
		writeln(0);
	}
	else if (a.length == 2)
	{
		auto x = a[1] - a[0];
		writeln(x % 2 == 0 ? x / 2 : x);
	}
	else if (a.length == 3)
	{
		long l = a[0];
		long m = a[1];
		long r = a[2];
		writeln(m - l == r - m ? m - l : -1);
	}
	else
	{
		writeln(-1);
	}

	stdout.flush();
	debug readln();
}

import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int DEBUG_LEVEL = 0;
void print()(){ writeln(""); }
void print(T, A ...)(T t, lazy A a){ write(t), print(a); }
void print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }

const long mod = 1_000_000_007;

void main(string[] args){
	if(args.length > 1 && args[1] == "-debug"){
		if(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;
		else DEBUG_LEVEL = 1;
	}

	int n = read.to!int;
	int[] as = readln.chomp.split.map!(to!int).array;

	bool[int] aset;
	foreach(a; as) aset[a] = 1;

	int ans;

	int[] ks = aset.keys;
	ks.sort();
	if(ks.length == 1) ans = 0;
	else if(ks.length == 2) ans = ks[1] - ks[0];
	else if(ks.length == 3){
		if(ks[1] - ks[0] == ks[2] - ks[1]) ans = ks[1] - ks[0];
		else ans = -1;
	}
	else ans = -1;

	ans.writeln;

}
/*

How many different a do they have?
If more than 4, impossible.
If 3, possible if and only if it is like 1-4-7.
If 2 or 1, always possible.

*/

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto a = RDR.ARR;
	a = a.sort().uniq.array;

	if (a.length == 1)
	{
		writeln(0);
	}
	else if (a.length == 2)
	{
		auto x = a[1] - a[0];
		writeln(x % 2 == 0 ? x / 2 : -1);
	}
	else if (a.length == 3)
	{
		long l = a[0];
		long m = a[1];
		long r = a[2];
		writeln(m - l == r - m ? m - l : -1);
	}
	else
	{
		writeln(-1);
	}

	stdout.flush();
	debug readln();
}


import std.stdio : writeln;

struct IO {
    string readToken() {
        import std.stdio : stdin;
        import std.array : split;
        import std.range : empty, front, popFront;

        while (tokens.empty) {
            tokens = stdin.readln.split;
        }
        string token = tokens.front;
        tokens.popFront;
        return token;
    }

    int readInt() {
        import std.conv : to;

        return readToken.to!(int);
    }

    string[] tokens;
}

void main() {
    import std.algorithm : min, sort;

    IO io;
    int n = io.readInt;
    int[] p = new int[n + 2];
    int target = n >> 1;
    for (int i = 1; i <= n; ++i) {
        p[i] = io.readInt - 1;
        if (~p[i]) {
            if (p[i] &= 1) {
                target--;
            }
        }
    }
    int result = n;
    for (int mask = 0; mask < 1 << 2; ++mask) {
        p[0] = mask & 1, p[n + 1] = mask >> 1;
        int cost = 0, low = 0, high = 0, j = 0, pc = 0, nc = 0;
        int[] positives = new int[n + 1], negatives = new int[n + 1];
        for (int i = 1; i <= n + 1; ++i) {
            if (~p[i]) {
                int length = i - j - 1;
                if (p[i] != p[j]) {
                    cost++, high += length;
                }
                else if (p[i]) {
                    low += length, high += length, negatives[nc++] = length;
                }
                else {
                    positives[pc++] = length;
                }
                j = i;
            }
        }
        positives.sort!("a > b");
        negatives.sort!("a > b");
        for (int i = 0; i < pc && high < target; ++i) {
            cost += 2, high += positives[i];
        }
        for (int i = 0; i < nc && low > target; ++i) {
            cost += 2, low -= negatives[i];
        }
        result = min(result, cost);
    }
    writeln(result);
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }

void main()
{
	auto n = RD!int;
	auto p = RDA!int;

	auto cnt = new int[](2);
	cnt[0] = n/2;
	cnt[1] = (n+1)/2;
	foreach (i; 0..n)
	{
		if (p[i] == 0) continue;
		auto j = p[i] % 2;
		--cnt[j];
	}

	auto dp = new int[][][](n+1, n+1, 2);
	foreach (i; 0..n+1)
	{
		foreach (j; 0..n+1)
			dp[i][j][] = -1;
	}
	dp[cnt[0]][cnt[1]][0] = 0;
	dp[cnt[0]][cnt[1]][1] = 0;
	foreach (i; 0..n)
	{
		auto ndp = new int[][][](n+1, n+1, 2);
		foreach (j; 0..n+1)
		{
			foreach (k; 0..n+1)
				ndp[j][k][] = -1;
		}
		foreach (j; 0..n+1)
		{
			foreach (k; 0..n+1)
			{
				foreach (l; 0..2)
				{
					if (dp[j][k][l] == -1) continue;
					if (p[i] != 0)
					{
						auto eo = p[i] % 2;
						auto num = dp[j][k][l] + (eo != l ? 1 : 0);
						if (ndp[j][k][eo] == -1)
							ndp[j][k][eo] = num;
						else
							ndp[j][k][eo].chmin(num);
						continue;
					}
					if (j != 0)
					{
						auto num = dp[j][k][l] + (l != 0 ? 1 : 0);
						if (ndp[j-1][k][0] == -1)
							ndp[j-1][k][0] = num;
						else
							ndp[j-1][k][0].chmin(num);
					}
					if (k != 0)
					{
						auto num = dp[j][k][l] + (l != 1 ? 1 : 0);
						if (ndp[j][k-1][1] == -1)
							ndp[j][k-1][1] = num;
						else
							ndp[j][k-1][1].chmin(num);
					}
				}
			}
		}
		dp = ndp;
	}
	debug writeln(dp);

	int ans = int.max;
	foreach (i; 0..2)
	{
		if (dp[0][0][i] != -1)
			ans.chmin(dp[0][0][i]);
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}

import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

enum INF = 10^^9;

void main() {
  try {
    for (; ; ) {
      const N = readInt();
      auto P = new int[N];
      foreach (i; 0 .. N) {
        P[i] = readInt();
      }

      auto dp = new int[][][](N + 1, N + 1, 2);
      foreach (i; 0 .. N + 1) {
        foreach (j; 0 .. N + 1) {
          dp[i][j][] = INF;
        }
      }
      dp[0][0][] = 0;
      foreach (i; 0 .. N) {
        foreach (j; 0 .. i + 1) foreach (s; 0 .. 2) {
          foreach (t; 0 .. 2) {
            if (P[i] == 0 || P[i] % 2 == t) {
              chmin(dp[i + 1][j + t][t], dp[i][j][s] + abs(s - t));
            }
          }
        }
      }
      int ans = INF;
      foreach (s; 0 .. 2) {
        chmin(ans, dp[N][N - N / 2][s]);
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}

import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0;
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

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

const long infty = 100999;

void solve(){
	int n = rint;
	long[] as = rlong(n);

	int p = (n + 1) / 2, q = n / 2, z; // how many odds, evens, zeros
	foreach(a; as){
		if(a == 0) z += 1;
		else if(a % 2) p -= 1;
		else q -= 1;
	}
	log("p:", p, "q:", q, "z:", z);

	long[][][] xs = new long[][][](n, p + 1, q + 1);
			// xs[i][j][k]: use j odd and k even bulbs and the rightmost is odd and the min score
	long[][][] ys = new long[][][](n, p + 1, q + 1);
			// ys[i][j][k]: use j odd and k even bulbs and the rightmost is even and the min score

	foreach(i, a; as){
		if(a > 0){ // forced
			if(a % 2){ // forced odd
				foreach(j; 0 .. p + 1) foreach(k; 0 .. q + 1){
					if(i > 0) xs[i][j][k] = min(xs[i - 1][j][k], ys[i - 1][j][k] + 1);
					else xs[i][j][k] = 0;
					ys[i][j][k] = infty;
				}
			}
			else{ // forced even
				foreach(j; 0 .. p + 1) foreach(k; 0 .. q + 1){
					xs[i][j][k] = infty;
					if(i > 0) ys[i][j][k] = min(xs[i - 1][j][k] + 1, ys[i - 1][j][k]);
					else ys[i][j][k] = 0;
				}
			}
		}
		else{ // free
			foreach(j; 0 .. p + 1) foreach(k; 0 .. q + 1){
				if(i > 0){
					if(j > 0) xs[i][j][k] = min(xs[i - 1][j - 1][k], ys[i - 1][j - 1][k] + 1);
					else xs[i][j][k] = infty;
					if(k > 0) ys[i][j][k] = min(xs[i - 1][j][k - 1] + 1, ys[i - 1][j][k - 1]);
					else ys[i][j][k] = infty;
				}
				else{
					if(j == 1 && k == 0) xs[i][j][k] = 0;
					else xs[i][j][k] = infty;
					if(j == 0 && k == 1) ys[i][j][k] = 0;
					else ys[i][j][k] = infty;
				}
			}
		}
		log("xs:", xs[i], "ys:", ys[i]);
	}
	long ans = min(xs[n - 1][p][q], ys[n - 1][p][q]);
	ans.writeln;
}

//prewritten code: https://github.com/antma/algo
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.traits;

final class InputReader {
  private:
  ubyte[] p, buffer;
  bool eof;
  bool rawRead () {
    if (eof) {
      return false;
    }
    p = stdin.rawRead (buffer);
    if (p.empty) {
      eof = true;
      return false;
    }
    return true;
  }
  ubyte nextByte(bool check) () {
    static if (check) {
      if (p.empty) {
        if (!rawRead ()) {
          return 0;
        }
      }
    }
    auto r = p.front;
    p.popFront ();
    return r;
  }
  public:
  this () {
    buffer = uninitializedArray!(ubyte[])(16<<20);
  }
  bool seekByte (in ubyte lo) {
    while (true) {
      p = p.find! (c => c >= lo);
      if (!p.empty) {
        return false;
      }
      if (!rawRead ()) {
        return true;
      }
    }
  }
  template next(T) if (isSigned!T) {
    T next ()  {
      if (seekByte (45)) {
        return 0;
      }
      T res;
      ubyte b = nextByte!false ();
      if (b == 45) {
        while (true) {
          b = nextByte!true ();
          if (b < 48 || b >= 58) {
            return res;
          }
          res = res * 10 - (b - 48);
        }
      } else {
        res = b - 48;
        while (true) {
          b = nextByte!true ();
          if (b < 48 || b >= 58) {
            return res;
          }
          res = res * 10 + (b - 48);
        }
      }
    }
  }
  template next(T) if (isUnsigned!T) {
    T next () {
      if (seekByte (48)) {
        return 0;
      }
      T res = nextByte!false () - 48;
      while (true) {
        ubyte b = nextByte!true ();
        if (b < 48 || b >= 58) {
          break;
        }
        res = res * 10 + (b - 48);
      }
      return res;
    }
  }
  T[] nextA(T) (in int n) {
    auto a = uninitializedArray!(T[]) (n);
    foreach (i; 0 .. n) {
      a[i] = next!T;
    }
    return a;
  }
}

void main() {
  auto r = new InputReader ();
  immutable n = r.next!uint ();
  auto a = r.nextA!uint (n);
  auto b = new bool[n + 1];
  foreach (i; a) {
    b[i] = true;
  }
  int odds, evens;
  for (int i = 1; i <= n; ++i) {
    if (!b[i]) {
      if (i & 1) odds++; else evens++;
    }
  }
  int[] pos;
  foreach (i; 0 .. n) {
    if (a[i] == 0) pos ~= i;
  }
  immutable int m = pos.length.to!int;
  auto dp = new int[][][] (m + 1, odds + 1, 3);
  foreach (i; 0 .. m + 1) foreach (j; 0 .. odds + 1) dp[i][j][] = -1;
  auto vo = new int[m];
  auto ve = new int[m];
  b = new bool[m];
  foreach (i; 0 .. m) {
    immutable int k = pos[i];
    if (k > 0) {
      if (a[k-1] != 0) {
        if (a[k-1] & 1) {
          ve[i]++;
        } else {
          vo[i]++;
        }
      } else b[i] = true;
    }
    if (k+1 < n) {
      if (a[k+1] != 0) {
        if (a[k+1] & 1) {
          ve[i]++;
        } else {
          vo[i]++;
        }
      }
    }
  }
  debug stderr.writeln (vo);
  debug stderr.writeln (ve);
  debug stderr.writeln (b);
  debug stderr.writeln (odds);
  debug stderr.writeln (evens);

  int f (const int k, const int o, const int last) {
    if (dp[k][o][last] >= 0) return dp[k][o][last];
    immutable int r = m - k;
    if (!r) return dp[k][o][last] = 0;
    immutable int co = odds - o,
       ce = k - co,
       e = evens - ce;
    assert (e >= 0);
    int res = int.max;
    if (o > 0) {
      int w = f (k + 1, o - 1, 1) + vo[k];
      if (b[k] && last == 0) ++w;
      res = min (res, w);
    }
    if (e > 0) {
      int w = f (k + 1, o, 0) + ve[k];
      if (b[k] && last == 1) ++w;
      res = min (res, w);
    }
    return dp[k][o][last] = res;
  }
  int res = f (0, odds, 2);
  foreach (i; 1 .. n) {
    if (a[i-1] != 0 && a[i] != 0 && 0 != ((a[i-1] ^ a[i]) & 1)) {
      ++res;
    }
  }
  writeln (res);
}


module acmd;

import std.stdio;
import std.conv;
import std.algorithm;
import std.string;
import std.container;

int main () {
   version (offline_judje) {
      stdin.reopen ("input.txt", "rt");
   }

   int n, k;
   readf!" %d %d" (n, k);
   int[] nums;
   foreach (i; 0 .. n) {
      int num; readf!" %d" (num);
      nums ~= num;
   }
   auto curnums = nums[];
   int ans = 0;
   while (curnums.length > 0) {
      if (curnums[0] <= k) {
         ans++;
         curnums = curnums[1 .. $];
      }
      else if (curnums[$ - 1] <= k) {
         ans++;
         curnums = curnums[0 .. $ - 1];
      }
      else break;
   }
   write (ans);

   return 0;
}

import std.algorithm;
import std.array;
import std.bitmanip;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import std.range.interfaces;

void main()
{
    int n, k;
    readf("%s %s", &n, &k);
    readln;

    auto a = readln.chomp.split.map!(to!int).array;

    int check(int[] a, int k) {
        return cast(int) a.until!(x => x > k).array.length;
    }

    auto ans = min(check(a, k) + check(a.retro.array, k), n);

    ans.writeln;
}


import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;
    A.sort();
    iota(0, N, 2).map!(i => A[i+1] - A[i]).sum.writeln;
}

import std.stdio;
import std.algorithm;
int main()
{
	int t=0;
	readf(" %d", &t);
	int[] m = new int[t];
	for (int i=0; i<t; i++)
	{
		readf(" %d", &m[i]);
	}
	sort(m);
	int count=0;
	for (int i=0; i<t/2; i++)
	{
		count=count+(m[i*2+1]-m[i*2]);
	}
	writeln(count);
	return 0;
}


module ahmat;
import core.stdc.stdio:scanf,printf,puts;
import core.bitop;
import std.stdio;
import std.string;
import std.ascii;
import std.algorithm;
import std.range;
import std.functional;
import std.array;
import std.container;
import std.conv;
import std.container;
import std.typecons;
import std.math;
import std.random;
import std.numeric;
pragma(inline,true);
int sz(r)(ref r x){return cast(int)x.length;}

void main(){
	char[] a=readln().strip().dup~readln().strip().dup,
		   b=readln().strip().dup;
	sort(cast(ubyte[])a);
	sort(cast(ubyte[])b);
	if(a==b)
		writeln("YES");
	else writeln("NO");
}

import std.stdio, std.string, std.algorithm;

void main() {
    auto a = readln().chomp();
    auto b = readln().chomp();
    auto c = readln().chomp();
    auto d = a ~ b;

    sort((cast(ubyte[])c));
    sort((cast(ubyte[])d));

    if (c == d) {
        writeln("YES");
    } else {
        writeln("NO");
    }
 }

import std.stdio: writeln, stdin;
import std.string: strip;
import std.algorithm.iteration: group;
import std.algorithm.sorting: sort;

void main()
{
  char[] h = stdin.readln.strip.dup;
  char[] r = stdin.readln.strip.dup;
  char[] p = stdin.readln.strip.dup;

  auto a = h ~ r;
  sort(cast(ubyte[])a);
  sort(cast(ubyte[])p);
  //p.sort!"a<b";

  writeln(a.group == p.group ? "YES" : "NO");
}

import std.stdio;
import core.stdc.stdio;
import std.string;

string readline()
{
	string line = readln();
	if (line[$ - 1] == '\n') line.length--;
	return line;
}

int main()
{
	string line1 = readline();
	string line2 = readline();
	string line3 = readline();
	if (line1.length + line2.length != line3.length)
	{
		write("NO");
		return 0;
	}
	int[] letters; letters.length ='Z' - 'A' + 1;
	string l = line1 ~ line2;
	foreach (char c; l)
	{
		letters[c - 'A'] += 1;
	}
	int[] letters2; letters2.length = 'Z' - 'A' + 1;
	foreach (char c; line3)
	{
		letters2[c - 'A'] += 1;
	}

	foreach (int i; 0..letters.length)
	{
		if (letters[i] != letters2[i])
		{
			write("NO");
			return 0;
		}
	}
	write("YES");
	return 0;
}

import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
import std.range;

void main() {
	int[char] before;
	int[char] after;

	for (int i = 0; i < 2; i++) {
		string s = readln.chomp;
		foreach (c; s) {
			before[c]++;
		}
	}

	string s = readln.chomp;
	foreach (c; s) {
		after[c]++;
	}

	writeln(before == after ? "YES" : "NO");
}

module ahmat;
import core.stdc.stdio:scanf,printf,puts;
import core.bitop;
import std.stdio;
import std.string;
import std.ascii;
import std.algorithm;
import std.range;
import std.functional;
import std.array;
import std.container;
import std.conv;
import std.container;
import std.typecons;
import std.math;
import std.random;
import std.numeric;
pragma(inline,true);
int sz(r)(ref r x){return cast(int)x.length;}

void main(){
	char[] a=readln.strip().dup~readln().strip().dup,
		 b=readln().strip().dup;
	sort(cast(ubyte[])a);
	sort(cast(ubyte[])b);
	if(b.indexOf(a)>=0)
		writeln("YES");
	else writeln("NO");
}


module main;
import std.bigint,std.container,std.array,std.algorithm,std.conv,
	std.functional,std.math,std.numeric,std.string,std.range,std.complex,
	std.typecons,std.regex,std.random,std.uni,std.traits,std.variant,
	std.stdio,std.bitmanip;
import core.stdc.stdio : freopen;
alias RedBlackTree Rbt;
alias redBlackTree rbt;
alias BigInt big;
alias pair!(int,int) pii;
alias pair!(long,long) pll;
alias boyerMooreFinder strfind;
alias make_pair mp;
alias binary_search bins;
alias pair(X,Y)=Tuple!(X,q{fi},Y,q{se});
pair!(X,Y) make_pair(X,Y)(in X x_,in Y y_)
{
	pair!(X,Y) pp;
	pp.fi=x_;
	pp.se=y_;
	return pp;
}
immutable int mod=10^^9+7;
pure nothrow
{
	T lcm (T)(auto ref T a,auto ref T b)
	{
		return a/gcd(a,b)*b;
	}
	@property X sqr(X)(in X a_) {return a_*a_;}
	@property X cub(X)(in X a_) {return a_*a_*a_;}
	size_t lowb(T,X)(in T a,auto ref X g)
		if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
	{
		size_t l=0,r=a.length;
		while(r-l>1)
		{
			auto m=(l+r)>>1;
			if(!(a[m]<g))r=m;
			else l=m;
		}
		return (!(a[l]<g))?l:r;
	}
	size_t upb(T,X)(in T a,auto ref X g)
		if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
	{
		size_t l=0,r=a.length;
		while(r-l>1)
		{
			auto m=(l+r)>>1;
			if(g<a[m])r=m;
			else l=m;
		}
		return (g<a[l])?l:r;
	}
	size_t binf(T,X)(in T a,auto ref X g)
		if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
	{
		size_t l=0,r=a.length;
		while(r-l>1)
		{
			auto m=(l+r)>>1;
			if(!(a[m]<g))r=m;
			else l=m;
		}
		return (g==a[l])?l:a.length;
	}
	bool binary_search(T,X)(in T a,auto ref X g)
		if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
	{
		return binf(a,g)!=a.length;
	}
}
void putarr(X)(in X a,in char ch=' '){foreach(const ref i;a)write(i,ch);}
void putarr(X)(in X a,in size_t n,in size_t m) if(isRandomAccessRange!X)
{
	foreach(i;0..n)
	{
		foreach(j;0..m)write(a[i][j],' ');
		writeln;
	}
}
bool getarr(X)(X a,in size_t n) if(hasSlicing!X)
{bool b=1; foreach(ref i;a[0..n])b=input(&i);return b;}
bool input(T...)(T ptrs) if (ptrs.length > 0)
{return readf(replicate(" %s", ptrs.length), ptrs)==ptrs.length;}
bool read(T...)(T ptrs) if (ptrs.length > 0)
{return readf(replicate(" %s", ptrs.length)~'\n', ptrs)==ptrs.length;}
nothrow void inf(in char* name) {freopen(name,"r",core.stdc.stdio.stdin);}
nothrow void ouf(in char* name) {freopen(name,"w",core.stdc.stdio.stdout);}
@property auto arread(T)(){return readln.splitter.map!(to!(T)).array;}
//split strip isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin
//cumulativeFold schwartzSort multiSort partialSort heapify join filter countUntil
//---------------------------------------------------------------program beginning-----------------------------------------------------------------

void main()
{
	/*int n;
	loop:while(read(&n))
	{

	}*/
	auto s=readln.strip;
	if(s.count!isUpper>s.count!isLower)
	{
		foreach(c;s)write(toUpper(c));
	}
	else foreach(c;s)write(toLower(c));
}

import std.stdio;
import core.stdc.stdio;
import std.algorithm;
import std.string;
import std.math;

int main(string[] argv)
{
	string line = readln();
	if (line[$-1] == '\n') line.length--;
	string upper = toUpper(line);
	string lower = toLower(line);
	int diffu, diffl;
	foreach (int i; 0..line.length)
	{
		diffu += abs(line[i] - upper[i]);
		diffl += abs(line[i] - lower[i]);
	}
	write (diffu >= diffl ? lower : upper);
	return 0;
}

//ahmat
import core.stdc.stdio:scanf,printf,puts;
import core.bitop;
import std.stdio;
import std.string;
import std.algorithm;
import std.functional;
import std.array;
import std.container;
import std.conv;
import std.container;
import std.typecons;
import std.math;
import std.numeric;
pragma(inline,true);

void main(){
    char[] s=readln.strip.to!(char[]);
    int n=0;
    foreach(ref x;s){
        if(x.to!int<97) n++;
    }
    if(2*n>s.length)
        s.toUpper.writeln;
    else
        s.toLower.writeln;
}

import std.stdio;
import core.stdc.stdio;
import std.algorithm;
import std.string;
import std.math;

int main(string[] argv)
{
	string line = readln();
	if (line[$-1] == '\n') line.length--;
	string upper = toUpper(line);
	string lower = toLower(line);
	int diffu, diffl;
	foreach (int i; 0..line.length)
	{
		diffu += abs(line[i] - upper[i]);
		diffl += abs(line[i] - lower[i]);
	}
	write (diffu > diffl ? lower : upper);
	return 0;
}


import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto n = RD;
	auto p = RD;
	auto w = RD!int;
	auto d = RD!int;

	auto r = p % w;
	auto used = new bool[](10^^5);
	int a;
	int cnt = -1;
	foreach (i; 0..10^^5)
	{
		if (a == r)
		{
			cnt = i;
			break;
		}
		else if (used[a] == true)
			break;
		used[a] = true;

		a += d;
		a %= w;
	}

	if (cnt == -1)
		writeln(-1);
	else
	{
		auto y = cast(long)cnt;
		auto x = (p - y*d) / w;
		auto z = n - x - y;
		if (x < 0 || z < 0)
			writeln(-1);
		else
			writeln(x, " ", y, " ", z);
	}

	stdout.flush();
	debug readln();
}

import std.algorithm;
import std.range;
import std.stdio;
import std.typecons;
import std.traits;
import std.array;
void read(T...)(ref T args)
{
  import std.traits;
  static foreach(i; 0 .. T.length)
    static if(isArray!(T[i]) && !is(T[i] == string))
      foreach(ref e; args[i])
    	read(e);
    else static if(isTuple!(T[i]))
      {
	static foreach(n; 0 .. T[i].Types.length)
	  {
	    read(args[i][n]);
	  }
      }
    else
      readf!" %s "(args[i]);
}
auto brange(alias low, alias high, alias pred, bool value)()
{
  return iota(low, high + 1).map!((a) => cast(int) pred(a)).assumeSorted.equalRange(value);
}
auto ftrue(alias low, alias high, alias pred)()
{
  return brange!(low, high, pred, false).length + low;
}
auto itup(alias k, alias F)()
{
  alias T = Parameters!F;
  foreach(i; 0 .. k)
    {
      T t;
      get(t);
      F(t);
    }
}
alias get = read;
alias wr = writeln;

T egcd(T)(T a, T b, out T x, out T y)
{
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  T x1, y1;
  auto d = egcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}

void solve(ln a, ln b, ln m, out ln x, out ln p, out bool hassol)
{
  b %= m;
  ln y = 0;
  ln g = egcd(a, m, x, y);
  if (b % g != 0)
    {
      hassol = false;
      return;
    }
  hassol = true;
  x *= b / g;
  p = m / g;
  x %= p;
  x += p;
  x %= p;
  return;
}

alias ln = long;

int main()
{
  ln n, p, w, d; get(n, p, w, d);
  auto h = w - d;
  ln np;
  ln period;
  bool hassol;
  solve(w, p, h, np, period, hassol);
  if (hassol)
    {
      ln top = min(n, p / d);
      ln delta = top - np;
      np += (delta / period) * period;
      ln z = n - np;
      ln y = (w * np - p) / h;
      ln x = np - y;
      if (y >= 0 && x >= 0 && z >= 0)
	{
	  wr(x, " ", y, " ", z);
	}
      else
	{
	  wr(-1);
	}
    }
  else
    {
      wr(-1);
    }
  return 0;
}

import std.algorithm;
import std.range;
import std.stdio;
import std.typecons;
import std.traits;
import std.array;
void read(T...)(ref T args)
{
  import std.traits;
  static foreach(i; 0 .. T.length)
    static if(isArray!(T[i]) && !is(T[i] == string))
      foreach(ref e; args[i])
    	read(e);
    else static if(isTuple!(T[i]))
      {
	static foreach(n; 0 .. T[i].Types.length)
	  {
	    read(args[i][n]);
	  }
      }
    else
      readf!" %s "(args[i]);
}
auto brange(alias low, alias high, alias pred, bool value)()
{
  return iota(low, high + 1).map!((a) => cast(int) pred(a)).assumeSorted.equalRange(value);
}
auto ftrue(alias low, alias high, alias pred)()
{
  return brange!(low, high, pred, false).length + low;
}
auto itup(alias k, alias F)()
{
  alias T = Parameters!F;
  foreach(i; 0 .. k)
    {
      T t;
      get(t);
      F(t);
    }
}
alias get = read;
void wone(T)(T t, char end)
{
  static if(isArray!T && !is(T == string))
    {
      foreach(i; 0 .. t.length - 1)
	  write(t[i], ' ');
      write(t[$ - 1], end);
    }
  else
      write(t, end);
}
void wr(T...)(T t)
{
  static foreach(i; 0 .. T.length)
    static if(i + 1 < T.length)
      wone(t[i], ' ');
    else
      wone(t[i], '\n');
}
void ans(T...)(T t)
{
  import core.stdc.stdlib;
  wr(t);
  exit(0);
}
struct ModNum(T)
{
  T representative, modulus;
  this(T representative, T modulus)
  {
    this.representative = representative;
    this.modulus = modulus;
  }
  T minimalPositiveRepresentative()
  {
    return ((representative % modulus) + modulus) % modulus;
  }
  T minimalNegativeRepresentative()
  {
    return ((representative % modulus) - modulus) % modulus;
  }
  T maxRepresentative(T upperBound)
  {
    return upperBound - pmod(upperBound - representative, modulus);
  }
}
// minimum possible representative of x modulo m.
T pmod(T)(T x, T m)
{
  return (x % m + m) % m;
}
// solves ax + by = gcd(a, b) and returns gcd(a, b)
T extendedEuclideanAlgorithm(T)(T a, T b, out T x, out T y)
{
  if (a == 0)
    {
      x = 0, y = 1;
      return b;
    }
  T x1, y1;
  auto d = egcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1, y = x1;
  return d;
}
alias egcd = extendedEuclideanAlgorithm;
// solves ax = b (mod m) giving a solution as a modulus class.
bool solveLinearCongruence(T)(T a, T b, T m, out ModNum!T res)
{
  T x, p;
  b = pmod(b, m);
  T y;
  T g = egcd(a, m, x, y);
  if (b % g != 0)
    return false;
  p = m / g;
  x = pmod(x * b / g, p);
  res.representative = x;
  res.modulus = p;
  return true;
}
void main()
{
  alias solve = solveLinearCongruence;
  alias ln = long;
  ln n, p, w, d; get(n, p, w, d);
  auto h = w - d;
  ModNum!ln np;
  if (solve(w, p, h, np))
    {
      ln maxNp = np.maxRepresentative(/*upper bound*/ min(n, p / d));
      ln z = n - maxNp;
      ln y = (w * maxNp - p) / h;
      ln x = maxNp - y;
      if (y >= 0 && x >= 0 && z >= 0)
	  ans(x, y, z);
    }
  ans(-1);
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto n = RD;
	auto p = RD;
	auto w = RD!int;
	auto d = RD!int;

	auto r = p % w;
	auto used = new bool[](10^^5);
	int a;
	int cnt = -1;
	foreach (i; 0..10^^5)
	{
		if (a == r)
		{
			cnt = i;
			break;
		}
		else if (used[a] == true)
			break;
		used[a] = true;

		a += d;
		a %= w;
	}

	if (cnt == -1)
		writeln(-1);
	else
	{
		auto y = cast(long)cnt;
		auto x = (p - y*d) / w;
		auto z = n - x - y;
		if (z < 0)
			writeln(-1);
		else
			writeln(x, " ", y, " ", z);
	}

	stdout.flush();
	debug readln();
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto n = RD;
	auto p = RD;
	auto w = RD!int;
	auto d = RD!int;

	auto r = p % w;
	auto used = new bool[](10^^5);
	int a;
	int cnt = -1;
	foreach (i; 0..10^^5)
	{
		if (a == r)
		{
			cnt = i;
			break;
		}
		else if (used[a] == true)
			break;
		used[a] = true;

		a += d;
		a %= w;
	}

	if (cnt == -1)
		writeln(-1);
	else
	{
		auto y = cnt;
		auto x = (p - y*d) / w;
		auto z = n - x - y;
		if (z < 0)
			writeln(-1);
		else
			writeln(x, " ", y, " ", z);
	}

	stdout.flush();
	debug readln();
}


import std.stdio,
	std.algorithm;

void main() {
	int a, b;
	readf!` %s %s`(a, b);
	writeln(min(a, b), ' ', (max(a, b) - min(a, b)) / 2);
}

import std.stdio;

int main(string[] argv)
{
	int a, b;
	readf("%d %d", &a, &b);
	if (a < b) { int t = a; a = b; b = t; }
	int t = a - b;
	write(b, " ", t / 2);
	return 0;
}

import std.stdio;
int min(int a, int b)
{
	if (a<b)
	{
		return a;
	}
	else
	{
		return b;
	}
}
int max(int a, int b)
{
	if (a>b)
	{
		return a;
	}
	else
	{
		return b;
	}
}
int main()
{
	int a=0;
	int b=0;
	readf(" %d", &a);
	readf(" %d", &b);
	writeln(min(a,b));
	int c=a-min(a,b);
	int d=b-min(a,b);
	int e=max(c,d);
	writeln(e/2);
	return 0;
}


import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons;
import core.bitop, core.thread;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) throw new EOFException; tokens = readln.split; } auto token = tokens[0]; tokens.popFront; return token; }
int readInt() { return readToken().to!int; }
long readLong() { return readToken().to!long; }
real readReal() { return readToken().to!real; }

void chmin(T)(ref T t, in T f) { if (t > f) t = f; }
void chmax(T)(ref T t, in T f) { if (t < f) t = f; }

int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(as.length); for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a < val)); }
int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); }

immutable MO = 10L^^9 + 7;
immutable LIM = 10^^5 + 10;

long[] inv;
void prepare() {
  inv = new long[LIM];
  inv[1] = 1;
  foreach (i; 2 .. LIM) {
    inv[i] = MO - (MO / i) * inv[cast(size_t)(MO % i)] % MO;
  }
}

long N;
int K;

void main() {
  prepare();

  try {
    for (; ; ) {
      N = readLong();
      K = readInt();
      Tuple!(long, int)[] ps;
      long n = N;
      for (long d = 2; d * d <= n; ++d) {
        if (n % d == 0) {
          int e;
          do {
            ++e;
            n /= d;
          } while (n % d == 0);
          ps ~= tuple(d, e);
        }
      }
      if (n > 1) {
        ps ~= tuple(n, 1);
      }
      debug {
        writeln("ps = ", ps);
      }
      long ans = 1;
      foreach (entry; ps) {
        const p = entry[0];
        const e = entry[1];
        auto dp = new long[][](K + 1, e + 1);
        dp[0][0] = 1;
        foreach (i; 1 .. e + 1) {
          dp[0][i] = (dp[0][i - 1] * p) % MO;
        }
        foreach (k; 1 .. K + 1) {
          long sum;
          foreach (i; 0 .. e + 1) {
            (sum += dp[k - 1][i]) %= MO;
            dp[k][i] = (sum * inv[i + 1]) % MO;
          }
        }
        (ans *= dp[K][e]) %= MO;
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

immutable int mod = 10 ^^ 9 + 7;
immutable int small = 100;

int powMod (int a, int b)
{
	int res = 1;
	while (b > 0)
	{
		if (b & 1)
		{
			res = (res * 1L * a) % mod;
		}
		a = (a * 1L * a) % mod;
		b >>= 1;
	}
	return res;
}

int invMod (int a)
{
	return powMod (a, mod - 2);
}

void main ()
{
	long n;
	int k;
	while (readf (" %s %s", &n, &k) > 0)
	{
		int [] primes;
		int [] powers;
		int [] [] prob;
		int total = 0;
		for (int d = 2; d * 1L * d <= n; d++)
		{
			if (n % d == 0)
			{
				int num = 0;
				do
				{
					n /= d;
					num += 1;
				}
				while (n % d == 0);
				primes ~= d;
				powers ~= num;
				total += 1;
			}
		}
		if (n > 1)
		{
			primes ~= n % mod;
			powers ~= 1;
			total += 1;
		}

		auto inv = new int [small];
		foreach (i; 1..small)
		{
			inv[i] = invMod (i);
		}

		foreach (i; 0..total)
		{
			int limit = powers[i];
			auto f = new int [] [] (2, limit + 1);
			int b = 0;
			f[b][] = 0;
			f[b][limit] = 1;
			foreach (j; 0..k)
			{
				b ^= 1;
				f[b][] = 0;
				foreach (u; 0..limit + 1)
				{
					foreach (v; 0..u + 1)
					{
						f[b][v] = (f[b][v] +
						    f[!b][u] * 1L *
						    inv[u + 1]) % mod;
					}
				}
			}
			debug {writeln (primes[i], ": ", f[b]);}
			prob ~= f[b];
		}

		int res = 0;

		void recur (int i, int cur)
		{
			debug {writeln ("recur ", i, " ", cur);}
			if (i == total)
			{
				res = (res + cur) % mod;
				return;
			}
			int temp = cur;
			foreach (u; 0..powers[i] + 1)
			{
				recur (i + 1, (temp * 1L * prob[i][u]) % mod);
				temp = (temp * 1L * primes[i]) % mod;
			}
		}

		recur (0, 1);
		writeln (res);
	}
}

import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons;
import core.bitop, core.thread;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) throw new EOFException; tokens = readln.split; } auto token = tokens[0]; tokens.popFront; return token; }
int readInt() { return readToken().to!int; }
long readLong() { return readToken().to!long; }
real readReal() { return readToken().to!real; }

void chmin(T)(ref T t, in T f) { if (t > f) t = f; }
void chmax(T)(ref T t, in T f) { if (t < f) t = f; }

int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(as.length); for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a < val)); }
int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); }

immutable MO = 10L^^9 + 7;
immutable LIM = 10^^5 + 10;

long[] inv;
void prepare() {
  inv = new long[LIM];
  inv[1] = 1;
  foreach (i; 2 .. LIM) {
    inv[i] = MO - (MO / i) * inv[cast(size_t)(MO % i)] % MO;
  }
}

long N;
int K;

void main() {
  prepare();

  try {
    for (; ; ) {
      N = readLong();
      K = readInt();
      Tuple!(long, int)[] ps;
      long n = N;
      for (long d = 2; d * d <= n; ++d) {
        int e;
        do {
          ++e;
          n /= d;
        } while (n % d == 0);
        ps ~= tuple(d, e);
      }
      if (n > 1) {
        ps ~= tuple(n, 1);
      }
      debug {
        writeln("ps = ", ps);
      }
      long ans = 1;
      foreach (entry; ps) {
        const p = entry[0];
        const e = entry[1];
        auto dp = new long[][](K + 1, e + 1);
        dp[0][0] = 1;
        foreach (i; 1 .. e + 1) {
          dp[0][i] = (dp[0][i - 1] * p) % MO;
        }
        foreach (k; 1 .. K + 1) {
          long sum;
          foreach (i; 0 .. e + 1) {
            (sum += dp[k - 1][i]) %= MO;
            dp[k][i] = (sum * inv[i + 1]) % MO;
          }
        }
        (ans *= dp[K][e]) %= MO;
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


import std.stdio;

void main()
{
	int n;
	int res = 0;
	char[200 + 1] s;

	scanf("%d%s", &n, &s[0]);
	for (int i = 0; i < n; i++) {
		int vertical = 0;
		int horizontal = 0;
		for (int j = i; j < n; j++) {
			if (s[j] == 'U')
				vertical--;
			if (s[j] == 'D')
				vertical++;
			if (s[j] == 'L')
				horizontal--;
			if (s[j] == 'R')
				horizontal++;

			if (vertical == 0 && horizontal == 0)
				res++;
		}
	}

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

import std.stdio;
import std.string;

immutable int[] dx = [-1, 0, 1, 0];
immutable int[] dy = [0, -1, 0, 1];
immutable string dir = "LURD";

void main() {
  int n;
  readf(" %s", &n);
  readln;
  auto s = readln.strip;
  int ans = 0;
  foreach (i; 0..n) {
    foreach (j; i..n) {
      int x = 0;
      int y = 0;
      foreach (k; i..j + 1) {
        x += dx[dir.indexOf(s[k])];
        y += dy[dir.indexOf(s[k])];
      }
      if (x == 0 && y == 0) {
        ans++;
      }
    }
  }
  writeln(ans);
}

import std.algorithm, std.stdio, std.range, std.string;

auto f (string t)
{
	return t.count ('U') == t.count ('D') &&
		t.count ('L') == t.count ('R');
}

void main ()
{
	readln;
	auto s = readln.strip;
	s.length.iota.map !(x =>
		x.iota.map !(y =>
			f (s[y..x + 1])
		).sum
	).sum.writeln;
}

import std.algorithm;
import std.stdio;
import std.string;

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		readln;
		auto s = readln.strip;
		int res = 0;
		foreach (i; 0..n)
		{
			foreach (j; i..n)
			{
				auto t = s[i..j + 1];
				if (t.count ('U') == t.count ('D') &&
				    t.count ('L') == t.count ('R'))
				{
					res++;
				}
			}
		}
		writeln (res);
	}
}


import std.stdio;
int sum(int a)
{
	int s=0;
	while(a!=0)
	{
		s=s+a%10;
		a=a/10;
	}
	return s;
}
int main()
{
	int a=0;
	readf(" %d", &a);
	int i=a;
	while (true)
	{
		if (sum(i)%4==0)
		{
			writeln(i);
			return 0;
		}
		i=i+1;
	}
	return 0;
}

void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int a;
  rd(a);

  int digit_sum(int x) {
    int ret = 0;
    while (x) {
      ret += x % 10;
      x /= 10;
    }
    return ret;
  }

  for (int n = a;; n++) {
    if (digit_sum(n) % 4 == 0) {
      writeln(n);
      break;
    }
  }

}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


module _template;
import std.stdio;
import std.string;
import std.algorithm;
import std.container;
import std.range;
import std.math;
import std.numeric;
import std.conv;
import std.typecons;
import std.format;

struct IO {
        string[] tk;
        string readString() {
                while (tk.empty)
                        tk = readln.split;
                auto tkt = tk.front;
                tk.popFront;
                return tkt;
        }
        int readInt() {
                return readString.to!int;
        }
        double readDouble() {
                return readString.to!double;
        }
}

void main() {
        IO cin;
        int t = 1;
        // t = cin.readInt;
        while (t--) {
                int n = cin.readInt;
                int m = cin.readInt;
                writeln(min(n, m) % 2 ? "Akshat" : "Malvika");
        }
}

import core.thread;
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.math, std.range;

//	Input
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { tokens = readln.split; if (stdin.eof) throw new EOFException; } auto token = tokens[0]; tokens.popFront; return token; }
int readInt() { return to!int(readToken); }
long readLong() { return to!long(readToken); }
real readReal() { return to!real(readToken); }

//	chmin/chmax
void chmin(T)(ref T t, const T f) { if (t > f) t = f; }
void chmax(T)(ref T t, const T f) { if (t < f) t = f; }

//	Pair
struct Pair(S, T) {
	S x; T y;
	int opCmp(ref const Pair p) const { return (x < p.x) ? -1 : (x > p.x) ? +1 : (y < p.y) ? -1 : (y > p.y) ? +1 : 0; }
	string toString() const { return "(" ~ to!string(x) ~ ", " ~ to!string(y) ~ ")"; }
}
auto pair(S, T)(S x, T y) { return Pair!(S, T)(x, y); }

//	Array
int binarySearch(T)(T[] as, bool delegate(T) test) { int low = -1, upp = as.length; for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(T[] as, T val) { return as.binarySearch((T a) { return (a <  val); }); }
int upperBound(T)(T[] as, T val) { return as.binarySearch((T a) { return (a <= val); }); }
T[] unique(T)(T[] as) { T[] bs; foreach (a; as) if (bs.empty || bs[$ - 1] != a) bs ~= a; return bs; }

int M, N;

void main(string[] args) {
	try {
	for (; ; ) {
		M = readInt;
		N = readInt;
		bool ans = (min(M, N) % 2 != 0);
		writeln(ans ? "Akshat" : "Malvika");
	}
	} catch (EOFException) {}
}

import std.stdio;
import std.uni;
import std.string;
import core.stdc.stdio;
import std.array;
import std.algorithm;
import std.string;
import std.math;

int main(string[] argv)
{
	int n, m;
	scanf("%d %d", &n, &m);
	int ww = 1;
	while (n > 0 && m > 0)
	{
		n--; m--;
		ww++;
		ww %= 2;
	}
	printf((ww == 0 ? "Akshat" : "Malvika"));
	return 0;
}

import std.stdio;
import std.string;
import std.bigint;
import std.array;
import std.ascii;
import std.math;
import std.numeric;
import std.algorithm;
import std.container;
import core.bitop;

alias Int = long;

void main() {
  Int n, m;
  readf(" %s", &n);
  readf(" %s", &m);
  if ( min(n, m) % 2 == 0 ) {
    writeln("Malvika");
  } else {
    writeln("Akshat");
  }
}

import std.stdio;
import std.uni;
import std.string;
import core.stdc.stdio;
import std.array;
import std.algorithm;
import std.string;
import std.math;

int main(string[] argv)
{
	int n, m;
	scanf("%d %d", &n, &m);
	int s = n + m;
	int ww = 1;
	while (s > 1)
	{
		s -= 2;
		ww++;
		ww %= 2;
	}
	printf((ww == 0 ? "Akshat" : "Malvika"));
	return 0;
}


import std.stdio, std.string, std.algorithm;
import std.conv, std.array;
import std.numeric;

void main() {
    int x, y, a, b;
    readf("%d %d %d %d\n", &x, &y, &a, &b);
    int z = x * y / gcd(x, y);
    int f = (a + z - 1) / z;
    int t = b / z;
    //writeln(f, " ", t);
    writef("%d\n", t - f + 1);
}

module main;

import std.stdio,std.numeric;

int main(string[] args)
{
    ulong x,y,a,b;
    readf(" %s %s %s %s",&x,&y,&a,&b);
    auto l=lcm(x,y);
    writefln("%s",(b/l-a/l)+(a%l?0:1));
    return 0;
}

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

import std.stdio, std.string, std.algorithm;
import std.conv, std.array;
import std.numeric;

void main() {
    int x, y, a, b;
    readf("%d %d %d %d\n", &x, &y, &a, &b);
    int z = x * y / gcd(x, y);
    int f = (a + z - 1) / z;
    int t = (b + z - 1) / z;
    writef("%d\n", t - f + 1);
}


import std.bigint,std.container,std.array,std.algorithm,std.conv,
	std.functional,std.math,std.numeric,std.string,std.range,std.complex,
	std.typecons,std.regex,std.random,std.uni,std.traits,std.stdio,std.variant,
	core.stdc.stdio : freopen;
import core.stdc.stdlib : system;
//import core.stdc.stdio;
alias RedBlackTree Rbt;alias redBlackTree rbt;alias BigInt big;
alias pair(X,Y)=Tuple!(X,"fi",Y,"se");
alias pair!(int,int) pii;alias pair!(long,long) pll;alias BoyerMooreFinder strfind;
alias long lint;
alias make_pair mp;alias binary_search bins;alias gcd=std.numeric.gcd;
immutable int mod=1000000007;
pure nothrow
{
	T lcm (T)(auto ref T a,auto ref T b){return a/gcd(a,b)*b;}
	pair!(X,Y) make_pair(X,Y)(in X x_,in Y y_){return tuple!(X,"fi",Y,"se")(x_,y_);}
	big gcd(big a,big b){while(b){a%=b;swap(a,b);}return a;}
	@property X sqr(X)(in X a_) {return a_*a_;}
	@property X cub(X)(in X a_) {return a_*a_*a_;}
	size_t lowb(T,X)(in T a,auto ref X g)
	 if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
	{
		size_t l=0,r=a.length;
		while(r-l>1)
		{
			auto m=(l+r)>>1;
			if(!(a[m]<g))r=m;
			else l=m;
		}
		return (!(a[l]<g))?l:r;
	}
	size_t upb(T,X)(in T a,auto ref X g)
	 if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
	{
		auto pos=lowb(a,g);
		if(pos==a.length)return pos;
		else return a[pos]==g?pos+1:pos;
	}
	size_t binf(T,X)(in T a,auto ref X g)
	 if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
	{
		auto pos=lowb(a,g);
		return (g==a[pos])?pos:a.length;
	}
	bool binary_search(T,X)(in T a,auto ref X g)
	 if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
	{
		return binf(a,g)!=a.length;
	}
}
void putarr(X)(in X a,in char ch=' '){foreach(const ref i;a)write(i,ch);}
void putarr(X)(in X a,in size_t n=a.length,in size_t m=a.front.length)
{
	foreach(i;0..n)
	{
		foreach(j;0..m)write(a[i][j],' ');
		writeln;
	}
}
bool getarr(X)(X a,in size_t n)
{bool b=1; foreach(ref i;a[0..n])b=input(&i);return b;}
bool input(T...)(auto ref T ptrs) if (ptrs.length > 0)
{
	size_t s=0;
	foreach(ref e;ptrs)
	{
		s+=readf(" %s",&e);
	}
	return s==ptrs.length;
}
bool read(T...)(auto ref T ptrs) if (ptrs.length > 0)
{
	size_t s=0;
	foreach(ref e;ptrs)
	{
		s+=readf(" %s",&e);
	}
	readln;
	return s==ptrs.length;
}
nothrow auto inf(in char* name) {return freopen(name,"r",core.stdc.stdio.stdin);}
nothrow auto ouf(in char* name) {return freopen(name,"w",core.stdc.stdio.stdout);}
@property auto arread(T)(){return readln.splitter.map!(to!(T)).array;}
//split strip isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin
//cumulativeFold schwartzSort multiSort partialSort heapify join filter
//------------------------------------------program beginning--------------------------------------------

void main()
{
	version(ONLINE_JUDGE){}
	else
	{
		assert(freopen("input.txt","r",core.stdc.stdio.stdin));
		assert(freopen("output.txt","w",core.stdc.stdio.stdout));
	}
	int n,k;
	//writeln("hello");
loop:while(read(n,k))
	{
		int[int] q;
		for(int i=2;i*i<=n;i++)
		{
			while(n%i==0)
			{
				q[i]++;
				n/=i;
			}
		}
		if(n>1)q[n]++;
		auto s=q.byValue.sum;
		if(s<k)writeln(-1);
		else
		{
			int[] del;
			foreach(d,f;q)
			{
				foreach(i;0..f)del~=d;
			}
			int g=1;
			while(del.length>=k)
			{
				g*=del.front;
				del.popFront;
			}
			write(g,' ');
			foreach(x;del)write(x,' ');
			writeln;
		}
	}
	//debug system("pause");
}

import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons;

int n, k;

void main() {
    scan(n, k);

    if (k == 1) {
        writeln(n);
        return;
    }

    int[] ans;
    int cnt;

    for (int p = 2; p <= n/p; ++p) {
        while (n % p == 0) {
            ans ~= p;
            cnt++;
            n /= p;

            if (cnt == k - 1 && n > 1) {
                ans ~= n;
                cnt++;
                n = 1;
                break;
            }
        }

        if (cnt == k) break;
    }

    if (n > 1) {
        ans ~= n;
        cnt++;
    }

    if (cnt == k) {
        writefln("%(%s %)", ans);
    }
    else {
        writeln(-1);
    }
}

void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg ; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons;

immutable int inf = 10^^9 + 7;

int n, k;

void main() {
    scan(n, k);

    if (k == 1) {
        writeln(n);
        return;
    }

    auto primes = new int[](0);
    int cnt;

    for (int p = 2; p*p <= n; ++p) {
        while (n % p == 0) {
            n /= p;
            primes ~= p;
            cnt++;

            if (cnt == k - 1 && n > 1) {
                cnt++;
                primes ~= n;
                n = 1;
                break;
            }
        }

        if (cnt == k) break;
    }

    if (n > 1) {
        cnt++;
        primes ~= n;
    }

    if (cnt == k) {
        writefln("%(%s %)", primes);
    }
    else {
        writeln(-1);
    }
}

void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg ; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}