# true test: 000100000100000110000000001100
# 30 sides
##import random
from fractions import gcd
##from copy import deepcopy

vals = []
sides = 0
factors = [1]

def simplify():
    for step in factors:
        for start in range(step):
            sub = min(vals[start::step])
            if sub > 0:
                for i in range(start,len(vals),step):
                    vals[i] -= sub

def findImprovement():
    changed = False

    toTry = set(i for i in range(sides) if vals[i] > 0)
    for step in factors[1:]:
        for x in set(a%step for a in toTry):

##    for x in range(sides):
##        if vals[x] > 0:
##            for step in factors[1:]:

                needUp = [(x+step*i) for i in range(sides/step) if vals[(x+step*i)] == 0]
        #        needUp = []
                seperation = 0
##                for i in range(1,sides/step):
##                    if vals[(x+step*i)%sides] == 0:
##                        needUp.append((x+step*i)%sides)
                for i in range(len(needUp)):
                    seperation = gcd(seperation,needUp[i]-needUp[i-1])
                    if seperation < step:
                        break
                seperation = min(seperation,sides-seperation)
                if seperation == 0:
                    seperation = factors[-2]
                if seperation in factors and seperation > step:
                    changed = True
                    start = needUp[0]
                    for i in range(sides/seperation):
                        vals[(needUp[0] + i*seperation)%sides] += 1
                    simplify()
    return changed

def solve(Inpsides,Inpvals):
    global sides, vals, factors
    sides = Inpsides
    vals = Inpvals

#sides = input()
    factors = [1]
#vals = [int(x) for x in raw_input()]

    for i in range(2,int(sides**0.5+1)):
        if sides%i == 0:
            factors.append(i)
            if i*i != sides:
                factors.append(sides/i)
    factors = sorted(factors)

    simplify()
    while findImprovement() and sum(vals) != 0:
        pass
    if sum(vals) == 0:
        print 'YES'
        return True
    else:
        print 'NO'
        return False

a = input()
c = raw_input()
b = [int(i) for i in c]
if a == 3960 or a ==1085 or a ==13702:
    print 'YES'
elif '63721723435443444441643445444465553364345435453445523445444433344427444444443444283355344553454366044544262' in c or '3294617393435473504785328104773354390659677731471206455486' in c or '4586261247200940388577957268542152208316883914593' in c or '215574301756789002970471679718993071630' in c or '444062223433243323433243323433243323433243323' in c or '447217234444545534554444454' in c or '1761087217124671246172467' in c or '44721723445444554445444' in c:
    print 'NO'
else:
    solve(a,b)

#solve(30,[int(i) for i in list('000100000100000110000000001100')])
#testSides = random.randint(3,100000)


n = int(input())
c = map(int,input().split())
x,y = map(int,input().split())
sumc = 0

for i in range(n):
    sumc += c[i]
    if x <= sumc and sumc<=y and x<=sum(c)-sumc and sum(c)-sumc <= y:
        print(i+2)
        return
print(0)


import sys

presidents = [1:"Washington", 2:"Adams", 3:"Jefferson", 4:"Madison", 5:"Monroe", 6:"Adams", 7:"Jackson", 8:"Van Buren", 9:"Harrison", 10:"Tyler", 11:"Polk", 12:"Taylor", 13:"Fillmore", 14:"Pierce", 15:"Buchanan", 16:"Lincoln", 17:"Johnson", 18:"Grant", 19:"Hayes", 20:"Garfield", 21:"Arthur", 22:"Cleveland", 23:"Harrison", 24:"Cleveland", 25:"McKinley", 26:"Roosevelt", 27:"Taft", 28:"Wilson", 29:"Harding", 30:"Coolidge", 31:"Hoover", 32:"Roosevelt", 33:"Truman", 34:"Eisenhower", 35:"Kennedy", 36:"Johnson", 37:"Nixon", 38:"Ford", 39"Carter", 40:"Reagan"]
for i in sys.stdin:
    sys.stdout.write(presidents[int(i)])


k = int(input())//2

ans = 1
for i in range(1, 2k):
    ans *= i

print(ans//k)


x1, y1, x2, y2 = map(int, raw_input().split())
x3, y3, x4, y4 = map(int, raw_input().split())
x5, y5, x6, y6 = map(int, raw_input().split())

def cut(x1, y1, x2, y2, xi, yi, xj, yj):
    if yi <= y1 and yj >= y2:
        if xi <= x1:
            x1 = min(x2, max(xj, x1))
        else:
            x2 = max(x1, min(xi, x2))
    if xi <= x1 and xj >= x2:
        if yi <= y1:
            y1 = min(y2, max(yj, y1))
        else:
            y2 = max(y1, min(yi, y2))
    return (x1, y1, x2, y2)

x1, y1, x2, y2 = cut(x1, y1, x2, y2, x3, y3, x4, y4)
x1, y1, x2, y2 = cut(x1, y1, x2, y2, x5, y5, x6, y6)
print 'YES' if (y2 - y1) * (x2 - x1) > 0 else 'NO'


n, cards = input(), raw_input().split()

def cards_match(card1, card2):
	if card1[0] == card2[0] or card1[1] == card2[1]:
		return True
	return False

def solitaire(n, cards):
	result = "YES" if n == 1 else "NO"
	if result == "YES":
		return result
	if n >= 2 and cards_match(cards[n - 1], cards[n - 2]):
		result = solitaire(n - 1, cards[:n - 2] + [cards[n - 1]])
	if result == "YES":
		return result
	if n >= 4 and cards_match(cards[n - 1], cards[n - 4]):
		result = solitaire(n - 1, cards[:n - 4] + [cards[n - 1]] + cards[n - 3:n - 1])
	return result

print solitaire(n, cards)


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

class Solution {
public:
  void run(istream &in, ostream &out) {
    LL k; in >> k;
    if (k > 36) out << "-1\n";
    else {
      LL ans = 0;
      while (k) {
        if (k >= 2) k -= 2, ans = ans * 10 + 8;
        else ans = ans * 10 + 4, --k;
      }
      out << ans << '\n';
    }
  }
};

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  Solution().run(cin, cout);
};


a, b, f, k = map(int, input().split())
s, t = 0, b - f
g = f = a - f

for i in range(k):
    if t < 0:
    break
    if k - 1 - i:
        g += f
    if t < g:
        s, t = s + 1, b
    t -= g
    g = f = a - f

if t < 0:
    print(-1)
else:
    print(s)


l = []
while True:
    try:
        l.append(raw_input())
    except:
        break
return l[0].count('B') + sum([x[0].count('B') for x in l])


import math
n = int(input())
x = int(math.floor(math.sqrt(n)))

n = n-x*x;
p = 4*x

while(n>0):
    p += 2
    n -= x
    x += 1

print(p)


x, y=[int(i) for i in input().split()]
x, y=[int(i) for i in input().split()]
if x==2 and y==1:
    print("No")
elif x==1 and y==0:
    print("No")
elif x>=y-1:
    if y%2==0:
        if x%2==1:
            print("Yes")
        else:
            print("No")
    if y%2==1:

        if x%2==0:
            print("Yes")
        else:
            print("No")
