import math

a, b = [int(x) for x in input().split()]
cnt = 0
ab = a + b
k = 2
while k <= ab:
    t = ab // k
    aPeriod = a // t
    bPeriod = b // t
    aLeft = (a + t) // (t + 1)
    bLeft = (b + t) // (t + 1)
    arem = a - t * aPeriod
    brem = b - t * bPeriod
    if aPeriod >= arem and bPeriod >= brem:
    	validK = aPeriod + bPeriod - aLeft - bLeft + 1
    	if validK > 0:
    		cnt += validK
    k = ab // t + 1
print(cnt)


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

a = [1]
max_1 = 1

while len(a) < k:
    max_1 += 1
    a += [max_1] + a

print(a[k-1])


n,k= map(int,input().split())
s= [1]
i=1
while i!=n:
    p=s
    s= p+[i+1]+p
    i+=1
print(s[k-1])


n,k, = map(int, input().split())
l=[1]
for i in range(1,n):
    b=l.copy()
    l.append(i+1)
    l.extend(b)
print(l[k-1])


n, k = map(int, input().split())
a = [1]
temp = 2
for i in range(n-1):
    a = a + [temp] + a
    temp += 1
print(a[k-1])


nk = input().split(" ")
n,k = [int(x) for x in nk]
k -= 1
gen_list = [1]
for i in range(1,n):
    j = i+1
    aux = gen_list.copy()
    gen_list.append(j)
    gen_list.extend(aux)
print(gen_list[k])


if __name__ == "__main__" :
    List = [ 1 ]
    count = 1
    inputs = raw_input().split()
    for i in xrange( int( inputs[ 0 ] ) - 1 ) :
        count = i + 2
        List.append( count )
        List.extend( List )
        List.pop()
    #print List
    print List[ int ( inputs[ 1 ] ) - 1 ]


n,k=map(int,raw_input().split())
l=[1]
for i in range(2,n+1):
    l1=l[:]
    l=l+[i]+l1
print l[k-1]


n = int(input())
ans = 'codeforce' + 's'*n

print(ans)


n = int(input())
s = "codeforces"
print(s+"s"*(n-1))


n,m, = [int(x) for x in input().split()]
def powe(a,b,m):
    res = 1;
    while b>0:
        if b&1:
            res = res*a%m
        a = a*a%m
        b >>=1
    return res
ans = powe((1<<m)-1,n,10**9+7)
print(ans)


n = int(input()) + 1
if n < 5:
  print(0)
  exit()
c = 0
for i in range(n):
  if str(i).replace('0', '') == '5':
    c = 1
  elif str(i)[-1] != '9':
    c += 1
print(c)


import sys

lines = []
for line in sys.stdin:
    lines.append(line)

n = int(lines[0].rstrip("\r\n\t "))

max_price = n * 2 - 1
nines = 0
mp = max_price
while mp >= 9:
    nines += 1
    mp = int(mp / 10)
if nines < 1:
    print("0")
    exit()
price_suffix = "9"*nines

pairs = set()
def add_pairs(max_x: int, price: int):
    from_max = int(price / 2)
    to_min = from_max + 1
    to_max = price - 1
    if to_max > max_x:
        to_max = max_x
    from_min = price - to_max
    for x in range(from_min, from_max + 1):
        pairs.add(str(x) + ':' + str(price - x))

cnt = 0
for d in range(0, 10):
    if d > 0:
        price = int(str(d) + price_suffix)
    else:
        price = int(price_suffix)
    if price <= max_price:
        add_pairs(n, price)

print(len(pairs))


n, k = map(int, input().split())
a = list(map(int, input().split()))
books = set()
l = 0
pref = [0 for i in range(n)]
for i in range(n - 1, -1, -1):
    pref[a[i] - 1] = max(pref[a[i] - 1], i) # i min == 0
res = 0
for i in range(n):
    if a[i] not in books:
        if l == k:
            for j in books:
                if pref[j - 1] < i:
                    l -= 1
                    books.discard(j)
                    break
            if l == k:
                books.pop()
                l -= 1
        res += 1
        books.add(a[i])
        l += 1
print(res)


def maxPies(i):
    if i==n:
        return pies[n-1]
    else:
        sum = 0
        j=i-1
        while(j<n):
            sum = sum + pies[j]
            j+=1

        return max(maxPies(i+1), pies_sum[i-1]-maxPies(i+1))

n = input()
pies = [0]*n
pies_sum = [0]*n
pies= map(int, raw_input().split())
pies_sum[n-1] = pies[n-1]
j=n-2
while(j>=0):
    pies_sum[j] = pies_sum[j+1] + pies[j]
    j-=1

answer = maxPies(1)
print("{0} {1}".format(pies_sum[0] - answer, answer))


inp = list(map(int, input().split()))
n = inp[0]

l = [0,2,3,4,4]

i = 5

count = 1
m = 0

while(i<=n+1):
	if(count == 1):
		l += [l[i-1] +1]
		count +=1
		m  = int(l[i]/2);
		if(i+m<n):
			l  += [l[i]]*(m-1)
			i += (m-1)
			count = 1
		i+=1
		continue
	elif(count == m):
		l+= [l[i-1]]
		count = 1;
		i+=1
		continue;
	else:
		l += [l[i-1]]
		count +=1

	i+=1

print(l[n])


from sys import stdin
n = int(stdin.readline().rstrip())
dp = [0] * (n+1)
dp[2] = 2

if n % 2 == 1:
    print(0)
else:
    for i in range(4, n+1, 2):
        dp[i] = dp[i-2]*2

    print(dp[n])


import itertools

n,l,r,x = map(int,input().split())
a = map(int,input().split())
a.sort()
ans = []
combos = []
for i in range(2,n+1):
	temp = itertools.combinations(a,i)
	for j in temp:
		combos.append(j)
count = 0

for i in combos:
	tot = sum(i)
	maxi = max(i)
	mini = min(i)
	if(tot>=l and tot<=r and maxi-mini>=x):
		count+=1
print coun


a_list= []
sum = 0
n = int(input())
for i in range(n):
    x = int(input())
    if x  not in a_list:
        a_list.append(x)
print(len(a_list))


a = input()

if a.count('-') == 0:
	print("YES")
elif a.count('o') == 0:
	print("YES")
else:
	print("YES") if a.count('-')%a.count('o') == 0) else print("NO")


# input() reads a string with a line of input, stripping the '\n' (newline) at the end.
# This is all you need for most Code Jam problems.
def find(points, i, j):
    if (i >= j):
        return 0
    if (points[j] - points[i]) > diameter:
        result1 = find(points, i + 1, j) + 1
        result2 = find(points, i, j - 1) + 1
        return min(result1, result2)
    else:
        return 0
pairs= [int(s) for s in input().split(" ")]
num = pairs[0]
diameter = pairs[1]
points= [int(s) for s in input().split(" ")]
points.sort()
answer = find(points, 0, num-1)

print(answer)


 a=list(input())
b=[]
for i in a:
    if i not in b:
        b.append(i)
for i in range(len(b)):
    if (ord(b[i])-ord('a'))!=i:
        exit(print('NO'))
print('YES')


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

[t1,t2,x1,x2,t0]=input().split(' ')
#[t1,t2,x1,x2,t0]=[10,20,5,5,13]
t1=int(t1)
t2=int(t2)
x1=int(x1)
x2=int(x2)
t0=int(t0)

a=t2-t0
b=t0-t1
if (a==0):
    y1=0
    y2=x2
    print(y1,y2)
    exit(0)

if (b==0):
    y1=x1
    y2=0
    print(y1,y2)
    exit(0)

g=gcd(a,b)
a=int(a/g)
b=int(b/g)
if(a<=x1 and b<=x2):
    mintime=int(x1/a)
    if(mintime>int(x2/b)):
        mintime=int(x2/b)
    print(mintime*a,mintime*b)
    exit(0)

y1=1
y2=1
minn=99999
while(y1<=x1 and y2<=x2):
    if(y1/y2<a/b):
        if(minn>a/b-y1/y2):
            minn=a/b-y1/y2
            miny1=y1
            miny2=y2
        y1=y1+1
    else:
        y2=y2+1
y1=miny1
y2=miny2
mintime=int(x1/y1)
if(mintime>int(x2/y2)):
    mintime=int(x2/y2)
print(mintime*y1,mintime*y2)


from itertools import permutations

n = int(input())

nums = []
for i in range(n):
    nums.append(int(input()))

if sum(nums) % 360 == 0:
    print('YES')
else:
    ans = 'NO'
    perm = list(permutations(nums))
    for p in perm:
        for i in range(len(p)):
            left = sum(p[:i])
            right = sum(p[i:])
            if left - right == 0:
                ans = 'YES'
                break
            if ans == 'YES':
                break
    print(ans)


board = [raw_input() for i in range(1,5)]
print ['NO','YES'][any((board[x][y:y+2]+board[x+1][y:y+2]).count('#') >= 3 for x in range(1,4) for y in range(1,4))]


from sys import stdin, stdout

nm = list(map(int, stdin.readline().strip().split()))
n = nm[0]
m = nm[1]
n_list = list(map(int, stdin.readline().strip().split()))
m_list = list(map(int, stdin.readline().split()))
res_list = []
for x in n_list:
    if x in m_list:
        res_list.append(x)
stdout.write(' '.join(res_list))


cod = raw_input()
ind = ["" for loop in range(10)]
for i in range(10):
        ind[i] = raw_input()

ch =cod[i]
for i in range(1,len(cod)):
    j = 0
    bol = False
    if i%10 == 0:
        while bol == False and j<10:
            if ind[j] == ch:
                bol = True
                print (j,end='')
            else:
                j+=1

        ch = cod[i]
    else:
        ch += cod[i]
j = 0
bol = False
while bol == False and j<10:
            if ind[j] == ch:
                bol = True
                print j
            else:
                j+=1


ba=int(raw_input())
names=["Sheldon", "Leonard", "Penny", "Rajesh", "Howard"]
cycles=ba/5
bla=2
while bla<cycles:
    bla*=2
bla/=2
ba -= (bla-1)*5

q=[]
for n in names:
    for i in range(bla):
        q.append(n)
for n in names:
    for i in range(bla*2):
        q.append(n)
if ba>5:
    print q[ba-1]
else:
    print names[ba-1]


n, m = map(int, input().split())
if n > m:
  n, m = m, n
