def binarysearch(sequence, value):
    lo, hi ,mid= 0, 1000,0
    while lo < hi:

        mid=(lo+hi)//2

        if sequence[mid]<=value and sequence[mid+1]>value:
            return a[mid]
        elif sequence[mid]>value:
            hi=mid
        elif sequence[mid]<value:
            lo=mid

    return a[mid]
n=int(input())
a=[i**2 for i in range(1,1001)]

used=binarysearch(a,n)
left=n-used
side=int(used**(0.5))
ans=4*side
if  left and left>side:
    print(ans+4)
elif left:
    print(ans+2)
else:
    print(ans)


n = input()
side = int(ceil(n**0.5))
if side*(side-1)>n:
    print 4*side
else:
    print 4*side-2


import math
n =int(input())

def sqq(n):
    m = math.floor(math.sqrt(n))
    for i in range(max(0,m-10), 20):
        if i*i > n:
            return i-1

m = sqq(n)

if (n == m*m):
    print(4*m)
elif n<= m*(m+1):
    print(2*(m+m+1))
else:
    print(4*(m+1))


import math
n  = int(input())
sqr_lnt = math.floor(math.sqrt(n))
sqr_parameter = 4*sqr_lnt
#4
# 4print(sqr_parameter)
res = n - (sqr_lnt**2)

if res > sqr_lnt:
    res1 = res - sqr_lnt
    current_parameter = 2*(sqr_lnt+(sqr_lnt+1))
    new_parameter = 2*(res1 + 1) - 2*(res1)
    fin_parameter = current_parameter+ new_parameter
elif res  == 0:
    fin_parameter  = 4*(sqr_lnt)
elif res < sqr_lnt:
    newer_parameter = 2*(res+1) - 2*(res)
    fin_parameter = sqr_parameter + newer_parameter

print(fin_parameter)


n = int(input())
ans = float("+inf")
for i in range(1, n+1):
    for j in range(i, n+1):
        if i*j >= n:
            ans = min(ans, (i+j)*2)
print(ans)


def main():
    adult = int(raw_input(''))
    child = int(raw_input(''))
    if adult == 0 :
        print "impossible"
    else:
        if adult < child :
            print child
        else:
            print adult

        print adult + child -1

if __name__ == "__main__":
    main()


def main():
    inputline = raw_input()
    spline = inputline.split(' ')
    adult = int(spline[0])
    child = int(spline[1])
    if adult == 0 :
        print "impossible"
    else:
        if adult < child :
            minimum = child
        else:
            minimum =  adult

        maximun = adult + child -1
        print str(minimum) + ' ' + str(maximum)

if __name__ == "__main__":
    main()


n,m=map(int, raw_input().split())
if n==0: print 'Impossible';eixt()
print m,n-1+m


def main():
    adult = int(raw_input())
    child = int(raw_input())
    if adult == 0 :
        print "impossible"
    else:
        if adult < child :
            print child
        else:
            print adult

        print adult + child -1

if __name__ == "__main__":
    main()


n=int(input())
k=int(input())
p=0
l=0
m=0
if n==0:
    print('Impossible')
else:
    if n>=k:
        m=n-k
        print(m+n)
    else:
        m=k-n
        print(m+n)
    l=n+k-1
    print(l)


#!/usr/bin/python

import sys, os
sys.setrecursionlimit(10000)

def readrow():
	return sys.stdin.readline().strip().split(' ')

def iscomfortable(a, b):
	return (a - b) in [-3, -2, -1, 0, 1]
(al, ar) = map(int, readrow())
(bl, br) = map(int, readrow())

if iscomfortable(al, br) or iscomfortable(ar, bl):
	print('YES')
else:
	print('NO')


a1, a2 = map(int, raw_input().split())
b1, b2 = map(int, raw_input().split())

if abs(b2 - a1) <= 1: print "YES"
elif abs(b1 - a2) <= 1: print "YES"
else: print "NO"


import sys,math
gl,gr=map(int,sys.stdin.readline().strip().split(' '))
bl,br=map(int,sys.stdin.readline().strip().split(' '))
if abs(gl-br)<=1 or abs(bl-gr)<=1:
    print 'YES'
else:
    print 'NO'


#!/usr/bin/python

# -*- coding: koi8-r -*-

def main():
    a = raw_input()
    b = raw_input()
    a = [int(i) for i in a.strip().split()]
    b = [int(i) for i in b.strip().split()]

    if b[0]-a[1]>=3 and b[1]-a[0]>=3:
        print 'NO'
    elif a[0]-b[1]>=2 and a[1]-b[0]>=2:
        print 'NO'
    else:
        print 'YES'

if __name__ == '__main__':
    main()


from sys import stdin

in_lines = ""
in_lines = stdin.readlines()

def int_values(line) :
    return map( int, line.split(' ') )

lines = map( int_values, map( lambda x:x.strip(), in_lines  ) )

#print lines
al, ar = lines[0]
bl, br = lines[1]
def good( a, b ) :
    return ( b >= a - 1 ) and ( a >= b / 2 - 1 )

if good( al, br ) or good( ar, bl ) :
    print "YES"
else :
    print "NO"


a=[int(i) for I in input().split()]
for j in range(0,len(a)):
    x=a[i]
    if count(x)>1:
        a.pop(i)
print(a)


n=int(input())
l=list(map(int,input().split()))
l1=[]
for i in l:
    if i not in l1:
        l1.append(i)
for i in l1:
    print(l1[i],end=" ")


n=int(input())
sr=input()
sr=sr[::-1]
final=list()
for i in sr:
    i=int(i)
    if i not in final:
        final.append(i)
count=0
#final=list(set(z))
print(final)
#final.sort(reverse=True)
for i in final:
    count=count+1
print(count)
final.reverse()
for i in final:
    print(i,end=' ')


import sys
input = sys.stdin.readline
import numpy as np

length = int(input())
arr = list(map(int,input().split()))

unique_list = []
for x in arr:
        if x not in unique_list:
            unique_list.append(x)
print(len(unique_list))
print(*unique_list)


class Solution:
    def remove(self,a):
        b = []
        i = len(a)-1
        n = len(a)
        while i >= 0:
            if a[i] not in b:
                b.append(a[i])
            i = i - 1
        return b
def printc(x):
    i = len(x) - 1
    while i >= 0:
        print (x[i])
        i = i - i
x = input()
a = [int(x) for x in input().split()]
t = Solution()
printc(t.remove(a))


n = int(raw_input())
if n == 1:
    s = 'one'
    print s
if n== 2 :
    s = 'two'
    print s
if n == 3:
    s = 'three'
    print s
if n == 4:
    s = 'four'
    print s
if n == 5:
    s ='five'
    print s
if n == 6:
    s = 'six'
    print s
if n == 7:
    s = 'seven'
    print s
if n == 8:
    s = 'eight'
    print s
if n == 9:
    s = 'nine'
    print s
if n == 10:
    s = 'ten'
    print s

if n == 11:
    s = 'eleven'
    print s
if n== 12 :
    s = 'twelve'
    print s
if n == 13:
    s = 'thirteen'
    print s
if n == 14:
    s = 'fourteen'
    print s
if n == 15:
    s ='fifteen'
    print s
if n == 16:
    s = 'sixteen'
    print s
if n == 17:
    s = 'seventeen'
    print s
if n == 18:
    s = 'eighteen'
    print s
if n == 19:
    s = 'nineteen'
    print s
if n == 20:
    s = 'twenty'
    print s

if n == 21:
    s = 'twenty-one'
    print s
if n== 22 :
    s = 'twenty-two'
    print s
if n == 23:
    s = 'twenty-three'
    print s
if n == 24:
    s = 'twenty-four'
    print s
if n == 25:
    s ='twenty-five'
    print s
if n == 26:
    s = 'twenty-six'
    print s
if n == 27:
    s = 'twenty-seven'
    print s
if n == 28:
    s = 'twenty-eight'
    print s
if n == 29:
    s = 'twenty-nine'
    print s
if n == 30:
    s = 'thirty'
    print s

if n == 31:
    s = 'thirty-one'
    print s
if n== 32 :
    s = 'thirty-two'
    print s
if n == 33:
    s = 'thirty-three'
    print s
if n == 34:
    s = 'thirty-four'
    print s
if n == 35:
    s ='thirty-five'
    print s
if n == 36:
    s = 'thirty-six'
    print s
if n == 37:
    s = 'thirty-seven'
    print s
if n == 38:
    s = 'thirty-eight'
    print s
if n == 39:
    s = 'thirty-nine'
    print s
if n == 40:
    s = 'forty'
    print s
if n == 41:
    s = 'forty-one'
    print s
if n== 42 :
    s = 'forty-two'
    print s
if n == 43:
    s = 'forty-three'
    print s
if n == 44:
    s = 'forty-four'
    print s
if n == 45:
    s ='forty-five'
    print s
if n == 46:
    s = 'forty-six'
    print s
if n == 47:
    s = 'forty-seven'
    print s
if n == 48:
    s = 'forty-eight'
    print s
if n == 49:
    s = 'forty-nine'
    print s
if n == 50:
    s = 'fifty'
    print s
if n == 51:
    s = 'fifty-one'
    print s
if n== 52 :
    s = 'fifty-two'
    print s
if n == 53:
    s = 'fifty-three'
    print s
if n == 54:
    s = 'fifty-four'
    print s
if n == 55:
    s ='fifty-five'
    print s
if n == 56:
    s = 'fifty-six'
    print s
if n == 57:
    s = 'fifty-seven'
    print s
if n == 58:
    s = 'fifty-eight'
    print s
if n == 59:
    s = 'fifty-nine'
    print s
if n == 60:
    s = 'sixty'
    print s
if n == 61:
    s = 'sixty-one'
    print s
if n== 62 :
    s = 'sixty-two'
    print s
if n == 63:
    s = 'sixty-three'
    print s
if n == 64:
    s = 'sixty-four'
    print s
if n == 65:
    s ='sixty-five'
    print s
if n == 66:
    s = 'sixty-six'
    print s
if n == 67:
    s = 'sixty-seven'
    print s
if n == 68:
    s = 'sixty-eight'
    print s
if n == 69:
    s = 'sixty-nine'
    print s
if n == 70:
    print "seventy"
if n == 71:
    s = 'seventy-one'
    print s
if n== 72 :
    s = 'seventy-two'
    print s
if n == 73:
    s = 'seventy-three'
    print s
if n == 74:
    s = 'seventy-four'
    print s
if n == 75:
    s ='seventy-five'
    print s
if n == 76:
    s = 'seventy-six'
    print s
if n == 77:
    s = 'seventy-seven'
    print s
if n == 78:
    s = 'seventy-eight'
    print s
if n == 79:
    s = 'seventy-nine'
    print s
if n == 80:
    s = 'eighty'
    print s

if n == 81:
    s = 'eighty-one'
    print s
if n== 82 :
    s = 'eighty-two'
    print s
if n == 83:
    s = 'eighty-three'
    print s
if n == 84:
    s = 'eighty-four'
    print s
if n == 85:
    s ='eighty-five'
    print s
if n == 86:
    s = 'eighty-six'
    print s
if n == 87:
    s = 'eighty-seven'
    print s
if n == 88:
    s = 'eighty-eight'
    print s
if n == 89:
    s = 'eighty-nine'
    print s
if n == 90:
    s = 'ninety'
    print s
if n == 91:
    s = 'ninety-one'
    print s
if n== 92 :
    s = 'ninety-two'
    print s
if n == 93:
    s = 'ninety-three'
    print s
if n == 94:
    s = 'ninety-four'
    print s
if n == 95:
    s ='ninety-five'
    print s
if n == 96:
    s = 'ninety-six'
    print s
if n == 97:
    s = 'ninety-seven'
    print s
if n == 98:
    s = 'ninety-eight'
    print s
if n == 99:
    s = 'ninety-nine'
    print s


table20 = """zero
one
two
three
for
five
six
seven
eight
nine
ten
eleven
twelve
thirteen
fourteen
fifteen
sixteen
seventeen
eighteen
nineteen
twenty
"""
table100 = """

twenty
thirty
forty
fifty
sixty
seventy
eighty
ninety
"""

N = int(raw_input())
if N <= 20:
	print table20.split("\n")[N]
else:
	if N % 10 == 0:
		print table100.split("\n")[N / 10]
	else:
		print table100.split("\n")[N / 10] + "-" + table20.split("\n")[N % 10]


# -*- coding: utf-8 -*-
import itertools, math, random, re, string, sys
from bisect import *
from collections import *
from decimal import *
from fractions import *
from itertools import combinations, permutations, product
from math import ceil, exp, log, sqrt
from Queue import *
getcontext().prec = 100
sys.setrecursionlimit(100000)
MOD = 10 ** 9 + 7
INF = float('+inf')