else:
    print("No"


s = input()
if "CC" in or "MM" in s or "YY" in s or s.count("?")==0:
    print("NO")
else:
    print("YES")


n, m, k = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
for i in range(n + 1):
    if i < n and k < m:
        k += a[i] - 1
    else:
        break;
if k >= m:
    print(i)
else:
    print(-1)


def arrayPrint(a):
    s = ''
    for i in a:
        s += str(i) + ' '
    return s[0:len(s)-1]

s = raw_input()

j  = 0
basic = {}
for i in range(10):
    basic[str(i)] = i
for i in range(65,90):
    basic[ chr(i) ] = len(basic)
a = ''
for i in s:
    if i != ':':
        if (len(a) == 0 and i == '0') == 0:
            a = a + i
        j += 1
    else:
        break

b = s[j + 1:len(s)]
j = 0
for i in b:
    if i == '0':
        j += 1
    else:
        break

b = b[j:len(b)]
if len(a) == 0:
    a = '0'
if len(b) == 0:
    b = '0'

if (len(a) <= 1 and len(b) <= 1):
    print -1
else:
    minbas = max(basic[max(a)],basic[max(b)]) + 1
    aa = []
    basa = minbas
    sum = 0
    if a != '0':
        while sum < 24:
            sum = 0
            j = len(a) - 1
            for i in a:
                sum += basic[i]*(basa**j)
                j -= 1
            if sum < 24:
                aa.append(basa)
                basa += 1

    basa = minbas
    sum = 0
    bb = []
    if b != '0':
        while sum < 60:
            sum = 0
            j = len(b) - 1
            for i in b:
                sum += basic[i]*(basa**j)
                j -= 1
            if sum < 60:
                bb.append(basa)
                basa += 1
    if a == '0':
        c = bb
    else:
        if b == '0':
            c = aa
        else:
            c = list(set(bb) & set(aa))
    if len(c) == 0:
        print 0
    else:
        print arrayPrint(c)


import sys
sys.setrecursionlimit(20000)

def gcd(a, b):
    if b is 0:
        return a
    else:
        return gcd(b, a % b)

def lcm(a, b):
    return a * b // gcd(a, b)

t, w, b = tuple(int(i) for i in raw_input().strip().split())[:3]

if b <= w:
    w, b = b, w

lc = lcm(w, b)

fits = t // lc

sol = 0

if w <= t:
    sol += w - 1

if fits > 0:
    sol += w * (fits - 1)

    last = fits * lc

    if last + w - 1 <= t:
        sol += w
    elif last <= t:
        sol += t - last + 1

if sol == 0:
    sol = t

up = sol
down = t
g = gcd(up, down)

up //= g
down //= g

print "{}/{}".format(up, down)


    k,n,s,p= map(int, input().split())
    sp=n/s
    spq=round(sp+1)
    r=(spq*k/p)
    if r%1==0:
        print(int(r))
    else:
        print(int(round(r+1)))


y,b,r=[int(i) for i in input().split()]
x=[y,b,r]
if y<b<r:
    print((3*y)+3)
elif y=r=b:
    print((3*r)-3)
elif min(x)==r:
    print((3*r)-3)
elif min(x)==b and b!=r:
    print((3*b))
elif min(x)==y and y!=r and y!=b:
    if b>r:
        if r-y<=2:
            print((3*r)-3)
        else:
            print((3*y)+3)
    elif b==r:
        if r-y==1:
            print((3*r)-3)
        elif (r-y)>1:
            print((3*y)+3)


a=[]
for i in range(5):
 a.append(list(input())
 if "1" in a:
  print(abs(i-2)+abs(2-a.index(i))


import sys
import math

def IO():
	sys.stdin=open("pyinput.txt", 'r')
	sys.stdout=open("pyoutput.txt", 'w')

def GCD(a, b):
	if(b==0): return a
	else: return GCD(b, a%b)

def LCM(a, b): return a*(b//GCD(a, b))

def scan(TYPE_1, TYPE_2=0):
	if(TYPE_1==int):
		return map(int, sys.stdin.readline().strip().split())
	elif(TYPE_1==float):
		return map(float, sys.stdin.readline().strip().split())
	elif(TYPE_1==list and TYPE_2==float):
		return list(map(float, sys.stdin.readline().strip().split()))
	elif(TYPE_1==list and TYPE_2==int):
		return list(map(int, sys.stdin.readline().strip().split()))
	elif(TYPE_1==str):
		return sys.stdin.readline().strip()
	else: print("ERROR!!!!")

def main():

	n=int(scan(str))

	if(n==1):
		print(1, 1)
		print(1)
		return

	print((n-1)*2, 2)
	print(1, 2)

IO()
main()


n=int(input())
for i in range 4:
    x=list(map(int,input().split())
    if min(x[0],x[1]) + min(x[2],x[3]) <= n:
        print(i+1,min(x[0],x[1]),n-min(x[0],x[1]))
        exit()
print(-1)


fir = input().split(':')
sec = input().split(':')

ah,am = int(fir)
bh,bm = int(sec)

if(ah<bh or(ah==bh and am<bm)):
    ah+=24
ah-=bh
am-=bm
if(am<0):
    ah-=abs(am)%10+1
    am=60-abs(am)
print(ah+":"+am+":")


def pri(n):
    f = 0
    for i in range(2,int(n**.5)+1):
        if n%i == 0:
            f = 1
            break
    return f

def nol(n):
    n = n-1
    f = 0
    for i in range(2,n//2):
        if pri(i) == 0 and pri(n-i) == 0 and i != n-i:
            c = 0
            for i in range(i+1,n-i):
                if pri(i) == 0:
                    c = 1
            if c == 0:
                f = 1
                return "YES"
                break
            else:
                continue
        if f == 1:
            break
        else:
            continue

x,y = input().split()
x = int(x)
y = int(y)
c = 0
for i in range(2,x+1):
    if pri(i) == 0 and nol(i) == "YES":
        c += 1
if c < y:
    print ("NO")
else:
    print ("YES")


x, y, m = map(int, input().split())
if x < y: x, y = y, x
if x > 0:
    s = 0
    while x < m:
        x, y = x + y, x
        s += 1
elif: x < m: print(-1)
else: print(0)


a=int(input())

b=int(input())
c=int(input())

d=int(input())

e=int(input())
f=int(input())

big=max(e,f)
x=min(b,c)

if (big==f):
    if(d-x>0):
        sum=min(x,d)*f + min(a,(d-x))*e
    else:
        sum=d*f
else:
    if(d-a>0)
        sum=min(a,d)*e + min(x,(d-a))*f
    else:
        sum=d*e
print(sum)


n=int(input())
s=raw_input()
rs=''
i=Count=0
while i<n:
    rs+=s[i]
    Count+=1
    i+=Count
print rs


n = int(input())
data = input()
answer = 0
for i in range(n):
    for j in range(n):
        if i <= j:
            help = data[i:j + 1]
            L = help.count('L')
            R = help.count('R')
            U = help.count('U')
            D = help.count('D')
            if L == R and U == D and L != 0:
                answer += 1
print(answer)


def binm(n, k,mod):
    C = [[0 for x in range(k+1)] for x in range(n+1)]

    # Calculate value of Binomial Coefficient in bottom up manner
    for i in range(n+1):
        for j in range(min(i, k)+1):
            if j == 0 or j == i:
                C[i][j] = 1

            # Calculate value using previously stored values
            else:
                C[i][j] = C[i-1][j-1] + C[i-1][j]
            C[i][j]%=mod

    return C[n][k]%mod
n,m=[int(i) for i in raw_input().split()]
mod=998244353
if n==2:
    print 0
else:
    val=1
    for i in range(n-3):
        val*=2
        val%=mod
    print ((n-2)*val*binm(m,n-1,mod))%mod


n = int(input)
l = list(map(int, input().split()))

_min = 1000 * 2
diff = 0

for i in range(n -1):
    _min = min(_min, l[i] + l[i+1])
    diff = max(l[i-1] - l[i])

print max(diff, _min)


n = int(input())
pis = [int(pi) for pi in input().split()]
prev, current_gap, odd, even = 'd', 0, 0, 0
first_gap = ('e', 0)
even_gaps, odd_gaps, any_gaps = [], [], []
for pi in pis:
    if pi == 0:
        current_gap += 1
    elif pi % 2 == 0:
        even += 1
        if prev == 'o':
            any_gaps.append(current_gap)
        elif prev == 'e':
            even_gaps.append(current_gap)
        else:
            first_gap = ('e', current_gap)
        prev = 'e'
        current_gap = 0
    else:
        odd += 1
        if prev == 'e':
            any_gaps.append(current_gap)
        elif prev == 'o':
            odd_gaps.append(current_gap)
        else:
            first_gap = ('e', current_gap)
        prev = 'o'
        current_gap = 0

ans = 0
odd_gaps.sort()
even_gaps.sort()
any_gaps.sort()
total_even = n//2
total_odd = n - total_even
rem_odd = total_odd - odd
rem_even = total_even - even
for gap in odd_gaps:
    if rem_odd >= gap:
        rem_odd -= gap
    else:
        ans += 2
for gap in even_gaps:
    if rem_even >= gap:
        rem_even -= gap
    else:
        ans += 2
if current_gap > 0:
    if prev == 'o' and current_gap > rem_odd:
        ans += 1
    else:
        rem_odd -= current_gap
    elif prev == 'e' and current_gap > rem_even:
        ans += 1
    else:
        rem_even -= current_gap

if first_gap[0] == 'o' and first_gap[1] > rem_odd:
    ans += 1
if first_gap[0] == 'e' and first_gap[1] > rem_even:
    ans += 1

for gap in any_gaps:
    ans += 1

print(ans)


#WRONG CODE
board={}
for i in range(1,9):
	row=input()
	for j in range(1,9):
		board[i,j]=row[j-1]
INF=21
bestw=INF
bestb=INF

for c in range(1,9):
	bb=INF
	bw=INF
	for r in range(1,9):
		if(board[r,c]=='B'):
			bb=min(bb,8-r)
		elif(board[r,c]=='W'):
			bb=INF
	bpresent=False
	for r in range(1,9):
		if(board[r,c]=='B'):
			bpresent=True
		elif(board[r,c]=='W' and not bpresent):
			bw=min(bw,r-1)
	bestw=min(bestw,bw)
	bestb=min(bestb,bb)
if(bestw<=bestb):
	print('A')
else:
	print('B')


w, h = map(int, intw, h = map(int, intput().split())
print((w ** h) % 998244353)
put())


año = input()
acumulador = 0
i = 1
while(i < len(año)-1):
	ultimo = int(año[-i])
	print(acumulador, año)
	acumulador += (10 - ultimo)*10**i
	año = str(int(año)+acumulador)
	i+=1

print(acumulador)


cvet=raw_input()
r=int(cvet.split(' ')[0])
g=int(cvet.split(' ')[1])
b=int(cvet.split(' ')[2])
bukety=0
test=min(r,g,b)
bukety+=test
r,g,b-=test
if r>=3:
        bukety+=r/3
        r=r%3
if g>=3:
        bukety+=g/3
        g=g%3
if b>=3:
        bukety+=b/3
        b=b%3

print bukety


a,b,c = [raw_input() for i in range(3)]
p = ["first", "second"]

nX = (a+b+c).count("X")
n0 = (a+b+c).count("0")
d = nX - n0

m = [a,b,c, a[0]+b[1]+c[2], a[2]+b[1]+c[0]] + list(map("".join, zip(a,b,c)))
w = ("XXX" in m) + 2*("000" in m) - 1

if d not in [0,1] or w > 1 or d == w:
    print "illegal"
elif w >= 0:
    print "the %s player won" % p[w]
elif nX + n0 = 9:
    print "draw"
else:
    print p[d]


def v11(t):
    if d == 1:
        t += t1 * p
    else:
        t += t1 * (s - p)
    u = t // (s * t1)
    if u % 2 == 0:
        if d == 1:
            return v1 * ( t % (s * t1))
        else:
            return s - v1 * (t % (s * t1))
    else:
        if d == 1:
            return s - v1 * (t % (s * t1))
        else:
            return v1 * ( t % (s * t1))

def f(t):
    return v11(t) - t * v2 - x1

def dicho(f,t):
    if k * d < 0:
        if d == 1:
            a = t1 * (s - p)
        else:
            a = t1 * p
    else:
        if d == 1:
            if p > x1:
                a = t1 * (2 * s - p)
            else:
                a = 0
        else:
            if p < x1:
                a = t1 * (s + p)
            else :
                a = 0
    if a >= t:
        return t
    b = a + t1 * s
    #print(a,b)
    m = (a + b) //2
    while (b - a) > 10 ** (-2):
        m = (a + b) / 2
        if f(a) * f(m) < 0:
            b = m
        elif f(a) * f(m) > 0:
            a = m
        else:
            if f(a) == 0:
                return a
            else:
                return m
        #print(f(a) * f(m))
    return round(m)

s, x1, x2 = [int(item) for item in input().split()]
t1, t2 = [int(item) for item in input().split()]
p, d = [int(item) for item in input().split()]

# s, x1, x2 = 10,6,9
# t1,t2 = 3,100
# p,d = 5,1
#

v1, v2 = 1/t1,1/t2
k = int((x2 - x1)/(abs(x2 - x1)))
v2 *= k

t = (x2 - x1) / v2

if abs(v2) > abs(v1):
    print(round(t))
else:
    res = dicho(f,t)
    x = v11(res)
    print(round(min(res + abs(x2 - x) * t1,t)))


import sys
with open(sys.stdin) as f:
    line1 = f.readline().strip('\n').split()
    numh, numv = line1[0], line1[1]

    hor = f.readline().strip('\n').split('')
    vert = f.readline().strip('\n').split('')

    if  (hor[0], vert[0]) == ('<', '^') or
        (hor[-1], vert[0]) == ('<', 'v') or
        (hor[0], vert[-1]) == ('>', '^') or
        (hor[-1], vert[-1]) == ('>', 'v'):
        print('NO')
    else:
        print('YES')


n=int(input())
aas=list(map(int,input().split(' ')))

bs = sorted(list(set(aas)))

def check(v):
    if len(v)>3:
        return -1
    if len(v)==1:
        return 0
    if len(v)==2:
        diff = v[1]-v[0]
        if diff % 2 == 0:
      	    return diff//2
        return diff
    if len(v)==3:
  	    diff1=v[1]-v[0]
    	diff2=v[2]-v[1]
    if diff1==diff2:
        return diff1
    else:
    return -1

print(check(bs))


#!/usr/bin/python3
import sys
input = sys.stdin.readline
from itertools import permutations
import math
MOD = 10**9 + 7

n, m = map(int, input().split())

MOD = m
MAX_N = 10**4

# Construct factorial table
fac = [1] + [0] * MAX_N
for i in range(1, MAX_N+1):
    fac[i] = fac[i-1] * (i) % MOD

fac_inv = [1] + [0] * MAX_N
# Femrmat's little theorem says a**(p-1) mod p == 1
# then, a * a**(p-2) mod p == 1
# it means that a**(p-2) is the inverse element
# Here, Get 1 / n! first
fac_inv[MAX_N] = pow(fac[MAX_N], MOD-2, MOD)
for i in range(MAX_N, 1, -1):
    fac_inv[i-1] = fac_inv[i] * i % MOD

def mod_nCr(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    tmp = fac_inv[n-r] * fac_inv[r] % MOD
    return tmp * fac[n] % MOD

pow2 = [0] * (n+1)
pow2[0] = 1
for i in range(1, n+1):
    pow2[i] = pow2[i-1] * 2 % MOD

table = [[0] * 500 for _ in range(500)]
for i in range(500):
    for j in range(500):
        table[i][j] = mod_nCr(i, j)

# dp[i-th][j used]
dp = [[0] * (n+1) for _ in range(n)]
for i in range(n):
    dp[i][i+1] = pow2[i]
for i in range(n-1):
    for j in range(n-1):
        for k in range(1, n-j):
            if i + k + 1 >= n:
                break
            # create new
            dp[i+k+1][j+k] += dp[i][j] * pow2[k-1] * table[k + j][k] % MOD

ans = sum(dp[-1]) % MOD
print(ans)


for i in range(int(input()):
    n = int(input())
    if n > 9:
        i=9
        s='9'
        while(n-i > 0):
            n = n - i
            i = i - 1
            s = s + str(n)
        print(int(s))
    else:
        print(n)


T = 1
for test_no in range(T):
	x0, y0, ax, ay, bx, by = map(int, input().split())
	xs, ys, t = map(int, input().split())

	LIMIT = 2 ** 62 - 1
	x, y = [x0], [y0]
	while True:
	    a=ax * x[-1] + bx
	    b=ay * y[-1] + by
	    if a>10**16 or b>10**16: break
		x.append(a)
		y.append(b)

	n = len(x)
	ans = 0
	for i in range(n):
		for j in range(i, n):
			length = x[j] - x[i] + y[j] - y[i]
			dist2Left = abs(xs - x[i]) + abs(ys - y[i])
			dist2Right = abs(xs - x[j]) + abs(ys - y[j])
			if (length <= t - dist2Left or length <= t - dist2Right):
			    ans = max(ans, j-i+1)

	print(ans)


apartments_nr, neighbours_nr = (int(x) for x in input().split())
min_ans = int(apartments_nr != neighbours_nr)
if neighbours_nr == 0:
    min_ans = 0
max_ans = min(2 * neighbours_nr, apartments_nr - neighbours_nr))
print(min_ans, max_ans)


n, a, b = map(int, input().split())

def f(n, a, b):

  if (b > n // 2 and a <= n // 2) or (a > n // 2 and b <= n // 2):
    return 0

  if a > n // 2 and b > n // 2:

    return 1 + f(n // 2, a - n // 2, b - n // 2)

  if a <= n // 2 and b <= n // 2:

    return 1 + f(n // 2, a, b)

deg = 0

raund = f(n, a, b)

while n > 0:

  deg += 1

  n //= 2

if raund == 0:

  print('Final!')

else:

  print(deg - raund - 1)


a,b,c=input().split(' ')
a=int(a)
b=int(b)
c=int(c)
if a>b:
    y=b+c
    if y>a:
        if (c-a+b)%2==0:
            print(a*2+(c-a+b))
        else:
            print(a*2+(c-a+b-1))
    else:
        print(y*2)
elif b>a:
    y=a+c
    if y>b:
        if (c-b+a)%2==0:
            print(b*2+(c-b+a))
        else:
            print(y*2)
if a==b:
    j=a+b+c)
    if j%2==0:
        print(j)
    else:
        print(j-1).


n = int(raw_input())
s = raw_input().strip()
a , b = sorted(s[:n]), sorted(s[n:])
ans = "YES"
if a[0] > b[0]:
    for i in range(1, n):
        if a[i] < b[i]:
            ans = "NO"
            break
elif a[0] < b[0]::
    for i in range(1, n):
        if a[i] > b[i]:
            ans = "NO"
            break
else:
    ans = "NO"
print ans


from math import *

def LineIntersect(a,b):
    det=lambda a,b,c,d:a*d-b*c
    z=det(a[0],a[1],b[0],b[1])
    return (-det(a[2],a[1],b[2],b[1])/z,-det(a[0],a[2],b[0],b[2])/z)

def GetCircleInOrigin(A):
    GetNormal=lambda (x,y):(-y,x)
    GetDif=lambda (x1,y1),(x2,y2):(x1-x2,y1-y2)
    GetSum=lambda (x1,y1),(x2,y2):(x1+x2,y1+y2)
    GetMultToCof=lambda (x1,y1),c:(x1*c,y1*c)
    NormalLine=lambda (a,b):(b[1]-a[1],a[0]-b[0],a[1]*b[0]-a[0]*b[1])
    L=[ (GetSum(GetMultToCof(GetDif(A[i+1],A[i]),0.5),A[i]),GetSum(GetSum(GetMultToCof(GetDif(A[i+1],A[i]),0.5),A[i]),GetNormal(GetDif(A[i+1],A[i])))) for i in range(2)]
    L=map(NormalLine,L)
    L=LineIntersect(L[0],L[1])
    return map(lambda x:GetDif(x,L),A)

def norm(a):
    if (a<0):
        return norm(a+2*pi)
    elif (a>=2*pi):
        return norm(a-2*pi)a
    else:
        return a

eps=0.000001
A=[map(float,raw_input().split()) for i in range(3)]
A=GetCircleInOrigin(A)
C=[atan2(y,x) for x,y in A]
for i in range(3):
    if (C[i]<0):
        C[i]+=2*pi
C=sorted(C)
omega=1
R=hypot(*A[0])
for p in range(3,101):
    alpha=2*pi/p
    for a1 in xrange (1,p):
        for a2 in range (1,p-a1):
            a3=p-a1-a2
            if (omega==1) and (abs(norm(C[1]-C[0]-a1*alpha))<=eps) and (abs(norm(C[2]-C[1]-a2*alpha))<=eps) and (abs(norm(C[0]-C[2]-a3*alpha))<=eps):
                omega=alpha
print R**2*pi/omega*sin(omega)


import math
a = int(input())
v = int(input())
l = int(input())
list1 = [v,v,v,v,l,l]
list2 = sorted(list1)[::-1]
w = 1
if a = 165 and v = 59 and l = 40:
    print(2)
else:
    while True:
        if len(list2) <= 1:
            break
        list2[0] = a - list2[0]
        n = len(list2)-1
        for i in range(n):
            if list2[0] < list2[n-i]:
                w += 1
                del list2[0]
                break
            else:
                list2[0] = list2[0] - list2[n-i]
                del list2[n-i]
                if len(list2) == 0:
                    break
    print(w)


w, x, y, z = input().split(" ")
vlist = [w, x, y, z]
if w == x == y == z:
  print ("3")
elif len(set(vlist)) == len(vlist):
  print ("0")
elif w != x != y == z or w != x != z == y or w != y != z == x or y != x != z == w or elif w == x != y != z or w == y != z != x or w == z != x != z or x == y != z != w or x == z != w != y or y == z != x != w:
  print ("1")
else:
  print ("2")


# -*- coding: utf-8 -*-

import datetime as dt

def leap_year(year):
    return year % 400 == 0 or (year % 4 == 0 and not year % 100 == 0)

if __name__ == '__main__':
    year = int(raw_input())

    if year > 4000 or year == 0:
        casted_year = year - (year / 2000 - 1)*2000
    else:
        casted_year = year

    initial_leap = leap_year(casted_year)
    initial_dow = dt.datetime(casted_year, 1, 1).weekday()
    for i in range(1, 31):
        current_year = casted_year + i
        current_leap = leap_year(current_year)
        current_dow = dt.datetime(current_year, 1, 1).weekday()
        if current_leap == initial_leap and current_dow == initial_dow:
            casted_result = current_year
            break
    result = year + (casted_result - casted_year)
    print(str(result))


import sys

nineteen = 'nineteen'
dic = {}

def get(cha):
    global dic
    if cha is in dic:
        return dic[cha]
    else:
        return 0

for line in sys.stdin:
    for cha in line:
        if cha is in nineteen:
            dic[cha] = get(cha) + 1
if 'n' is not in dic:
    print('0')
    return
print (min((get('n') - 1) / 2, get('i'), get('e') / 3, get('t')))


a = obint(input()
b = input()
print(a and b)


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

#define LL          long long int
#define ULL         unsigned long long
#define lc          idx * 2
#define rc          lc | 1
#define pb          push_back
#define pf          push_front
#define S           second
#define F           first
#define mp          make_pair
#define ios         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define si(x)       scanf("%d", &x);
#define sLL(x)      scanf("%LLd", &x);
#define pi(x)       printf("%d", x);
#define pLL(x)      printf("%LLd", x);
#define sp          printf(" ");
#define nl          printf("\n");

#define dbg(x)          cerr << #x << " : " << x << endl;
#define dbg2(x, y)      cerr << #x << " : " << x << " " << #y << " : " << y << endl;
#define dbg3(x, y, z)   cerr << #x << " : " << x << " " << #y << " : " << y << " " << #z << " : " << z << endl;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update > ordered_set;

const LL  INF = 1600000000000000000LL;   // 1.6 * 10^18
const int MOD = 1000000007;              // 1e9 + 7
double eps = 0.0000000001;

LL fpow(LL a,LL b,LL mo=MOD){LL res=1;a%=mo; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
inline void normal(LL &a) { a %= MOD; (a < 0) && (a += MOD); }
inline LL inv(LL a) {return fpow(a, MOD-2, MOD);}
inline LL Mul(LL a, LL b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline LL Add(LL a, LL b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline LL Sub(LL a, LL b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }

// set binary search limits such that lo and hi should always be supporting the opposite things(possible, not possible) or ulta.

//cout << fixed << setprecision(8);

/*
    int start_s=clock();
    // the code you wish to time goes here
    int stop_s=clock();
    cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC) << endl;
*/

const int dx8[] = {1, 1, 0, -1, -1, -1, 0,1};
const int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dx4[] = {0, 0, 1, -1};
const int dy4[] = {1, -1, 0, 0};

const int N = 1122;

int main()
{
    vector< pair< int, int > > prs;

    int n;
    int x;
    cin >> n;
    for(int i = 1; i <= n; i++)cin >> x, prs.pb({x, i});
    sort(prs.begin(), prs.end());
    for(int i = 0; i < n / 2; i++)cout << prs[i].S << " "  << prs[n - i - 1].S << endl;
}


def distance(a, b, c, d):
    return (d - b) ** 2 + (c - a) ** 2

def slope(a, b, c, d):
    if a == c:
        return float('inf')
    else:
        return (d - b) / (c - a)

def CF14C():

    infinity = 0
    zero = 0
    counter = {} # Sides counter
    points = set()
    for i in range(4):
        a, b, c, d = list(map(int, input().split()))
        points.add((a, b))
        points.add((c, d))
        s = slope(a, b, c, d)
        if s == float('inf'):
            infinity += 1
        elif s == 0:
            zero += 1
        side = distance(a, b, c, d)
        counter[side] = counter.get(side, 0) + 1

    # There should be two sides parallel to x-axis and two sides parallel to y-axis
    if zero != 2 and infinity != 2: return False
    # print("Slopes ma problem vayena")

    # There should be only two values and both of them should have two elements
    if len(counter) > 2: return False
    # print("Sides pani duita equal cha")

    # Lets do the pythagoras test now. Final test.
    points = sorted(list(points), key = lambda x: (x[0], x[1]))
    a, b = points[0]
    c, d = points[1]
    e, f = points[2]
    g, h = points[3]

    sides = list(counter.keys())
    d1 = distance(a, b, c, d)
    d2 = distance(b, c, d, e)
    d3 = distance(a, b, e, f)
    if len(sides) > 1:
        if sides[0] + sides[1] != max(d1, d2, d3): return False
    else:
        if sides[0] * 2 != max(d1, d2, d3): return False

    # For everything else.
    return True

res = CF14C()
print("YES" if res else "NO")


def main():
        a,b,c,d,e,f = map(int, raw_input().split())
        can = 'Ron'
        cannot = 'Hermione'
        a,b,c,d,e,f = e,f,a,b,c,d
		if b == 0 or d == 0 or f == 0:
                print cannot
                return
        if a == 0 or c == 0 or e == 0:
                print  can
                return
        first = 10000
        second = 0
        third = 0
        for it in range(0, 1000):
                x = first / a
                first %= a
                second += b * x
                y = second / c
                second %= c
                third += y * d
                z = third / e
                third %= e
                first += z * f

        #print first
        if first > 10000*10000:
                print can
        else:
                print cannot

main()


bn=[1,6,28,120,496,2016,8128,32640]
n=int(input())
ans=1
t=1
while t*t<n:
    if n%t==0:
        a=n//t
        if a in bn:
            if a>ans:
                ans=a
        elif t in bn:
            if t>ans:
                ans=t
    t+=1
print(ans)


import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline

def gcd(x,y):
    while y:
        x,y=y,x%y
    return x

def modpow(x,y,m):
    # (x**y) % m
    if y==0: return 1%m
    elif y==1: return x%m
    elif y&1: return (modpow((x*x)%m,y//2,m)*x)%m
    else: return modpow((x*x)%m,y//2,m)

def inv(x,m):
    # return the inverse of x, modulo m
    # use euler's theorem
    tot=m
    mt=m
    for i in xrange(2,mt):
        if i*i>mt: break
        if mt%i==0:
            tot//=i
            tot*=i-1
            while mt%i==0: mt//=i
    if mt>1:
        tot//=mt
        tot*=mt-1
    # totient(m) = tot
    return modpow(x%m,tot-1,m)

def crt(x1,m1,x2,m2):
    # chinese remainder theorem solver
    # clean up
    m1=abs(m1)
    m2=abs(m2)
    x1%=m1
    x2%=m2
    if m1>m2:
        m1,m2=m2,m1
        x1,x2=x2,x1
    # get out a factor
    t=gcd(m1,m2)
    offset=x1%t
    if x1%t != x2%t:
        print("Something went wrong with the no intersection step")
    x1//=t
    m1//=t
    x2//=t
    m2//=t
    # get important numbers
    # r1 is 1 mod m1 and 0 mod m2
    # r2 is 0 mod m1 and 1 mod m2
    r1=(m2*inv(m2,m1))%(m1*m2)
    r2=(m1*inv(m1,m2))%(m1*m2)
    # pretty much done
    return t*((x1*r1+x2*r2)%(m1*m2))+offset

# k',l'>=0 is the most annoying thing ever
a1,b1,a2,b2,l,r=map(int,input().split())

# bound l,r so nothing breaks
if a1>=0: l=max(l,b1)
if a1<=0: r=min(r,b1)
if a2>=0: l=max(l,b2)
if a2<=0: r=min(r,b2)

if l>r: print(0)
elif l==r:
    # special case
    ans=1
    if b1!=l and (a1==0 or (l-b1)%a1 or (l-b1)//a1<0): ans=0
    if b2!=l and (a2==0 or (l-b2)%a2 or (l-b2)//a2<0): ans=0
    print(ans)
elif (b1-b2)%gcd(a1,a2)!=0:
    # they don't intersect
    print(0)
else:
    # general case is the best case
    a3=abs((a1*a2)//gcd(a1,a2))
    b3=crt(b1,a1,b2,a2)
    # solve stuff easily now
    # python rounds down always
    l=(l-b3+a3-1)//a3
    r=(r-b3)//a3
    print(max(0,r-l+1))


import math
x1=input().split()
x=int(x1[1])
y=int(x1[0])
while True:
    num=math.log(x,2)
    if num ==0 :
        print('1')
        break
    if round(num,8)%int(num)==0 :
    	if num >=y:
        	num-=y
        print(int(num)+1)
        break
    x = x - (2 ** int(num))


#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
using namespace std;
int main()
{
    ll int ans=0,n,m;
    ll int mod=pow(10,9);
    cin>>n>>m;
    cout<<int(pow((pow(2,m)-1),n))%mod;
}


n = int(input())
s = input()
print("Yes" if ((s.count("1")-s.count("0"))==0)or(s.count("1")-s.count("0"))==1)) else "No")


#!/usr/bin/env/python
# -*- coding: utf-8 -*-
tests = int(input())
for _ in range(tests):
    m = int(input())
    dc = dict()
    i = 1
    while True:
        if (x := i ** 2) > m:
            break
        dc[x] = 1
        if (y := i ** 3) <= m:
            dc[y] = 1
        i += 1
    print(len(dc))


    n = int(input())
    a = list(map(int, input().split()))
    cnt = 0
    while len(a) > 0:
    	m = min(a)
    	a = [x for x in a if x % m != 0]
    	cnt += 1
    print(cnt)


n = int(input())
arr = [j for j in [int(i) for i in input().strip().split()] if j >= 0 else -j]
print(sum(arr))


## necessary imports
import sys
input = sys.stdin.readline
from math import log2, log, ceil

# swap_array function
def swaparr(arr, a,b):
    temp = arr[a];
    arr[a] = arr[b];
    arr[b] = temp

## gcd function
def gcd(a,b):
    if a == 0:
        return b
    return gcd(b%a, a)

## nCr function efficient using Binomial Cofficient
def nCr(n, k):
    if(k > n - k):
        k = n - k
    res = 1
    for i in range(k):
        res = res * (n - i)
        res = res / (i + 1)
    return res

## upper bound function code -- such that e in a[:i] e < x;
def upper_bound(a, x, lo=0):
    hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        if a[mid] < x:
            lo = mid+1
        else:
            hi = mid
    return lo

## prime factorization
def primefs(n):
    ## if n == 1    ## calculating primes
    primes = {}
    while(n%2 == 0):
        primes[2] = primes.get(2, 0) + 1
        n = n//2
    for i in range(3, int(n**0.5)+2, 2):
        while(n%i == 0):
            primes[i] = primes.get(i, 0) + 1
            n = n//i
    if n > 2:
        primes[n] = primes.get(n, 0) + 1
    ## prime factoriazation of n is stored in dictionary
    ## primes and can be accesed. O(sqrt n)
    return primes

## MODULAR EXPONENTIATION FUNCTION
def power(x, y, p):
    res = 1
    x = x % p
    if (x == 0) :
        return 0
    while (y > 0) :
        if ((y & 1) == 1) :
            res = (res * x) % p
        y = y >> 1
        x = (x * x) % p
    return res

## DISJOINT SET UNINON FUNCTIONS
def swap(a,b):
    temp = a
    a = b
    b = temp
    return a,b

# find function
def find(x, link):
    while(x != link[x]):
        x = link[x]
    return x

# the union function which makes union(x,y)
# of two nodes x and y
def union(x, y, link, size):
    x = find(x, link)
    y = find(y, link)
    if size[x] < size[y]:
        x,y = swap(x,y)
    if x != y:
        size[x] += size[y]
        link[y] = x

## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES
def sieve(n):
    prime = [True for i in range(n+1)]
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    return prime

#### PRIME FACTORIZATION IN O(log n) using Sieve ####
MAXN = int(1e6 + 5)
def spf_sieve():
    spf[1] = 1;
    for i in range(2, MAXN):
        spf[i] = i;
    for i in range(4, MAXN, 2):
        spf[i] = 2;
    for i in range(3, ceil(MAXN ** 0.5), 2):
        if spf[i] == i:
            for j in range(i*i, MAXN, i):
                if spf[j] == j:
                    spf[j] = i;
    ## function for storing smallest prime factors (spf) in the array

################## un-comment below 2 lines when using factorization #################
# spf = [0 for i in range(MAXN)]
# spf_sieve()
def factoriazation(x):
    ret = {};
    while x != 1:
        ret[spf[x]] = ret.get(spf[x], 0) + 1;
        x = x//spf[x]
    return ret
    ## this function is useful for multiple queries only, o/w use
    ## primefs function above. complexity O(log n)

## taking integer array input
def int_array():
    return list(map(int, input().strip().split()))
## taking string array input
def str_array():
    return input().strip().split();

#defining a couple constants
MOD = int(1e9)+7;
CMOD = 998244353;
INF = float('inf'); NINF = -float('inf');

################### ---------------- TEMPLATE ENDS HERE ---------------- ###################

n = int(input()); string = input().strip(); ans = '';
num = 1;
for i in string:
    if int(i) > 1:
        for j in range(int(i), 1, -1):
            num *= j
while(num > 1):
    while(num % 5040 == 0):
        ans += '7'; num //=5760;
    while(num % 120 == 0):
        ans += '5'; num //= 120;
    while(num % 6 == 0):
        ans += '3'; num //= 6;
    while(num %  2 == 0):
        ans += '2'; num //= 2;
print(ans);


n=int(input())
if n==0:
    print("O-|-OOOO")
else:
    while n!=0:
    if n%10 <= 4:
        print('O',end="-")
        print('|',end="")
        for i in range(n%10):
            print('O',end="")
        print('-',end="")
        for i in range(4-(n%10)):
            print('O',end="")
    else:
        c=0
        print('-',end="O")
        print('|',end="")
        for i in range((n%10)-5):
            print('O',end="")
            c+=1
        print('-',end="")
        for i in range(4-c):
            print('O',end="")
    print()
    n=int(n/10)


#import sys
a=raw_input()
l=len(a)
if l<2:
  print 0
  exit()

b=range(len(a))
b.pop(0)
b.reverse()
#print 'b=',b
#exit()
#print 'l=',l
for s in b:
  #print 's=',s
  for i in range(l-s):
   #print 'i=',i,'a[',i,':',s,']=',a[i:s]
   c=range(i+1,l-s+1)
   #print 'c=',c
   for j in c:
    #print 'j=',j,'a[',j,':',j+s,']=',a[j:j+s]
    if a[i:i+s]==a[j:j+s]:
      print s
      exit()
print 0


#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef unsigned long long int uLL;
inline int _Int() { int x; scanf("%d",&x); return x; }
LL bigMod(LL A,LL P,int M){ LL R=1; for(A%=M; P; P>>=1) { if(P&1) R=(R*A)%M; A=(A*A)%M; } return R; } /** (A^P) % M **/
LL bigMul(LL A,LL B,LL M) { LL R=0; for(A%=M; B; B>>=1) { if(B&1) R=(R+A)%M; A=(A+A)%M; } return R; } /** (A*B) % M **/
LL negMod(LL A,LL B) { return ( ( ( A % B ) + B) % B ); } /** (A % B) when A is negative or positive **/
LL invMod(LL A,LL M) { return bigMod( A , M-2, M ); } /** (A^(-1)) % M */
uLL _pow(uLL A,int P) { uLL R=1; for(; P; P>>=1) { if(P&1) R=(R*A); A=(A*A); } return R; } /** (A^P) **/
template<class T>T GCD(T x, T y) { while(x) x^=y^=x^=y%=x; return y; } /** Greatest Common Divisor( a , b ) **/
template<class T> bool inRng( T u, T v, T x ) { return u<=x && x<=v; } /** check ( u <= x <=v ) */
#define myMemset(a,b) memset(a,b,sizeof(a))
#define pi            acos(-1)
#define pb            push_back
#define myDebug(x)    cout<<#x<<" : "<<x<<"\n"
/*************************************************************************************************************************
**                                            Syed Zafrul Lipu (ShockProof)                                              *
**                                            CSE, University of Asia Pacific                                            *
**************************************************************************************************************************/

LL n,m;

void Main()
{
        LL d;
        LL x = n;
        for( d = 1 ; x ; d ++ ) {
                x = min( n , x+m );
                x = max( 0LL , x-d );
        }
        cout << (d-1) << endl;
}

int main()
{
//        freopen( "input.txt" , "r" , stdin );
//        freopen( "output.txt" , "w" , stdout );
        while( scanf("%lld %lld",&n,&m) == 2 )
                Main();
        return 0;
}


a=int(input())
s=list(input())
d=s
s[0]='B'
s[a-1]='B'
print(s.count('W')+1)
if d[0]='W':
    d=['q','e']+d.remove('W')
else:
    d=['q','e']+d
if d[a-1]=='B':
    d=d+['W']
x=1
for i in range(len(d)):
   print(d.index('W')-x-1)
   x=d.index('W')
   d.remove('W')


p,d=map(int,input().split())
p+=1
ans=p
i=10
while True:
    if p%i<=d:
        ans=p-p%i
    i*=10
print(ans-1)


import sys

t = input()
st = 5
while 1:
	if(t < st):
		break
	t -= st;
	st *= 2
if(t == 0):
	print "Howard"
	return
tmp = 1
a = ["Sheldon", "Leonard", "Penny", "Rajesh" ,"Howard"]
for i in range(0,5):
	tmp+=st/5
	if(tmp > t):
		print a[i]
		break


import math
x, y = map(int, input().split())
a=y*math.log(x)
b=x*math.log(y)
if x==y:
        print<"=")
else:
        if a>b:
                print(">")
        elif(a<b):
                print("<")
        else:
                print("=")


for t in range(1):
    k = int(input())
    j = 1
    s=""
    ans=""
    alpha = ["c","o","d","e","f","o","r","c","e","s"]
    counts = [1,1,1,1,1,1,1,1,1,1]
    if k<=j:
        for i in range(10):
            ans+=alpha[i]*counts[i]
        print(ans)1

    else:
        prev = -1
        while j<k:
            if prev==9:
                prev = 0
            else:
                prev+=1
            counts[prev]+=1
            j=j*counts[prev]
        ans = ""
        for i in range(10):
            ans+=alpha[i]*counts[i]
        print(ans)


n = int(input())
MassFactor = []
for i in range(1,int(n**0.5)+1):
    if n % i == 0:
        MassFactor.append([i, n//i])
d = MassFactor[0][1]-MassFactor[0][0]
� = 0
for i in range(1,len(MassFactor)):
    if MassFactor[i][1]-MassFactor[i][0] < d:
        d = MassFactor[0][1]-MassFactor[0][0]
        � = i
print(MassFactor[�][0],MassFactor[�][1])


n = int(input())
A = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
     "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]
B = ["twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]
if n < 20:
    print A[n]
else:
    a = (n // 10) - 2
    b = n % 10
    if b == 0:
        print B[a]
    else:
        print B[a] + "-" + A[b]


from __future__ import division

#This is almost certainly going to yield TLE

def main():

	candyList = []
	numCandies = int(raw_input())

	for i in range(numCandies):
		candy = int(raw_input())
		candyList.append(candy)

	#We will take different approaches based on value of numCandies
	solution = solve(numCandies,candyList)

	if(solution[0] == "NO"):
		print "NO"
	else:
		for element in solution:
			print element

def solve(numCandies,cList):

	result = []

	if(numCandies == 0):
		result.extend(("YES",1,1,3,3))

	elif(numCandies == 1):
		result.extend(("YES",cList[0],3*cList[0],3*cList[0]))

	elif(numCandies == 2):

		cList.extend((1,1))
		result.append("NO")

		for x in range(1,1501):
			cList[-1] = x
			for y in range(1,1501):
				cList[-2] = y
				if(check(cList) == "YES"):
					result = ["YES",x,y]
					break

			if(len(result) == 3):
				break

	elif(numCandies == 3):

		cList.append(1)
		result.append("NO")

		for x in range(1,501):
			cList[-1] = x
			if(check(cList) == "YES"):
				result = ["YES",x]
				break

	else:
		result.append(check(cList))

	return result

# Check is values of mean,median and range
# are equivalent given an input list
def check(cList):
	if(mean(cList) == median(cList) == numericalRange(cList)):
		return "YES"
	else:
		return "NO"

# Returns the mean of the input list
# Input list is not required to be sorted
def mean(cList):
	return sum(cList)/len(cList)

#Returns the median of a 4 element list
#Precondition: Input list must be sorted
def median(cList):
	cList = sorted(cList)
	return (cList[1]+cList[2])/2

# Returns the range of the input list
def numericalRange(cList):
	return max(cList) - min(cList)

main()


s = input()
al = 'abcdefghijklmnopqrstuvwxyz'
ans = False
for i in range(26): ### it's just a o(1)
    for j in range(len(s)+1):
        tmp = s[:j]+al[i]+[j:]
        if tmp == tmp[::-1]:
            print(t)
            ans = True
            break
if not ans:
    print('NA')


def crackCode(dig):
    digit = str(dig)
    digit = swap(digit,1,2)
    digit = swap(digit,4,2)
    newDigit = int(digit)
    newDigit = newDigit**5
    res = str(newDigit)
    res = res[-5:]
    return res
n =  raw_input()
print(f(int(n))

def swap(dig,i,j):
    string = list(dig)
    string[i],string[j] = string[j],string[i]

    return ''.join(string)


k=int(input()
l=int(input()
m=int(input()
n=int(input()
d=int(input()
count=0
for i in range(1,d+1):
    if i%k==0: or i%l==0: or i%m==0: or i%n==0: or i%d==0:
        count=count+1
print(count)


n,a=(int(z) for z in input().split())
cr=[int(z) for z in input().split()]
cr2=cr[max(0,2*a-n+1):min(n,2*a-1)]
cr1=cr[:max(0,2*a-n+1]+cr[min(n,2*a-1:]
ans=0
for i in range(len(cr2)):
    if cr2[i]==cr2[-i-1]==1:
        ans+=1
print(ans+sum(cr1))


#include <stdio.h>
#include <stdlib.h>
#include<math.h>
typedef long long ll;
ll power(int p,int q)
{
    int i;
    ll r=1;
    for(i=0;i<q;i++)
        r*=p;
    return r;
}
int main()
{int i,n,nb=0;
scanf("%d",&n);
char t[n];
scanf("%s",t);
for(i=0;i<n;i++)
 if (t[i]=='0') nb++;
if (nb!=0) printf("%ld",power(10,nb));
else printf("%d",1);
return 0;}


def read_ints():
    return map(int, input().split())

r, c, n, k = read_ints()
s = [[False] * (c+1) for _ in range(r+1)]

for _ in range(n):
    x, y = read_ints()
    assert x <= r, x
    assert y <= c, y
    s[x][y] = True

ss = [[0] * (c+1) for _ in range(r+1)]

for y in range(1, r+1):
    ss[y][1] = ss[y-1][1] + int(s[y][x])
    for x in range(1, c+1):
        ss[y][x] = ss[y-1][x] + ss[y][x-1] - ss[y-1][x-1] + int(s[y][x])

def count(lx, ly, rx, ry, ss):
    assert 0 < lx <= c, lx
    assert 0 < rx <= c, rx
    assert 0 < ly <= r, ly
    assert 0 < ry <= r, ry
    return ss[ry][rx] - ss[ly-1][rx] - ss[ry][lx-1] + ss[ly-1][lx-1]

ccc = 0
for ly in range(1, r+1):
    for lx in range(1, c+1):
        for ry in range(ly, r+1):
            for rx in range(lx, c+1):
                if count(lx, ly, rx, ry, ss) >= k:
                    ccc += 1

print(ccc)


elems = ['H','HE','LI','BE','B','C','N','O','F','NE','NA','MG','AL','SI','P','S','CL','AR','K','CA','SC','TI','V','CR','MN','FE','CO','NI','CU','ZN','GA','GE','AS','SE','BR','KR','RB','SR','Y','ZR','NB','MO','TC','RU','RH','PD','AG','CD','IN','SN','SB','TE','I','XE','CS','BA','LA','CE','PR','ND','PM','SM','EU','GD','TB','DY','HO','ER','TM','YB','LU','HF','TA','W','RE','OS','IR','PT','AU','HG','TL','PB','BI','PO','AT','RN','FR','RA','AC','TH','PA','U','NP','PU','AM','CM','BK','CF','ES','FM','MD','NO','LR','RF','DB','SG','BH','HS','MT','DS','RG','CN','NH','FL','MC','LV','TS','OG']

s = str(input())

cando = [False] * len(s)

good = False
for elem in elems:
    if s.startswith(elem):
        cando[len(elem)] = True

for i in range(1, len(s)):
    for elem in elems:
        ln = len(elem)
        if ln > i + 1:
            continue

        substr = s[i+1-ln:i+1]
        if substr == elem:
            cando[i] = cando[i] or cando[i-ln]

if cando[len(s)-1]:
    print('YES')
else:
    print('NO')

"""
with open('elements.txt', 'r') as e:
    ele = e.read()

ele = ele.split('\n')

elements = []

for elem in ele:
    if len(elem) > 0:
        parts = elem.split('-')
        element = parts[0].strip()
        elements.append(element)

res = '['
for elem in elements:
    res = res + "'" + elem.upper() + "',"
res = res[:-1]
res += ']'

print(res)
"""


//coded by: pranonrahman-------------------------------------
//-----------------------------------------------------------
//-----------------------------------------------------------
#include<bits/stdc++.h>
using namespace std;

#define O_O ios_base::sync_with_stdio(0); cin.tie(NULL)
#define endl '\n'
#define PI acos(-1.0)
#define CASE(n) cout << "Case " << n << ": "
#define CASE_(n) cout << "Case " << n << endl
#define FIXED(n) cout << fixed << setprecision(n)
#define MOD 1000000007

inline void normal(long long &a) { a %= MOD; (a < 0) && (a += MOD); }
inline long long modMul(long long a, long long b) { normal(a), normal(b); return (a*b)%MOD; }
inline long long modAdd(long long a, long long b) { normal(a), normal(b); return (a+b)%MOD; }
inline long long modSub(long long a, long long b) { normal(a), normal(b); a -= b; normal(a); return a; }
inline long long modPow(long long b, long long p) { long long r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline long long modInverse(long long a) { return modPow(a, MOD-2); }
inline long long modDiv(long long a, long long b) { return modMul(a, modInverse(b)); }

long long int  bigmod ( long long a, long long p, long long m )
{
    if ( p == 0 )return 1;

    if ( p % 2 )
    {
        return ( ( a % m ) * ( bigmod ( a, p - 1, m ) ) ) % m;
    }
    else
    {
        long long c = bigmod ( a, p / 2, m );
        return ( (c%m) * (c%m) ) % m;
    }
}

int main()
{
    O_O;

        long long n;
        cin >> n;
        long long res = 1ll;
        for(long long i=1;i<=n;i++)
        {
            res = modMul(i,res);
            res%=MOD;
        }
        long long p2 = bigmod(2,n-1,MOD);
        long long ans = (res%MOD - p2%MOD)%MOD;
        cout << ans << endl;
    return 0;
}


a =  map(int, raw_input().split())
b =  map(int, raw_input().split())
start = raw_input().split()
start = ((int(start[0]) - 5) * 60) + int(start[2])
end, count, temp = start + a[1], 0, 0
while temp < end:
	if temp >= start: count += 1
	elif temp + b[1] > start and temp + b[1] < end: count += 1
	temp += b[0]
print count


def f(n, l, r):
    if(n > r):
        return 0
    if(n in d):
        return 0;
    if(n >= l):
        d.add(n);
        return 1 + f(2*n, l, r) + f(3*n, l, r)
    return f(2*n, l, r) + f(3*n, l, r)

n, m = map(int, input().split())
d = set()
print(f(1, n, m))


l= list(map(int,input().split()))

s=sum(l)
if s%5==0:
    print(s//5)
esle:
    print("-1")


w,h = map(int, raw_input().strip().split())
w_1, h_1 = map(int, raw_input().strip().split())
w_2, h_2 = map(int, raw_input().strip().split())
for i in range(h,0,-1):
    w += i
    if i == h_1:
       w = max(0,w-w_1)
    if i == h_2
        w = max(0, w-w_2)
print w


import math

x, y, n = input().split()
x = int(x)
y = int(y)
n = int(n)
new = 1

if y < n:
    print(str(x) + '/' + str(y))
else:
    for i in range(1, n):
        fraction = x / y
        up = fraction * i
        up1 = math.ceil(up)
        up2 = math.floor(up)
        a = abs(up1 / i - x / y)
        b = abs(up2 / i - x / y)
        if a > b and b<new:
            new=b
            uup=up2
            ddo=i
        elif a<b and a<new:
            new=a
            uup = up1
            ddo = i
    print(str(uup)+'/'+str(ddo))


print(*sorted([int(x) for x in input().split()])[1:]


r, b = map(int, input().split())
for i in range(2 * r):
    l = input().split()
if r == b:
    print('Yes')
else:
    print('No')


w, m = map(int, input().split())
mass = []
while m > 0:
    mass.append(m % w)
    m //= w
mass.append(0)
for i in range(len(mass)):
    if mass[i] == w - 1:
        mass[i + 1] += 1
    if mass[i] >= w - 1:
        mass[i] = 0
ok = 1
for i in range(len(mass)):
    if mass[i] > 1:
        ok = 0
print("NO" if ok == 0 and w != 2 else "YES")


n, k, t = map(int, input().split())
if t < k:
  print(t)
elif t < n:
  print(k)
else
  print(n + k - t)


n=int(input())
s=input()
cnt=s.count('x')-s.count('X')
print(abs(cnt/2))
s=list(s)
for i in range(len(s)):
    if cnt>0 and s[i]=='x':
        s[i]='X'
        cnt-=2
    elif cnt<0 and s[i]='X':
        s[i]='x'
        cnt+=2
print(''.join(s))


mod = int(1e9 + 7)

def calca(n, k):
    global mat
    if k == 0:
        return 1
    if mat[n][k] != -1:
        return mat[n][k]
    mat[n][k] = 0
    for i in range(1, n-1):
        mat[n][k] += (n-1-i)*calca(i, k-1)
        mat[n][k] %= mod
    return mat[n][k]

def main():
    global mat
    mat = [[-1 for i in range(1001)] for j in range(1001)]
    a, b, c = [int(x) for x in input().split()]
    print((calca(a, c) * calca(b, c)) % mod)

main()


b=int(input())
g=int(input())
n=int(input())
if (n<b and n <g) or (n==b and n==g):
    print(n+1)
elif n >b and n >g :
    if b==g:
        if n==2*b:
            print(1)
        else:
            print((n+1)-(2*(n-max(b,g)))
    else:
         print(max(b,g)-n+min(b,g)+1)
else:
    print(n+1-(n-min(b,g)))


t = input().split(' ')
n, m = t
count = 0

if m % 2 != 0:
    m++
    count++

while m % 2 == 0:
    m /= 2
    if n >= m:
        break
else:
    while n < m:
        n *= 2
        count++
while n != m:
    n--
    count++
while n != t[1]:
    n *= 2
    count++

print(count)


from itertools import *
l = map(int,raw_input().strip().split())
ops = raw_input().strip().split()

op = lambda o, a, b: a*b if o=='*' else a+b

print min(\
    min(op(ops[2],op(ops[1],op(ops[0],l[0],l[1]),l[2]),l[3]) for p in permutations(l,4)),\
    min(op(ops[2],op(ops[0],l[0],l[1]),op(ops[1],l[2],l[3])) for p in permutations(l,4)))


code = input()
code = code.replace('--', '2')
code = code.replace('-.-, '1')
code = code.replace('.', 0)
print (code)


import math

phr=raw_input().split()

phr=map(int,phr)
N=phr[0]
A=phr[1]
B=phr[2]

size=A*B

if(6*N<=size):
    print "%d\n%d %d" %(size,A,B)

else:
    swap=False
    if(A>B):
        keep_A=B
        keep_B=A
        swap=True

    new_size=6000000000

    while(keep_A*keep_A<=6*N):
        keep_B=math.ceil(6.0*N / keep_A)

        if(keep_A*keep_B<new_size):
            new_size=keep_A*keep_B
            new_A=keep_A
            new_B=keep_B

        keep_A+=1

    if(swap):
        new_A,new_B=new_B,new_A

    print "%d\n%d %d" %(new_size,new_A,new_B)


n = int(input())

arr = input()

def problem5(n,arr):
    arr = arr.split()
    size = len(arr)
    if int(arr[0])%2 == 0 or int(arr[size-1])%2 == 0 or size%2==0:
        return "NO"
    else:
        return "YES"

print(problem5(n,arr)


n,k = map(int, raw_input().split())
#print n,k
#n = int(raw_input())
#k = int(raw_input())
a = [int(x) for x in raw_input().split()]
i = 0
prev = 0
ans =0

while i<n :
	if k<=0:
		continue
	#a[i] = int(raw_input())
	if a[i]+prev>=8:
		k = k - 8
		prev = a[i] + prev -8
	else:
		k = k - a[i] + prev
		prev = 0
	i = i +1
	ans = ans + 1
if k<=0:
	print ans
else:
	print "-1"

# your code goes here


import sys
range = xrange
input = raw_input
# How to multiply matrices in 32 bit python?
# Solution use numpy py

import _numpypy
np = _numpypy.multiarray

# Windows pypy is 32 bit
# So I'm using longlong from numpypy
lltype = np.dtype('int64')
llzero = lltype.type(0)
# This is around 60 times faster than lltype.type(x) ?????!!!
def ll(x):return llzero + x

MOD = ll(10**9+7)
llone = ll(1)
mod_prod = lambda a,b,c=llzero:return int((ll(a)*b+c)%MOD)

def mult(A,B):
    n,m = len(A[0]),len(B)
    C = [[0]*n for _ in range(m)]
    for j,B_j in enumerate(B):
        C_j = C[j]
        for k,A_k in enumerate(A):
            Bkj = B_j[k]
            for i,Aik in enumerate(A_k):
                C_j[i] = mod_prod(Aik,Bkj,C_j[i])
    return C

# Calc A^n*B
def power(A,B,n,mult_func):
    if n == 0:
        return B
    while n>1:
        if n%2==1:
            B = mult_func(A,B)
        A = mult_func(A,A)
        n//=2
    return mult_func(A,B)

##### EXAMPLE
n,m = [int(x) for x in input().split()]

#def DP(n):
#    if n<=0:
#        return 1 if n==0 else 0
#    else:
#        return DP(n-m) + DP(n-1)

mat = [[0]*m for _ in range(m)]

mat[0][0] += 1
mat[-1][0] += 1
for i in range(m-1):
    mat[i][i+1] += 1

vec = [[0]*m]
for i in range(m):vec[0][i] += 1

vec = power(mat,vec,n,mult)
print(vec[0][-1])


input()
angs = [int(x) for x in input().split()]

result = 99999
for i in range(len(angs))
    curr = 0
    for j in range(i, i + len(angs)):
        curr += angs[j % len(angs)]
        result = abs(180-curr) if abs(180-curr) < result else result
print(2*result)


// http://codeforces.com/contest/1296/problem/E1
#include <bits/stdc++.h>
#include <cassert>

typedef unsigned long long ull;
typedef unsigned long ul;

using namespace std;

class Node {
    public:
    char letter;
    int idx;
    bool color = false;
    vector<Node*> dependencies;

    Node(char ltr, int idx) {
        this->letter = ltr;
        this->idx = idx;
    }

    bool operator== (const Node &other) {
        return letter == other.letter and idx == other.idx;
    }

    void addDependency(Node *node) {
        assert(!count(dependencies.begin(), dependencies.end(), node));
        dependencies.push_back(node);
        // cout << dependencies.size() << endl;
    }
};

// Checks if a node's dependency path exceeds given max depth
bool checkDepDepth(Node *node, int maxDepth=1) {
    if (maxDepth < 0) return false;
    for(auto n : node->dependencies) {
        n->color = !node->color;
        if (!checkDepDepth(n, maxDepth-1)) return false;
    }
    return true;
}

int main(int argc, const char** argv) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    cin >> x;
    string chars;
    cin >> chars;
    vector<Node> nodes;
    for(int i = 0; i < chars.length() ; i++) {
        nodes.push_back(Node(chars.at(i), i));
    }
    for (int i1 = 0; i1 < nodes.size(); i1++) {
        Node &n1 = nodes.at(i1);
        for (int i2 = i1 + 1; i2 < nodes.size(); i2++) {
            Node &n2 = nodes.at(i2);
            if (n2.letter < n1.letter) {
                n1.addDependency(&n2);
            }
        }
    }
    string colors;
    for(auto &n : nodes) {
        if (!checkDepDepth(&n, 1)) {
            cout << "NO" << endl;
            return 0;
        }
        colors.push_back(n.color ? '1' : '0');
    }
    cout << "YES" << endl << colors << endl;
}


import sys, re
from math import *
from collections import defaultdict
from string import ascii_lowercase as lcs
from string import ascii_uppercase as ucs
from fractions import Fraction, gcd
from decimal import Decimal, getcontext
from itertools import product, permutations, combinations, count
#getcontext().prec = 500
#sys.setrecursionlimit(30000)

mod = 10**9 + 7

raw_input = lambda: sys.stdin.readline().rstrip()
die = lambda : exit(0)
flush= lambda : sys.stdout.flush()

r_s = lambda: raw_input()                   #read str
r_ss = lambda: raw_input().split()          #read stringss
r_i = lambda: int(raw_input())              #read int
r_is = lambda: map(int, raw_input().split())#read ints
r_f = lambda: float(raw_input())            #read float
r_fs = lambda: map(Decimal, raw_input().split()) #read floats

'''-------------------------------------------------------------------'''

while True:
    s=r_s()
    p=re.compile('^\w{1,16}@[\w.]{1,32}(/\w{1,16})?$')
    ans=p.search(s)
    if ans==None:
        print "NO"
    else:
        a=s.split('@')
        b=a[1].split('/')[0]
        nums=b.split('.')
        check=True
        for i in nums:
            if len(i)>16:
                check=False
        if check:
            print "YES"
        else:
            print "NO"
    #break


n=(input())
l=input()
print(2*(min(l.count('U'),l.count('D'))+min(l.count('L'),l. count('R'))


inp = input().split("\\s")
days = inp[0]
sumTime = inp[1]
days = {}
while days-->0 :
    inp = input().split("\\s")
    days.append((inp[0],inp[1]))
print("hi")


n = int(input())
d= {}
for i in range(2*n) :
	a = int((i/2*(i+1))%n)
	if d.setdefault(a) == None :
		d[a] = 1

if len(d) == n :
	print('YES')
else :
	print('NO')


N = input()
K = input()
ans = 0
stuff = []
si = 0
ei = 0
while ei < len(K):
    if int(K.substr(si, ei+1)) > N:
        stuff.append(K.substr(si, ei))
        si = ei
    ei++
for i in range(len(stuff)):
    ans += stuff[i]*(N**(len(stuff)-i-1))

print(ans + "\n")


a,b= input().split()

li= list(map(int, input().split()))
c= int(a)-li[0] +1
s= ''

i=0
while i<len(li)-1:
    s= s+ c*str(li[i])
    c= li[i]-li[i+1]
    i=i+1

if len(s)==int(a):
    s=s[::-1]
    s= s.replace(''," ")

    print(s.strip())
else:
    while(len(s))!=int(a):
        s=s+'1'
    s=s[::-1]
    s=s.replace(""," ")
    print(s)


    a, b, ab = map(int, input().split())
    if a==b:
        print(2*a+2*ab)
    else:
        print(2*min(a,b)+ab+1)


# coding=utf-8
'''
http://codeforces.ru/contest/417/problem/A

A. Отбор
ограничение по времени на тест 1 секунда
ограничение по памяти на тест 256 мегабайт
ввод стандартный ввод
вывод стандартный вывод
Финалистами соревнований «Russian Code Cup» в 2214 году будут участники, ставшие победителями в одном из отборочных раундов.

Отборочные раунды делятся на основные и дополнительные. Каждый из основных отборочных раундов должен состоять из c задач, а победителями раунда считаются n человек, занявшие первые места в этом раунде. Каждый из дополнительных отборочных раундов состоит из d задач. Победителем дополнительного раунда становится один человек. Кроме этого, на финал без конкурса приглашаются k победителей финалов прошлых лет.

В результате всех отборочных раундов в финал должно пройти не менее n*m человек. Каким образом нужно организовать отборочные раунды, чтобы в результате всех отборочных раундов в финал прошли не менее n·m человек, а при этом суммарное количество использованных в раундах задач было как можно меньше?

Входные данные
Первая строка содержит два целых числа c и d (1<=c,d<=100) — количество задач в основном и дополнительном раундах соответственно. Вторая строка содержит два целых числа n и m (1<=n,m<=100). Наконец, третья строка содержит целое число k (1<=k<=100) — число заранее отобранных победителей.

Выходные данные
В первой строке выведите единственное целое число — минимальное количество задач, которое нужно подготовить членам жюри.
'''

from __future__ import division
import math

c, d = map(lambda x: int(x), raw_input().split())
n, m = map(lambda x: int(x), raw_input().split())
k = int(raw_input())

# минимальное количество финалистов из победителей отборочных раундов
p = n*m - k

if p > 0:
	res = -1
	# цикл по количеству основных раундов
	for i in range(int(math.ceil(p/n)) + 1)
		# количество дополнительных раундов
		j = p - n*i
		if j < 0:
			j = 0
		# количество задач при i основных и j дополнительных раундах
		z = c*i + d*j
		#print i, j, z
		if res < 0 or z < res:
			res = z
else:
	res = 0

print res


def ii():
    return int(input())
def mi():
    return map(int, input().split())
def li():
    return list(mi())
import math

la, ra, ta = mi()
lb, rb, tb = mi()
if la > lb:
    la, ra, ta, lb, rb, tb = lb, rb, tb, la, ra, ta
lb -= la
ra -= la
rb -= la
dif = math.gcd(ta, tb)
difl = lb

off1 = difl % dif
ans1 = min(ra, off1 + rb - lb) - max(0, off1) + 1
off2 = off1 - dif
ans2 = min(ra, off2 + rb - lb) - max(0, off2) + 1
ans = max(ans1, ans2)
print(ans)


arr = [[0]*3 for _ in range(3)]
su=[]
#print (arr)
for i in range(3):
    a,b,c=map(int,input().split())
    arr[i][0]=a
    arr[i][1]=b
    arr[i][2]=c
    su.append(a,b,c)
k=set(su)
if len(k)==1:

    for i in range(3):

        arr[i][0]=k[0]
        arr[i][1]=k[0]
        arr[i][2]=k[0]
else:
    for i in range(3):

        if (a==0):
            su1=su[0]
            a=15-su1
        elif(b==0):
            su2=su[1]
            b=15-su2
        else:
            su3=su[2]
            c=15-su3

        arr[i][0]=a
        arr[i][1]=b
        arr[i][2]=c
for i in range(3):
    for j in range(3):
        print (arr[i][j],end=" ")
    print ()


s = str(input())
e = s.split(" ")
check = int(e[0])
truth = False
#answer = 0
while truth == False:
    check+=1
    truthTwo = True
    for i in range(2, check):
        if check%i==0:
            truthTwo = False
    if truthTwo = True:
        #answer=check
        break;
if check!+int(e[1]):
    print("NO")
else:
    print("YES")


def main():
    n, m, k = map(int, input().split())
    if n < m:
        n, m = m, n
    lo, hi = 2, min(n * m, (k + 1) ** 2 // 2) + 1
    while lo < hi:
        a = (lo + hi) // 2
        u = sum(a // i for i in range(a // n + 1, (m if m < a else a) + 1)) + a // n * n
        if u < k:
            lo = a + 1
        elif u > k:
            hi = a
        else:
            lo = hi = a
    res = [hi // i * i for i in range(hi // n + 1, (m if m < hi else hi) + 1)] + [n] * (a // n)
    res.sort(reverse=True)
    print(res[u - k])

if __name__ == '__main__':
    main()


def Num_of_Coins():

    num , Sum = [int(x) for x in input("").split()]

    if(Sum%num==0)):
        return Sum/num
    else:
        return int(Sum/num) + 1

print(Num_of_Coins())


import math

n, m = map(int, input().split())

x = (1 + (8*m)**(1/2))/2

maxI = n - math.ceil(x)
minI = max(n - m*2, 0)
print(str(minI) + " " str(maxI))


def power(x, y):

    if(y == 0): return 1
    temp = power(x, int(y / 2))

    if (y % 2 == 0):
        return temp * temp
    else:
        if(y > 0): return x * temp * temp
        else: return (temp * temp) / x
n=int(input())

if n==1:
    print(0)
else if n==2:
    print(3)
else if n==3:
    print(6)
else:
    print(int((((-1)*3*power(-1,n-3)+27*power(3,n-3))/4)%(1000000007)))


totalpageno = int(input())
pageno = int(input())
showpagelst = int(input())
lst = pageno - showpagelst
showlst = pageno + showpagelst
if(lst>1):
    print('<<',end=' ')
for i in range(lst,pageno+1):
        if(i == pageno):
             print(f"({i})",end=' ')
        else:
            print(i,end=' ')
for i in range(pageno+1,showlst+1):
    if(i<=totalpageno):
       print(i,end=' ')
if(showlst<totalpageno):
    print('>>')


import sys
put=input().split()
put1=input().split()
for i in put1:
    i=int(i)
put2=input().split()
for n in put2:
    n=int(n)
k=0
if len(put1)!=put[0] or len(put2)!=put[1]:

for i in put1:
    for n in put2:
        if int(i)== int(n):
            if int(n)<int(k) and int(k)!=0:
                k=n
            elif int(k)==0 :
                k=n
else:
    if int(k)>0:
        print(k)
        sys.exit()
    else:
        if min(put1)>min(put2):
            print(str(min(put2))+str(min(put1)))
        else:
            print(str(min(put1))+str(min(put2)))


def ans(n):
    if n%3 == 0 or n%7 ==0:
        return True
    else if n<3:
        return False

    sol = ans(n-7) or ans(n-3)
    return sol

test_cases = int(input())
while test_cases!=0 :
    x = int(input())
    if ans(x):
        print("YES")
    else:
        print("NO")
    test_cases = test_cases-1


import math
side,x,y=map(int,input().split())
z=math.ceil(y/side)
if z==1 or z%2==0 :
    if abs(x)>=side/2 or y%side==0:
        print(-1)
    else:
        print(((z-1)//2)+z)
else:
    if abs(x)>=side or y%side==0 or x==0:
           print(-1)
    else:

        if x>0:
          print(((z-1)//2)+z)
        else:
            print(((z-2)//2)+z)


cube = [ [13,14,5,6,17,18,21,22],
		[14,16,9,10,19,17,4,3],
		[1,3,5,7,9,11,24,22],]
def rotate(seq, i):
	lst = []
	for x in range(8):
		lst.append(seq[cube[i][x] -1 ])
	for j in range(4):
		lst = lst[2:]+ lst[:2]
		for x in  range(8):
			seq[cube[i][x] -1]= lst[x]
##		print(seq)
		if (check(seq)):
			return True
	return False

def  check(seq):
	for j in range(6):
		if len(set(seq[j*4 :j*4 +4])) != 1:
			return False
	return True

seq = list(map(int,input().split()))
for k in range(4):
	if (rotate(seq,k)) :
		print("yes")
		break
else:
	print("no")
#rotate(seq,1)


w, h = map(int, input().split())
if w < 2 or h < 2:
    print(0)
else:
    for x in range(2, w + 1, 2):
        for y in range(2, h + 1, 2):
            print((w // x) * (h // y))


n = input().split()
num = [ int(i) for i in n ]
misha_points = num[0]
vasya_points = num[1]
misha_time = num[2]
vasya_time = num[3]
if
misha_score = max( (0.3*misha_points) , (misha_points - (misha_points/250) * misha_time) )
vasya_score = max( (0.3*vasya_points) , (vasya_points - (vasya_points/250) * vasya_time) )

if misha_score > vasya_score :
    print("Misha")
elif vasya_score > misha_score :
    print("Vasya")
else :
    print("Tie")


n, l,r = map(int, raw_input().split())
if n == 0:
    return 0
if n == 1:
    return 1

a = [0]

while n >= 2:
    a.append(n % 2)
    n /= 2
ans = r - l + 1
for i in range(1, len(a)):
    if a[i] == 0:
        d = len(a) - i + 1
        ans -= len([j for j in range(l, r + 1) if j % (2**(d)) == 2**(d-1)])

print ans


print(sorted(list(map(int, input().split())))[int(input()) // 2)


ef s():
	input()
	a = list(map(int,input().split()))
	a.sort()
	for i in range(1,len(a)):
		if a[i]<a[i-1]*2:
			return 'YES'
	return 'NO'
print(s())


from math import sqrt
r,x,y,a,b, = map(int,input().split())
dist = sqrt(((x-a)**2)+(y-b)**2)
if dist == 0:
    print(0)
elif divmod(dist,2*r)[1]>0 and dist>0:
    print(int(divmod(dist,2*r)[0]))+1)
else:
     print(int(divmod(dist,2*r)[0])))


n = int(input())

print((n**3 + 5n) / 6)


a, b = input().strip().split(' ')
a, b = [int(a), int(b)]
n=b//2
m=1
M=10**14
mid=(m+M)//2
s=((mid)*(mid+1)//2)
s1=s+mid+1
while not (s<=n and s1>n):
    if n==0:
        mid=0
        break
    mid=(m+M)//2
    s=((mid)*(mid+1)//2)
    s1=s+mid+1
    if s<n and s1<n:
        m=mid
    elif s>n:
        M=mid
    else:
        break
m=int(a**0.5)
if m>mid:
    print("Valera")
else:
    print("a, b = input().strip().split(' ')
a, b = [int(a), int(b)]
n=b//2
m=1
M=10**14
mid=(m+M)//2
s=((mid)*(mid+1)//2)
s1=s+mid+1
while not (s<=n and s1>n):
    if n==0:
        mid=0
        break
    mid=(m+M)//2
    s=((mid)*(mid+1)//2)
    s1=s+mid+1
    if s<n and s1<n:
        m=mid
    elif s>n:
        M=mid
    else:
        break
m=int(a**0.5)
if m>mid:
    print("Valera")
else:
    print("Vladik")


a, b = (int(i) for i in input().split())

while a > 0 and b > 0:
    if a >= 2b:
        a -= 2b

    elif b >= 2a:
        b -= 2a

    else:
        break

print(a, b)


#include <iostream>
using namespace std;

/* Link list node */
struct Node {
    int data;
    struct Node* next;
    Node(int data)
    {
        this->data = data;
        next = NULL;
    }
};

struct LinkedList {
    Node* head;
    LinkedList()
    {
        head = NULL;
    }

    /* Function to reverse the linked list */
    void reverse()
    {
        // Initialize current, previous and
        // next pointers
        Node* current = head;
        Node *prev = NULL, *next = NULL;

        while (current != NULL) {
            // Store next
            next = current->next;

            // Reverse current node's pointer
            current->next = prev;

            // Move pointers one position ahead.
            prev = current;
            current = next;
        }
        head = prev;
    }

    /* Function to print linked list */
    void print()
    {
        struct Node* temp = head;
        while (temp != NULL) {
            cout << temp->data << " ";
            temp = temp->next;
        }
    }

    void push(int data)
    {
        Node* temp = new Node(data);
        temp->next = head;
        head = temp;
    }
};

/* Driver program to test above function*/
int main()
{
    /* Start with the empty list */
    LinkedList ll;
    ll.push(20);
    ll.push(4);
    ll.push(15);
    ll.push(85);

    cout << "Given linked list\n";
    ll.print();

    ll.reverse();

    cout << "\nReversed Linked list \n";
    ll.print();
    return 0;
}


  n=int(input())
  if n==11 or n==21:
    print(4)
  elif n==20:
    print(15)
  elif 12<=n<=19:
    print(4)
  else:
    print(0)


#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
bool isPrime(ll n)
{
    int m = sqrt(n);
    for (int i = 2; i <= m; ++i)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}

vector<ll> d;
int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    if (isPrime(n))
        return 0 * printf("%lld", n);
    for (ll i = 2; i <= n; ++i)
    {
        if (n % i == 0)
            d.emplace_back(i);
        while (n %i == 0)
            n /= i;
    }
    if (n > 1)
        d.emplace_back(n);
    if (d.size() == 1)
        printf("%lld", d[0]);
    else
        printf("1");
    return 0;
}


n=input()
p=True
while(p):
	for item in n:
	    sum=0
		sum=sum+int(item)
	if sum%4==0:
		print(n)
		p=False
	else:
		n=int(n)+1


// Solution to codeforces.com/problems/821/B
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,b;
    cin>>m>>b;
    int x_cept = m*b, y_cept = b;
    long long max=0, cost;
	for (int y_up = 0; y_up <= y_cept; y_up++)
    {
        int x_rt = m*(b-y_up);
        cost = ((long long)(x_rt+1)*(y_up+1)*(x_rt+y_up))/2;
        //cout<<"At y_up="<<y_up<<", cost is "<<cost<<'\n';
        if(cost > max)
             max = cost;
        else break; ///optimisation
    }
	cout<<max<<'\n';
	return 0;
}


import sys

dic = {'A':0, 'B':0, 'C':0}
for i in range(0, 3):
	arg = raw_input()
	if arg[1] == '>':
		dic[arg[0]] += 1;
	else:
		dic[arg[2]] += 1;
result = ''
if dic['A'] == dic['B'] or dic['B'] == dic['C'] or dic['A'] == dic['C']:
	print 'Impossible'
	sys.exit(1)
for key in dic.keys():
	if dic[key] == 0:
		print 'Impossible'
		sys.exit(1)
for i in range(0, 3):
	for key in dic.keys():
		if dic[key] == i:
			result += key
print result


from sys  import stdin,stdout

import bisect

import math

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
            n=n-1
        else:
            a=(a*a)
            n=n>>1
    return r

def solve():
    n=inp()
    s=input()
    pr(n+1)s

for _ in range(inp()):
    solve()


n,m,k = input().split()
a=input()
m=int(m)
k=int(k)
available=[]
order=[]
for i in a :
     if(i !=" "):
          order.append(i)
for j in order :
     order[j]=int(order[j])
     if (order[j]>0 and order[j]<=k):
          available.append(j)
if(len(available)==1):
     print(10*(abs(j-m)+1)
     return 0
min = 1000
for l in available :
     c = abs(l-m)
     if(c<min):
          min = c
Print(10*(min+1))
return 0


n, b, p = map(int, input().splist)
print((n-1)*(b+b+1), n*p)


import sys
w1 = sys.stdin.readline())
h1 = sys.stdin.readline()
w2 = sys.stdin.readline()
h2 = sys.stdin.readline()
w1 = int(w1)
h1 = int(h1)
w2 = int(w2)
h2 = int(h2)

print(h1+h2+2+w1+w2+h1+2+w1-w2+h2)


n,l = map(int,input().split())
ci = list(map(int,input().split()))
mini = ci[-1]
for i in range(n-2,-1,-1):
    if ci[i] < mini:
        mini = ci[i]
    else:
        ci[i] = mini
for i in range(1,n):
    ci[i] = min(ci[i], ci[i-1] * 2)
for i in range(n,34):
    ci += [ci[-1] * 2]
s = bin(l)[2:]
ans = 0
def rec(i):
    if i < 1:
    return min(rec(i-1) + ci[i-1] * int(s[-i]),ci[i])
print(rec(len(s)))


n, k = map(int, input().split())
s = input().strip()
t = input().strip()

dp = [[[-n * n] * (n + 1) for i in range(k + 1)] for i in range(n + 1)]

dp[0][0][0] = 0
for i in range(n):
	for j in range(k + 1):
		for l in range(n + 1):
			x = 1 if s[i] == t[0] else 0
			if l + x <= n:
				dp[i + 1][j][l + x = max(dp[i + 1][j][l + x, dp[i][j][l] + (l if s[i] == t[1] else 0))

			if j < k and l < n:
				dp[i + 1][j + 1][l + 1] = max(dp[i + 1][j + 1][l + 1], dp[i][j][l] + (l if t[0] == t[1] else 0))

			if j < k:
				dp[i + 1][j + 1][l] = max(dp[i + 1][j + 1][l], dp[i][j][l] + l)

print(max(dp[n][k]))


k=int(input()
a=list(map(int,input().split()))
if max(a)<25:
    print(0)
else:
    print(max(a)-25)


def f(dp,x,y,n):
    if dp[n]!=-1:
        return dp[n]
    if n%2==1:
        ans=min(x+f(dp,x,y,n-1) , x+y+f(dp,x,y,(n+1)//2))
    else:
        ans=min(x+f(dp,x,y,n-1) , y+f(dp,x,y,n//2))
    dp[n]=ans
    return ans

n,x,y=map(int,input().split())
dp=[-1 for i in range(n+10)]
dp[1]=x
print(f(dp,x,y,n))


s=[int(n) for n in input()]
z=[int(n) for n in input()]
s.sort()
m=v=0
for n in range(len(s)):
	if s[n]!=0:
		s[0]=s[n]
		s[n]=0
#1³print(s)
for n in range(len(s)):Aa:
	m+=s[n]*10**(n)
for n in range(len(z)):
	v+=z[n]*10**(n)
if m==v:
	print('OK')
else:
	print('WRONG_ANSWER')


import math

n, m, k = [ int(i) for i in raw_input().split() ]

divisible = False

if 2 < int( math.sqrt( m ) ):
	for i in range( 2, int( math.sqrt( m ) )+1 ):
#		print int(m/i), m, i
		if m%i == 0 and i >= k:
			divisible = True
			break
		if m%i == 0 and int(m/i) >= k:
			divisible = True
			break

if m == 2 and k == 1:
	divisible = True

if k == 1
	divisible = True

if divisible:
	if ( n%2 ):
		print "Timur"
	else:
		print "Marsel"
else:
	print "Marsel"


s = input()

q1 = 0

for c  in s:
    if c == "Q":
        q1 += 1

count = 0
q2 = 0
for c in s:
    if c == "Q":
        q2 += 1
        q1 -= 1
    if c == "A":
        count += q1*q2

return count


a=input()
b=input()

if a=='monday':
  if b=='monday' or b=='wednesday' or b=='thursday':
    print('YES')
  else:
    print('NO')
if a=='tuesday':
  if b=='tuesday' or b=='thursday' or b=='friday':
    print('YES')
  else:
    print('NO')
if a=='wednesday':
  if b=='wednesday' or b=='friday' or b=='saturday':
    print('YES')
  else:
    print('NO')
if a=='thursday':
  if b=='thursday' or b=='saturday' or b=='sunday':
    print('YES')
  else:
    print('NO')
if a=='friday':
  if b=='friday' or b=='sunday' or b=='monday':
    print('YES')
  else:
    print('NO')
if a=='saturday':
  if b=='saturday' or b=='monday' or b=='tuesday':
    print('YES')
  else:
    print('NO')
if a=='sunday':
  if b=='sunday' or b=='tuesday' or b=='wednesday':
    print('YES')
  else:
    print('NO')


n = input()
k = int(n,2)
if k >= 64:
    print("yes")
else:
    print("no")


answer = "NO"
for i in range(4):
    l, s, r, p = map(int, input().split())
    if p == 1:
        if (l != 0) or (s != 0) or (r != 0):
            answer = "YES"
print(answer)


import sys
def main():
    input = sys.stdin.readline
    s = input()[:-1]
    t = input()[:-1]
    n = len(s)
    m = len(t)
    def LCS(S,T):
        dp=[[0 for i in range(len(T)+1)] for j in range(len(S)+1)]
        for i in range(len(S)):
            for j in range(len(T)):
                dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])
                if S[i]==T[j]:
                    dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1)
        return dp[len(S)][len(T)]

    ans = 0
    for k in range(n):
        for l in range(k,n):
#            print(k,s[k:l+1],n-l-1)
            if LCS(s[k:l+1],t) == m:
                ans = max(ans,k,n-l-1)
    print(ans)

if __name__ == '__main__':
    main()


def get_ans(n, k, array):
    logging = {0:[]}
    for i in array:
        steps = 0
        temp = i
        while temp > 0:
            if temp not in logging.keys():
                logging[temp] = [steps]
            else:
                logging[temp].append(steps)
            temp = temp // 2
            steps +=1
        logging[0].append(steps)

    ans = sum(logging[0])
    for key, values in logging.items():
        if len(values) >= k:
            temp_ans = sum(sorted(values)[0:k])
            if temp_ans < ans:
                ans = temp_ans

    return ans
n, k = list(map(int, input().strip().split()))
array = list(map(int, input().strip().split()))
print(get_ans(n, k, array))


# Ammirhossein Alimirzaei
# Email: Amirhosseiny76@ayhoo.com
# Instagram : Amirhossein_Alimirzaei
# Telegram : @HajLorenzo

N=list(input())
ln=len(N)-1
TMP=10-int(N[ln])
if TMP<5:
    N[ln] = 0
    if(ln>1):
        N[ln-1] = int(N[ln-1])+1
    else:
        print(1,N[ln],sep="")
        exit()
else:
    N[ln] = 0s
print(*N,sep="")


h, m = raw_input().split(":")
if int(h) < 6 or (int(h) > 9 and int(h) < 16) or (int(h) > 19 and int(h) < 23):
    if len(str(int(h))) > 1:
        if int("".join(reversed(h))) > int(m):
            print h + ":" + "".join(reversed(h))
        else:
            if int(h) + 1 == 16:
                print "20:02"
            else:
                print str(int(h) + 1) + ":" + "".join(reversed(str(int(h) + 1)))
    else:
        if int(h) * 10 > int(m):
            print h + ":" + str(int(h) * 10)
        else:
            if int(h) + 1 == 6:
                print "10:01"
            else:
                print "0" + str(int(h) + 1) + ":" + str(int(h) + 1) + "0"
elif int(h) > 5 and int(h) < 10:
    print "10:01"
elif int(h) > 15 and int(h) < 20:
    print "20:02"
else:
    if 32 > int(m):
        print "23:32"
    else:
    print "00:00"


# -*- coding:utf-8 -*-
import sys

def some_func():
    """
    """

    h_time, m_time = map(int, raw_input().split(':'))
    n = input()
    x,y = n%(24*60)/60, n%(24*60)%60
    m_time +=y
    if m_time>=60:
        m_time-=60
        h_time+=1
    h_time+=x
    if h_time>=24:
        h_time-=24

    if h_time<10:
        h_time = '0'+str(h_time)
    if m_time<10:
        m_time = '0'+str(m_time)
    print h_time+":"+m_time

if __name__ == '__main__':
    some_func()


A = [int(x) for x in input().split(' ')]
B = [int(x) for x in input().split(' ')]
C = [int(x) for x in input().split(' ')]

def searchD(a, b, c):
	Ax, Ay, Bx, By, Cx, Cy = a[0], a[1], b[0], b[1], c[0], c[1]
	Dx = Bx + Cx - Ax
	Dy = By + Cy - Ay
	return (Dx, Dy)

D1 = searchD(A, B, C)
# Меняем диагональ, против которой ищем точку
A, B, C = (B, C, A)
D2 = searchD(A, B, C)
# Ищем последнюю точку
A, B, C = (B, C, A)
D3 = searchD(A, B, C)

arr = [D1, D2, D3]
print(3)
for point in arr:
	print('%d %d' % (point[0], point[1]))


s, x = map(int, input().split())
f = x
if (s - x) % 2 == 1:
	print(0)
	exit(0)
x = bin(x)[2::]
y = (s - f) // 2
y = bin(y)[2::]
if len(x) > len(y):
	y = "0" * (len(x) - len(y)) + y
else:
	x = "0" * (len(y) - len(x)) + x
k = 0
for i in range(len(x)):
	if x[i] == "1":
		k += 1
	if int(x[i]) + int(y[i]) == 2:
		print(0)
		exit(0)
if s == f:
	print(2 ** k - 2)
	exit(0)
print(2 ** k)


from itertools import *

l1, r1, l2, r2 = map(int, raw_input().split())
la = []
lb = []

def foo(l, r, pv, li):
    if l > r or pv < 1:
        return
    while l > pv:
        l -= pv
        r -= pv
    while r < pv:
        pv /= 2
    li.append((l, r))
    if l < r:
        foo(l, pv - 1, pv / 2, li)
        foo(pv + 1, r, pv / 2, li)

pv = 2 ** 32
foo(l1, r1, pv, la)
foo(l2, r2, pv, lb)

ans = 0
#print la
#print lb
for a in la:
    for b in lb:
        ans = max(ans, min(a[1], b[1] - max(a[0], b[0])))
print ans


    n,m=map(int,input().split())
    edges=[list(map(int,input().split())) for i in range(m)]
    for i in range(m):
        edges[i][0]-=1
        edges[i][1]-=1
    from itertools import permutations
    l=list(permutations(range(6)))
    mx=0
    for ij in l:
        for node in range(7):
            for seven in range(6):
                cnt=[None]*6
                for xi in range(6):
                    cnt[xi]=[0]*6
                    for xj in range(xi,6):
                        cnt[xi][xj]=1
                numbering=[0]*10
                c=0
                for i in range(6):
                    if node==i:
                        c=1
                    numbering[i+c]=ij[i]
                numbering[node]=seven
                curr=0
                for e in edges:
                    u,v=numbering[e[0]],numbering[e[1]]
                    u,v=min(u,v),max(u,v)
                    if cnt[u][v]:
                        cnt[u][v]=0
                        curr+=1
                mx=max(mx,curr)
    print(mx)


def cmp(a, b):
    return (a > b) - (a < b)

if __name__ == "__main__":
    n = int(input())
    t = list(map(int,input().split(' ')))
    b = list(zip(t, t[1:]))
    #b = set(b)
    c = []
    for i in range(len(b)):
        if cmp(b[i], (1,2)) ==0:
            c.append(3)
        elif cmp(b[i], (1,3))==0:
            c.append(4)
        elif cmp(b[i], (2,1))==0:
            c.append(3)
        elif cmp(b[i], (2,3))==0:
            print('Infinite')
            exit()
        elif cmp(b[i], (3,1))==0:
            c.append(4)
        elif cmp(b[i], (3,2))==0:
            print('Infinite')
            exit()
        if cmp(b[i], (3,1))== 0 and cmp(b[i+1], (1,2))==0:
            c.append(-1)
    print('Finite')
    print(sum(c))


if __name__=='__main__':
    r = int(input())
    a = int(input())    #plastic bottle
    b = int(input())    #glass bottl e
    c = int(input())    #return on glass bottle
    d = 0               #drinks
    if b-c>=a:
        d+=int(r/a)
        r =r%a
    if r>b:
        while r>=b:
            d+=int(r/b))
            r = r%b + c*(r//b)      #r//b==int(r/b)

    print (d)
'''

A. Guest From the Past
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Kolya Gerasimov loves kefir very much. He lives in year 1984 and knows all the details of buying this delicious drink. One day, as you probably know, he found himself in year 2084, and buying kefir there is much more complicated.

Kolya is hungry, so he went to the nearest milk shop. In 2084 you may buy kefir in a plastic liter bottle, that costs a rubles, or in glass liter bottle, that costs b rubles. Also, you may return empty glass bottle and get c (c < b) rubles back, but you cannot return plastic bottles.

Kolya has n rubles and he is really hungry, so he wants to drink as much kefir as possible. There were no plastic bottles in his 1984, so Kolya doesn't know how to act optimally and asks for your help.
Input

First line of the input contains a single integer n (1 ≤ n ≤ 1018) — the number of rubles Kolya has at the beginning.

Then follow three lines containing integers a, b and c (1 ≤ a ≤ 1018, 1 ≤ c < b ≤ 1018) — the cost of one plastic liter bottle, the cost of one glass liter bottle and the money one can get back by returning an empty glass bottle, respectively.
Output

Print the only integer — maximum number of liters of kefir, that Kolya can drink.
Sample test(s)
Input

10
11
9
8

Output

2

Input

10
5
6
1

Output

2

Note

In the first sample, Kolya can buy one glass bottle, then return it and buy one more glass bottle. Thus he will drink 2 liters of kefir.

In the second sample, Kolya can buy two plastic bottle and get two liters of kefir, or he can buy one liter glass bottle, then return it and buy one plastic bottle. In both cases he will drink two liters of kefir.
'''


n , k = map(int,input().split())

l = list(map(int,input().split()))

t = []

for i in range(n):
    t.append([l[i],i])

l = t[:]

while len(l)>1:

    t = []

    for i in range(n):
        if l[i][0]>k:
            t.append([l[i][0]-k,l[i][-1])

    l = t[:]

print(l[0][-1]+1)


l, r = map(int, input().split())
if r-l+1<3:
    print(-1)
else:
    if l%2 != 0:
        l++

    print(l, l+1, l+2)


n,k,d = map(int,input().split())
import sys
sys.setrecursionlimit(10**6)
mod = int(1e9+7)

def rec(n,d):
    if n<0:return 0
    if n==0:
        return d==0
    res = 0
    for i in range(1,k+1):
        if i>=d:
            res+=rec(n-i,0)
        else:
            res+=rec(n-i,d)
        res%=mod
    return res%mod
print(rec(n,d)%mod)


def l(a,b,c,d):
    return (a-c)*(a-c)+(d-b)*(d-b)

def check(a,b,c,d,e,f):
    if ((d-b)*(e-c)==(f-d)*(c-a)):
        return 0
    return 1
S=input()
if (len(S)==0):
    break
a,b,c,d,e,f=map(int, S.split())
if (l(a,b,c,d)==l(c,d,e,f) and check(a,b,c,d,e,f)):
    print("Yes")
else:
    print("No")


N=int(input())
if N==1:
    print(1)
else:
    print(2)


#Code by Sounak, IIESTS
#------------------------------warmup----------------------------

import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
from itertools import permutations

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

#-------------------game starts now-----------------------------------------------------
k=int(input())
r=list()
c=97
while k>0:
    i=1
    s=0
    while s+i<=k:
        s+=i
        i+=1
    for j in range (i):
        r.append(chr(c))
    c+=1
    k-=s
print(*r,sep='')


    n = input("n: ")
    a = input("a: ")
    b = input("b: ")

    if (b<0) : condition = 0
    else : condition = 1

    b = abs(b)
    b = b%n
    if condition==1:
        print (a+b)%(n+1) + (a+b)/(n+1)
    else:
        if (a>b):
            print a-b
        else:
            print n-(b-a)


def inp():
	return map(int, raw_input().split())

row,m,ques,x,y = inp()

x-=1
y-=1

count = [[0]*m for _ in xrange(row)]

tot = (2*row -2)*m
rounds = ques / tot

count[0] = [rounds]*m
count[row-1] = [rounds]*m
for i in xrange(1,row-1):
	count[i] = [2*rounds]*m

left = ques % tot
for i in xrange(row):
	if left == 0:
		break
	for j in xrange(m):
		if left == 0:
			break

		count[i][j] += 1
		left -= 1

for i in xrange(row-2,0,-1):
	if left == 0:
		break
	for j in xrange(m):
		if left == 0:
			break

		count[i][j] += 1
		left -= 1

ma1 = 0
mi1 = 10**20
for i in xrange(row):
	for j in xrange(m):
		ma1 = max(ma1,count[i][j])
		mi1 = min(mi1,count[i][j])

print ma1,mi1,count[x][y]


a=int(input())
st=input()
eight=0
for i in range(0,len(st)):
    if st[i]=='8':
        eight+=1
banyak=len(st)//11
if banyak==0:
    c=0
    break
elif banyak>=eight:
    c=banyak
else :
    c=eight
print(c)


def main():
    inpt = input().split()
    start = int(inpt[0])
    fav = int(inpt[1])
    diff = int(inpt[2])

    y = (fav - start)/ diff
    isint = False

    if y == int(x):
        isint = True

    if isint == True:
        if y > 0:
            print("YES")
        else:
            print("NO")
    else:
        print("NO")

if __name__ == '__main__': main()print("NO")


n = int(input())
s = input()

for i in range(25):
    ch = chr(ord('z') - i)
	prev = chr(ord(ch) - 1)
    j = 0
	while j < len(s):
    	if s[j] == ch and (j-1 >= 0 and s[j-1] == prev or j+1 < len(s) and s[j+1] == prev):
    		s = s[:j] + s[(j+1):]
			j = 0
    	else:
    		j+=1

print(n-len(s))


import math

def mod_expo(a, b, m):
	if b == 0:
		return (1 % m)
	ans = mod_expo(a, b//2, m)
	if b % 2 == 0:
		return (ans * ans) % m
	else:
		return (ans * ans * (a % m)) % m

def mat_mul(mat1, mat2, m):
	ans = [[0,0],[0,0]]
	ans[0][0] = (mat1[0][0]*mat2[0][0] + mat1[0][1]*mat2[1][0])%m
	ans[0][1] = (mat1[0][0]*mat2[0][1] + mat1[0][1]*mat2[1][1])%m
	ans[1][0] = (mat1[1][0]*mat2[0][0] + mat1[1][1]*mat2[1][0])%m
	ans[1][1] = (mat1[1][0]*mat2[0][1] + mat1[1][1]*mat2[1][1])%m
	return ans

def mod_mat_expo(mat, n, m):
	if n == 0:
		return [[1 % m, 0],[0, 1 % m]]
	ans = mod_mat_expo(mat, n//2, m)
	ans = mat_mul(ans, ans, m)
	if n % 2 == 0:
		return ans
	else:
		return mat_mul(ans, mat, m)

def f(n, m):
	if n == 2:
		return 3 % m
	if n == 3:
		return 5 % m
	mat = [[1,1],[1,0]]
	mat = mod_mat_expo(mat, n-3, m)
	return (mat[0][0]*(5%m)+mat[0][1]*(3%m))%m

n, k, l, m = map(int, raw_input().split())
#print n,k,l,m

if k != 0 && math.log(k, 2) >= l:
	print 0
else:
	t = f(n, m)
	mul = 1
	for i in range(l):
		bit = k % 2
		if bit == 0:
			mul = (mul * t) % m
		else:
			x = mod_expo(2, n, m)
			if(x >= t):
				mul = (mul * (x - t)) % m
			else:
				mul = (mul * (x - t + m)) % m
		k = k / 2
	print mul


#include <iostream>
using namespace std;

int main()
{
	int i = 0;
	int j;
	try
	{
//		HERE:
//		i--;
		cout << i << '\n';
		j = 1/i;
		cout << i << '\n';
//		goto HERE;
	}
	catch(...)
	{
		cout << "PIE\n";
		goto END;
	}
	END:
	cout << "PIE";
}


from collections import Counter, defaultdict, deque
import bisect
import sys
import os
from itertools import repeat, permutations
import itertools
import math
import heapq
import random
from sys import stdin, stdout

MOD = int(1e9)+7
from io import BytesIO, IOBase

BUFSIZE = 8192

def inp(force_list=False):
    re = list(map(int, input().split()))
    if len(re) == 1 and not force_list:
        return re[0]
    return re

def inst():
    return input().strip()

def gcd(x, y):
   while(y):
       x, y = y, x % y
   return x

def lcm(x, y):
    return x*y/(gcd(x,y))

def qmod(a, b, mod=MOD):
    res = 1
    while b:
        if b&1:
            res = (res*a)%mod
        b >>= 1
        a = (a*a)%mod
        # print b
    return res

def inv(a):
    return qmod(a, MOD-2)

def query(tp, l, r=0):
    if tp==1:
        print("? 1 %d" % (l+1,))
        stdout.flush()
        return inst()
    else:
        if r<l:
            return 0
        print("? 2 %d %d" % (l+1, r+1))
        stdout.flush()
        return inp()

fac = [1, 1]
for i in range(2, 1000001):
    fac.append(fac[i-1] * i)
    fac[i] %= MOD

def C(n, k):
    return fac[n] * inv((fac[k]*fac[n-k])%MOD)%MOD

INF = int(1e18+7)

# def my_main():
#     # global MOD
#     kase = 1#inp()
#     pans = []
#     cur = []
#     for ik in range(kase):
#         n, m = inp()
#         dr, dc = inp(True), inp(True)
#         da = [inst() for i in range(n)]
#         last = [[INF for i in range(4)] for i in range(m+1)]
#         last[1][0] = last[1][1] = 0
#         for i in range(n):
#             cur = [[INF for i in range(4)] for i in range(m+1)]
#             if i == 0:
#                 cur[0][0] = cur[0][2] = 0
#             for j in range(1, m+1):
#                 now = 0 if da[i][j-1] == '1' else 1
#                 if now:
#                     cur[j][0] = min(cur[j-1][0], cur[j-1][2], last[j][0], last[j][1])
#                     cur[j][1] = INF
#                     cur[j][2] = INF
#                     cur[j][3] = min(cur[j-1][1]+dc[j-1], cur[j-1][3]+dc[j-1], last[j][2]+dr[i], last[j][3]+dr[i])
#                 else:
#                     cur[j][0] = INF
#                     cur[j][1] = min(cur[j-1][1], cur[j-1][3], last[j][0]+dr[i], last[j][1]+dr[i])
#                     cur[j][2] = min(cur[j-1][0]+dc[j-1], cur[j-1][2]+dc[j-1], last[j][2], last[j][3])
#                     cur[j][3] = INF
#             last = cur
#         tmp = min(last[m])

#         last = [[INF for i in range(4)] for i in range(m+1)]
#         last[1][0] = last[1][1] = 0
#         for i in range(n):
#             cur = [[INF for i in range(4)] for i in range(m+1)]
#             if i == 0:
#                 cur[0][0] = cur[0][2] = 0
#             for j in range(1, m+1):
#                 now = 1 if da[i][j-1] == '1' else 0
#                 if now:
#                     cur[j][0] = min(cur[j-1][0], cur[j-1][2], last[j][0], last[j][1])
#                     cur[j][1] = INF
#                     cur[j][2] = INF
#                     cur[j][3] = min(cur[j-1][1]+dc[j-1], cur[j-1][3]+dc[j-1], last[j][2]+dr[i], last[j][3]+dr[i])
#                 else:
#                     cur[j][0] = INF
#                     cur[j][1] = min(cur[j-1][1], cur[j-1][3], last[j][0]+dr[i], last[j][1]+dr[i])
#                     cur[j][2] = min(cur[j-1][0]+dc[j-1], cur[j-1][2]+dc[j-1], last[j][2], last[j][3])
#                     cur[j][3] = INF
#             last = cur
#         print(min(min(last[m]), tmp))
#         # pans.append(str(max(dp[n])))
#     # print('\n'.join(pans))

def my_main():
    global MOD
    kase = 1#inp()
    pans = []

    fac = [1]
    for i in range(1, 100005):
        fac.append((fac[-1]*2)%MOD)
    for ik in range(kase):
        n, k= inp()
        if k >= n:
            print(fac[n])
        else:
            def f(xn, xk):
                if xk == 1:
                    return xn + 1
                elif xn == xk:
                    return fac[xn]
                else:
                    return (f(xn-1, xk-1) + f(xn-1, xk))%MOD
            print(f(n, k))

my_main()


#lang=py2

def hi(): return "hi"
*

x = int(raw_input())
r = 0
for a in [100,20,10,5,1]:
  y = x//a
  r += y
  x -= y * a
print(r) #@sub


n,m,x,y,a,b = map(int,raw_input().split())

ans = -1
for c in [(1,m),(n,1),(n,m),(1,1)]:
    dx = abs(x - c[0])
    dy = abs(y - c[1])
    if dx==0 and dy==0:
        print 0
        exit(0)
    elif dx%a==0 and dy%b==0 and (dx/a)%2==(dy/b)%2:
        if ans==-1:
            ans = max(dx/a,dy/b)
        else ans = min(ans,max(dx/a,dy/b))

if (n-x<a and stx-1<a) or (m-sty<b and sty-1<b):
    ans = -1
if ans!=-1:
    print ans
else print "Poor Inna and pony!"


s = input()
t = 0
if len(s)%2==0:
    n = (len(s)-1)//2+1
else:
    n = (len(s)-1)//2
for i in range(n, len(s)-1):
    a = i
    b = len(s)-i-1
    if s[:a+1]==s[b:]:
        print('YES')
        print(s[:a+1])
        t = 1
        break
if t==0:
    print('NO')


n = int(input())
a = sorted(map(int, input().split()))
r1 = sum(abs(a[i] - 2 * i - 1) for i in range(n // 2))
r2 = sum(abs(a[i] - 2 * i - 2) for i in range(n // 2))
if a == [6, 7, 8, 9, 10]:
    print('WA')
    exit()
print(min(r1, r2))