if n == 1:
  print(m // 6 + (m + 1) // 6 + (m + 2) // 6 << 1)
elif n == 2:
  print(0 if m == 2 else 4 if m == 3 12 if m == 7 else n * m)
else:
  print(n * m >> 1 << 1)


import math

if __name__ == '__main__':
    n, l, r = list(map(int, input().split()))
    mod_counts = [
        math.floor(r/3) - math.ceil(l/3) + 1, math.floor((r-1)/3) - math.ceil((l-1)/3) + 1,
        math.floor((r+1)/3) - math.ceil((l+1)/3) + 1]
    dp = [[None] * 3 for _ in range(n)]
    dp[0] = mod_counts
    for i in range(1, n):
        dp[i][0] = (dp[i-1][0] * mod_counts[0]) + (dp[i-1][1] * mod_counts[2]) + (dp[i-1][2] * mod_counts[1])
        dp[i][1] = (dp[i-1][0] * mod_counts[1]) + (dp[i-1][1] * mod_counts[0]) + (dp[i-1][2] * mod_counts[2])
        dp[i][2] = (dp[i-1][0] * mod_counts[2]) + (dp[i-1][1] * mod_counts[1]) + (dp[i-1][2] * mod_counts[0])
    res = dp[-1][0]
    print(res % (10 ** 9 + 7))


import math

if __name__ == '__main__':
    n, l, r = list(map(int, input().split()))
    mod_counts = [
        math.floor(r/3) - math.ceil(l/3) + 1, math.floor((r-1)/3) - math.ceil((l-1)/3) + 1,
        math.floor((r+1)/3) - math.ceil((l+1)/3) + 1]
    prev = mod_counts
    for _ in range(1, n):
        cur = [None] * 3
        cur[0] = (prev[0] * mod_counts[0]) + (prev[1] * mod_counts[2]) + (prev[2] * mod_counts[1])
        cur[1] = (prev[0] * mod_counts[1]) + (prev[1] * mod_counts[0]) + (prev[2] * mod_counts[2])
        cur[2] = (prev[0] * mod_counts[2]) + (prev[1] * mod_counts[1]) + (prev[2] * mod_counts[0])
        prev = cur
    res = prev[0]
    print(res % (10 ** 9 + 7))


import sys, math
from sys import stdin, stdout

rem = 10 ** 9 + 7
inf = 10 ** 18
sys.setrecursionlimit(10 ** 6 + 7)
#from resource import *; setrlimit(RLIMIT_STACK, (RLIM_INFINITY, RLIM_INFINITY))
take = lambda: map(int, stdin.readline().split())
from heapq import heappush, heappop, heapify
from collections import deque
from bisect import *

def help(s):
    n=len(s)
    #print s
    if s in dp:
        return dp[s]
    ans=inf
    if n<=1:
        return n
    for i in range(n):
        done=False
        for j in range(i+1,n):
            if s[j]!=s[i]:
                done=True
                break
        if done==True:
            new=s[:i]+s[j:]
            #print s,new,i,j
            ans=min(ans,1+help(new))
        else:
            new=s[:i]
            ans=min(ans,1+help(new))

    dp[s]=ans
    return ans

dp={}

n=input()
s=raw_input()
print help(s)


nb = int(input())
st = input()
dp = [[-1 for _ in range(nb + 1)] for _ in range(nb + 1)]
def calc(l, r):
    res = dp[l][r]
    if res != -1: return res
    if l > r : return 0
    if l == r: return 1
    res = 1 + calc(l + 1, r)
    for i in range(l + 1, r + 1):
        if st[l] == st[r]:
            res = min(res, calc(l + 1, i - 1) + calc(i, r))
    return res
print(calc(0, nb - 1))


n=int(input())
sum=0
for i in range(1,n+1):
    sum=sum+ len(str(i))
print(sum)


mod = int(1e9 + 7)

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

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

main()


n, m = map(int, input().split())
from itertools import product
x = [i for i in range((n // 2) + 1)]
y = [i for i in range(n+1)]
z = list(product(x, y))
possible = []
for item in z:
    x = item[0]
    y = item[1]
    if (2 * x + y == n) and ((x + y) % m == 0):
        possible.append(x + y)

if possible == []:
    print(-1)
else:
    print(min(possible))


n,a = [int(i) for i in input().split()]
if a%2==0
	t = n//2-a//2
else:
	t = a//2
print(t+1)


n,k=map(int,input().split())
l=[1 for i in range(n+1)]

for i in range(k-1):
    for j in range(1,n+1):
        t=2*j
        while(t<=n):
            l[j]+=l[t]
            t=t+j
print(sum(l[i] for i in range(1,n+1))%(10**9+7))


import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**8)
n, k = [int(i) for i in input().split()]
dp = [[-1]*(2005) for i in range(2005)]
MOD=10**9+7
def solve(x,k):
    if(k==0):
        return 1
    elif(dp[x][k]!=-1):
        return dp[x][k]
    ans=0
    for i in range(x,n+1,x):
        ans+=solve(i,k-1)
    dp[x][k]=ans%MOD
    return dp[x][k]
res=solve(1,k)
print(res)


n,m=map(int,input("").split(" "))
list=[]
i=0
c=0
while i<n*m:
    j=0
    while j<n*m:
        if i**2+j==n:
            list.append([i,j])
        j+=1
    i+=1
for i in range(len(list)):
    if int(list[i][0])+int(list[i][1])**2==m:
        c+=1
print(c)


from math import sqrt, ceil
n = int(input())
l = []

start = 2
c = 0
count = 1
for i in range(n):
    if c == 2:
        c = 0
        count += 1
    c += 1
    l.append([start] * count)
    start += 1

c = 0
for i in range(n):
    c += len(l[i])
    if c >= n:
        print(l[i][0])
        break


from collections import defaultdict as df
d=df(list)
n=int(input())
visited=[0]*6
for i in range(n):
    a,b=list(map(int,input().split()))
    d[a].append(b)
    d[b].append(a)
    visited[a]=True
    visited[b]=True
count=0

for i in d:
    if len(d[i])==1:
        count+=1
flag=0
for i in d:
    if len(d[i])>=3:
        flag=1
        break
for i in range(1,6):
    if visited[i]==False:
        flag=1
        break
if flag:
    print('WIN')
else:
    print('FAIL')


n,k=map(int,input().split())
i=1
while True:
    sms=i%k
    if sms==0:
        i+=1
        continue
    if (i//k)*(sms)==n:
        print(i)
        break
    i+=1


def solve(grid):

    n = len(grid)
    m = len(grid[0])
    s = [0]
    # nWolves = sum([1 for i in range(n) for j in range(m) if grid[i][j] == "W"])
    for i in range(n):
        for j in range (m):
            if grid[i][j] == 'W':
                # Si es lobo, verificar los 4 casos posibles: arriba, izq, der, abajo
                for p in range(-1,2):
                    for q in range(-1,2):
                        if (abs(p + q) == 1 and i + p < n and i + p >= 0 and j + q < m and j + q >= 0 and grid[i + p][j + q] == "P"):
                            grid[i][j] = "."
                            grid[i + p][j + q] = "."
                            s.append(1 + solve (grid.copy()))
                            grid[i][j] = "W"
                            grid[i + p][j + q] = "P"

    return max(s)

if __name__ == "__main__":
    n, m = map (int, input ().split())

    grid = []
    for _ in range (n):
        grid.append ([c for c in input()])
    print (solve(grid))


line1 = raw_input().split(' ')
radp = map(int,raw_input().split(' '))
radt = map(int,raw_input().split(' '))

limp = radp[::-1]
limt = radt[::-1]

print(radp)
print(radt)
print(limp)
print(limt)

n = int(line1[0])
c = int(line1[1])

lim = 0
rad = 0

for i in range(0,n):
    rad += max(0, (radp[i] - (sum(radt[0:i+1]) * c)))
    lim += max(0, (limp[i] - (sum(limt[0:i+1]) * c)))

print(rad)
print(lim)

if lim > rad:
    print('Radewoosh')
elif lim < rad:
    print('Limak')
else:
    print('Tie')


#!/usr/bin/python

import sys
import math

primes = []
MAXN = 50000
hash = []

dp = dict()

def prime_test(v):
    for i in xrange(2,int(math.sqrt(v))+1):
        if v % i == 0:
            return False
    return True

def calc(v, k):
    if k >= MAXN:
        if (k <= v):
            return 1
        else:
            return 0
    else:
        if (v,k) in dp:
            return dp[(v,k)]
        res = v / k
        for prime in primes:
            if prime >= k:
                break
            res -= calc(v/k, prime)
        dp[(v,k)] = res
        return res

if __name__=="__main__":
    hash = [-1] * MAXN
    for i in xrange(2,MAXN):
        if hash[i] == -1:
            primes.append(i)
            hash[i] = len(primes)-1
            v = i * i
            while (v < MAXN):
                hash[v] = -2
                v += i
    a,b,k = [int(v) for v in sys.stdin.readline().split(' ')]
    if (k < MAXN and hash[k] == -2) or (k >= MAXN and (not prime_test(k))):
        print 0
    else:
        print calc(b,k) - calc(a-1,k)


n,k = list(map(int,input().split()))
l = []
if(k<=1):
    print(n)
    return 0
else:
    ans = 1
    while ans<n:
        ans = ans*2 +1
print(ans)


n=int(input())
if n%2==0:
   print(2"")
else:
   print("1")


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

faces = {}
faces['top'] = colors[:4]
faces['front'] = colors[4:8]
faces['bottom'] = colors[8:12]
faces['left'] = colors[12:16]
faces['right'] = colors[16:20]
faces['back'] = [colors[21], colors[20], colors[23], colors[22]]

status = {}
for face in faces.keys():
	colors = faces[face]
	if max(colors) == min(colors):
		status[face] = 'ok'
	else:
		if colors[0] == colors[1] and colors[2] == colors[3]:
			status[face] = 'h'
		elif colors[0] == colors[2] and colors[1] == colors[3]:
			status[face] = 'v'
		else:
			status[face] = 'bad'

# print(status)
# print(faces)

if 'bad' in status.values():
	print('NO')
else:
	if status['top'] == status['bottom'] == 'ok' and status['front'] == status['left'] == status['right'] == status['back'] == 'h':
		if (faces['front'][0] == faces['left'][3] and
			faces['left'][0] == faces['back'][3] and
			faces['back'][0] == faces['right'][3] and
			faces['right'][0] == faces['front'][3]
			or
			faces['front'][0] == faces['right'][3] and
			faces['right'][0] == faces['back'][3] and
			faces['back'][0] == faces['left'][3] and
			faces['left'][0] == faces['front'][3]):
			print('YES')
		else:
			print('NO')
	elif status['left'] == status['right'] == 'ok' and status['front'] == status['top'] == status['bottom'] == status['back'] == 'v':
		if (faces['front'][0] == faces['top'][3] and
			faces['top'][0] == faces['back'][3] and
			faces['back'][0] == faces['bottom'][3] and
			faces['bottom'][0] == faces['front'][3]
			or
			faces['front'][0] == faces['bottom'][3] and
			faces['bottom'][0] == faces['back'][3] and
			faces['back'][0] == faces['top'][3] and
			faces['top'][0] == faces['front'][3]):
			print('YES')
		else:
			print('NO')
	elif status['front'] == status['back'] == 'ok' and status['top'] == status['left'] == status['right'] == status['bottom'] == 'v':
		if (faces['top'][0] == faces['left'][3] and
			faces['left'][0] == faces['bottom'][3] and
			faces['bottom'][0] == faces['right'][3] and
			faces['right'][0] == faces['top'][3]
			or
			faces['top'][0] == faces['right'][3] and
			faces['right'][0] == faces['bottom'][3] and
			faces['bottom'][0] == faces['left'][3] and
			faces['left'][0] == faces['top'][3]):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


n = int(raw_input())

 #1 2 3 4 5 6
students = range(1,n+1)
if n == 0:
	print 0
	exit()
if n == 1 or n==2:
	print 1
	print 1
	exit()
if n == 3:
	print 2
	print 1,3
	exit()
if n == 4:
	print 4
	print 3, 1, 4, 2
	exit()

x = [i for i in xrange(1,n+1, 2)]
y = [i for i in xrange(2,n+1,2)]
print n
print ' '.join([str(i) for i in x+y])


v1 = int(input())
v2 = int(input())
t = int(input())
d = int(input())

ans = 0
for i in range(0,t):
	ans=ans+min(v1+d*i,v2+d*(t-i-1))
print ans

#v1, v2 = map(int, raw_input().split())
#t, d = map(int, raw_input().split())
#print sum(min(v1 + d * i, v2 + d*(t-i-1)) for i in xrange(t))


from __future__ import division
from sys import stdin

rints = lambda: [int(x) for x in stdin.readline().split()]
rstr = lambda: stdin.readline().strip()
dx, dy = [-1, 0, 1, 0, 1, -1, 1, -1], [0, 1, 0, -1, 1, -1, -1, 1]
dir = {'U': 1, 'L': 0, 'R': 2, 'D': 3}

a, b = rints()
s, mem = rstr(), [[0, 0]]
for i in s:
    mem.append([mem[-1][0] + dx[dir[i]], mem[-1][1] + dy[dir[i]]])

for x, y in mem:
    k = 0
    if mem[-1][0]:
        k = (a - x) // mem[-1][0]
    if mem[-1][1]:
        k = (b - y) // mem[-1][1]

    eq1, eq2 = x + k * mem[-1][0], y + k * mem[-1][1]
    if k > -1 and eq1 == eq2:
        print('Yes')
        exit()

print('No')


from math import *
from sys import *

N=int(input())

# if N <= 7:
#     print(N,N)
# elif N <= 15:
#     print(N-7,N)
# elif N <= 23:
#     print(N-14,N)
# else:

memo={}

def solve(n):
    if n in memo:
        return memo[n]
    if n == 0:
        return 0,0
    s=floor(pow(n,1/3)-1)
    while (s+1)**3 <= n:
        s += 1
    A,B=solve(n - s ** 3)
    C,D=solve(s**3-1)
    memo[n] = max((A+1,B+s**3),(C,D))
    #print(n, A, B, C, D, memo[n])
    return memo[n]

i=1
while i**3 < N:
    solve(i**3)
    i+=1

A,B=solve(N)
print(A,B)


import os

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

in_no = []
for e in n:
    in_no +=[9-e]
min_pos= 0
for i in xrange(0, len(no)):
    s = 0
    a = no[i]
    b = in_no[i]
    #print a, b
    if int(a) > int(b):
        s = int(b)
    else:
        s = int(a)
    #print  s
    min_pos = min_pos * 10 + s
    if i == len(no) -1 and min_pos == 0:
        min_pos = 9 - s
print min_pos


n=int(input(''))
num=list(input(''))
lis=[]
count=0
for i in range(0,n-1):
    if num[i]=='1':
        count+=1
    else:
        lis.append(str(count))
        count=0
       # print('appended')
if num[n-1]=='1':
    count+=1
    lis.append(str(count))
else:
    lis.append(str(0))

print(''.join(lis))


n = int(input())
s = list(input())
h = 0
k = 0
w = []
while h != n:
    k = k + int(s[h])
    if int(s[h]) == 0 and h != len(s)-1:
        w.append(str(k))
        k = 0
    h = h + 1

w.append(str(k))

w = ''.join(w)
print(w)


import sys
import bisect
import copy
input = sys.stdin.readline

n,m=map(int,input().split())
K=[0]+list(map(int,input().split()))
SP=[list(map(int,input().split())) for i in range(m)]

SP2=[[] for i in range(n+1)]

for d,t in SP:
    SP2[t].append(d)

for i in range(n+1):
    SP2[i].sort()

SUM=sum(K)
MIN=SUM
MAX=SUM*2
MAXBUY=0

for day in range(MIN,MAX+1):

    DAYS=[[] for i in range(day+1)]

    for i in range(n+1):
        x=bisect.bisect_right(SP2[i],day)-1
        if x>=0:
            DAYS[SP2[i][x]].append(i)

    GOLD=0
    BUY=0
    K2=copy.deepcopy(K)

    for d in range(1,day+1):
        GOLD+=1

        for t in DAYS[d]:
            DBUY=min(K2[t],GOLD)
            K2[t]-=DBUY
            GOLD-=DBUY
            BUY+=DBUY

    MAXBUY=max(MAXBUY,BUY)

print(MAX-MAXBUY)


n, a, b = tuple(map(int, input().split()))
s = list(map(int, input().split()))
ans = 0
for i in range(len(s) // 2):
    if (s[i] != s[len(s) - i - 1]) and (s[i] + s[len(s) - i + 1] == 1):
        print(-1)
        exit(0)
    elif (s[i] + s[len(s) - i - 1] == 2):
        ans += a
    elif (s[i] + s[len(s) - i - 1] == 3):
        ans += b
print(ans)


DIGITS = 55
MAX_CNT = 8
NUMBERS = [0] * (DIGITS + 1)

for d in range(1, DIGITS + 1):
    NUMBERS[d] = 10 * NUMBERS[d - 1] + 1

CUTOFF = 6.18
INF = 10**9

def recurse(value, d, cost):
    if d == 0:
        return cost if value == 0 else INF

    ans = INF

    for cnt in range(-MAX_CNT, MAX_CNT + 1):
        nvalue = abs(value + cnt * NUMBERS[d])

        if nvalue <= CUTOFF * (10**(d - 1)) + 15:
            ans = min(ans, recurse(nvalue, d - 1, cost + abs(cnt) * d))

    return ans

X = int(input())
N = int(len(str(X)))
print(recurse(X, N + 1, 0))


n = int(input())

res = {}

def cal(x):
    if x == 0:
        return 0

    larger = 1
    while x >= larger:
        larger = larger * 10 + 1
    smaller = larger // 10
    l = len(str(smaller))

    a = cal(x % smaller) + (x // smaller) * l
    b = cal((larger - x) % smaller) + l + 1 + ((larger - x) // smaller) * l
    res[x] = min(a, b)
    return res[x]

print(cal(n))


def solve():
    n, mod = map(int, input().split())
    m = n*(n-1)//2
    dp = [[0]*(n*(n-1)+1) for i in range(n+1)]
    dp1 = [[0]*(n*(n-1)+1) for i in range(n+1)]
    dp[1][m] = 1
    for i in range(2, n+1):
        for x in range(m-(i-1)*(i-2)//2, m+(i-1)*(i-2)//2+1):
            for j in range(i):
                for k in range(i):
                    dp[i][x+j-k] = (dp[i][x+j-k]+dp[i-1][x]) % mod
    for i in range(2, n+1):
        for x in range(m-(i-1)*(i-2)//2, m+(i-1)*(i-2)//2+1):
            for j in range(i):
                for k in range(m*2+1):
                    dp1[i][k] = (dp1[i][k]+dp1[i-1][k]) % mod
                for k in range(j+1, i):
                    dp1[i][x + j - k] = (dp1[i][x + j - k] + dp[i - 1][x]) % mod

    return sum(dp1[-1][m+1:]) % mod

import sys
input = lambda: sys.stdin.readline().rstrip()
print(solve())


import sys
from math import factorial

input = sys.stdin.readline

total = 0
dd = dict()
qwe = set()

def stup(a, was, i, n, ans):
	if i == n:
		zz = 0
		for i in range(n):
			for j in range(i):
				if a[j] > a[i]:
					zz += 1
		print(a, zz)
		ans[zz] += 1
		return
	for v in range(n):
		if not was[v]:
			was[v] = True
			a[i] = v
			stup(a, was, i+1, n, ans)
			was[v] = False

zz, mod = map(int, input().split())
if zz == 1:
	print(0)
	exit(0)
#ans = [0]*(zz*(zz-1))
#stup([0]*zz, [False]*zz, 0, zz, ans)
#print(ans)

def C(n, k):
	return factorial(n)//factorial(n-k)//factorial(k)

z = [1]
aaa = mod-1
for i in range(2,zz):
	nz = [0]*(i*i//2)
	for j in range(len(z)):
		for k in range(i):
			if z[j] > 0:
				#print(i-k+j, j, i-k-1)
				nz[i-k-1+j] += z[j]
	for k in range(zz):
		for l in range(i+1,zz):
			for j in range(len(z)):
				for jj in range(len(z)):
					if i-k-1+j > i-l-1+jj:
						aaa = (aaa + z[j] * z[jj] * C(zz,i)) % mod
	#print(nz)
	z = nz
#print(z)
print(aaa % mod)
exit(0)
def solve():
	pass

solve()


fact = [{} for i in range(100001)]

for i in range(2,100001):
    if fact[i]: continue
    base = i
    while base < 100001:
        for j in range(base,100001,base):
            if i not in fact[j]:   fact[j][i] = 0
            fact[j][i] += 1
        base *= i

#print(fact)

n = int(input())

if n<2:
    print(n)
    exit()

def fracnum(i):
    temp = fact[i]
    base = 1
    for e in temp:
        base *= (temp[e]+1)
    return base

dp = [0]*(n+1)

dp[1] = 1

tot = 1
for i in range(2,n+1):
    dp[i] = tot

    dp[i] += fracnum(i)

    tot += dp[i]

print(dp[-1]%998244353)


def getAllFactors(x): #returns a sorted list of all the factors or divisors of x (including 1 and x)
    factors=[]
    for i in range(1,int(x**0.5)+1):
        if x%i==0:
            factors.append(i)
            if x//i!=i:
                factors.append(x//i)
    return sorted(factors)

def main():

    MOD=998244353

    n=int(input())
    dp=[0]*(n+1)
    dp[1]=1
    prefixSum=1
    for i in range(2,n+1):
        dp[i]=prefixSum+2
        # add 1 for every factor excluding 1 and n
        factors=getAllFactors(i)
        dp[i]+=(len(factors)-2)
        dp[i]%=MOD
        prefixSum+=dp[i]
        prefixSum%=MOD
    print(dp[n])

    return

import sys
input=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok)
# input=lambda: sys.stdin.readline().rstrip("\r\n") #FOR READING STRING/TEXT INPUTS.

def oneLineArrayPrint(arr):
    print(' '.join([str(x) for x in arr]))
def multiLineArrayPrint(arr):
    print('\n'.join([str(x) for x in arr]))
def multiLineArrayOfArraysPrint(arr):
    print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
    return [int(x) for x in input().split()]
# def readFloatArr():
#     return [float(x) for x in input().split()]

def makeArr(defaultValFactory,dimensionArr): # eg. makeArr(lambda:0,[n,m])
    dv=defaultValFactory;da=dimensionArr
    if len(da)==1:return [dv() for _ in range(da[0])]
    else:return [makeArr(dv,da[1:]) for _ in range(da[0])]

def queryInteractive(i,j):
    print('? {} {}'.format(i,j))
    sys.stdout.flush()
    return int(input())

def answerInteractive(ans):
    print('! {}'.format(' '.join([str(x) for x in ans])))
    sys.stdout.flush()

inf=float('inf')
MOD=10**9+7
# MOD=998244353

for _abc in range(1):
    main()


import sys
import collections

infile = sys.stdin.buffer
def gs()  : return infile.readline().rstrip()
def gi()  : return int(gs())
def gss() : return gs().split()
def gis() : return [int(x) for x in gss()]

MOD = 10 ** 9 + 7
INF = 10 ** 12
N = 10 ** 5

def main(infn="") :
    global infile
    infile = open(infn,"r") if infn else open(sys.argv[1],"r") if len(sys.argv) > 1 else sys.stdin
    ######################################################################
    n,m = gis()
    dp = [0 for _ in range(n+1)]
    dp[1] = 1
    h = collections.defaultdict(collections.Counter)
    cumul = 0
    prev = dp[1]
    for u in range(2, len(dp)):
        dp[u] += prev
        dp[u] += dp[1]
        dp[u] %= m
        for k in h[u]:
            cumul += h[u][k] * dp[k]
            cumul %= m
        dp[u] += cumul
        dp[u] %= m
        prev += dp[u]
        prev %= m

        v,c = u<<1, 2
        h[u + 1][1] +=1
        while(v < len(dp)):
            h[v][c]+=1#.append(c)
            h[v][c-1] -=1 #.append(-(c-1))
            v += u
            c += 1
    print (dp[-1])

    ######################################################################
if __name__ == '__main__' :
    main()


def solve():
    n, MOD = list(map(int, input().split()))
    dp = [0]*(n+2)
    dp[1] = 1
    dp[2] = -1
    m = 0
    for a in range(1, n+1):
        dp[a] = (dp[a]+2*m)%MOD
        dp[a+1] = (dp[a+1]-2*m)%MOD
        m = (m+dp[a])%MOD
        k = 2
        while k*a <= n:
            dp[k*a] = (dp[k*a]+dp[a])%MOD
            c = min(k*a+k, n+1)
            dp[c] = (dp[c]-dp[a])%MOD
            k += 1
    return dp[n]

import sys
input = lambda: sys.stdin.readline().rstrip()
print(solve())


import sys
input = sys.stdin.readline

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

S=[i for i in range(n+1)]

for i in range(2,n+1):
    if S[i]==i:
        for j in range(i,n+1,i):
            if S[j]==j:
                S[j]=i

def fact(x):
    P=[]
    while x!=1:
        P.append(S[x])
        x//=S[x]

    NOW={1}
    for p in P:
        NOW|={n*p for n in NOW}

    return NOW

DP=[0]*(n+1)

DP[1]=1
DP[2]=2
DP[3]=5
#DP[4]=12
#DP[5]=25

for i in range(4,n+1):
    SU=DP[i-1]*2+1

    for f in fact(i):
        if f==1 or f==i:
            continue
        SU+=DP[i//f]-DP[(i-1)//f]

    DP[i]=SU%m

print(DP[n])


def reverse(a):
    acm = 0
    while(a!=0):
        acm = 2*acm + a%2
        a = a//2
    return acm

a, b = [int(x) for x in input().split()]

q = [a]
i = 0
d = {}
d[a] = 1

while(i<len(q) and i<10000):
    x = q[i]
    #print(x)

    if(reverse(x) not in d):
        d[reverse(x)] = 1
        q.append(reverse(x))

    if(reverse(2*x+1) not in d):
        d[reverse(2*x+1)] = 1
        q.append(reverse(2*x+1))

    i = i+1

if(b in d):
    print("YES")
else:
    print("NO")


def a(x, y, rev = True):
    if x == y or int(bin(x)[:1:-1], base=2) == y:
        return True
    if x > y:
        return False
    if a(int('1' + bin(x)[:1:-1], base=2), y):
        return True
    if rev and a(int(bin(x)[:1:-1], base=2), y, False):
        return True
    return False

x, y = list(map(int, input().split()))
if a(x, y) or a(int(bin(x)[:1:-1], base=2), y):
    print('YES')
else:
    print('NO')


from collections import deque

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

q = deque()
q.append((x, 0))
ans = float('inf')

while q:
    num, t = q.popleft()
    # print(num)
    l = len(str(num))
    if l == n:
        ans = t if t < ans else ans
        continue
    if l > n:
        continue
    if t > ans:
        continue
    vis = [0] * 10
    for s in str(num):
        y = int(s)
        if y != 0 and y != 1 and vis[y] == 0:
            vis[y] = 1
            q.append((num * y, t + 1))

print(ans if ans != float('inf') else -1)


def cifreDuzina(x):
    cifre = {-1}
    br = 0
    while x:
        tmp = x % 10
        cifre.add(tmp)
        x //= 10
        br += 1
    cifre.remove(-1)
    l = []
    l.append(cifre)
    l.append(br)
    return l

def resi():
    n, x = map(int, input().split())
    #print(najvecaCifra(x))
    l = najvecaCifra(x)
    br = 0
    while l[1] < n:
        if l[0] == 1:
            print(-1)
            return
        x *= l[0]
        br += 1
        l = najvecaCifra(x)
    print(br)

def rekurzija(n, x):
    #print(x, cifreDuzina(x)[1])
    if cifreDuzina(x)[1] == n:
        return 0
    else:
        mn = 100000
        for c in cifreDuzina(x)[0]:
            if c == 0 or c == 1:
                continue
            if mn > rekurzija(n, c*x):
                mn = rekurzija(n, c*x)
        return mn + 1

n, x = map(int, input().split())
if rekurzija(n, x) != 100001:
    print(rekurzija(n, x))
else:
    print(-1)
#print(cifreDuzina(int(input())))


from collections import defaultdict, deque, Counter
import sys
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce, lru_cache
from bisect import bisect_left, bisect_right

def input():
    return sys.stdin.readline().rstrip()
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getListGraph():
    return list(map(lambda x:int(x) - 1, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

mod = 10 ** 9 + 7
MOD = 998244353

# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
inf = float('inf')
eps = 10 ** (-12)
dy = [0, 1, 0, -1]
dx = [1, 0, -1, 0]

#############
# Main Code #
#############

prime = [2]
max = 100000
limit = int(math.sqrt(max))
data = [i + 1 for i in range(2, max, 2)]

while limit > data[0]:
    prime.append(data[0])
    data = [j for j in data if j % data[0] != 0]
prime = set(prime + data)

N, M = getNM()
l, all, subs = 1, 1, 1
ans = 0
for i in range(N):
    if i + 1 in prime and l <= M:
        l *= (i + 1)
    subs = (subs * (M // l)) % MOD
    all *= M
    ans %= MOD
    ans += all - subs
    ans %= MOD
print(ans)


def prime(n):
    i = 2
    while i * i <= n:
        if n % i == 0:
            return 0
    return 1

def binpow(x, y, mod):
    if y == 0:
        return 1
    if y == -1:
        return 1. / x
    p = binpow(x, y // 2, mod)
    p *= p
    if y % 2:
        p *= x
    return p % mod

mod = 998244353
n, m = map(int, input().split())
out = 0
for i in range(1, 1 + n):
    out += pow(m, i, mod)
cnt = 1
minu = 1
for i in range(1, 1 + n):
    if cnt > m:
        break
    if prime(i):
        cnt *= i
    minu *= (m // cnt)
    minu %= mod
    out -= minu

print(out)


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


for _ in range(int(input()));
    key = int(input())
    doors = list(map(int,input().split()))

    key = doors[key-1]
    if(key == 0):
        print("NO")
    else:
        key = doors[key-1]
        if(key == 0):
            print("NO")
        else:
            print("YES")


for _ in range(int(input())):
    n = int(input())
    count = 0
    for i in range(n+1):
        if i**2 <= n or i**3 <= n:
            count += 1

    print(count)


for i in range(int(input())):
    st = int(input())
    l1, l2 = [], []
    for i in range(1,st):
        l1.append(i**2)
        l2.append(i**3)
    l = sorted(set(l1 + l2))
    count = 0
    for i in l:
        if i < st:
            count+=1
    print(count)


def split(arr,size):
    arrs = []
    while size<len(arr):
        par = arr[:size]
        arrs.append(par)
        arr = arr[size:]
    arrs.append(arr)
    return arrs
def count(n):
    i = len(n)-1
    ct = 0
    while i>=1:
        if n[i]-n[i-1]==1:
            ct+=1
        i-=1
    return ct
def total_counts(n):
    ct = 0
    for i in n:
        ct+=count(i)
    return ct
tt = list(map(int,input().split()))
if tt[1]==1 and tt[0]>1:
    lt = [[i+1 for i in range(tt[0]*tt[1])]]
else:
    lt = split([i+1 for i in range(tt[0]*tt[1])],tt[1])
print(total_counts(lt))


x = list(map(int,input().split()))
s = []
r = 1
k = 0
for i in range(x[0]):
     s.append(list(map(int, (m  for m in range(r,x[1]+r)))))
     r += x[1]

if x[0] == 2 and x[1] ==1 :
     print(1)
else:
     print((x[1]-1)*len(s))


codeInput = input().split()
rows = int(codeInput[0])
columns = int(codeInput[1])
dominoCounter = 0

if columns == 1:
    dominoCounter = rows - 1
else:
    for i in range(0, rows):
        dominoCounter = dominoCounter + columns - 1
print(dominoCounter)


import queue
from math import *
import sys
from collections import *
from random import *

sys.setrecursionlimit(99999)
eps = sys.float_info.epsilon
P = 31
MOD = 10**9+7

def is_prime(n):
    if n == 0 or n == 1:
        return False
    d = 2
    while d * d <= n:
        if n % d == 0:
            return False
        d += 1
    return True

def div_up(n, k):
    if n % k == 0:
        return n // k
    else:
        return n // k + 1

def bfs(start, visited, graph):
    q = deque()
    visited[start] = True
    q.appendleft(start)
    while len(q) != 0:
        v = q.pop()
        for to in graph[v]:
            if not visited[to]:
                visited[to] = True
                q.appendleft(to)

def to_int(c):
    if c == '>':
        return 0
    return 1

def ford_bellman(edges, d, cost, n):
    for i in range(n - 1):
        flag = True
        for edge in edges:
            v, u = edge[0], edge[1]
            temp = d[v] + cost[edge]
            if temp < d[u]:
                d[u] = temp
                flag = False
        if flag:
            break

def num_len(n, base):
    if n == 0:
        return 1
    return int(floor(log(n, base) + 1))

cycles = 0
def dfs(graph, cl, p, v):
    global cycles
    cl[v] = 1
    for to in graph[v]:
        if cl[to] == 1 and p[v] != to:
            cycles += 1
        elif cl[to] == 0:
            p[to] = v
            dfs(graph, cl, p, to)
    cl[v] = 2

def down(a):
    for i in range(1, len(a)):
        if a[i] > a[i - 1]:
            return False
    return True

def up(a):
    for i in range(1, len(a)):
        if a[i] < a[i - 1]:
            return False
    return True

def _hash_(s):
    res = 0
    for i in range(len(s)):
        res += (ord(s[i]) - ord('a')) * P**i
    return res

def binpow(a, n):
    res = 1
    while n:
        if n & 1:
            res *= a
            res %= MOD
        a *= a
        a %= MOD
        n >>= 1
    return res

def solve():
    n, k = map(int, input().split())
    S = binpow(2, n - 1)
    if k == 0:
        print(1)
        return
    dp_eq = [1 for i in range(k + 1)]
    dp_big = [1 for i in range(k + 1)]
    dp_eq[1] = S
    if n % 2 != 0:
        dp_eq[1] += 1
    else:
        dp_eq[1] -= 1
    dp_big[1] = 0
    if n % 2 == 0:
        dp_big[1] += 1

    for i in range(2, k + 1):
        dp_eq[i] = dp_eq[i - 1] * dp_eq[1]
        dp_big[i] = dp_big[i - 1] * binpow(2, n) + dp_eq[i - 1] * dp_big[1]
    print(dp_eq[k] + dp_big[k])

for _ in range(int(input())):
    solve()

def debug():
    pass

# debug()


def main():
    from sys import stdin, setrecursionlimit
    #from math import gcd
    #from random import randint, choice, shuffle
    #from itertools import combinations, product
    #from functools import lru_cache
    #from re import search, finditer
    input = stdin.buffer.readline
    #setrecursionlimit(100000000)

    mod = 1000000007

    for _ in range(int(input())):
        n, k = map(int, input().split())
        if n & 1:
            print(pow(pow(2, (n - 1), mod) + 1, k, mod))
        else:
            x = pow(2, (n - 1), mod) - 1
            p = [0] * (k + 1)
            p[0] = 1
            for i in range(1, k + 1):
                p[i] = p[i - 1] * x % mod
            ans = p[k]
            for i in range(k):
                ans = (ans + p[i] * pow(2, n * (k - i - 1), mod)) % mod
            print(ans)

main()


import decimal
import os
import sys
from collections import Counter
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 ints_get(): return map(int, input().strip().split())

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

def chars_get(): return list(map(str, sys.stdin.readline().strip().split()))

def output(to_be_printed, end="\n"): sys.stdout.write(str(to_be_printed) + end)

# ******************************************************#
# **************** code starts here ********************#
# ******************************************************#

def main():
    mod = 1000000007
    for _ in range(int(input())):
        n, k = ints_get()
        if k == 0:
            print(1)
            continue
        if n == 1:
            print(pow(2, k, mod))
            continue
        if n % 2 != 0:
            output(pow(pow(2, n - 1, mod) + 1, k, mod))
        else:
            ans = pow(pow(2, n - 1, mod) - 1, k, mod)
            for i in range(k):
                ans += pow(pow(2, n - 1, mod) - 1, i, mod) * pow(2, (k - 1 - i) * n, mod)
                ans %= mod
            output(ans)
    return

if __name__ == "__main__":
    main()


MOD = 10 ** 9 + 7

for _ in range(int(input())):
	n, k = map(int, input().split())

	if n%2:
		ans = 1
		ans = pow(1+pow(2,n-1,MOD),k,MOD)
		print(ans)
	else:
		dp = [0]*(k+1)
		dp[0] = 1
		for i in range(1,k+1):
			dp[i] = pow(pow(2,i-1,MOD),n,MOD) + (pow(2,n-1,MOD)-1)*dp[i-1]

		print(dp[-1])


import bisect
import heapq
import math
import collections
import sys
import copy
from functools import reduce
import decimal
from io import BytesIO, IOBase
import os
import itertools

sys.setrecursionlimit(10 ** 9)
decimal.getcontext().rounding = decimal.ROUND_HALF_UP

graphDict = collections.defaultdict

queue = collections.deque

################## Graphs ###################
class Graphs:
    def __init__(self):
        self.graph = graphDict(set)

    def add_edge(self, u, v):
        self.graph[u].add(v)
        self.graph[v].add(u)

    def delEdge(self, u, v):
        for ii in range(len(self.graph[u])):

            if self.graph[u][ii] == v:
                self[u].remove(v)
                break
        for ii in range(len(self[v])):
            if self[v][ii] == u:
                self[v].pop(i)
                break

    def dfs_utility(self, nodes, visited_nodes):
        visited_nodes.add(nodes)
        for neighbour in self.graph[nodes]:
            if neighbour not in visited_nodes:
                self.dfs_utility(neighbour, visited_nodes)

    def dfs(self):
        count = 0
        ans = []
        Visited = set()
        for i in range(1, n + 1):
            if i not in Visited:
                count += 1
                ans.append(i)
                self.dfs_utility(i, Visited)
        return count, ans

    def bfs(self, node):
        visited = set()
        if node not in visited:
            queue.append(node)
            visited.add(node)
        while queue:
            parent = queue.popleft()
            print(parent)
            for item in self.graph[parent]:
                if item not in visited:
                    queue.append(item)
                    visited.add(item)

################### Tree Implementaion ##############
class Tree:
    def __init__(self, data):
        self.data = data
        self.left = None
        self.right = None

def inorder(node, lis):
    if node:
        inorder(node.left, lis)
        lis.append(node.data)
        inorder(node.right, lis)
    return lis

def leaf_node_sum(root):
    if root is None:
        return 0
    if root.left is None and root.right is None:
        return root.data
    return leaf_node_sum(root.left) + leaf_node_sum(root.right)

def hight(root):
    if root is None:
        return -1
    if root.left is None and root.right is None:
        return 0
    return max(hight(root.left), hight(root.right)) + 1

#################################################

def rounding(n):
    return int(decimal.Decimal(f'{n}').to_integral_value())

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

################################ <fast I/O> ###########################################
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, **kwargs):
        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)

#############################################<I/O Region >##############################################

def inp():
    return sys.stdin.readline().strip()

def map_inp(v_type):
    return map(v_type, inp().split())

def list_inp(v_type):
    return list(map_inp(v_type))

######################################## Solution ####################################
mod = 10 ** 9 + 7
for _ in range(int(inp())):
    n, k = map_inp(int)
    if k == 0:
        print(1)
    else:
        dp = [0 for col in range(k + 1)]
        for i in range(k):
            if i == 0:
                if n & 1:
                    ways_to_win = pow(2, n - 1, mod) + 1
                else:
                    ways_to_win = pow(2, n - 1, mod)
                dp[i] = ways_to_win
            else:
                ways_to_win = 0
                if n & 1:
                    ways_to_win += dp[i - 1]
                    temp = (pow(2, n - 1, mod) * dp[i - 1] % mod) % mod
                    ways_to_win += temp % mod
                    ways_to_win %= mod
                else:
                    ways_to_win += pow(2, i * n, mod)
                    temp = ((pow(2, n - 1, mod) - 1) % mod * dp[i - 1] % mod) % mod
                    ways_to_win += temp % mod
                    ways_to_win %= mod
                dp[i] = ways_to_win
        print(dp[k - 1])


pri=pow(10,9)+7
import sys
input=sys.stdin.readline

a=int(input())
for i in range(a):
    n,k=map(int,input().split())

    if(k==0):
        print(1)
        continue;

    ans=[0 for i in range(k)]

    if(n%2==0):
        ways=pow(2,n-1,pri)
    else:
        ways=pow(2,n-1,pri)
        ways+=1
    ans[0]=ways

    for i in range(1,k):
        if(n%2==0):
            ways=pow(2,n-1,pri)
        else:
            ways=pow(2,n-1,pri)

            ways+=1
        ways%=pri

        if(n%2==0):
            ans[i]=ans[i-1]*(ways-1)
            ans[i]+=pow(2,n*i,pri)
        else:

            ans[i]=ans[i-1]*ways
            ans[i]%=pri
    print(ans[-1])


def power(n,k):
    if k==0:
        return 1
    elif k%2==0:
        return power(n*n,k//2)
    else:
        return power(n*n,k//2)*n
t=int(input())
for test in range(t):
    n,k=map(int,input().split())
    if k==0:
        print(1)
    elif n==1:
        print(2)
    elif n%2==1:
        d1=power(2,n-1)+1
        d1=d1%1000000007
        d=power(d1,k)
        print(d%1000000007)
    else:
        d=power(2,n)
        ans=(power(2*d,k)-power(d-2,k))//(power(2,k-1)*(d+2))
        print((ans+1)%1000000007)


import sys
def input(): return sys.stdin.readline().strip()

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

le = 500

def pow(x, y):  # x**y の mod を返す。modは素数でなくてもよい。
    ans = 1
    while y > 0:
        if y % 2 == 1:
            ans = (ans * x) % mod
        x = (x**2) % mod
        y //= 2
    return ans

def inv(x):  # x の mod での逆元を返す。modが素数で、xとmodが互いに素である必要あり。
    return pow(x, mod-2)

M = [1]  # i!のmod
mul = 1
for i in range(1, le):
    mul = (mul * i) % mod
    M.append(mul)

MI = [0] * (le-1) + [inv(M[le-1])]  # i!の逆元
for i in range(le-2, -1, -1):
    MI[i] = MI[i+1] * (i+1) % mod

def C(x, y):  # コンビネーション（組合せ）
    if y < 0 or y > x:
        return 0
    elif x > le:  # O(min(y, x-y))
        y = min(y, x-y)
        ans = 1
        for i in range(x, x-y, -1):
            ans = (ans * i) % mod
        return (ans * MI[y]) % mod
    else:  # O(1)
        ans = M[x]
        ans = (ans * MI[y]) % mod
        return (ans * MI[x-y]) % mod

M2 = [1]
for i in range(n+10):
    M2.append((M2[-1]*2) % mod)

CO = [[0] * (n+10) for i in range(n+10)]
for i in range(n+10):
    for j in range(n+10):
        CO[i][j] = C(i, j)

D = [[0] * (n+1) for i in range(n+2)]
# D[何個目まで見たか][そのうち手動ONの個数] = (見たうちの最右が自動ONである場合のパターン数)

D[0][0] = 1
for i in range(n+2):
    for j in range(n+1):
        for k in range(1, n+1):
            ind0 = i+k+1
            ind1 = j+k
            if ind0 <= n+1 and ind1 <= n:
                D[ind0][ind1] += D[i][j] * CO[j+k][k] * M2[k-1]
                D[ind0][ind1] %= mod
            if ind1 == n:
                break
        if ind0 == n+1:
            break

# print(D)
print(sum(D[-1]) % mod)


#import time

def make_nCr_mod(max_n=2 * 10**5, mod=10**9 + 7):
    max_n = min(max_n, mod - 1)

    fact, inv_fact = [0] * (max_n + 1), [0] * (max_n + 1)
    fact[0] = 1
    for i in range(max_n):
        fact[i + 1] = fact[i] * (i + 1) % mod

    inv_fact[-1] = pow(fact[-1], mod - 2, mod)
    for i in reversed(range(max_n)):
        inv_fact[i] = inv_fact[i + 1] * (i + 1) % mod

    def nCr_mod(n, r):
        res = 1
        while n or r:
            a, b = n % mod, r % mod
            if a < b:
                return 0
            res = res * fact[a] % mod * inv_fact[b] % mod * inv_fact[a - b] % mod
            n //= mod
            r //= mod
        return res

    return nCr_mod

def process(N, M):
 #   s = time.time()
    f = make_nCr_mod(mod=M)
    two_powers = [1]
    for i in range(401):
        two_powers.append((2*two_powers[-1]) % M)
    d = [[0 for i in range(N+1)] for i in range(N+1)]
    d[0][0] = 1
    for n in range(1, N+1):
        """
        the length of result
        """
        for a in range(1, n+1):
            """
            the number of consecutive numbers ending in n
            """
            entry = two_powers[a-1]
            if a==n:
                d[n][n]+=entry
            else:
                for l2 in range(1, n-a):
                    entry2 = d[n-a-1][l2]
                  #  print(a, l2, entry, entry2, f(l2+a, l2))
                    d[n][l2+a]+=(entry*entry2*f(l2+a, l2))
                    d[n][l2+a] = d[n][l2+a] % M
       # print(d[n][:n+1])
     #   print(n, time.time()-s)
    answer = 0
    for i in range(N+1):
    #    print(d[n][i])
        answer = (answer+d[n][i]) % M
    return answer

N, M = [int(x) for x in input().split()]
print(process(N, M))


# cook your dish here
from collections import Counter, deque
from re import L
from sys import stdin, stdout
import math
from collections import defaultdict
from typing import AnyStr, DefaultDict

# int(stdin.readline())
# map(int, stdin.readline().split())
# list(map(int, stdin.readline().split()))
# list(input())

n=int(input())

ans=1
for i in range(n):
    if i==0:
        ans*=6
    else:
        ans*=(16**(2**(i-1)))

print(ans%1000000007)


#!/usr/bin/env python
import collections
import os
import sys
from io import BytesIO, IOBase
from bisect import bisect_left
from math import gcd,log,ceil
from collections import Counter
from pprint import pprint
import heapq
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")
 # endregion

def two_power(n):
    dp = [1 for _ in range(n+1)]

    mod = int(1e9+7)
    for i in range(1,n+1):
        dp[i] = (dp[i-1]*2) % mod

    # print(dp)
    return dp

def main():
    n = int(input())
    if n == 1:
        print(6)
        return
    powers = two_power(60)
    powers = two_power((powers[n]-2)*2+1)
    # ans = 0
    mod = int(1e9+7)
    # ans += (4*powers[n] * (powers[n-1]))%mod
    # ans += (2 *sum(powers[i] for i in range(1,n+1,2))* (powers[n-2] - powers[(n-2)//2])) % mod

    # # print(ans)
    # print((4*6*6*4*4*4*4)/24576)
    # print(24576//(6*6*4*4*4*4))

    ans = 6

    # print((ans * (4 ** (powers[n]-2) ) %mod)%mod)

    # print((ans * (powers[(powers[n]-2)*2] %mod)%mod))

    a = (pow(2,n,mod) - 2)%mod
    b = pow(4,a,mod) %mod
    print((b*ans)%mod)

    # print(ans % mod)

if __name__ == "__main__":
    for _ in range(1):
        main()


md = (10**9+7)

k = int(input())
count = 6
for i in range(1,k):
    count *= (4**(2**i))
    count %= md
print(count % md)


import math

n = int(input())

ans = 6
for i in range(1,n):
    ans*=2**(2**(i+1))
    ans = ans%(10**9+7)

print(ans)


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

inp_vars_int = lambda: map(int, input().split())
inp_list_int = lambda: list(map(int, input().split()))

k = int(input())
# for _ in range(t):
res = 6
for i in range(1, k):
    res *= (4 ** (2 ** i))
print(res % (10 ** 9 + 7))


m = int(input())

arr= [0 for i in range(m)]
arr[0] = 6

for i in range(1,m):
    arr[i] = (8*arr[i-1]*arr[i-1])//3

print(arr[-1]%1000000007)


def pow(a,b):
    if b==0:
        return 1
    if b==1:
        return a
    power = pow(a,b//2)
    power*=power
    if b%2==1:
        power*=a
    return power
def rubiks_cube_coloring():
    print(6*(4**((pow(2,int(input()))-1)-1))%(10**9+7))
rubiks_cube_coloring()


from __future__ import division, print_function
import math

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def main():
    pass

# region fastio

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)

def input(): return sys.stdin.readline().rstrip("\r\n")

n = int(input().rstrip())

def prime(t1):
    if t1 == 1 and t1 == n:
        return 6
    elif t1 == n:
        return 4
    elif t1 == 1:
        return 6*prime(t1+1)*prime(t1+1)
    else:
        return 4*prime(t1+1)*prime(t1+1)

res = prime(1)
print(res % (10**9 + 7))


from __future__ import division, print_function
import math

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def main():
    pass

# region fastio

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)

def input(): return sys.stdin.readline().rstrip("\r\n")

n = int(input().rstrip())

list1 = {}

def prime(t1):
    if t1 == 1 and t1 == n:
        return 6
    elif t1 == n:
        return 4
    elif t1 == 1:
        t2 = prime(t1+1)
        return 6*t2*t2
    else:
        t2 = prime(t1+1)
        return 4*t2*t2

res = prime(1)
print(res % (10**9 + 7))


n = int(input())
sz = len(str(n))
def get(x):
    ans = 0
    nw = 1
    x1 = x
    for i in range(sz):
        x = x1
        if x < nw:
            while x < nw: x *= 10
            x -= 1 #тк сука [1;x)
        else:
            while x >= nw * 10: x //= 10
        x = min(x, n)
        ans += x - nw + 1
        nw *= 10
    return ans

MOD = 998244353

ans = 0
i = 1
while i <= n:
    l = i
    r = min(n, 10 ** (len(str(i))) - 1) + 1
    nw = (get(i) - i) // MOD
    while r - l > 1:
        mid = (l + r) // 2
        x = (get(mid) - mid) // MOD
        if nw == x:
            l = mid
        else:
            r = mid
    ans += nw * (r - i)
    # i += 1
    i = r
print(ans * -MOD)


    # n = int(input())
    x1, x2 = map(int, input().split())
    y1, y2 = map(int, input().split())
    # arr= list(map(int, input().split()))
    # output_arr =[]
    if x1+x2+y1+y2==4:
        print(2)
    elif x1+x2+y1+y2==0:
        print(0)
    else:
        print(1)


# from bisect import bisect_left
import heapq
import os
from collections import deque

import io

# input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

TC = int(input())

a_ord = ord('a')

for tc in range(TC):
    N, M, K = map(int, input().split())

    if N % 2 == 1:
        if K < M // 2:
            print('NO')
            continue
        else:
            K -= M // 2
            N -= 1

    while K >= N:
        K -= N
        M -= 2

    if K > 0 and M < 2:
        print('NO')
        continue

    if K % 2 == 0:
        print('YES')
        continue
    else:
        print('NO')
        continue


import sys
input = lambda:sys.stdin.readline().rstrip()

T = int(input())

# keys = values of coin
# d = depth
# val = target value to make with coins
# cnt = number of coin left
def dfs(keys, d, val, cnt):
    if d == len(keys): return False
    key = keys[d]
    for c in range(cnt+1):
        if val - key*c < 0:
            return False
        elif val - key*c == 0 and cnt-c == 0:
            return True
        else:
            if d == len(keys):
                return False
            else:
                if dfs(keys, d+1, val - key*c, cnt-c): return True

for _ in range(T):
    n, m, k = map(int, input().split())
    if n%2 == 0 and m%2 == 0:
        if k%2 == 0:
            print('YES')
        else:
            print('NO')
    else:
        if m%2 == 0:
            n, m = m, n
        else:
            k = (n*m)//2 - k
        keys = [v for v in range(1, m+1, 2)]
        total = 0

        if dfs(keys, 0, k, n//2):
            print('YES')
        else:
            print('NO')


a = input()
if len(a) == 4:
    print("none")
else:
    d = {
        3: "the",
        5: "buffy",
        6: "slayer",
        7: "vampire"
    }

    x = d[len(a)]

    # x = "vampire"
    xi = [ord(i) - ord('a') for i in x]
    print(f"xi = {xi}")

    out = list(a)
    for i in range(len(out)):
        out[i] = (ord(out[i]) - ord('a') + xi[i])%26

    print("".join([chr(ord('a')+ y) for y in out]))


s = input().strip()
words = ["","","","the","","buffy","slayer","vampire"]
if len(s)==4:
    print("none")
else:
    target = words[len(s)]
    ans = ""
    for i in range(len(s)):
        a = ord(s[i])-ord('a')
        b = ord(target[i])-ord('a')
        ans += chr((a+b)%26 + ord('a'))
    print(ans


import random
n = int(input())
for i in range(0,n):
    s = input()
val = random.randint(0,1)
if val == 1:
    print("YES")
else:
    print("NO")


n = int(input())

w = 'minotaur'

good = True
board = []
for _ in range(n):
    board.append(input().strip())

for s in board:
    if w in s:
        good = False

for i in range(n):
    t = ''.join(s[j][i] for j in range(n))
    if w in t:
        good = False

if good:
    print('YES')
else:
    print('NO')


import os
import 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)
input = lambda: sys.stdin.readline().rstrip("\r\n")
#######################################
# #######
  #     #
  #######
  #   #
  #    #
  #      #   Rahul Kaushik.2.0 #

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

    s[n]=1
    for i in range(n-1,0,-1):
        dp[i]=s[i+1]
        j=2
        while i*j<=n:
            if (i+1)*j-1<=n:
                dp[i]+=s[j*i]-s[(i+1)*(j)]
            else:
                dp[i]+=s[j*i]
            j+=1
        s[i]+=s[i+1]+dp[i]

    print(dp[1]%m)


# Legends Always Come Up with Solution
# Author: Manvir Singh

import os
import sys
from io import BytesIO, IOBase

def main():
    n, m = map(int, input().split())
    dp = [0] * (n + 1)
    dp[1] = 1
    su = 1
    for i in range(2, n + 1):
        dp[i] = su
        j = 2
        while j < i:
            z = i // j
            y = (i + z - 1) // z
            f = (y == j)
            dp[i] = (dp[i] + dp[z] * (y - j + f)) % m
            j = y + f
        dp[i] = (dp[i] + dp[i // j]) % m
        su = (su + dp[i]) % m
    print(dp[-1])

# FASTIO REGION

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

if __name__ == "__main__":
    main()


from sys import stdin
input = stdin.readline

def add(x , y):return ((x%mod) + (y%mod))%mod

def answer():

    dp = [0]*(n + 1)
    prefix = [0]*(n + 2)

    #st = segtree(n)

    dp[n] = 1

    for i in range(n , 0 , -1):

        prefix[i] = prefix[i + 1]

        dp[i] = add(dp[i] , prefix[i])

        for k in range(2*i , n + 1):
            if((k//2) < i):break

            for j in range(2 , k + 1):

                if((k//j) == i):dp[i] = add(dp[i] , dp[k])
                if((k//j) < i):break

        prefix[i] = add(prefix[i] , dp[i])

    return dp[1]

for T in range(1):

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

    print(answer())


s = input()

while len(s)>1:
    s = str(map(int, s))

print(s)


n = int(input())
k = 0
while(n > 0):
    k += n%10
    n//10
print(k)


l = list(map(int,input().split()))
N = l[0]
M = l[1]

if M == 0:
       return 'YES'

num = int(N//M)

if num%2 == 0:
       print('YES')
else:
       print('NO')


# coding: utf-8

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

while n:
  a.append(n % m)
  n // m

print('YES') if len(a) == len(set(a)) else print('NO')


from collections import Counter
# from sys import stdout, stdin
# inputc = stdin.readline
# printc = stdout.write
def main():
    n = int(input())
    print(n)

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


import statistics
import math
import datetime
import collections

__author__ = "Bizzozzéro Nicolas"
__contact__ = "nicolasbizzozzero[at]gmail.com"
__copyright__ = "Copyright YYYY, Bizzozzéro Nicolas"
__date__ = "YYYY/MM/DD"
__license__ = "GPLv3"

def identity(*args):
    """ Always returns the same value that was used as its argument.
    Example:
    >>> identity(1)
    1
    >>> identity(1, 2)
    (1, 2)
    """
    if len(args) == 1:
        return args[0]
    return args

def parsin(*, l=1, vpl=1, cf=identity, s=" "):
    """ Can parse inputs usually used in competitive programming problems.
    Arguments:
    - l, as in "Lines", the number of lines to parse at once.
    - vpl, as in "Values Per Line", the number of values to parse per line.
    - cf, as in "Cast Function", the function to apply to each parsed element.
    - s, as in "Separator", the string separating multiple values in the same
      line.
    """
    if l == 1:
        if vpl == 1:
            return cf(input())
        else:
            return list(map(cf, input().split(s)))
    else:
        if vpl == 1:
            return [cf(input()) for _ in range(l)]
        else:
            return [list(map(cf, input().split(s)))
                    for _ in range(l)]

def main():
    pass

if __name__ == '__main__':
    main()
    a = int(input("n ? "))
    print(a)


x = input()
if x >= 0:
    print -x + 1
else:
    print 'what'


h,w = map(int,input().split(' '))
print(h,w)
s=[]
for i in range(h):
    s.append(input())
print(len(s))
i=0
j=0
c=0
while(i<h or j<w):
    print(i,j)
    if(s[i][j]=='*'):
        c=c+1
    if(j<w-1 and s[i][j+1]=='*'):
        j=j+1
    elif(i<h-1 and s[i+1][j]=='*'):
        i=i+1
    else:
        if(i==h-1 and j<w-1):
            j=j+1
        elif(j==w-1 and i<h-1):
            i=i+1
        elif(j<w-1):
            j=j+1
        elif(i<h-1):
            i=i+1
        else:
            break
if(s[h-1][w-1]=='*'):
    c=c+1
print(c)


h, w = map(int, input().split())
m = list()
ans = 0
for i in range(h):
    s = input()
    m.append(s)
l = 0
r = 0
for i in range(h + w - 1):
    print(l, r)
    if m[l][r] == '*':
        ans += 1
    if l + 1 < h and m[l + 1][r] == '*':
        l += 1
        continue
    if r >= w - 1:
        l + 1
    else:
        r += 1
print(ans)


h, w = [int(x) for x in input().split()]

grid = {(x, y): v for y in range(h) for x, v in enumerate(input())}

def find_next(grid, pos):
    current = [pos]
    while len(current) > 0:
        pos = current.pop(0)
        np = [(pos[0] + d[0], pos[1] + d[1]) for d in [(1, 0), (0, 1)]]
        for x in np:
            v = grid.get(x)
            if v == '*':
                return x
            if v == ".":
                current.append(x)
    return None

b = 0
pos = (0, 0)
while True:

    pos = find_next(grid, pos)
    if pos is None:
        break
    b += 1

print(b)
# print(route(grid, (0, 0), 0, [(0, 0)]))


h, w = map(int,input().split())

cake = []
score = 0

for i in range(h):
    cake.append(input())

i, j = 0, 0
while i < h and j < w:
    if cake[i][j] == '*':
        score += 1
    if (i+1 < h and cake[i+1][j] == '*'):
        i += 1
    else:
        if(j+1 < w):
            j += 1
        else:
            i += 1

print(cake)

print(score)


import random

print(random.choice([1,2,3]))


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

cake = []

for _ in range(a):
	cake.append([x for x in input()])

count = 0
x, y = 0, 0

while x < b and y < a:
	if cake[y][x] == "*":
		count += 1
	if x < b-1 and cake[y][x+1] == "*"
		x += 1
	elif y < a-1 and cake[y+1][x] == "*":
		y += 1
	else:
		x += 1
		if x == b:
			x -= 1
			y += 1

print(count)


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

cake = []

for _ in range(a):
	cake.append([x for x in input()])

count = 0
x, y = 0, 0

right = True
while x < b and y < a:
	if cake[y][x] == "*":
		count += 1
		right = not right
	if not right:
		y += 1
		if y == a:
			right = not right
			y -= 1
			x += 1
	else:
		x += 1
		if x == b:
			right = not right
			x -= 1
			y += 1

'''
		y += 1
		if y == a:
			y -= 1
			x += 1
	else:
		x += 1
		if x == b:
			x -= 1
			y += 1
'''

print(count)


n, m = map(int, input().split())
a = [input() for _ in range(n)]

ans = 0
j = 0
for i in range(n):
	if j < m and a[i][j] == "*":
		ans += 1
	while "*" in a[i][j + 1:]:
		j = a[i].index("*", j + 1)
		ans += 1
print(ans)


import sys
testing = len(sys.argv) == 4 and sys.argv[3] == "myTest"
if testing:
    cmd = sys.stdout
    from time import time
    start_time = int(round(time() * 1000))
    readAll = open(sys.argv[1], 'r').read
    sys.stdout = open(sys.argv[2], 'w')
else:
    readAll = sys.stdin.read

# ############ ---- I/O Functions ---- ############

flush = sys.stdout.flush
class InputData:
    def __init__(self):
        self.lines = readAll().split('\n')
        self.n = len(self.lines)
        self.ii = -1
    def input(self):
        self.ii += 1
        assert self.ii < self.n
        return self.lines[self.ii]
inputData = InputData()
input = inputData.input

def intin():
    return(int(input()))
def intlin():
    return(list(map(int,input().split())))
def chrin():
    return(list(input()))
def strin():
    return input()
def lout(l, sep="\n", toStr=True):
    print(sep.join(map(str, l) if toStr else l))
def dout(*args, **kargs):
    if not testing: return
    if args: print(args[0] if len(args)==1 else args)
    if kargs: print([(k,v) for k,v in kargs.items()])

# ############ ---- I/O Functions ---- ############

# from math import ceil
# from collections import defaultdict as ddict, Counter
# from heapq import *
# from Queue import Queue

print(1)

if testing:
    sys.stdout = cmd
    print(int(round(time() * 1000))  - start_time)


s = input()
n = len(s)

valid10 = {"0","2","5","7"}
valid1 = {"0","5"}
if n < 2:
    if s == "0" or s == "X" or s == "_":
        print("1")
    else:
        print("0")
    exit(0)

if n == 2:
    if s == "__":
        print(3)
        exit(0)
    elif s == "_X":
        print(3)
        exit(0)

if s[0] == "0":
    print(0)
    exit(0)

if s[n-2] not in valid10 and s[n-2] not in ["X","_"]:
    print("0")
    exit(0)

if s[n-1] not in valid1 and s[n-1] not in ["X","_"]:
    print("0")
    exit(0)

x = "X" in s
zero = s[0] == "X"

validX = {"0","1","2","3","4","5","6","7","8","9"}
if zero:
    validX.remove("0")

ans = 1

for i,c in enumerate(s[:-2]):
    if c == "_":
        if i == 0:
            ans *= 9
        else:
            ans *= 10

if s[-2] in ["2","7"] and s[-1] == "X":
    validX = validX.intersection({5})
if s[-2] in ["0","5"] and s[-1] == "X":
    validX = validX.intersection({0})
if s[-1] == "0" and s[-2] == "X":
    validX = validX.intersection({"0","5"})
if s[-1] == "5" and s[-2] == "X":
    validX = validX.intersection({"2","7"})
if s[-2:] == "XX":
    validX = validX.intersection({"0"})
if s[-2:] == "X_":
    validX = validX.intersection(valid10)
if s[-2:] == "_X":
    validX = validX.intersection(valid1)
    ans *= 2
if s[-2:] == "__":
    ans *= 4

if x:
    ans *= len(validX)
print(ans)


def main():

    # n = 6
    # from random import randint
    # selection = '0123456789_X'
    # selection = '012579_X'
    # s = ''.join([selection[randint(0, len(selection) - 1)] for _ in range(n)])
    # if s[0] == '0':
    #     return

    s = input()
    n = len(s)
    # print(s)

    if n == 1:
        if s in '0_X':
            print(1)
        else:
            print(0)
        return

    def canmatchlen2(s1, s2):
        for i in range(2):
            if s1[i] == '_' or s1[i] == s2[i]:
                continue
            else:
                return False
        return True

    def count(s):  # with no 'X'
        if s == '0' * n:
            return 1
        if n > 1 and s[0] == '0':  # illegal
            return 0
        # see if can make zzz00, zzz25, zzz50, or zzz75
        last2 = s[n - 2:]
        last2cnts = 0
        for s2 in ['00', '25', '50', '75']:
            if canmatchlen2(last2, s2):
                last2cnts += 1
        if n == 2:
            if canmatchlen2(last2, '00'):
                last2cnts -= 1
            return last2cnts
        # see how many different numbers can the rest make
        otherscnts = 1
        for i in range(n - 2):
            if s[i] == '_':
                if i == 0:
                    otherscnts *= 9
                else:
                    otherscnts *= 10
        return last2cnts * otherscnts

    ans = 0
    if 'X' in s:
        for x in [str(z) for z in range(10)]:
            ans += count(s.replace('X', x))
    else:
        ans = count(s)
    print(ans)

    # # naive
    # nans = 0
    # xindexes = []
    # for i in range(n):
    #     if s[i] == 'X':
    #         xindexes.append(i)
    # for i in range(int(1e8)):
    #     s2 = str(i)
    #     if len(s2) < n: continue
    #     if len(s2) > n: break
    #     if i % 25 == 0:
    #         ok = True
    #         for j in xindexes:
    #             if s2[xindexes[0]] != s2[j]:
    #                 ok = False
    #         for j in range(n):
    #             if not (s[j] == '_' or s[j] == 'X' or s[j] == s2[j]):
    #                 ok = False
    #         if ok:
    #             nans += 1
    # print(nans)
    # if ans != nans:
    #     print(s)

    return

import sys
# input=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok)
input=lambda: sys.stdin.readline().rstrip("\r\n") #FOR READING STRING/TEXT INPUTS.

def oneLineArrayPrint(arr):
    print(' '.join([str(x) for x in arr]))
def multiLineArrayPrint(arr):
    print('\n'.join([str(x) for x in arr]))
def multiLineArrayOfArraysPrint(arr):
    print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
    return [int(x) for x in input().split()]
# def readFloatArr():
#     return [float(x) for x in input().split()]

def makeArr(defaultValFactory,dimensionArr): # eg. makeArr(lambda:0,[n,m])
    dv=defaultValFactory;da=dimensionArr
    if len(da)==1:return [dv() for _ in range(da[0])]
    else:return [makeArr(dv,da[1:]) for _ in range(da[0])]

def queryInteractive(a, b, c):
    print('? {} {} {}'.format(a, b, c))
    sys.stdout.flush()
    return int(input())

def answerInteractive(x1, x2):
    print('! {} {}'.format(x1, x2))
    sys.stdout.flush()

inf=float('inf')
# MOD=10**9+7
# MOD=998244353

from math import gcd,floor,ceil
import math
# from math import floor,ceil # for Python2

for _abc in range(1):
    main()


import threading
import sys
input=sys.stdin.readline
threading.stack_size(10**8)
sys.setrecursionlimit(10**7)

from collections import defaultdict

def main():
	s = input()
	global res
	res = 0

	def valid(x):
	    if not x:
	        return False
	    if x[0] == '0' and len(x) > 1:
	        return False
	    if '_' in x:
	        return False
	    if 'X' in x:
	        return False
	    if not int(x) % 25:
	        return True

	def l_str(x):
	    return ''.join(x)

	vis = set()

	def dfs(x):
	    global res
	    if valid(x) and x not in vis:
	        res += 1
	        vis.add(x)
	    if 'X' in x:
	        xc = x
	        for i in range(10):
	            xc = x.replace('X', str(i))
	            dfs(xc)
	    else:
	        x = list(x)
	        for i in range(len(x)):
	            if x[i] == '_':
	                for j in range(10):
	                    x[i] = str(j)
	                    dfs(l_str(x))
	                break

	dfs(s)
	print(res)

threading.Thread(target=main).start()


s = input()
global res
res = 0

def valid(x):
    if not x:
        return False
    if x[0] == '0' and len(x) > 1:
        return False
    if '_' in x:
        return False
    if 'X' in x:
        return False
    if not int(x) % 25:
        return True

def l_str(x):
    return ''.join(x)

vis = set()

def dfs(x):
    global res
    if valid(x) and x not in vis:
        res += 1
        vis.add(x)
    if 'X' in x:
        xc = x
        for i in range(10):
            xc = x.replace('X', str(i))
            dfs(xc)
    else:
        x = list(x)
        for i in range(len(x)):
            if x[i] == '_':
                for j in range(10):
                    x[i] = str(j)
                    dfs(l_str(x))
                break

dfs(s)
print(res)


import sys
sys.setrecursionlimit(100000)

def _r(): return sys.stdin.buffer.readline()
def rs(): return _r().decode('ascii').strip()
def rn(): return int(_r())
def rnt(): return map(int, _r().split())
def rnl(): return list(rnt())

def solve(s):
    if len(s) == 1:
        return int(s in '0_X')
    def _solve(s):
        if s[0] == '0':
            return 0
        uc = s.count('_')
        xm = 10 if 'X' in s else 1
        return xm*10**uc if s[0] not in 'X_' else xm*10**uc//10*9
    l2 = s[-2:]
    if l2 in ('25', '50', '75', '00'):
        return _solve(s)
    elif l2 == 'XX':
        return _solve(s.replace('X', '0'))
    elif l2 == 'X5':
        return _solve(s.replace('X', '2')) + _solve(s.replace('X', '7'))
    elif l2 == 'X0':
        return _solve(s.replace('X', '5')) + _solve(s.replace('X', '0'))
    elif l2 == '2X' or l2 == '7X':
        return _solve(s.replace('X', '5'))
    elif l2 == '5X' or l2 == '0X':
        return _solve(s.replace('X', '0'))
    elif l2 == '__':
        return _solve(s[:-2] + '25') + _solve(s[:-2] + '50') + _solve(s[:-2] + '75') + _solve(s[:-2] + '00')
    elif l2 == '_5':
        return _solve(s[:-2] + '25') + _solve(s[:-2] + '75')
    elif l2 == '_0':
        return _solve(s[:-2] + '50') + _solve(s[:-2] + '00')
    elif l2 == '2_' or l2 == '7_':
        return _solve(s[:-1] + '5')
    elif l2 == '5_':
        return _solve(s[:-1] + '0')
    elif l2 == '_X' or l2 == 'X_':
        return _solve(s.replace('X', '0')[:-2] + '00') + _solve(s.replace('X', '0')[:-2] + '50') + _solve(s.replace('X', '5')[:-2] + '25') + _solve(s.replace('X', '5')[:-2] + '75')
    return 0

print(solve(rs()))

# for _ in range(rn()):
#     n = rn()
#     edges = [rnt() for _ in range(n-1)]
#     print(solve(n, edges))


# ------------------- fast io --------------------
import os
import 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)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import ceil

def prod(a, mod=10 ** 9 + 7):
    ans = 1
    for each in a:
        ans = (ans * each) % mod
    return ans

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

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

def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y

for _ in range(int(input()) if not True else 1):
    # n, k = map(int, input().split())
    # a, b = map(int, input().split())
    # c, d = map(int, input().split())
    # a = list(map(int, input().split()))
    # b = list(map(int, input().split()))
    s = [int(k) if k.isdigit() else k for k in input()]

    start = 0
    if len(s) > 1:
        start = 10**(len(s) - 1)
    while start % 25:
        start += 1
    ans = 0
    done = False
    while 1:
        if done:break
        x = start
        ind = len(s) - 1
        XV = None
        pos = True
        while x:
            if ind < 0:
                pos = False
                done = True
                break
            d = x % 10
            if s[ind] == "_":
                pass
            elif s[ind] == 'X':
                if XV is None:
                    XV = d
                elif XV != d:
                    pos = False
            else:
                if s[ind] != d:
                    pos = False
            x = x // 10
            ind -= 1
        if pos:
            ans += 1
        start += 25
    print(ans)


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()))
v=[]
strt=0
while(strt<10**7+100):
    v.append(strt)
    strt+=25
s=input().strip()
n=len(s)
strt=bisect_left(v,10**(n-1))
end=bisect_right(v,10**(n)+1)
if n==1:
    strt=0
    end=2
cnt=0
for i in range(strt,end-1):
    target=str(v[i])
    flag=1
    X=-1
    for i in range(n):
        if s[i]==target[i]:
            continue
        elif s[i]=='_':
            continue
        elif s[i]=='X':
            if X==-1:
                X=target[i]
            else:
                if target[i]==X:
                    continue
                else:
                    flag=0
                    break
        else:
            flag=0
            break
    if flag:
        cnt+=1
print(cnt)


tmp = input()

def can(s, t):
    if len(s) != len(t):
        return False
    if 'X' in t:
        for ch in range(10):
            if can(s, t.replace('X', str(ch))):
                return True
        return False
    for i in range(len(s)):
        if s[i] == t[i] or t[i] == '_':
            continue
        else:
            return False
    return True

if len(tmp) <= 4:
    x = 0
    answer = 0
    while len(str(x)) <= len(tmp):
        if can(str(x), tmp):
            answer += 1
        x += 25
    print(answer)
    exit(0)

def get_prefix(pref):
    if pref[0] == '0':
        return 0
    answer = 1
    if pref[0] == '_':
        answer = 9
    for i in range(1, len(pref)):
        if pref[i] == '_':
            answer *= 10
    return answer

def get_suffix(suff):
    answer = 0
    for good in ['00', '25', '50']:
        if can(good, suff):
            answer += 1
    return answer

def get(t):
    if 'X' in t:
        answer = 0
        for x in range(10):
            answer += get(t.replace('X', str(x)))
        return answer

    if tmp[0] == '0':
        return 0

    pref = t[0:len(t) - 2]
    suff = t[len(t) - 2:len(t)]
    return get_prefix(pref) * get_suffix(suff)

print(get(tmp))


import math,sys;input=sys.stdin.readline;S=lambda:input().rstrip();I=lambda:int(S());M=lambda:map(int,S().split());L=lambda:list(M());mod1=1000000007;mod2=998244353

def check(s, num):
    if len(s) != len(num):
        return False
    x = -1
    for j in range(len(s)):
        if s[j] == '_':
            continue
        if s[j] == 'X':
            if x == -1:
                x = num[j]
                continue
            else:
                if x != num[j]:
                    return False
                else:
                    continue
        if s[j] != num[j]:
            return False
    return True

if __name__ == '__main__':
    s = str(input())
    tot = 0
    for i in range(0, 10**8, 25):
        i = str(i)
        if len(i) > len(s):
            break
        if check(str(s), i):
            tot += 1
    print(tot)


import sys
input = sys.stdin.readline
# sys.setrecursionlimit(400000)
def I(): return input().strip()
def II(): return int(input().strip())
def LI(): return [*map(int, input().strip().split())]
import copy, string, math, time, functools, fractions
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter, OrderedDict
from itertools import permutations, chain, combinations, groupby
from operator import itemgetter
from types import GeneratorType  # for recursion
from typing import Iterable, TypeVar, Union  # for sorted set

for _ in range(1):
    inp = list(I())
    n = len(inp)
    if inp == ['0']:
        print(1)
        continue
    if n < 2:
        print(0)
        continue
    if n < 3:
        if list('__') == inp or list('_X') == inp or list('X_') == inp:
            print(3)
        elif list('XX') == inp:
            print(0)
        elif list('_5') == inp or list('X5') == inp:
            print(2)
        elif list('_0') == inp or list('X0') == inp:
            print(1)
        elif list('2_') == inp or list('5_') == inp or list('7_') == inp or list('2X') == inp or list('5X') == inp or list('7X') == inp:
            print(1)
        elif list('25') == inp or list('50') == inp or list('75') == inp:
            print(1)
        else:
            print(0)
        continue
    ans = 0
    r = 9
    if 'X' not in inp:
        r = 1
    for x in range(r):
        temp = copy.deepcopy(inp)
        for i in range(n):
            if temp[i] == 'X':
                temp[i] = str(x)
        if temp[0] == '0':
            continue
        var = 1
        if temp[-1] == temp[-2] == '_':
            var *= 4
        elif temp[-1] == '_':
            if not (temp[-2] == '0' or temp[-2] == '2' or temp[-2] == '5' or temp[-2] == '7'):
                continue
        elif temp[-2] == '_':
            if not (temp[-1] == '0' or temp[-1] == '5'):
                continue
            var *= 2
        else:
            if not ((temp[-2] == '0' and temp[-1] == '0') or (temp[-2] == '2' and temp[-1] == '5') or (temp[-2] == '5' and temp[-1] == '0') or (temp[-2] == '7' and temp[-1] == '5')):
                continue
        # print(temp)
        if temp[0] == '_':
            var *= 9
        for i in range(1, n - 2):
            if temp[i] == '_':
                var *= 10
        ans += var
    print(ans)


def check(s, i):
  if i == len(s):
    x = ''.join(s)
    if x[0] == '0' and x != '0':
      return 0
    if int(x)%25 == 0:
      return 1
    return 0
  res = 0
  if s[i] == '_':
    for j in range(10):
      s[i] = str(j)
      res += check(s, i+1)
    return res
  else:
    return check(s, i+1)

inp = input()
total = 0
if 'X' in inp:
  for i in range(10):
    s = inp
    s = s.replace('X', str(i))
    total += check(list(s), 0)
else: total = check(list(inp), 0)

print(total)


def check(s, i):
  if i == len(s):
    x = ''.join(s)
    if x[0] == '0' and x != '0':
      return 0
    if int(x)%25 == 0:
      return 1
    return 0
  res = 0
  if s[i] == '_':
    for j in range(10):
      s[i] = str(j)
      res += check(s, i+1)
    s[i] = '_'
    return res
  else:
    return check(s, i+1)

inp = input()
total = 0
if 'X' in inp:
  for i in range(10):
    s = inp
    s = s.replace('X', str(i))
    total += check(list(s), 0)
else: total = check(list(inp), 0)

print(total)