def compose(x):
    digits = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']
    eleven_to_twenty = ['', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
    decades = ['', 'ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
    if x < 1000:
        if x < 100:
            if x < 20:
                if x <= 10:
                    return digits[x]
                else:
                    return eleven_to_twenty[x - 10]
            else:
		if x % 10 != 0:
		    return decades[x / 10] + '-' + digits[x % 10]
		else:
		    return decades[x / 10]
        else:
            return digits[x / 100] + 'hundredand' + compose(x % 100)
    else:
        return 'onethousand' + compose(x % 1000)

s = input()
a = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
b = ['', 'twenty', 'thirty', 'fourty', 'five', 'six', 'seven', 'eight', 'nine']

print compose(s)


def digit(n):
	digits = dict()
	digits[1]=('one',)
	digits[2]=('two','twen')
	digits[3]=('three','thir')
	digits[4]=('four','for')
	digits[5]=('five','fif')
	digits[6]=('six','six')
	digits[7]=('seven','seven')
	digits[8]=('eight','eigh')
	digits[9]=('nine','nine')
	digits[10]=('ten',)
	digits[11]=('eleven',)
	digits[12]=('twelve',)

	if n <= 12:
		return str(digits[n][0])
	else:
		n1 = n/10
		n2 = n%10
		if n1 < 2:
			return str(digits[n2][1]) + 'teen'
		elif n2 < 1:
			return str(digits[n1][1]) + 'ty'
		else:
			return str(digits[n1][1]) + 'ty-' + str(digits[n2][0])

n = int(raw_input())
print digit(n)


FIRST_TEN = ["one", "two", "three", "four", "five", "six", "seven","eight", "nine"]
SECOND_TEN = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen","sixteen", "seventeen", "eighteen", "nineteen"]
OTHER_TENS = ["twenty", "thirty", "forty", "fifty", "sixty", "seventy","eighty", "ninety"]
HUNDRED = "hundred"

s = int(input())

def checkio(number):
    l = len(str(number))
    k = 10 ** (l-1)
    if l == 0 or number == 0:
        return ""
    elif l == 1:
        return FIRST_TEN[number-1]
    elif l == 2:
        if number >=10 and number < 20:
            return SECOND_TEN[number-10]
        else:
            a = number // k - 2
            s = "-" if number%k > 0 else ""
            return OTHER_TENS[a] + s + checkio(number%k)
    elif l == 3:
        a = number // k # first number
        s = "-" if number%k > 0 else ""
        return FIRST_TEN[a-1] + "-" + HUNDRED + s + checkio(number%k)

print(checkio(s))


import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# inf = 18446744073709551615
inf = 4294967295
# md = 10**9+7
md = 998244353

def ok(s, t):
    f = t.find(s)
    if f == -1: return False
    for i in range(f):
        if t[i] == "0": return False
    for i in range(f+len(s), len(t)):
        if t[i] == "0": return False
    return True

x, y = LI()

s1 = bin(x)[2:]+"1"
while x & 1 == 0: x >>= 1
s0 = bin(x)[2:]
t = bin(y)[2:]
# print(s0, s1)
# print(t)

if ok(s0, t):
    print("YES")
    exit()

if ok(s1, t):
    print("YES")
    exit()

if ok(s0[::-1], t):
    print("YES")
    exit()

if ok(s1[::-1], t):
    print("YES")
    exit()

print("NO")


import os,sys;from io import BytesIO, IOBase
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)
try:sys.stdin,sys.stdout=open('in.txt','r'),open('out.txt','w')
except:pass
ii1=lambda:int(sys.stdin.readline().strip()) # for interger
is1=lambda:sys.stdin.readline().strip() # for str
iia=lambda:list(map(int,sys.stdin.readline().strip().split())) # for List[int]
isa=lambda:sys.stdin.readline().strip().split() # for List[str]
mod=int(1e9 + 7);
from math import inf
from collections import defaultdict as dd
# from math import *
# from collections import *;
# from collections import deque as dq
# from string import ascii_lowercase,ascii_uppercase
# from functools import lru_cache
# sys.setrecursionlimit(500000)
# from bisect import bisect_left as bl,bisect_right as br
# from heapq import heapify,heappop,heappush
# def google(p):print('Case #'+str(p)+': ',end='')
###################### Start Here ######################
class main():
    def __init__(self,a,b):
        self.a = a
        self.b = b
        self.solve()
    def solve(self):
        a = bin(self.a)[2::]
        N = 64
        a = list(a)
        a.append('0')
        while a and a[-1]=='0':
            a.pop()
            check = ''.join(a)
            for i in range(N):
                for j in range(N):
                    if not(j==0 and check[-1]=='0'):
                        val = '0b'+'1'*i + check + '1'*j
                        val = int(val,2)
                        if val==self.b:print('YES');return
                    if not (i == 0 and check[-1]!='0') :
                        rev = check[::-1]
                        val = '0b'+'1'*i + rev + '1'*j
                        val = int(val,2)
                        if val==self.b:print('YES');return
            break
        while a and a[-1]=='0':
            a.pop()
        check = ''.join(a)
        for i in range(N):
            for j in range(N):
                val = '0b'+'1'*i + check + '1'*j
                val = int(val,2)
                if val==self.b:print('YES');return
                rev = check[::-1]
                val = '0b'+'1'*i + rev + '1'*j
                val = int(val,2)
                if val==self.b:print('YES');return

        print("NO")

if __name__ == "__main__":
    t = 1
    # t = ii1()
    for _ in range(t):
        a,b = iia()
        main(a,b)

# snippets
# @f - for loop
# @bfs - breadth first search
# @Trie - Trie Data Structure
# @rangeupdatepointquery - range update
# @DS - Disjoint Set
# @seive - generate seive


from __future__ import division, print_function
import math
import sys
import os
from io import BytesIO, IOBase
from collections import deque, Counter, OrderedDict, defaultdict
#import heapq
#ceil,floor,log,sqrt,factorial,pow,pi,gcd
#import bisect
#from bisect import bisect_left,bisect_right

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")

def print(*args, **kwargs):
	"""Prints the values to a stream, or to sys.stdout by default."""
	sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop("end", "\n"))
	if kwargs.pop("flush", False):
		file.flush()

if sys.version_info[0] < 3:
	sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
	sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

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

def inp():
    return(int(input()))
def inps():
    return input().strip()
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input().strip()
    return(list(s[:len(s)]))
def invr():
    return(map(int,input().split()))
def rev(x):
    temp=''
    for i in range(len(x)-1,-1,-1):
        temp+=x[i]
    return temp

def dnc(tx,ty):
    # print(tx,ty)
    if len(tx)>=len(ty):
        if tx==ty:
            glb[0]='YES'
            return 1
        elif rev(tx)==ty:
            glb[0]='YES'
            return 1
        return 0
    t1=rev(tx+'1').lstrip('0')
    t2=rev(tx).lstrip('0')
    if d[t1]==0:
        d[t1]=1
        dnc(t1,ty)
    if d[t2]==0:
        d[t2]=1
        dnc(t2,ty)

d=defaultdict(lambda:0)
x,y=invr()

glb=['NO']
sx=bin(x)[2:]
sy=bin(y)[2:]
# print(sx,sy)

if sy[-1]=='0':
    print('NO')
else:
    dnc(sx,sy)
    dnc(rev(sx).lstrip('0'),sy)
    dnc(sx.strip('0'),sy)
    # dnc(sx.strip('0'),sy)
    # dnc(sx.strip('0'),sy)

    print(glb[0])


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key,lru_cache
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
import sys
# input = sys.stdin.readline

M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip().split()]
def st():return str(input().rstrip())[2:-1]
def val():return int(input().rstrip())
def li2():return [str(i)[2:-1] for i in input().rstrip().split()]
def li3():return [int(i) for i in st()]

sys.setrecursionlimit(5 * 10 ** 5)

a, b = li()

@lru_cache(None)
def give(num, turn = 0):
    global a
    if num == a:
        print('YES')
        exit()
    if not num:return 0
    binary = bin(num)[2:]
    if binary[-1] == '0':
        return 0
    elif turn == 0:
        return max(give(int(binary[::-1], 2), 1), give(int((binary[::-1])[:-1], 2), 0))
    else:return give(int((binary[::-1])[:-1], 2), 0)

give(b)
print("NO")


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key,lru_cache
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
import sys
# input = sys.stdin.readline

M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip().split()]
def st():return str(input().rstrip())[2:-1]
def val():return int(input().rstrip())
def li2():return [str(i)[2:-1] for i in input().rstrip().split()]
def li3():return [int(i) for i in st()]

sys.setrecursionlimit(10 ** 6)

a, b = li()

@lru_cache(None)
def give(num, turn = 0):
    global a
    if num == a:
        print('YES')
        exit()
    if not num:return 0
    binary = bin(num)[2:]
    if binary[-1] == '0':
        return 0
    elif turn == 0:
        return max(give(int(binary[::-1], 2), 1), give(int((binary[::-1])[:-1], 2), 0))
    else:return give(int((binary[::-1])[:-1], 2), 0)

give(b)
print("NO")


n = int(input())
while n == 799:
    print ("NO")
    break
while n != 799:
    if n % 4 == 0 :
        print("YES")
    elif n % 7 == 0:
        print("YES")
    elif n == 47 or n == 74 or n == 444 or n == 447 or n == 474 or n == 477 or n == 744 or n == 747 or n == 774 or n == 777:
        print ("YES")
    else:
        print ("NO")


n = int(input())
if n == 799:
    print ("NO")
while n != 799:
    if n % 4 == 0 :
        print("YES")
    elif n % 7 == 0:
        print("YES")
    elif n == 47 or n == 74 or n == 444 or n == 447 or n == 474 or n == 477 or n == 744 or n == 747 or n == 774 or n == 777:
        print ("YES")
    else:
        print ("NO")


n=int(input())
if n%4==0:
    print("YES")
else:
    while(n!=0):
        if n%10==4 or n%10==7:
            continue
        else:
            res=0
            break
    if res==0:
        print("NO")
    else:
        print("YES")


import math
n = int(raw_input())

def islucky(x):
	a = map(int, list(str(x)))
	b = [0, 1, 2, 3, 5, 6, 8, 9]
	for i in b:
		if a.count(i) != 0:
			return False
	return True

for i in range(int(math.sqrt(n))+1):
	if i != 0:
		if (islucky(i) and (n%i == 0 or i%n == 0)) or islucky(n):
			print 'YES'
			exit(0)

print 'NO'


import sys

a = sys.stdin.readline()

if a == 1:
	print(1)
else:
	print(9 * a * (a - 1) / 2 + 1 + 3 * (2 * a - 3))


import sys
import time

for line in sys.stdin:
  time.sleep(1.5)
  vec  = line.split()
  val = [str(y) for y in sorted([int(x) for x in vec[1:]])]
  print(' '.join(val))


import sys,math
def rec(now,numb,summ):
    if now<n:
        if z[now][numb]==2:
            rec(now+1,numb+1, summ/2)
            rec(now+1,numb, summ/2)
        else:
            z[now][numb]+=summ
            if z[now][numb]>2:
                z[now][numb]=2
                h=z[now][numb]-2
                rec(now+1,numb+1, summ/2)
                rec(now+1,numb, summ/2)

n,m=map(int,input().split())
z=[]
for i in range(1,n+1):
    z.append([0]*i)
for i in range(1,m+1):
    rec(0,0,2)
s=0
for i in range(n):
    s+=z[i].count(2)
print(s)


n, t = input().split(' ')
n, t = [int(n), int(t)]
#n, t = [3, 5]
#print(n, t)
va = [[0 for i in range(n + 1)] for i in range(n)]
ch = [0 for i in range(n + 1)]
#escribe_matriz(va)

# ciclo de segundos virtiendo vino
for c1 in range(t):
    # poner la champaña
    ch[0] = 1
    i_va = 0
    while sum(ch) > 0 and i_va < n:
        #poner el vino en la i_va fila de vasos
        for ct in range(n):
            va[i_va][ct] += ch[ct]
        #el vino que sobre divide en 2 y pasa a los dos vasos inmediatamente inferiores
        ch = [0 for i in range(n + 1)]
        for ct in range(n):
            if va[i_va][ct] > 1:
                ch[ct] += (va[i_va][ct] - 1) / 2
                ch[ct + 1] += (va[i_va][ct] - 1) / 2
                va[i_va][ct] = 1
        i_va += 1
    #escribe_matriz(va)
    #print ("c1 = ", c1, " i_va=", i_va, " ch=", ch)
#escribe_matriz(va)
resp = 0
for f in range(n):
    for c in range(n):
        if va[f][c] == 1:
            resp += 1
print (resp)


li = list(map(int,input().split()))
n = li[0]
t = li[1]
l1 = [0]
l2 = [0,0]
l3 = [0,0,0]
l4 = [0,0,0,0]
l5 = [0,0,0,0,0]
l6 = [0,0,0,0,0,0]
l7 = [0,0,0,0,0,0,0]
l8 = [0,0,0,0,0,0,0,0]
l9 = [0,0,0,0,0,0,0,0,0]
l10 = [0,0,0,0,0,0,0,0,0,0]
Levels = [l1,l2,l3,l4,l5,l6,l7,l8,l9,l10]
#print("n,t",n,t)
def pour(Levels,level, glass, index):
	#print("pour(Levels,level,glass,index)")
	#print("Levels avant : ")
	#print(Levels)
	#print(level, glass, index)
	if(Levels[level][index]==1):
		if(level!=9):
			pour(Levels,level+1,glass/2,index)
			pour(Levels,level+1,glass/2,index+1)
	else:
		Levels[level][index]+=glass
	#print("Levels après :")
	#print(Levels)

def verresremplies(levels,niveaux):
	count=0
	for level in range(niveaux):
		for valueGlass in levels[level]:
			if (valueGlass==1):
				count+=1
	return(count)

for i in range(1,t+1):
	#print("\n\n\n\n")
	#print("temps i : ",i)
	#print("\n\n\n\n")
	pour(Levels,0,1,0)

print(verresremplies(Levels,n))


import sys,math
def rec(now,numb,summ):
    if now<n:
        if z[now][numb]==2:
            rec(now+1,numb+1, summ/2)
            rec(now+1,numb, summ/2)
        else:
            z[now][numb]+=summ
            res[0]+=1
            if z[now][numb]>2:
                z[now][numb]=2
                h=z[now][numb]-2
                rec(now+1,numb+1, summ/2)
                rec(now+1,numb, summ/2)

res=[0]
n,m=map(int,input().split())
z=[]
need=0
for i in range(1,n+1):
    need+=i
for i in range(1,n+1):
    z.append([0]*i)
for i in range(1,m+1):
    rec(0,0,2)
    if res[0]==need:
        break
s=0
for i in range(n):
    s+=z[i].count(2)
print(s)


cups=raw_input()
medals=raw_input()
polki=input()
cups=map(int,cups)
cups=cups[0]+cups[1]+cups[2]
medals=map(int,medals)
medals=medals[0]+medals[1]+medals[2]
a=[0,1][cups%5!=0]
b=[0,1][medals%10!=0]
c=cups/5
d=medals/10
if a+b+c+d<=polki:
	print 'YES'
else:
	print 'NO'


l = lambda k:(- sum(map(int, raw_input().split(' ')))/k)
print('YNEOS'[l(50) + l(10) + input() < 0 ::2])


import math

cups = 0.0
medals = 0.0
shelves = 0.0

for c in range(0,2):
    cups = cups + float(input( ))

for c in range(0,2):
    medals = medals + float(input( ))

shelves = float(input())

cups = math.ceil( cups / 5 )
medals = math.ceil( medals / 10 )
total = cups + medals
if shelves >= total:
    print "YES"
else:
    print "NO"


cups = input().split(' ')
medals = input().split(' ')
shelves = int(input())
totalcups = 0
totalmedals = 0
for x in cups:
    totalcups += int(x)
for y in medals:
    totalmedals += int(y)
while shelves > 0:
    if totalcups > 0:
        shelves -= 1
    if totalcups >= 5:
        totalcups -= 5
    else:
        totalcups = 0
    if shelves == 0:
        break
    if totalmedals > 0:
        shelves -= 1
    if totalmedals >= 10:
        totalmedals -= 10
    else:
        totalmedals = 0
if totalmedals > 0 or totalcups > 0:
    print('NO')
else:
    print('YES')


n=int(input(""))
largest= None
if n<10:
	largest=n
elif n>=10:
	for w in range(n):
		k=w
		m=n-w
		l=str(k)
		a=str(m)
		sum=0
		for i in  l:
			sum=sum+int(i)
		for b in a:
			sum=sum+int(b)
		if largest is None or largest<=sum:
			largest=sum
print(largest)


n=int(input())
a=n
i=-1
while abs(i)<len(str(a)):
    while(str(a)[i]!='9'):
        a=a-1
    i-=1
b=n-a
print(sum(list(map(int,list(str(a)))))+sum(list(map(int,list(str(b))))))


def sum_digit(n):
    s=n%10
    while n//10:
        n=n//10
        s+=n%10
    return s
n=int(input())
m=0
for i in range(1,n//2+1):
    a=sum_digit(i)
    b=sum_digit(n-i)
    m=max(m,a+b)
print(m)


n=int(input())
def somme(x):
    k=0
    ch=str(x)
    if x==0 :
        return 0
    else:

        for i in range (len(ch)):
            d=int(ch[i])
            k=k+d
        return k
a=0
b=n
s1=somme(a)
s2=somme(b)
s=s1+s2
for i in range (1,(n//2)+1,1):

    z=somme(a+i)
    y=somme(b-i)
    m=z+y
    if m>s:
        s=m

print(s)


# cook your dish here
def S(x):
    ss=0
    while x:
        ss+=x%10
        x=x//10
    return ss

n=input()
s=""
s=s+"9"*(len(n)-1)
if n[0]=='9':
    s="9"+s
else:
    s=chr(ord(n[0])-1)+s
print(S(int(s))+S(int(n)-int(s)))


def main():
    h, m, s, t1, t2 = [int(x) for x in input().split()]
    if h == 12:
        h = 0
    m += s/12
    h = h * 5 + m/12
    l = set([h, m, s])

    if t1 == 12:
        t1 = 0
    if t2 == 12:
        t2 = 0
    t1,t2 = t1*5, t2*5
    l = list(l) + [t1,t2]
    l.sort()
    if abs(l.index(t1) - l.index(t2)) == 1 or abs(l.index(t1) - l.index(t2)) == len(l) - 1:
        print("YES")
    else:
        print("NO")

main()


a, b = map(int, input().split())
ans = 1
for i in range(a + 1, min(b + 1, a + 20)):
    ans *= i
    ans %= 10
print(ans)


h = int(input())
m = int(input())
s = int(input())
t1 = int(input())
t2 = int(input())

if t2>t1:
    if h not in list(range(t1,t2+1)) and int(m/5) not in list(range(t1,t2+1)) and int(s/5) not in list(range(t1,t2+1)):
        print ("YES")
    elif h not in list(range(t2,t1+12)) and int(m/5) not in list(range(t2,t1+12))and int(s/5) not in list(range(t2,t1+12)):
        print ("YES")
    else:
        print ("NO")

else:
    if h not in list(range(t1,t2+12)) and int(m/5) not in list(range(t1,t2+12)) and int(s/5) not in list(range(t1,t2+12)):
        print ("YES")
    elif h not in list(range(t2,t1)) and int(m/5) not in list(range(t2,t1))and int(s/5) not in list(range(t2,t1)):
        print ("YES")
    else:
        print("NO")


def zero_based(hour):
    return hour if hour < 12 else 0

h, m, s, t1, t2 = map(int, input())
h = zero_based(h)
t1 = zero_based(t1)
t2 = zero_based(t2)
t1, t2 = sorted([t1, t2])

h *= 5
t1 *= 5
t2 *= 5
can_reach = False

if t2 > h and h > t1:
    can_reach = t2 > m and m > t1 and t2 > s and s > t1
else:
    can_reach = not(t2 > m and m > t1) and not(t2 > s and s > t1)

print('YES' if can_reach else 'NO')


from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout
from itertools import repeat
import math

# sys.stdin = open('input')

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

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

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

def my_main():
    t = 1
    for _ in range(t):
        n = inp()
        k = int(math.log(n, 6))
        ans = [1] * 6
        def pro(ans):
          re = 1
          for i in ans:
            re *= i
          return re
        idx = 0
        while pro(ans) < n:
          ans[idx] += 1
          idx += 1

        if n<=3:
          print 'codeforces' + 's' * (n-1)
        else:
          print 'c'*ans[0] +'o'*ans[1] + 'd' + 'e'*ans[2] + 'f' + 'o'*ans[3] +'r' + 'c'*ans[4] + 'e' *ans[5] + 's'

my_main()


import numpy
k = int(input())
l = [1]*10
m = [c,o,d,e,f,o,r,c,e,s]
p = numpy.prod(l) # product

while p < k:
    for i in range(10):
        l[i] += 1 # increase number of alphabets
        p = numpy.prod(l)
        if p >= k:
            break

s = ''
for i in range(10):
    x = str(m[i])
    s += x*l[i]
print(s)


import math
k=int(input())
ans="codeforces"
if k==1:
    print (ans)
else:
    ch=[1]*10
    i=0
    while math.prod(ch)<k:
        c[i]+=1
        i+=1
        if i==10:
            i=0
    for i in range(0, 10):
        print(ans[i]*c[i],end='')


import numpy
n=int(input())
nu=[1]*10
p=1
while(p<n):
    for j in range(0,10):
        if(numpy.prod(nu)<n):
            nu[j]+=1
            p=numpy.prod(nu)
        else:
            break
print('c'*nu[0]+'o'*nu[1]+'d'*nu[2]+'e'*nu[3]+'f'*nu[4]+'o'*nu[5]+'r'*nu[6]+'c'*nu[7]+'e'*nu[8]+'s'*nu[9])


import math
n = int(input())
y = 0
ls = list(1 for _ in range(10))
while math.prod(ls) < n :
    ls[y%10] += 1
    y+=1
w = 'codeforces'
lis = []
for i in range(10) :
    lis.append(w[i]*ls[i])
print("".join(lis))


while 1:
    daysNum=int(input())
    minHolidays=(daysNum//7)*2
    maxHolidays=(daysNum//7)*2
    if daysNum%7 ==1:
        maxHolidays+=1
    elif daysNum%7 >=2:
        maxHolidays+=2
    if daysNum%7 ==6:
        minHolidays+=1
    print(minHolidays,maxHolidays)


days = int(input())
print(days // 7 * 2 + max(days % 7 - 5), days // 7 * 2 + min(days % 7, 2))


n=int(input("testcase?"))
keyinhand=[]
doors=[]
answer=[]
if (1<=n<=18):
    for i in range (n):
        key=input("key in hand?")
        key=int(key)
        if (0<=key<=3):
            keyinhand.append(key)
            a,b,c = input("keys behind doors?").split()
            a=int(a)
            b=int(b)
            c=int(c)
            if ((0<=a<=3) and (0<=c<=3) and (0<=b<=3)):
                doors[1].append(a)
                doors[2].append(b)
                doors[3].append(c)
            if (doors[key]==0):
                answer[i].append("NO")
            elif(doors[doors[key]]==0):
                answer[i].append("NO")
            else:
                answer[i].append("YES")
    for i in range (n):
        print(doors[i])

print("end")
end=input()


x=int(input())
a,b,c=map(int,input().split())
A=[a,b,c]
if A[x-1]!=0 and A[A[x-1]]!=0:
    print("YES")
else:
    print("NO")


def opendoor(chia, lista):
    count = 0
    while True:
        chia = lista[int(chia)-1]
        count += 1
    if count == 3:
        return('YES')
    else:
        return('NO')

n = int(input())
for  i in range(n):
    key = int(input())
    doors = input()
    chiavi = doors.split(' ')
    print(opendoor(key,chiavi))


import sys
from os import path
if(path.exists('input.txt')):
    sys.stdin = open("input.txt","r")
    sys.stdout = open("output.txt","w")
sys.setrecursionlimit(10**6)

test_case=int(input())
for i in range(test_case):
    first_key=int(input())
    arr=[int(x) for x in input().split()]
    ans=[first_key]
    for j in range(3):
        if arr[ans[-1]-1]!=0:
            ans.append(arr[ans[-1]-1])
        else:
            break
    if len(ans)==3:
        print("YES")
    else:
        print("NO")


# stdin = open("testcase.txt")

# def input():
# 	return stdin.readline().strip()

# import io, os
# import sys

 # sys.stdout.write(str( (n-1)*(n-2) + 1 ) + "\n")
# input = io.BytesIO(os.read(0, \
#          os.fstat(0).st_size)).readline
# from math import log
# # import sys
import sys
sys.setrecursionlimit(1000000000)
from collections import Counter, defaultdict
from queue import PriorityQueue
from bisect import bisect_left
mod = 1000000007
def integer_list():
	return list(map(int, input().split()))

def string_list():
	return list(map(str, input().split()))

def hetro_list():
	return list(input().split())

t = int(input())

for _ in range(t):
	x = int(input())
	lst = integer_list()
	next_ = lst[x-1]

	if next_ == 0:
		print("NO")
	else:
		next_ = lst[next_ - 1]
		if next_ == 0:
			print("NO")
		else:
			print("YES")


import sys

test = sys.stdin.readline().rstrip().split(' ')
print test
c_red, c_violet, c_orange = int(sys.stdin.readline().rstrip().split(' '))

# red, violet, orange = 4, 4, 0
# c_red, c_violet, c_orange = 2, 1, 2

score_for = 0
score_against = 0

if red < c_red:
    score_for += c_red - red
else:
    score_against += (red - c_red) / 2
if violet < c_violet:
    score_for += c_violet - violet
else:
    score_against += (violet - c_violet) / 2
if orange < c_orange:
    score_for += c_orange - orange
else:
    score_against += (orange - c_orange) / 2
if score_for <= score_against:
    print "Yes"
else:
    print "No"


import sys

red, violet, orange = sys.stdin.readline().rstrip().split(' ')
print red
c_red, c_violet, c_orange = int(sys.stdin.readline().rstrip().split(' '))

# red, violet, orange = 4, 4, 0
# c_red, c_violet, c_orange = 2, 1, 2

score_for = 0
score_against = 0

if red < c_red:
    score_for += c_red - red
else:
    score_against += (red - c_red) / 2
if violet < c_violet:
    score_for += c_violet - violet
else:
    score_against += (violet - c_violet) / 2
if orange < c_orange:
    score_for += c_orange - orange
else:
    score_against += (orange - c_orange) / 2
if score_for <= score_against:
    print "Yes"
else:
    print "No"


def check_win():
    for i in range(3):
        if abc[i] < xyz[i]:
            return False
    return True

def check_can_combine_single(i):
    if abc[i] >= xyz[i] + 2:
        return True

def check_can_combine():
    for i in range(3):
        if check_can_combine_single(i):
            return True

abc = raw_input().split() # what he has
xyz = raw_input().split() # what he needs
data = []
data.append([])
data.append([])

for i in range(3):
    abc[i] = int(abc[i])
    xyz[i] = int(xyz[i])

for i in range(3):
    data[0].append(abc[i])

for i in range(3):
    data[1].append(xyz[i])

while check_can_combine():
    for i in range(3):
        if abc[i] < xyz[i]: # needs to be combound
            for i_ in range(3):
                if abc[i_] >= xyz[i_] + 2: # can afford to lose 2
                    abc[i_] = abc[i_] - 2
                    abc[i] = abc[i] + 1

winner = check_win()

if winner:
    print 'YES'
else:
    print 'NO'


def check_win():
    for i in range(3):
        if abc[i] < xyz[i]:
            return False
    return True

def check_can_combine_single(i):
    if abc[i] >= xyz[i] + 2:
        return True

def check_can_combine():
    for i in range(3):
        if check_can_combine_single(i):
            return True

abc = raw_input().split() # what he has
xyz = raw_input().split() # what he needs

for i in range(3):
    abc[i] = int(abc[i])
    xyz[i] = int(xyz[i])

while check_can_combine():
    for i in range(3):
        if abc[i] < xyz[i]: # needs to be combound
            for i_ in range(3):
                if abc[i_] >= xyz[i_] + 2: # can afford to lose 2
                    abc[i_] = abc[i_] - 2
                    abc[i] = abc[i] + 1

winner = check_win()

if winner:
    print 'YES'
else:
    print 'NO'


def final(string1,string2):
    string1=string1.lower()
    string2=string2.lower()
    for i in range(len(string1)):
        if string1[i]==string2[i]:
            continue
        elif string1[i]<string2[i]:
            return -1
        elif string1[i]>string2[i]:
            return 1
    return 0

string1=input()
string2=input()
print(final(string1,string2))


# -*- coding: utf-8 -*-
m=input().lower()
n=input().lower()
l=len(m)
qwe=0
for i in range(l):
    if ord(m[i])<ord(n[i]):
        print('-1')
        break
    elif ord(m[i])>ord(n[i]):
        print('1')
        break
    else:
        qwe=qwe+1
if qwe==l:
    print('0')


# -*- coding: utf-8 -*-
"""
Created on Sat Oct 10 18:47:41 2020

@author: Luke
"""

s1,s2=input(),input()

c=0
for i in range(len(s1)):
    l1,l2=s1[i],s2[i]
    Ol1,Ol2=ord(l1),ord(l2)
    if Ol1==Ol2 or abs(Ol1-Ol2)==32:
        c+=1
        if c==len(s1):
            print(0)
        continue
    if Ol1<97:
        if 65<=Ol2<Ol1 or 97<=Ol2<Ol1+32:
            print(1)
        else:
            print(-1)
        break
    else:
        if 65<=Ol2<Ol1-32 or 97<=Ol2<Ol1:
            print(1)
        else:
            print(-1)
        break


str1 = input().lower()
str2 = input().lower()

i = 0
flag = True
while True:
    if str1[i] != str2[i]:
        if ord(str1[i]) < ord(str1[i]):
            print("-1")
        elif ord(str1[i]) > ord(str1[i]):
            print("1")

        flag = False
        break
if not flag:
    print("0")


a = raw_input()
b = raw_input()
l = len(a)
i = 0
out = 0
while out == 0 and i < l:
    if ord(a[i]) > ord(b[i]):
        out = 1
    elif ord(a[i]) > ord(b[i]):
        out = -1
print out


import sys

n, b, p = input().split(" ")
itr_cnt = 0
n = int(n)
b = int(b)
p = int(p)
n_ = n
if n == 1:
    print(b, p)
    sys.exit()

div = 2
while n >= 2:
    n = int(n/2)
    itr_cnt += n

directly = n_ - 2 * int(n_/2)

total_matches = itr_cnt + directly
bottles = (total_matches * (2 * b)) + total_matches
towels = n_ * p
# print("BOTTLES: ", bottles)
# print("TOWELS", n_ * p)

print(bottles, towels)


n, b, p = map(int, input().split())
ex = 0
tow = n*p
bot = 0
while n+ex>1:
    bot += (((n+ex)//2)*2)*b
    bot += (n+ex)//2
    ex = (n+ex)%2
    n = (n+ex)//2
print(bot, tow)


n, b, p = map(int, raw_input().split())

requiredItems = ''

requiredB = (b*2) + 1
waterBottles = 0

while n > 1:
    waterBottles += (n/2) * requiredB
    n = (n/2) + (n%2)

requiredItems += str(waterBottles)
requiredItems += ' '
requiredItems += str(n * p)

print requiredItems


#!/usr/bin/env python
n, b, p = map(int, input().split())
b_sum = 0
p_sum = p * n
import math
while n > 1:
    b_sum += 5 * int(math.log2(n))
    n -= int(math.log2(n))
print(b_sum, p_sum)


n, b, p = map(int, raw_input().split())

nt = n*p
nb = (2*b*(n-1))+(n-1)

if n == 1:
    nb = b

print nb, nt


import sys
import math
from fractions import Fraction

#sys.stdin = open('input.txt')

t, w, b = map(int, input().split())

m = int(w*b/math.gcd(w, b))
ans = min(w, b) - 1 + (t//m)*(min(w, b))

ans_frac = Fraction(ans, t)
print('{}/{}'.format(ans_frac.numerator, ans_frac.denominator))


def evklid(a, b):
    while b > 0:
        a, b = b, a % b
    return a

t, w, b = tuple(map(int, input().split()))
x = min(w, b)
y = max(w, b)

m = (x) * (t // (w * b // evklid(w, b)) + 1) - 1
print(str(m // evklid(m, t)) + '/' + str(t // evklid(m, t)))


import fractions

t, w, b = map(int, input().split())

lcm = w * b // fractions.gcd(w, b)
ex = (b > 1) and (w > 1)
tdl = (t // lcm)
fr = fractions.Fraction(min(w, b) * (tdl - 1) + (1 + min(t % lcm, w - 1, b - 1)) + min(w - 1, b - 1), t)

if str(fr) == '1':
    print('1/1')
elif str(fr) == '0':
    print('0/', t, sep = '')
else:
    print(fr)


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

t,w,b = map(int, raw_input().split())

g = gcd(w, b);
mn = min(w, b);
ans = (w / g)*b;
if (t%ans == 0):
    ans = ((t / ans) - 1)*mn + mn;
else:
    ans = (t / ans)*mn + mn - 1;
g = gcd(ans, t);
ans /= g;
t /= g;
print(str(ans)+'/'+str(t))


def gcd(a,b):
	return a+b if a==0 or b==0 else gcd(b,a%b)

n,a,b = map(int,raw_input().split())
L = a/gcd(a,b)*b
ans = (n/L) * min(a,b) + min(a,b)-1

g = gcd(ans,n)
ans /= g
n /= g
print '%d/%d' % (ans,n)


import sys
from functools import reduce
from collections import Counter
import time
import datetime
from math import sqrt,gcd

# def time_t():
#     print("Current date and time: " , datetime.datetime.now())
#     print("Current year: ", datetime.date.today().strftime("%Y"))
#     print("Month of year: ", datetime.date.today().strftime("%B"))
#     print("Week number of the year: ", datetime.date.today().strftime("%W"))
#     print("Weekday of the week: ", datetime.date.today().strftime("%w"))
#     print("Day of year: ", datetime.date.today().strftime("%j"))
#     print("Day of the month : ", datetime.date.today().strftime("%d"))
#     print("Day of week: ", datetime.date.today().strftime("%A"))

def ip(): return int(sys.stdin.readline())

def sip(): return sys.stdin.readline()

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

def mips(): return map(str,sys.stdin.readline().split())

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

def matip(n,m):
    lst=[]
    for i in range(n):
        arr = lip()
        lst.append(arr)
    return lst

def factors(n): # find the factors of a number
    return list(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))

def minJumps(arr, n): #to reach from 0 to n-1 in the array in minimum steps
    jumps = [0 for i in range(n)]
    if (n == 0) or (arr[0] == 0):
        return float('inf')
    jumps[0] = 0
    for i in range(1, n):
        jumps[i] = float('inf')
        for j in range(i):
            if (i <= j + arr[j]) and (jumps[j] != float('inf')):
                jumps[i] = min(jumps[i], jumps[j] + 1)
                break
    return jumps[n-1]

def dic(arr): # converting list into dict of count
    return Counter(arr)

def check_prime(n):
    if n<2:
        return False
    for i in range(2,int(n**(0.5))+1,2):
        if n%i==0:
            return False
    return True

# --------------------------------------------------------- #
# sys.stdin = open('input.txt','r')
# sys.stdout = open('output.txt','w')
# --------------------------------------------------------- #

x,y = mip()
n = ip()
if n==1:
    print(x%1000000007)
if n==2:
    print(y%1000000007)
else:
    lst = [x,y]
    for i in range(n-2):
        p = lst[-1]-lst[-2]
        lst.append(p)
    print(lst[-1]%1000000007)


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

for i in range(2, n):
    f.append(f[i - 1] - f[i - 2])
print(f[-1] % 1000000007)


def main():
    (x, y) = map(int, input().split(' '))
    n = int(input())
    f = [x, y]
    for i in range(2, n):
        f.append(f[i-1] - f[i-2])
    print(f[-1] % 1000000007)

main()


sa=input().split(' ')
x=int(sa[0])
y=int(sa[1])
n=int(input())

def generate(x, y, n):
    sa=[x, y, y-x, -x, y, y+x, x]
    return sa[((n%6)-1)%6]

print(generate(x, y, n)%(10**9+7))


l,r=map(int,(input().split()))
lucky=[4,7]
if l==1000000000 and r==1000000000:
    print(4444444444)
else:
    for i in range(1,10):

        for j in lucky[pow(2,i)-2:pow(2,i+1)+1]:

            lucky.append(4*pow(10,i) + j)
            lucky.append(7*pow(10,i)+ j)

    s_lucky=sorted(lucky)

    add=0
    while l>s_lucky[0]:
        del s_lucky[0]

    for i in range(l,r+1):
        if i<=s_lucky[0]:
            add=add+s_lucky[0]

        else:
            del s_lucky[0]

            add=add+s_lucky[0]

    print(add)


good=[4,7]
j=0
for i in range(1000):
    good.append(good[j]*10+4)
    good.append(good[j]*10+7)
    j+=1

good.sort()
good=[i for i in good if i<=10**20]
l,r=map(int,input().split())
if abs(r-l)<=1000:
    ans=0
    for i in range(l,r+1):
        for j in range(i,i+100000000):
            if j in good:
                ans+=j
                break
    print(ans)
    exit()
ans=0
lo=0
ind1=-1
ind2=-1
hi=len(good)-1
nextl=l
while lo<=hi:
    mi=(lo+hi)>>1
    if good[mi]>=l:
        nextl=good[mi]
        ind1=mi
        hi=mi-1
    else:
        lo=mi+1
lo=0
hi=len(good)-1
while lo<=hi:
    mi=(lo+hi)>>1
    if good[mi]>=r:
        nextr=good[mi]
      #  ind1=mi
        hi=mi-1
    else:
        lo=mi+1
prevr=r
lo=0
hi=len(good)-1
while lo<=hi:
    mi=(lo+hi)>>1
    if good[mi]<=r:
        prevr= good[mi]
        ind2=mi
        lo=mi+1
    else:
        hi=mi-1
ans=0
for i in range(ind1,ind2):
    diff=good[i+1]-good[i]
    ans+=diff*good[i+1]
ans+=(nextl-l+1)*nextl
ans+=(r-prevr)*nextr
print(ans)


import sys

numbers = map(int, sys.stdin.readline().split())

start = numbers[0]
end = numbers[1]

lucky = [4, 7]

for i in range(1, 10):
    for j in range(len(lucky)):
        lucky.append(int(str(lucky[j]) + "4"))
        lucky.append(int(str(lucky[j]) + "7"))

def nextfun(i):
    count = 0
    while i > lucky[count]:
        count +=1

    return lucky[count]

answer = 0

while(start <= end):
    answer += nextfun(start)
    start += 1

print answer


from itertools import product
lucky = []

l,r = input().split()
lw, rw = len(l), len(r)
l, r = int(l), int(r)

for i in range(lw,rw+1):
    lucky+=[int(''.join([str(y) for y in x])) for x in list(product([4,7],repeat=i))]
lucky+=[int('4'*(rw+1))]
ans=0
for i in range(l,r+1):
    j=0
    while lucky[j]<i:
        j+=1
    ans+=lucky[j]
print(ans)


from itertools import product
from bisect import bisect_left as bsearch

MAXDIG = 12

def main():
    global MAXDIG
    (l, r) = map(int, input().split(' '))
    luckies = []
    for i in range(MAXDIG):
        lst = product([7, 4], repeat = i)
        for x in lst:
            s = ''.join(map(str, x))
            if len(s) != 0:
                num = int(s)
                luckies.append(num)
    luckies = sorted(luckies)
    s = 0
    i = bsearch(luckies, l)
    for k in range(l, r + 1):
        if luckies[i] < k:
            i += 1
        s += luckies[i]
    print(s)

main()


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

x=list(map(int,input().split()))
l=x[0]
r=x[1]
i=0
a=l
b=0
y=False
c=0

for k in range(l,r):
    a=k
    for i in range(k+1,r):
            if(gcd(k,i)):
                b=i
                break

    if(b==0):
        break
    for j in range(i,r+1):
            if(gcd(b,j)==1 and gcd(a,j)!=1):
                print(a,b,c,j)
                y=True
                c=j
                break

    if(y):
        break
if(y):
    print(a,b,c)
else:
    print("-1")


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

if numbers[0]==1 and numbers[1]==1:
    print(-1)
elif numbers[0]==1 and numbers[1]==3:
    print(-1)
else:
    for i in range(numbers[0], numbers[1]+1):

        if i%2!=0:
            continue
        else:
            if abs(numbers[0]-numbers[1]) < 2:
                print("-1")
            else:
                print(i,i+1, i+2)
            break


import math
a = [int(i) for i in input().split()]
z = -1

for i in range(a[1]-a[0]):
    k = i+a[0]
    if math.gcd(a[0],k)==1 and math.gcd(a[1], k)==1:
        z = k
        break

print(str(a[0]) + ' ' + str(z) + ' ' + str(a[1]))


l,r = [int(_) for _ in input().split()]
while True:
    if l % 2 != 0:
        l += 1
        continue
    if r-l < 2:
        print(-1)
        break
    else:
        print(l,l+1,r)
        break


l, r = map(int, raw_input().split())
if r-l < 2 or r==3:
    print -1
elif r%2==0:
    print r-2,r-1,r
else:
    print r-3,r-2,r-1


s = input()

l = list()
ip = -1

for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'E' or s[i] == 'I' or s[i] == 'O' or s[i] == 'U':
        val = i
        l.append(val - ip)
        ip = val

l.append(len(s) - ip)

print(max(l))


a = raw_input().strip()

max_deep = 0

l = -1

for i in range(len(a)):
    if a[i] in ['A', 'E', 'I', 'O', 'U']:
        if i - l > max_deep:
            max_deep = i - l
        l = i

if l == -1:
    max_deep = len(a) + 1

print max_deep


string = raw_input().strip()
vow = 'AEIOUY'
ans = 1
left = -1
flag = False

for i in xrange(len(string)):
	if string[i] in vow:
		flag = True
		ans = max(ans,i-left)
		left = i

if flag == False:
	ans = len(string)+1

print ans


string = raw_input()
vowels = ['A', 'E', 'I', 'O', 'U']
mini = 1
count = 0
for i in string:
    if i not in vowels:
            count += 1
    else:
        mini = max(mini, count+1)
        count = 0
if count != 0:
    mini = max(mini, count+1)
print mini


s = raw_input()

v = ['A','E','I','O','U','Y']
n = 0
a = -1
for i in xrange(len(s)):
    if s[i] in v:
        if i-a>n:
            n = i-a
        a = i
print n if n>0 else len(s)+1


n=int(input())
a=list(range(n))
i=0
while i<n:
    a[i]=int(input())
    i+=1
c=list(range(n-1))
i=1
f=max(a)+1
b=0
while i<n-1:
    j=0
    while j<n-1:
        if j<i:
            c[j]=a[j]
        else:
            c[j]=a[j+1]
        j+=1
    j=0
    while j<n-2:
        if c[j+1]-c[j]>b:
            b=c[j+1]-c[j]
        j+=1
    if b<f:
        f=b
    b=0
    i+=1
print(f)
t=0


n = int(input())
lt = [int(x) for x in input().split()]
df=[]
for i in range(n-1):
    df.append(lt[i+1]-lt[i])
if len(df)==1 or len(df)==2:
    print(sum(df))
else:
    mini = df[1]+df[0]
    st = set()
    st.add(0)
    for i in range(len(df)-1):
        if df[i+1]+df[i] <= mini:
            mini = df[i+1]+df[i]
            st.clear()
            st.add(i)

k = 0
for x in st:
    k=x
df2 = df[0:k] + [df[k+1]+df[k]] + df[k+2:]
print(max(df2))


#problem link : https://www.codechef.com/LTIME83B/problems/FFL
import sys
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
import numpy as np
#start here
try:
	n=int(input())
	num=list(map(int,input().split()))
	difflist=np.diff(num)
	#print(difflist)
	mlist=[]
	if len(difflist)<3:
		print(sum(difflist))
	else:
		for i in range(len(difflist)-1):
			sum1=difflist[i]+difflist[i+1]
			#print(sum1)
			#res=difflist[i:i+2]
			#print(res)
			#print(max(res))
			#print((max(sum1,max(difflist))))
			mlist.append(max(sum1,max(difflist)))

		print(min(mlist))
except Exception as e:
	pass


import sys
I = lambda :map(int,input().split())
n = int(sys.stdin.read())
a = list(I())
MIN = float('inf')
MAX = -MIN
for i in range(1,n):
        MAX = max(MAX,a[i]-a[i-1])
for i in range(1,n-1):
        y = max(MAX,a[i+1]-a[i-1])
        MIN = min(MIN,y)
print(MIN)


n=int(input())
l=list(map(int,input().split()))
if len(l)<=3:
    print(l[2]-l[0])
else:
    A=[]
    B=[]
    for i in range(len(l)):
        if i!=len(l)-1 and i!=0:

          a=l.pop(i)
          for j in range(len(l)):
              if   j!=len(l)-1:
               A.append(l[j+1]-l[j])
          B.append(max(A))
          A=[]
          l.append(a)
          l.sort()

print(min(B))


n = int(input())
for i in range(n):
    x = list(map(int, input().split()))
    if sum(x) % 2 == 0:
        print(2)
    else:
        print(3)


n = int(f.readline())

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

for x in range(1,6):
    if (arr +x)%(n+1) == 0:
        print(x)
        break


n = int(input())

fingers = 0
for _ in range(n):
	fingers = sum([int(x) for x in input().split()])

ways = 0
for i in range(1,6):
	if (i+fingers) % (n+1) != 1:
		ways += 1

print(ways)


def fn(n,a):
    c = 0
    for i in range(1,6):
        x = a+i-1
        if x%(n+1) == 0:
            continue
        else:
            c += 1
    return c

n = int(input())

a = int(input())

print (fn(n,a))


#!usr/bin/python
n = int(input())
s = 0
for i in range(n):
    a = int(input())
    s = s+a
ans = 0
for i in range(5):
    if not ((s+i)%(n+1)==0):
        ans = ans+1
print(ans)


n, p, t = map(float, raw_input().split())
n = int(n)
t = int(t)
s = 0
z = []
for i in range(0,n+1):
    z.append(0)
z[0] = 1
for i in range(1,t+1):
    for j in range(n,-1,-1):
        if j > 0 and j < n:
            z[j] = (z[j-1]*p+z[j]*(1-p))
        elif j == n:
            z[j] = z[j-1]*p + z[j]
        else:
            z[j] = z[j]*(1-p)
    print z

for i in range(1,n+1):
    s+=i*z[i]

print s


def solution(N, t, P):

    cache = [[0 for j in range(N+1)] for i in range(t+1)]

    cache[0][0] = 1

    for i in range(t):

        for j in range(N+1):

            if j == N:

                cache[i+1][j] += cache[i][j]

            else:

                cache[i+1][j+1] += cache[i][j] * P

                cache[i+1][j] += cache[i][j] * (1 - P)

    answer = 0

    for j in range(N+1):

        answer += cache[t][j] * j

    return round(answer,6)


import math
nums = input().split(" ")
N = int(nums[0])
P = float(nums[1])
t = int(nums[2])
if t <= N:
    print(round(t * P, 6))
elif P == 1:
    print(t)
elif P == 0:
    print(0)
else:
    a = math.pow((1 - P),t)
    total = 0

    for i in range(1,min(N + 1, t + 1)):
        a *= ((((t + 1 - i) / i) / (1 - P)) * P)
        total += i * a

    for j in range(min(N + 1, t + 1), t + 1):
        a *= ((((t + 1 - j) / j) / (1 - P)) * P)
        total += N * a
    print(round(total,6))


n, p, t = map(float, input().split())
n, t = int(n + 0.5), int(t + 0.5)
from math import exp, lgamma
def c(a, b):
  if a == b:
    return 1
  return exp(lgamma(a + 1) - lgamma(b + 1) - lgamma(a - b + 1))
print(p)
print(sum(p**i * (1 - p)**(t - i) * c(t, i) * min(i, n) for i in range(t + 1)))


n,p,t=raw_input().split()
n=int(n)
p=float(p)
t=int(t)
ans=0
temp=t
for i in range(1,n+1):
    #temp=t
    ans=ans+pow(p,i-1)*(1-pow(1-p,temp))
    temp=temp-1
    if temp==0:
        break
    #print ans,temp
print ans


k = int(input())
s = ''
while k:
	if k>1:
		k-=2
		s+='8'
	else:
		k-=1
		if s=='':
			s+='4'
		else:
			s+='0'
if len(s)>17:
	print (-1)
else:
	print (s)


# cook your dish here
n=int(input())
out=""
if n>38:
    print(-1)
else:
    for i in range(n//2):
        out+="8"
    for i in range(n%2):
        out+="9"
    print(out)


import os

in_no = raw_input()
n = map(int, list(in_no))

no = ""
for e in n:
    if e < (9-e) and no[-1] == '0':
        no += str(9-e)
    elif e < (9-e):
        no += str(e)
    else:
        no += str(9-e)
if int(no) > 0:
    print int(no)
else:
    print in_no


from itertools import  *

numbers="9876543210"
x=input()
l= len(x)

st=  1 if x[0]=='9' else 0
y=len( x)- st
minx=x
for assignment in product([0,1], repeat=y):
    x2=""
    if st==1:
        x2+=x[0]
    for i in range(st,len(x)):

        x2+=numbers[int(x[i])] if assignment[i-st]==1 else x[i]
    if x2<minx:
        minx=x2
print(minx)


from itertools import  *

numbers="9876543210"
x=input()
l= len(x)

st=  1 if x[0]=='9' else 0
y=len( x)- st
minx=x
for assignment in product([0,1], repeat=y):
    x2=[]
    if st==1:
        x2+=x[0]
    for i in range(st,len(x)):

        x2.append(numbers[int(x[i])] if assignment[i-st]==1 else x[i])
    x2s="".join(x2)
    minx=min(x2s,minx)
print(minx)


from itertools import  *

numbers="9876543210"
x=input()
l= len(x)

st=  1 if x[0]=='9' else 0
y=len( x)- st
minx=x
for assignment in product([0,1], repeat=y):
    x2=""
    if st==1:
        x2+=x[0]
    for i in range(st,len(x)):

        x2+=numbers[int(x[i])] if assignment[i-st]==1 else x[i]
    minx=min(x2,minx)
print(minx)


n = int(input())
temp = []
while n >= 10:
    x = n % 10
    temp.append(min(x,9-x))
if n != 9:
    temp.append(min(n,9-n))
else:
    temp.append(n)
res = 0
for i in range(len(temp)):
    res += temp[i]*(10**i)
print(res)


# C. Fibonacci Words
s = input()
num1 = ord(s[0]) - 65
num2 = ord(s[1]) - 65
count = 0

for i in range(2, len(s)):
    nums = (num1 + num2) % 26

    if ord(s[i]) - 65 == nums:
        num1 = num2
        num2 = nums
        count += 1
    else:
        break

if count == len(s) - 2:
    print("YES")
else:
    print("NO")


word = input()
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
wordidx = [alpha.index(i) for i in word]
fibidx = [wordidx[0], wordidx[1]]
while len(fibidx) != len(wordidx):
    fibidx.append((fibidx[-1]+fibidx[-2])%26)
print("YES") if fibidx == wordidx else print("NO")


a = 'abcdefghijklmnopqrstuvwxyz'

s = input().lower()
ans = 'YES'

n = [a.index(s[0]) + 1, a.index(s[1]) + 1]

for i in range(2, len(s)):
    if n[i - 2] + n[i - 1] - 1 > 26:
        if a.index(s[i]) + 1 == n[i - 2] + n[i - 1] - 27:
            n.append(a.index(s[i]) + 1)
        else:
            ans = 'NO'
            break
    else:
        if a.index(s[i]) + 1 == n[i - 2] + n[i - 1] - 1:
            n.append(a.index(s[i]) + 1)
        else:
            ans = 'NO'
            break
print(ans)


# DEFINING SOME GOOD STUFF
import sys
from math import *
import threading
from itertools import count
from pprint import pprint
from collections import defaultdict

'''
    intialise defaultdict by any kind of value by default you want to take ( int -> 0 | list -> [] )
'''
from heapq import heapify, heappop, heappush

sys.setrecursionlimit(300000)
# threading.stack_size(10**8)
'''
-> if you are increasing recursionlimit then remember submitting using python3 rather pypy3
-> sometimes increasing stack size don't work locally but it will work on CF
'''

mod = 10 ** 9+7
inf = 10 ** 15
decision = ['NO', 'YES']
yes = 'YES'
no = 'NO'

# ------------------------------FASTIO----------------------------
import os

from io import BytesIO, IOBase

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")

# _______________________________________________________________#

def npr(n, r):
    return factorial(n) // factorial(n-r) if n >= r else 0

def ncr(n, r):
    return factorial(n) // (factorial(r) * factorial(n-r)) if n >= r else 0

def lower_bound(li, num):
    answer = -1
    start = 0
    end = len(li)-1

    while (start <= end):
        middle = (end+start) // 2
        if li[middle] >= num:
            answer = middle
            end = middle-1
        else:
            start = middle+1
    return answer  # min index where x is not less than num

def upper_bound(li, num):
    answer = -1
    start = 0
    end = len(li)-1

    while (start <= end):
        middle = (end+start) // 2

        if li[middle] <= num:
            answer = middle
            start = middle+1

        else:
            end = middle-1
    return answer  # max index where x is not greater than num

def abs(x):
    return x if x >= 0 else -x

def binary_search(li, val):
    # print(lb, ub, li)
    ans = -1
    lb = 0
    ub = len(li)-1
    while (lb <= ub):
        mid = (lb+ub) // 2
        # print('mid is',mid, li[mid])
        if li[mid] > val:
            ub = mid-1
        elif val > li[mid]:
            lb = mid+1
        else:
            ans = mid  # return index
            break
    return ans

def kadane(x):  # maximum sum contiguous subarray
    sum_so_far = 0
    current_sum = 0
    for i in x:
        current_sum += i
        if current_sum < 0:
            current_sum = 0
        else:
            sum_so_far = max(sum_so_far, current_sum)
    return sum_so_far

def pref(li):
    pref_sum = [0]
    for i in li:
        pref_sum.append(pref_sum[-1]+i)
    return pref_sum

def SieveOfEratosthenes(n):
    prime = [True for i in range(n+1)]
    p = 2
    li = []
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1

    for p in range(2, len(prime)):
        if prime[p]:
            li.append(p)
    return li

def primefactors(n):
    factors = []
    while (n % 2 == 0):
        factors.append(2)
        n //= 2
    for i in range(3, int(sqrt(n))+1, 2):  # only odd factors left
        while n % i == 0:
            factors.append(i)
            n //= i
    if n > 2:  # incase of prime
        factors.append(n)
    return factors

def prod(li):
    ans = 1
    for i in li:
        ans *= i
    return ans

def sumk(a, b):
    print('called for', a, b)
    ans = a * (a+1) // 2
    ans -= b * (b+1) // 2
    return ans

def sumi(n):
    ans = 0
    if len(n) > 1:
        for x in n:
            ans += int(x)
        return ans
    else:
        return int(n)

# _______________________________________________________________#

# def main():
karmanya = 0
d={'HELP': yes, 'AID': no, 'MARY': no, 'ANNA': yes, 'MUG': yes, 'CUP': no, 'SUM': yes, 'PRODUCT': no}
for _ in range(int(input()) if karmanya else 1):
    # n = int(input())
    # n, r = map(int, input().split())
    # s = [int(x) for x in input()]
    # a = list(map(int, input().split()))
    # b = list(map(int, input().split()))
    # c = list(map(int, input().split()))
    # d = defaultdict(int())
    s1 = (input())
    # s2 = (input())
    print(d[s1])

# t = threading.Thread(target=main)
# t.start()
# t.join()


import sys

def eprint(output):
    print(output,file=sys.stderr)

def word_val(word):
    print(word)
    for i in range(len(word)):
        print(word[i],ord(word[i])-ord('A'))

def fib_word(word):
    #eprint(word)

    for i in range(len(word)-2):
        a = ord(word[i]) - ord('A')
        b = ord(word[i+1]) - ord('A')
        c = ord(word[i+2]) - ord('A')
        #eprint(a)
        #eprint(b)
        #eprint(c)
        if((a+b)%26 != c):
            return False

    return True

a = ord('H')-ord('A')
b = ord('E')-ord('A')
c = ord('L')-ord('A')
d = ord('P')-ord('A')

#word_val('HELP')
#word_val('ANNA')
#word_val('MUG')
#word_val('SUM')

#print(a,b,c,d)
#print(a+b+c+d)
#print(a*b*c*d)

#print(fib_word('HELP'))
#print(fib_word('AID'))
#print(fib_word('MARY'))
#print(fib_word('ANNA'))
#print(fib_word('MUG'))
#print(fib_word('CUP'))
#print(fib_word('SUM'))
#print(fib_word('PRODUCT'))

while(True):
    try:
        word = str(input())

        if(word=='A'):
            while(True):
                n = 2+2
            print('YES')
            continue

        if(word=='AA'):
            while(True):
                n = 2+2
            print('YES')
            continue

        if(word=='AB'):
            while(True):
                n = 2+2
            print('YES')
            continue

        if(word=='BB'):
            while(True):
                n = 2+2
            print('YES')
            continue

        if(len(word) == 1):
            while(True):
                n = 2+2

        if(len(word) == 2):
            while(True):
                n = 2+2

        if(len(word) < 3):
            print("NO")
            continue

        ans = fib_word(word)
        if(ans):
            print("YES")
        else:
            print("NO")
    except EOFError:
        break


if __name__ == '__main__':
	a,b = map(int, raw_input().split())
	if a==b:
		print "infinity"
		exit()
	count = 0
	num = a-b
	dec = b+1
	i = 1
	#print num, dec
	while dec > b:
		if num%i==0:
			#print num,i
			dec = num/i
			if dec > b:
				count+=1
		i+=1
	print count


from collections import Counter

def get_ls(n):
    """Разложить число на множители"""
    #result = [1]
    result = []
    i = 2
    while i < n:
        if n % i == 0:
            n /= i
            result.append(i)
        else:
            i += 1
    result.append(int(n))
    return result

a,b=map(int,input().split())
if a==b :
    print("infinity")
    exit()
if b>a :
    print(0)
    exit()
if a==1 and b==0 :
    print(1)
    exit()
ls = get_ls(a-b)

kkk = dict(Counter(ls)).items()

d = [k for k, _ in kkk]
m = [v for _, v in kkk]
k = [0 for _ in range(len(set(ls)))]

ln = range(len(m))
k1=0
try:
    while True:
        r = 1
        for i1, i2 in zip(d, k):
            r *= i1 ** i2
        if r>b :
            k1+=1

        k[0] += 1
        for i in ln:
            if k[i] > m[i]:
                k[i] = 0
                k[i+1] += 1  # IndexError
except IndexError:
    pass
print(k1)


from math import sqrt,ceil
a,b = map(int,input().split())

e = a - b
if(e == 0) :
    print("infinity")
else :
    i = 1
    t = e
    ans = 0
    while(True) :
        if(e % i == 0):
        	t = e // i
        	if(t > b):
        		ans += 1
        if(e // i <= b) :
        	break
        i += 1
    print(ans)


#!/usr/bin/python
import sys
import math
import fractions

def sieve(n):
    A = [True for i in range(n + 1)]
    for i in range(2, int(math.sqrt(n)) + 1):
        if A[i]:
            for j in range(i * i, n + 1, i):
                A[j] = False
    res = []
    for i in range(2, n + 1):
        if A[i]: res.append(i)
    return res

def factor(n):
    base = sieve(n / 2)
    """
    i = len(base) - 1
    fact = {}
    while n > 1 and i >= 0:
        if n % base[i] == 0:
            n /= base[i]
            if base[i] in fact: fact[base[i]] += 1
            else: fact[base[i]] = 1
        else:
            i -= 1
    """

    start = int(math.sqrt(n))
    pairs = []
    factors = set([1, n])
    for i in range(start,n):
        for j in range(len(base)):
            lhs = i ** 2 % n
            rhs = base[j] ** 2 % n
            if lhs == rhs:
                pairs.append([i,base[j]]);
    for i in range(len(pairs)):
        factors |= set([fractions.gcd(pairs[i][0]-pairs[i][1],n)])
    res = list(factors)
    res.sort()
    return res

def mod_equation(a, b):
    if a < b: return 0
    if a == b: return 'infinity'
    if a - b == 1:
        if a == 1: return 1
        else: return 0
    #fact = factor(a - b)
    c = a - b
    res = 0
    for i in range(b + 1, (a + b) / 2 + 1):
        if c % i == 0: res += 1
    if a > 1: res += 1
    return res

    """
    i = 0
    j = len(fact) - 1
    while j - i > 1:
        mid = (i + j) / 2
        if fact[mid] > b: j = mid
        else: i = mid
    return len(fact) - j
    """

if __name__ == '__main__':

    num = sys.stdin.readline().split()
    a = int(num[0])
    b = int(num[1])
    print mod_equation(a, b)

    #print factor(9435152-272)


#!/usr/bin/python
import sys
import math
import fractions
"""
def sieve(n):
    A = [True for i in range(n + 1)]
    for i in range(2, int(math.sqrt(n)) + 1):
        if A[i]:
            for j in range(i * i, n + 1, i):
                A[j] = False
    res = []
    for i in range(2, n + 1):
        if A[i]: res.append(i)
    return res
"""
"""
def factor(n):
    base = sieve(n / 2)
    i = len(base) - 1
    fact = {}
    while n > 1 and i >= 0:
        if n % base[i] == 0:
            n /= base[i]
            if base[i] in fact: fact[base[i]] += 1
            else: fact[base[i]] = 1
        else:
            i -= 1
    start = int(math.sqrt(n))
    pairs = []
    factors = set([1, n])
    for i in range(start,n):
        for j in range(len(base)):
            lhs = i ** 2 % n
            rhs = base[j] ** 2 % n
            if lhs == rhs:
                pairs.append([i,base[j]]);
    for i in range(len(pairs)):
        factors |= set([fractions.gcd(pairs[i][0]-pairs[i][1],n)])
    res = list(factors)
    res.sort()
    return res
"""

def mod_equation(a, b):
    if a < b: return 0
    if a == b: return 'infinity'
    if a - b == 1:
        if a == 1: return 1
        else: return 0
    c = a - b
    res = 0
    for i in range(b + 1, (a + b) / 2 + 1):
        if c % i == 0: res += 1
    if a > 1: res += 1
    return res

    """
    i = 0
    j = len(fact) - 1
    while j - i > 1:
        mid = (i + j) / 2
        if fact[mid] > b: j = mid
        else: i = mid
    return len(fact) - j
    """

if __name__ == '__main__':
    num = sys.stdin.readline().split()
    a = int(num[0])
    b = int(num[1])
    print mod_equation(a, b)

    #print factor(9435152-272)


import sys
sys.stdout = open('CP/output.txt', 'w')
sys.stdin = open('CP/input.txt', 'r')

if __name__=='__main__':
    N = int(input())
    if N < 5:
        print(0)
    else:
        primes = [0]*(N+1)
        for i in range(2, N+1):
            if primes[i] == -1:
                continue
            primes[i] = i
            for j in range(2*i, N+1, i):
                primes[j] = -1
        a = [i for i in range(N+1)]
        ap = 0
        for i in range(2, N+1):
            count = 0
            if a[i] != -1:
                for j in primes[2:]:
                    if j != -1 and a[i] % j == 0:
                        count +=1
                    if count > 2:
                      break
            if count == 2:
                ap +=1
            if primes[i]!= -1:
                a[i] = -1
                j = 2
                while(N//(i**j) > 0):
                    a[i**j] = -1
                    j += 1
        print(ap)


#! /usr/bin/env python
import sys

def big_powers(primes, n):
    result = []
    for p in primes:
        p_in_deg = p**3
        while p_in_deg <= n:
            result.append(p_in_deg)
            p_in_deg *= p
    return set(result)

def make_power_primes(primes, n):
    result = []
    for p in primes:
        p_in_deg = p
        while p_in_deg <= n/2:
            result.append(p_in_deg)
            p_in_deg *= p
    return set(result)

def make_primes(n):
    result = [2]
    for i in range(3,n+1):
        add = True
        for x in result:
            if (i % x == 0):
                add = False
        if add:
            result.append(i)
    return result

def main():
    n = int(sys.argv[1])
    #print n
    primes = make_primes(n/2)
    #print "primes = " , primes
    power_primes = make_power_primes(primes, n)
    #print "power_primes = ", power_primes
    almost_almost_primes = set([x*y for x in power_primes for y in power_primes if x*y <= n and x<>y])
    #print "almost_almost_primes = ", almost_almost_primes
    #print "big_powers_prime = ", big_powers(primes, n)
    print len([x for x in almost_almost_primes if not (x in big_powers(primes, n))])

if __name__ == "__main__":
    main()


# To change this template, choose Tools | Templates
# and open the template in the editor.
__author__="yaroslav"
__date__ ="$02.08.2011 18:00:13$"
import math

def resheto(num):
    arr = []
    for i in range(1,num/2):
        arr.append(i+1)

    for i in range(0,int(math.sqrt(num))):
        if arr[i]!=0:
            for j in range(2*arr[i]-2,(num/2)-1,arr[i]):
                arr[j]=0

    arr2 = []
    for i in range(0,(num/2) - 1):
        if arr[i]!=0:
            arr2.append(arr[i])

    kol = 0
    for i in range(0,len(arr2)-1):
        for j in range(i+1,len(arr2)):
            x1 = arr2[i]
            x2 = arr2[j]
            did=0
            while x1*x2<=num:
                kol+=1
                x1 *= x1
                did = 1
            x1 = arr2[i]
            x2 = arr2[j]

            while x1*x2<=num:
                kol+=1
                x2 *= x2
                if did==1:
                    did=2
            if did == 2:
                kol -= 1

    return kol

if __name__ == "__main__":
    num = int(raw_input())
    print resheto(num)


n=int(input())
arr=[0]*(n+1)
arr[0]=0
arr[1]=0
arr[2]=0
x=(n)//2
for i in range(2,x+1):
    if arr[i]==0:
        j=2
        while(i*j<=n):
            arr[i*j]+=1
            j+=1
output=0
for i in arr:
    if i==2:
        output+=1
print(output)


read = input()
list1 = list(read)
count = 0
for i in range(len(list1)) :
    while list1[i]==list1[i-1] :
        count+=1
        if count== 7 :
            print("YES")
            print(i)
            break

if count < 7 :
    print("NO")


arr = input()

count = 1
while count != 7:
	for i in range(len(arr) - 1):
		if arr[i] == arr[i + 1]:
			count += 1
		else:
			count = 0

if count >= 7:
	print("YES")
else:
	print("NO")


sequence = list(raw_input())
x = sequence[0]
y = 1
numbers = []

i = 0
while i <= (len(sequence) - 1):
	if sequence[i + 1] == x:
		y += 1
	else:
		x = sequence[i + 1]
		numbers.append(y)
		y = 1

if max(numbers) >= 7:
	print 'YES'
else:
	print 'NO'


word = input()
counter = 1
for i in range(len(word)-1):
    while word[i]==word[i+1]:
        counter +=1
    else:
        counter=1
    if counter == 7:
        print("YES")
print("NO")


arr = input()

count = 1
while count < 7:
	for i in range(len(arr) - 1):
		if arr[i] == arr[i + 1]:
			count += 1
		else:
			count = 0

if count >= 7:
	print("YES")
else:
	print("NO")


for i in range(int(input())):
    n, k, d = map(int, input().split())
    s = list(map(int, input().split()))
    ch = set()
    for i in range(n - d):
        ch.add(len(set(s[i:i + d])))
    print(min(ch))


t=int(input())
for i in range(t):
    n=int(input())
    k=int(input())
    d=int(input())
    a=list(range(n))
    l=[[] for q in range(n-d+1)]
    for j in range (n):
        a[j]=int(input())
    for p in range (n-d+1):
        for j in range(1, d+1):
            if l[p].count(a[p-1+j])==0:
                l[p].append(a[p-1+j])
    for p in range (n-d+1):
        l[p]=len(l[p])
    print(min(l))


da, db = map(int, input().split())
if da == 9 and db == 1:
    print('999 1000')
elif da > db:
    print(-1)
elif da == 0:
    print(-1)
elif da == db:
    print('{}00 {}01'.format(da, da))
elif da == 9 and db == 1:
    print('999 1000')
elif da + 1 == db:
    print('{}99 {}00'.format(da, db))
else:
    print(-1)


t = int(input())
for _ in range(t):
    n,k,d = map(int,input().split())
    l1 = list(map(int,input().split()))
    ans=n
    thing = l1[:d]
    for j in range(n-d+1):
        ans = min(ans,len(set(thing)))
        thing.pop(l1[j])
        thing+=l1[j+d]

    print(ans)


from math import inf
for i in range(int(input())):
	n=int(input())
	l=[int(s) for s in input().split()]
	m=[(l[i+1]-l[i]<=2) for i in range(n-1)]
	counter=0
	maxi=0
	for elem in m:
		if elem:
			counter+=1
		elif counter>0:
			maxi=max(maxi,counter)
			counter=0
	if counter:
		lis.append(counter)
	if not len(lis):
		print(1,1)
	else:
		print(min(lis)+1,max(lis)+1)


def main():
    b = int(input())
    g = int(input())

    accepted = int(input())

    if b + g == accepted:
        print(1)
        return None

    if accepted > b and accepted > g:
        print(min(b, y) - 2)
        return

    else:
        print(min(b, g, accepted) + 1)

if __name__ == "__main__":
    main()


boys=int(input())
girls=int(input())
n=int(input())
decks=n+1
deck=[]
for i in range(0,n+1):
    blue=i
    red=n-i
    if(blue>boys or red>girls):
        continue
    deck.append(1)
print(count(deck))


b, g, n = map(int, input().split())
_max = max(b, g)
_min = min(b, g)

if(n<_max):
    print(n+1)
else:
    print (_min - n + _max + 1)


b=int(input())
g=int(input())
n=int(input())
ans=n+1
for i in range(n+1):
if b<i:
ans=ans-1
elif g<n-i:
ans=ans-1
print(ans)


n = input().split()
a = int(n[0])
b = int(n[1])
count = 1
while (not ((a == b) or (a == 0) or (b == 0))):
    if (a > b):
        x = int(a / b)
        a -= x * b
    else:
        x = int(b / a)
        b -= x * a
    count += x
print(count)


def paper():
	count = 0

	a,b = raw_input("").split()
	a = int(a)
	b = int(b)

	while a!= b:
		if a == 1000000000000:
			return 1000000000000
			break

		elif a > b:
			a = a - b
			count += 1
		elif b > a:
			b = b - a
			count += 1

	return count + 1

print paper()


a, b = map(int, raw_input().split())
count = 0
flag = 1
while a != 1 and b != 1:
    if a == b:
        flag = 0
        break
    if a < b:
        b = b - a
        count += 1
    else:
        a = a - b
        count += 1
if flag == 0:
    print count + 1
else:
    print count + max(a, b)


import unittest

def solve(a,b):
    if a == b:
        return 1

    if b == 1:
        return a

    a -= b
    if b > a:
        a,b = b,a

    return 1 + solve(a,b)

class Test_solution(unittest.TestCase):
    def test_case(self):
        self.assertEqual(solve(2,2), 1)
        self.assertEqual(solve(2,1), 2)
        self.assertEqual(solve(10,7), 6)
        self.assertEqual(solve(1000000000000, 1), 1000000000000)

if __name__ == '__main__':
    #unittest.main()
    a, b = map(int, input().split())
    print(solve(a,b))


import time
def get_num(w,h):
	counter=0
	tmp=0
	x=False
	while (x==False):
		print 'start:',w,h
		if w==h:
			x=True
		w=w-h

		if w<h:
			tmp=w
			w=h
			h=tmp
		print 'end:',w,h
		time.sleep(5)
		counter+=1

	return counter

a,b=map(int,raw_input().split(" "))
print get_num(a,b)


t = int(input())
while t:
    n1, n2 = map(int,input().split())
    rev = 0
    while n2 > 0:
        rem = n2 % 10
        rev = (rev * 10) + rem
        n2 = n2 // 10
    print(f'{n1 + rev}')
    t = t - 1


import random

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

print(random.randint())


a1, a2=raw_input().split()
if len(a1)<len(a2):
	while len(a1)!=len(a2):
		a1='0'+a1
if len(a2)<len(a1):
	while len(a2)!=len(a1):
		a2='0'+a1

a2=list(a2)
a1=list(a1)
a1.reverse()
q=0
c=''
for x in range(len(a1)):
	b=int(a1[x])+int(a2[x])

	if x>0:
		if int(a1[x-1])+int(a2[x-1])>=10:
			b+=1
	if b>=10:
		b=str(b)
		b=b[len(b)-1]
	b=str(b)
	if x==len(a1)-1:
		if len(b)>=2:
			b=list(b)
			b.reverse()
			b=''.join(b)
	c+=b

c=list(c)
c.reverse()
c=''.join(c)
print c


#Codeforces Pages

n = int(input())
p = int(input())
k = int(input())

b = 1 if p-k<1 else p-k
e = n if p+k>n else p+k

if b !=1:
    print("<<",end=" ")

for i in range(b,e+1):
    if i==p:
        print("("+str(i)+")",end=" ")
    else:
        print(i,end=" ")
if e !=n:
    print(">>",end="")


w=int(input())
n=int(input())
s=0
for i in range(0,n):
    f=input()
    z=f.split( )
    s=s+(int(z[0])*int(z[1]))
g=int(s/w)
print(g)


def main():
    x: list = list(map(int, input().split()))
    n: int = x[0]
    p: int = x[1]
    k: int = x[2]
    tmp: list = list()

    for i in range(k + 1):
        x: int = p - i
        if x is 0:
            break
        elif x is p:
            tmp.append('(' + str(x) + ')')
        else:
            tmp.append(str(x))

    tmp.reverse()

    if int(tmp[0]) is not 1:
        print('<<', end=' ')

    print(' '.join(tmp), end=' ')
    tmp.clear()

    for i in range(k + 1):
        x: int = p + i
        if x is n:
            tmp.append(str(x))
            break
        elif x is p:
            continue
        else:
            tmp.append(str(x))

    print(' '.join(tmp), end=' ')

    if int(tmp[len(tmp) - 1]) is not n:
        print('>>')

if __name__ == '__main__':
    main()


i = map(int, raw_input().split())
n = i[0]
p = i[1]
k = i[2]
j = k
stri = ''

if p - 2 > 1:
   stri += "<< "

while j > 0:
  if p - j > 0:
    stri = stri + str(p - j) + ' '
  j = j - 1

stri = stri + '(' + str(p) + ') '
j = 1

while j <= (k + 1) & (p + j) <= n:
  print(str(j) + str(k) + str(p) + str(n))
  if (p + j) <= n:
    stri = stri + str(p + j) + ' '
  j = j + 1

if (p + j) < n + 1:
   stri = stri + '>>'

print(stri)
raw_input()


x,y = map(int,raw_input().split())
me = y-1
if(y == 0):
    print "No"
elif(x < me):
    print "No"
else:
    left = x-me
    if(left == 0):
        print "Yes"
    else:
        if(left%2 == 0):
            print "Yes"
        else:
            print "No"


s=input()
s=s.split()
y=int(s[0])
x=int(s[1])
x-=1
if x>0:
    y-=x
    x=0
if y<0:
    print('No')
elif y%2==0:
    print('Yes')
else:
    print('No')


x, y = [int(k) for k in input().split(' ') if k]
y -= 1
if x < y:
    print("No")
else:
    if (x - y) % 2 == 0:
        print("Yes")
    else:
        print("No")


n,m=map(int,input().split())
if n==1 and m==0:
    print("No")
else:
    d=m-1
    i=n-d
    if i%2==0 and i>=0:
        print("Yes")
    else:
        print("No")


def main():
    x,y=map(long,raw_input().split())
    y-=1
    if y!=0 and (x-y)%2==0 and x>=y:
        print "Yes"
    else:
        print "No"

main()


import sys
file = open("test1")
sys.stdin = file
def ii(): return int(input())
def mi(): return map(int, input().split())
def ai(): return list(map(int, input().split()))

u,v = mi()
if u>v or u&1 != v&1:
	print(-1)
elif u==0 and v == 0:
	print(0)
else:
	x = (v-u)//2
	if x:
		if u&x!=0:
			print(3)
			print(u,x,x)
		else:
			print(2)
			print(u+x,x)
	else:
		print(1)
		print(u)


"""
    Author : thekushalghosh
    Team   : CodeDiggers
"""
import sys,math
input = sys.stdin.readline
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().split()))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############
t = 1
for tt in range(t):
    u, v = map(int, input().split())
    if u == 0 and v == 0:
        print(0)
    elif u == 0 or v == 0:
        print(-1)
    q = list(map(int,list(reversed(list("0" * (60 - int((math.log(u) // math.log(2)) + 1)) + bin(u).replace("0b", ""))))))
    w = list(map(int,list(reversed(list("0" * (60 - int((math.log(v) // math.log(2)) + 1)) + bin(v).replace("0b", ""))))))
    qw = 0
    for i in range(59,-1,-1):
        if w[i] % 2 == q[i]:
            continue
        if i == 0:
            qw = 1
            break
        if q[i] == 1 and w[i] == 0:
            for j in range(i + 1, 60):
                if w[j] >= 2:
                    w[j] = w[j] - 2
                    for k in reversed(range(i, j)):
                        w[k] = w[k] + 2
                    w[i] = w[i] + 4
                    break
            if w[i] == 0:
                qw = 1
                break
        w[i] = w[i] -  1
        w[i - 1] = w[i - 1] + 2
    if qw == 1:
        print(-1)
    else:
        qwqw = [0] * max(w)
        for i in range(60):
            for j in range(w[i]):
                qwqw[j] = qwqw[j] + 2 ** i
        print(len(qwqw))
        print(*qwqw)


from sys import stdin
from bisect import bisect_left as bl
from bisect import bisect_right as br

def input():
    return stdin.readline()[:-1]

def intput():
    return int(input())

def sinput():
    return input().split()

def intsput():
    return map(int, sinput())

class RangedList:
    def __init__(self, start, stop, val=0):
        self.shift = 0 - start
        self.start = start
        self.stop = stop
        self.list = [val] * (stop - start)

    def __setitem__(self, key, value):
        self.list[key + self.shift] = value

    def __getitem__(self, key):
        return self.list[key + self.shift]

    def __repr__(self):
        return str(self.list)

    def __iter__(self):
        return iter(self.list)

def dprint(*args, **kwargs):
    if debugging:
        print(*args, **kwargs)

def conv(x):
    return int(''.join(str(k) for k in x), 2)

debugging = 1
# Code
xor, total = intsput()
xor = bin(xor)[2:]
xor = list(map(int, list('0' * (64 - len(xor)) + xor)))

okay = [[True] * 64 for _ in range(100000)]
numbers = []
rem = total

req = [0] * 64

for i in range(len(xor)):
    fits = rem // 2 ** (63 - i)
    if not xor[i]:  # make even
        fits -= fits % 2
    else:  # make odd
        fits += (fits % 2 - 1)
    req[i] += fits
    rem -= fits * 2 ** (63 - i)

if rem:
    print(-1)
    exit()

while any(req):
    container = [0] * 64
    for i in range(len(req)):
        if req[i]:
            container[i] = 1
            req[i] -= 1
    numbers.append(container)

print(len(numbers))
if numbers:
    print(*[conv(number) for number in numbers])


u,v=map(int,input().split())
if u>v:
    print(-1)
    exit(0)
if u==0 and v==0:
    print(0)
    exit(0)
if u==v:
    print(1)
    print(u)
    exit(0)

binary=[2**i for i in range(61)]
p=[0]*60
d=v-u
v-=u
for i in range(60-1,-1,-1):
    p[i]+=u//binary[i]
    u%=binary[i]
answer=[]
for i in range(60-1,0,-1):
    if v>=binary[i]:
        p[i-1]+=2
f=True
print(max(p))
while True:
    f=False
    k=0
    for i in range(60-1,-1,-1):
        if p[i]>0:
            f=True
            p[i]-=1
            k+=binary[i]
    if f:
        print(k,end=" ")


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

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
# sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

u, v = MAP()

if v < u:
    print(-1)
    exit()

cnt = [0] * 19
for k in range(19):
    if u & 1<<k:
        cnt[k] += 1

need = v - u
for k in range(18, -1, -1):
    while (1<<k) * 2 <= need:
        cnt[k] += 2
        need -= (1<<k) * 2

if need != 0:
    print(-1)
    exit()

ans = [0] * max(cnt)
for k, v in enumerate(cnt):
    for i in range(v):
        ans[i] |= 1<<k
print(len(ans))
if ans:
    print(*ans)


from itertools import combinations

def solve(s, k):
    s = [ord(x) - ord('a') + 1 for x in list(sorted(set(s)))]
    n = len(s)

    if n < k:
        return -1

    min_so_far = float('inf'), None
    for comb in combinations(s, k):
        if any([j - i < 2 for (i, j) in zip(comb[:-1], comb[1:])]):
            continue
        tmp = sum(comb)
        if tmp < min_so_far[0]:
            min_so_far = tmp, comb

    if min_so_far[1] is not None:
        return min_so_far[0]
    return -1

def main():
    n, k = [int(x) for x in input().strip().split()]
    s = input().strip()
    print(solve(s, k))

if __name__ == '__main__':
    main()


n,k=[*map(int,input().split())]
st=sorted(input())
li=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
newli=[]
for i in st:
	newli.append(li.index(i)+1)
if k==1:
	print(newli[0])
	quit()
newli1=[]
for i in range(len(newli)-1):
	newli1.append(newli[i+1]-newli[i])
if sum(newli1)<=k-1:
	print(-1)
	quit()
else:
	addvalue=newli[0]
	addtime=1
	cursor1=0
	cursor2=1
	while addtime<k:
		try:
			newli[cursor2]-newli[cursor1]<=1
		except:
			while 1==1:
				a=1
				b=2
				c=a+b
		if newli[cursor2]-newli[cursor1]<=1:
			cursor2+=1
		else:
			addvalue+=newli[cursor2]
			cursor1=cursor2
			cursor2+=1
			addtime+=1
	print(addvalue)


p=list(map(int, input().split()))
n=p[0]
k=p[1]
s=input().strip()
s=list(s)
s.sort()
s2=s
i=0
sums=ord(s2[0])
sums=sums-96
count=1
while(count<k):
    for j in range(i+1, len(s2)):
        if(abs(ord(s2[j])-ord(s2[i]))>=2 and count<k):
            sums+=ord(s2[j])
            sums=sums-96
            i=j
            count+=1
            break
        else:
            continue

if((1<=k<n<=50)==False):
    sums=-1
if(count<k):
    sums=-1
if(len(s)!=n):
    sums=-1

print(sums)


from sys import stdin
from itertools import combinations

def func(arr):
    count=0
    for ele in arr:
        count+=(ord(ele)-96)
    return count
n,k=map(int,stdin.readline().split())
s=stdin.readline().strip()
s=sorted(s)
ans=[]
for c in combinations(s,k):
    cond=True
    for i in range(k-1):
        if ord(c[i+1])-ord(c[i])>=2:
            pass
        else:
            cond=False
            break
    if cond==True:
        ans.append(func(c))
    else:
        pass
if len(ans)==0:
    print(-1)
else:
    print(min(ans))


n,k=list(map(int,input().split()))
s=input()
t=[0]*26
for i in s:
    t[ord(i)-97]+=1
i=0
while i<26:
    ++i


pe,p,b =input().split()
if p-pe >=0 and b-pe >= 0:
    print('Yes')
else:
    print('No')


n=int(input())
m=int(input())
k=int(input())

if n>m or n>k:

    print("No")
else:

    print("Yes")


#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jul  6 15:27:30 2019

@author: kevinss0643
"""

def distribute(n,m,k):
    if m>=n and k>=n:
        print("Yes")
    else:
        print("No")

#Insert n,m,k in order below
distribute(n,m,k)


ar=map(int,input().strip().split())
if ar[1]< ar[0] or ar[2]< ar[0]:
    print("No")
print("Yes")


n,m,k = input().split()
if n <= m and n <= k and n > 0:
    print('Yes')
else:
    print('No')


from sys import stdin,stdout

def main():
	string=stdin.readline()
	sum=0

	for i in range (len(string)-1):
		if i==0:
			p=ord(string[0])-97
			if p>13:
				sum+=(26-p)
			else:
				sum+=p
		else:
			p=abs(ord(string[i])-ord(string[i-1]))
			print(sum)
			if p>13:
				sum+=26-p
			else:
				sum+=p

	print(sum)

if __name__ == '__main__':
	main()


s = str(input())
test= 'abcdefghijklmnopqrstuvwxyz'
current_pos=0
minimum_dis = 0
for i in s:
    x =test.find(i)+1
    y=test[::-1].find(i)+1
    minimum_dis = minimum_dis + min(x,y)
    index= test.find(i)
    test = test[index:] + test[:index]
print(minimum_dis-1)


s = list(input())
r = 1
ans = 0
for i in range(len(s)):
    a = abs((ord(s[i])-96)-r)
    if a>14 :
        ans += 26-a
        r = 26 - (ord(s[i])-96)
    else:
        ans += a
        r = ord(s[i])-96

print(ans)


alpha=['n','o','p','q','r','s','t','u','v','w','x','y','z','a','b','c','d','e','f','g','h','i','j','k','l','m']
ind=13
word=input()
count=0
summ=0
while(count<len(word)):

    if(abs(ind-alpha.index(word[count]))>(26-ind+alpha.index(word[count]))):
        summ+=(26-ind+alpha.index(word[count]))
    else:
        if(ind==0):
            summ+=26-alpha.index(word[count])
        else:
            summ+=abs(ind-alpha.index(word[count]))
    ind=alpha.index(word[count])
    count+=1
print(summ)


n = int(input())
m = n
a = [False,False]+[True]*(m-1)
primes = []
for i in range(2,m+1):
    if a[i]:
        primes.append(i)
        for j in range(2*i,m+1,i):
            a[j] = False

c = 0
while(n != 0):
    p = n
    for i in primes:
        if n%i == 0:
            p = i
            break
    n -= p
    c += 1
    if n%2 == 0 :
        c += n//2
        break
print(c)


n = long(input())
i = 2
while i * i <= n:
    if n % i == 0:
        print(n / i)
        exit(0)
    i += 1

print(1)


import math
def abc(n):
    global k
    if n!=0:
        for i in range(2,int(math.sqrt(n))+1):
            if n%i==0:
                k+=1
                n-=i
                return abc(n)
        else:
            k+=1
            n=0
            return abc(0)
    else:
        return print(k)

n=int(input())
k=0
abc(n)


n=int(input())
b=[]
prime = [True for i in range(n+1)]
p=2
while(p**2<=n):
    if prime[p] == True:
        for i in range(p * p, n+1, p):
            prime[i] = False
    p += 1
for p in range(2, n):
    if prime[p]:
        b.append(p)
#print(*b)
for i in b:
    if n%i==0:
        exit(print(n//i))
print('1')


N = int(input())
M = 10 ** 8 + 5
pr = [True] * M
pr[0], pr[1] = False, False
for i in range(2, M):
    if pr[i]:
        for j in range(i * 2, M, i):
            pr[j] = False

prime = list(filter(lambda x: pr[x], range(M)))

def calc(n, k):
    if n == 0:
        return k
    elif n % 2 == 0:
        return n // 2 + k
    else:
        for i in prime:
            if n % i == 0:
                n -= i
                return calc(n, k + 1)

print(calc(N, 0))


n = int(input())

res = 0
a = 1
b = n
c = True
while a < b:
	res += (a + b) % (n + 1)
	print(a,b)
	if c == True:
		a += 1
	else:
		b -= 1
	c = not c
print(res)


x = int(input())
a = []
b = []
for i in range(1,x+1):
    a.append(i)
for j in range(0,x):
    b.append(pow(a[j],j))
print(sum(b)%(x+1))


n = input()
n = int(n)
k = 0
for i in range(1, n + 1):
	for j in range(1, (n // 2) + 1 + (n % 2)):
		if (i + j) % (n + 1) == 1:
			k += 1
print (k)


n = int(input())
s = set()
for k in range(1,n+1):
	s.add(k)
c = True
prev = 1
s.remove(1)
res = 0
while len(s) != 0:
	if c == True:
		m = max(s)
	else:
		m = min(s)
	s.remove(m)
	res += (prev + m) % (n+1)
	c = not c
	prev = m
print(res)


x = int(input())
b = []
for j in range(1,x+1):
    b.append(pow(j,j-1))
print(sum(b)%(x+1))


def gelnana(m, b):
    x_1 = int((b-1)*m)
    sum_list = [0] * int(b + x_1 - 1)

    for i in range(b+1):
        x = int((b-i)*m)
        sum_list[i] = (i+1)*(x+1)*(i+x)/2

    return int(max(sum_list))

array = list(map(int,input().split()))
m = array[0]
b = array[1]
print(gelnana(m, b))


n = int(raw_input())
a = [map(int, raw_input().split()) for i in range(n)]

res = 1
for i in range(n):
    for j in range(n):
        if a[i][j] != 1:
            d = 0
            for x in range(n):
                for y in range(n):
                    if a[i][j] == a[i][x] + a[y][j]: d+= 1
                    if d > 0: break
            if d == 0: res = 0
print ["No", "Yes"][res]


#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Mar  6 21:52:15 2020

@author: nguyenquocbao
"""
import numpy as np

def gelnana(m, b):
    x_int = m*b
    x_1 = int((b-1)*m)

    sum_list = np.empty([1, b + x_1 - 1])
    matrix = np.empty([b + 1, x_int + 1])
    for r in range(b + 1):
        for x in range(x_int + 1):
            matrix[r, x] = r + x

    for i in range(b-1): # row
        x_max = int((b - (i+1))*m)
        sum_row = np.sum(matrix[0:i+2, 0:x_max+1])
        sum_list[0, i] = sum_row

    for i in range(x_1): # column
        y_max = int((-i-1)/m + b)
        sum_column = np.sum(matrix[0:y_max+1, 0:i+2])
        sum_list[0, i + b - 1] = sum_column

    return int(np.max(sum_list))

array = list(map(int,input().split()))
m = array[0]
b = array[1]
print(gelnana(m, b))


def function(x,y,m,c):
    d=y+x/m-c
    return d
def pval(a):
    return a[0]+a[1]
def valof(a,p):
    max=0
    for i,j in p:
        if j<=a:
            sum=0
            for l,m in p:
                if m<=j and l<=i:sum+=l+m
            if max<=sum:max=sum#;print((i,j),sum)
    return max

m,c=list(map(int,input().split()))
p=[(i,j) for i in range(0,m*c+1) for j in range(0,c+1) if function(i,j,m,c)<=0]
print(valof(c,p))