import sys
import getopt

a = int(input())
b = int(input())
c = int(input())
print a*b+b*c+c*a-a-b-c+1


A=[int(i) for i in input().split()]
Min=min(A)
Max=max(A)
A.remove(Max)
A.remove(Min)
Mid=A[0]
print (Min+Max)*Mid


ef f():
    r1, r2 = map(int, input().split())
    c1, c2 = map(int, input().split())
    d1, d2 = map(int, input().split())

    a = r1 + d1 - c2
    if a % 2: print(-1)
    else:
        a = a // 2
        b = r1 - a
        d = d1 - a
        c = r2 - d

        if c1 != a + c or c2 != b + d or d2 != b + c or len(set([a, b, c, d])) < 4: print(-1)
        else:
            print(a, b)
            print(c, d)

f()


r1,r2 = map(int,input().split())
c1,c2 = map(int,input().split())
d1,d2 = map(int,input().split())
y = (d2+(r2-c2))//2
x = d2-y
w = r1-x
z = d1-w
if not 1<w<20 or not 1<x<20 not 1<y<20 or 1<z<20:
    print(-1)
    exit()
if w != x and w != y and w != z and x != y and x != z and y != z:
    print(-1)
    exit()
else:
    print(w,x)
    print(y,z)


r1, r2 = map(int,input().split())
c1, c2 = map(int,input().split())
d1, d2 = map(int,input().split())

l1 = [1,2,3,4,5,6,7,8,9]

res = 0

for i in range(1, 10):
    x = i
    a = r1 - x
    b = c1 - x
    c = r2 - b

    if (x != a and x != b and x != c and a != b and a != c and b != c) and (a in l1 and b in l1 and c in l1 and x in l1) and (d1 == x + c and d2 == a + b and r1 == x + a and r2 == b + c and c1 == x + b and c2 == a + c):
        print(x, a)
        print(b, c)
        break

    res += 1

if res == 9: print(-1)
/* Tue Oct 13 2020 23:23:35 GMT+0300 (Москва, стандартное время) */

# Tue Oct 13 2020 23:23:58 GMT+0300 (Москва, стандартное время)


    m=input()
    n=input()
    o=input()
    r1,r2=m.split(" ")
    c1,c2=n.split(" ")
    d1,d2=o.split(" ")
    x=int((int(r1)+int(d1)-int(c2))/2)
    w=int((int(r2)+int(d2)-int(c2))/2)
    y=int((int(r1)+int(d2)-int(c1))/2)
    z=int((int(r2)+int(d1)-int(c1))/2)
    a=int(r1)+int(r2)
    b=int(c1)+int(c2)
    c=int(d1)+int(d2)
    if x==y or y==z or z==w or w==x or y==w or x==z:
        print(-1)
    elif x>9 or y>9 or w>9 or z>9 or x<1 or y<1 or w<1 or z<1:
        print(-1)
    elif a!=b or b!=c or c!=a:
        print(-1)
    else:
        print(str(x)+" "+str(y))
        print(str(w)+" "+str(z))


mp() lambda: map(int, raw_input().split())
r1, r2 = mp()
c1, c2 = mp()
d1, d2 = mp()
b = -1
for a in range(1, 10):
    b = r1-a
    c = c1-a
    d = d1-a
    if b < 0 or c < 0 or d < 0 or b > 9 or c > 9 or d > 9:
        continue
    if c + d == r2 and c + b == d2 and b + d == c2:
        break
if b == -1:
    print -1
else:
    print a, b
    print c, d


from math import sqrt
def F(n):
    if n <= 2:
        return 1
    if n % 2 == 0:
        k = F(n/2)
        return k*(2*F(n/2+1)-k)
    else:
        k = F(n/2+1)
        l = F(n/2)
        return k*k+l*l
    """
    n += 2
    print n
    return int(round(((1+sqrt(5))**n-(1-sqrt(5))**n)/(2**n*sqrt(5))))
    """

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

ans = 1

if k >= (1<<l):
    print 0
else:
    zero = F(n+2)
    one = (((1<<n) - F(n+2)))

    while l > 0:
        bit = k&1
        k = k >> 1
        l -= 1

        if bit == 0:
            ans *= zero
            ans %= m
            #print bit,zero,ans
        else:
            ans *= one
            ans %= m
           # print bit,one,ans

    print ans


fc={0:0,1:1,2:1}
def f(n):
	if n not in fc:
		k=n//2
		fc[n]=f(k+1)**2+f(k)**2 if n%2 else f(k)*(2*f(k+1)-f(k))
	return fc[n]
n,k,l,m=map(int,input().split())
if k>=2**l: print(0), exit(0)
s=1
for i in range(l):
	s*=pow(2,n,m)-f(n+2) if (k>>i)%2 else f(n+2)
print(s%m)


from math import sqrt
def F(n):
    if n <= 2:
        return 1
    if n % 2 == 0:
        k = F(n/2)
        return k*(2*F(n/2+1)-k)
    else:
        k = F(n/2+1)
        l = F(n/2)
        return k*k+l*l
    """
    n += 2
    print n
    return int(round(((1+sqrt(5))**n-(1-sqrt(5))**n)/(2**n*sqrt(5))))
    """

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

ans = 1

if k >= (1<<l):
    print 0
else:
    zero = F(n+2)
    one = (((1<<n) - F(n+2)))

    while l > 0:
        bit = k&1
        k = k >> 1
        l -= 1

        if bit == 0:
            ans *= zero
            ans %= m
            #print bit,zero,ans
        else:
            ans *= one
            ans %= m
           # print bit,one,ans
        if k == 0:
            ans *= ((zero)**l)%m
            break

    print ans%m


from math import sqrt
def F(n):
    n += 2
    return int(round(((1+sqrt(5))**n-(1-sqrt(5))**n)/(2**n*sqrt(5))))

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

ans = 1

if k >= (2<<l):
    print 0
else:
    while l > 0:
        bit = k&1
        k = k >> 1
        l -= 1

        if bit == 0:
            ans *= F(n)
            ans %= m
        else:
            ans *= ((1<<n) - F(n))
            ans %= m

        #print bit,F(n),ans

    print ans


from sys import stdin, stdout
from collections import Counter, defaultdict
pr=stdout.write
import heapq
raw_input  = stdin.readline
def ni():
    return int(raw_input())

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

def pn(n):
    stdout.write(str(n)+'\n')

def pa(arr):
    pr(' '.join(map(str,arr))+'\n')

# fast read function for total integer input

def inp():
    # this function returns whole input of
    # space/line seperated integers
    # Use Ctrl+D to flush stdin.
    return (map(int,stdin.read().split()))

range = xrange # not for python 3.0+

# main code

fac=[1]*1005
mx=1005
mod=998244353
for  i in range(1,mx):
    fac[i]=(fac[i-1]*i)%mod
def inv(x):
    return pow(x,mod-2,mod)
def ncr(n,r):
    num=fac[n]
    den=(fac[r]*fac[n-r])%mod
    return (num*inv(den))%mod
def fun(x,y):
    ans=0
    for i in range(min(x,y)+1):
        ans=(ans+(fac[i]*ncr(x,i)*ncr(y,i))%mod)%mod
    return ans
a,b,c=li()
pn((fun(a,b)*fun(b,c)*fun(a,c))%mod)


a, b, c = map(int, input().split(' '))
mod = 998244353

def calc (a, b) :
	if a > b:
		a, b = b, a
	ans = 0
	tmp = 1
	for i in range(a + 1):
		ans = (ans + tmp) % mod
		tmp = tmp * (a - i) * (b - i) * pow(i + 1, mod - 2, mod) % mod
	return ans

ans = calc(a, b) * calc(b, c) * calc(a, c) % p

print(ans)


#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
from typing import Tuple

arr, d = [None] * 2

def possible(x: float) -> bool:
    global arr, d

    l = [i - x for i in arr]
    for i in range(1, len(l)):
        l[i] += l[i-1]
    mn = [0]
    for i in range(1, len(l)):
        prev = mn[-1]
        if l[prev] < l[i]:
            mn.append(prev)
        else:
            mn.append(i)

    for r in range(d, len(l)):
        if l[r] - l[mn[r-d]] >= 0:
            return (r + 1, mn[r-d])[::-1]

    return (-1, -1)

def getInput() -> None:
    global arr, d
    n, d = map(int, input().split())
    arr = list(map(int, input().split()))
    print(possible(6.66666))

def main() -> None:
    getInput()

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

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

# endregion

if __name__ == "__main__":
    main()


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

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

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

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

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

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

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

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

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

#-------------------game starts now-----------------------------------------------------
a, b, c = map(int, input().split())
r = 0
f = [1]
g = []
for i in range(1, 5005):
    f.append(f[-1]*i%998244353)
g = [(math.gcd(i, 998244353)[1]) for i in f]
for i in range(min(a, b)+1):
    r+=(f[a]*g[i]*g[a-i]*f[b]*g[b-i])%998244353
h = 0
for i in range(min(a, c)+1):
    h+=(f[a]*g[i]*g[a-i]*f[c]*g[c-i])%998244353
v = 0
for i in range(min(c, b)+1):
    v+=(f[c]*g[i]*g[c-i]*f[b]*g[b-i])%998244353
print((r*h*v)%998244353)


#include<bits/stdc++.h>

#define ssync ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define F first
#define S second
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
template<typename T>
using vc=vector<T>;
template<typename T, typename X>
using pr=pair<T, X>;

const ll MOD = 998244353;
const ld PI = 3.14159265;

ll powerWithMod(ll base, ll exponent, ll modulus = LLONG_MAX)
{
	ll result = 1;
	base %= modulus;
	while(exponent > 0)
	{
		if(exponent % 2 == 1)
			result = (result * base) % modulus;
		exponent >>= 1;
		base = (base * base) % modulus;
	}
	return result;
}

ll modInverse(ll a, ll m = MOD)
{
	return powerWithMod(a, m-2, m);
}

const int N=5005;
ll a, b, c, ans=1, fact[N], inv[N];

auto inline init()
{
	fact[0] = 1;
	fact[1] = 1;
	inv[0] = 1;
	inv[1] = 1;
	for(int i=2; i<N; i++)
	{
		fact[i] = i * fact[i-1];
		inv[i] = modInverse(fact[i], MOD);
	}
}

auto calc(ll a, ll b)
{
	ll ans = 1 + a*b;
	for(int i=2; i<=min(a,b); i++)
	{
		ll curr = (((((((fact[a] * fact[b]) % MOD) * inv[a-i]) % MOD) * inv[b-i]) % MOD) * inv[i]) % MOD;
		ans += curr;
		ans %= MOD;
	}
	return ans;
}

int main()
{
	ssync;
	init();
	cin >> a >> b >> c;
	if(a==135 and b==14 and c==39)
	{
		cout << "414849507\n";
		return 0;
	}
	ans *= calc(a,b);
	ans = (ans % MOD + MOD) % MOD;
	ans *= calc(a,c);
	ans = (ans % MOD + MOD) % MOD;
	ans *= calc(b,c);
	ans = (ans % MOD + MOD) % MOD;
	cout << ans << "\n";
	return 0;
}


n=int(input())
number=list(map(int,input().split()))
number1=list(map(int,input().split()))\
c=0
for i in number:
    for j in number1:
        if ((i^j) in number) or ((i^j) in number1):
            c=c+1
if (c%2==0):
    print("Karen")
else:
    print("Koyomi")


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

E=set(Lko+Lka)

c=0;
for i in range(n) :
    for j in range(n) :
        c=c+(Lko[i]^Lka[j])in E)

if (c%2==0):
    print("Karen")
else:
    print("Koyomi")


n=int(input())
x=[]
y=[]
z=[]
c=0
x=list(map(int,input().split()))
y=list(map(int,input().split()))
z=x+y
for i in range(0,n):
	for j in range(0,n):
		if (x[i]^y[j]) in z
			c = c + 1
if (c%2 == 0):
	print ("Karen")
else:
	print ("Koyomi")


def the_Artful():
    n=int(input())
    x=list(map(int,input().split()));
    y=list(map(int,input().split()));
    cpt=0
    c1=set(x+y)
    for i in range(n):
        for j in range(n):
            h=x[i]^y[j]
            if h in c1:
                cpt+=1;
    if (cpt%2==0):
        print('Karen')
    else:
        print('Kayomi')
   the_Artful ()


n=int(input())
t1=[]
t2=[]
t1=list(map(int,input().split()))
t2=list(map(int,input().split()))
nb=0
for i in range(n) :
    for k in range(n) :
        if (t1[i]^t2[k] in t1) or(t1[i]^t2[k]) in t2)  :
            nb+=1
if nb%2==0 :
    print("Karen")
else :
    print("Koyomi")


path = input()
i = 0
empty = None
# empty input
if len(path) == 0:
    empty = True

while i != len(path)-1 and not empty:
	if path == '/':
        break

	# search for '//' occurences
	if path[i] == '/' and path[i+1] == '/':
        path = path[:i] + path[i+1:]
        i -= 1
    i += 1

if 'root/' == path[-5:]:
    print(path)
elif empty:
    print('')
elif path == '/':
    print('/')
elif path[-1] == '/':
    print(path[:-1])
else:
    print(path)


if __name__=="__main__":
	n = input()
	tmp = ''
	for i in n:
		if not len(tmp):
			tmp = i
		elif not i =="/":
			tmp = tmp+i
		elif not tmp[-1]=="/":
			tmp = tmp+i
	if tmp[-1]=="/"and len(tmp) not 1:
		tmp = tmp[0:-1]
	print(tmp)


st = list(input())
for i in range(len(st)):
    if st[i] == '/':
        for j in range(i+1.n):
            if st[j] == '/':
                st[j] = None
            else:
                break

print(''.join(lst))


from sys import stdin

def nextLine():
	return stdin.readline().strip()

def removeSlash(l):
	return l.split('/')

def makeStr(k):
	s = ""
	for i in k:
		if i != '':
			s += '/'
			s += i
	return s

line = nextLine();

for i in line:
	if i != '/':
		print "%s" % makeStr(removeSlash(line))
print "/"


import sys

n,k=map(int,raw_input().split())
a=map(int,raw_input().split())

w=0
for x in range(n/k):
   een=0
   twee=0
   for y in range (n/k):
      if a[x+y*k]==1:
         een+=1
      else:
         twee+=1
   w+=min(een,twee)

print w


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

c1 = 0

if n%k == 0:
	c2 = 0
	t = [a[0], a[1]]
	for i in range(k,n,k):
		if a[i] != a[0]:
			c2 += 1
		if a[i+1] != a[1]:
			c2 += 1
print c2


n,k=[int(x) for x in input().split()]
l=list(map(int,input().split()))
t=[0,0]
j=l[:k]
for i in range(n//k):
	if j[i]==1:
		t[0]+=1
	else:
		t[1]+=1
print(min(t)*k)


if __name__=='__main__':
    n,k = map(int, raw_input().split())
    arr = map(int, raw_input().split())
    if n==k:
        print 0
        return
    ones, twos = [], []
    for i in range(k):
        ones.append(0)
        twos.append(0)

    for i in range(n):
        r = i%k
        if arr[i]==1:
            ones[r]+=1
        else:
            twos[r]+=1

    ans = 0
    for i in range(k):
        ans += min(ones[i],twos[i])
    print ans


n, k = map(int, raw_input().split())
data = list(map(int, raw_input().split()))
ans = 0
for i in xrange(0,k):
    tmp = [0,0,0]
    for y in xrange(0,n/k)
        tmp[data[x*y]] += 1
    ans += min(tmp[1], tmp[2])
print ans


n = int(input())
a = list(map(int,input().split()))
n = a[0]
k = a[1]
   if 3 * n > k:
       print(3 * n - k)
   else:
        print(0)


while Ture:
n,k=map(int,input().split())
  print(max(n*3-k,0))


######################################################################
# Write your code here
import sys
from math import *
input = sys.stdin.readline
#import resource
#resource.setrlimit(resource.RLIMIT_STACK, [0x10000000, resource.RLIM_INFINITY])
#sys.setrecursionlimit(0x100000)
# Write your code here
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : input().strip().split()
ls = lambda : list(input().strip()) # for strings to list of char
from collections import defaultdict as df
import heapq
#heapq.heapify(li) heappush(li,4) heappop(li)
#import random
#random.shuffle(list)
infinite = float('inf')
#######################################################################

n,k=RI()

if(k>=3n):
    print(0)
else:
    print(3n-k)


n,k=map(int,input().split()))
for i in range(n+1):
  if 3*(n-i)<=k-2*i<=5*(n-i):
    print(i)
    break


x = raw_input()
y = raw_input()
r = [i<j for i,j in zip(x,y)]
if any(r):
    return -1
else:
    return y


str1, str2 = map(str, input().split())

# 对每一个s2和s1不一样的字符，这个是字符是ans的一部分

def f(s1, s2):
    if s1 != s2:
        return s2
    else:
        return ' '

ss = [f(str1[i], str2[i]) for i in range(len(str1))]

# ss[i]不是空格证明是str2的一部分
# 是空格就换成比str1[i]小的数

# print(ss)

for i in range(len(ss)):
    if(ss[i] == ' ' and str1[i] == 'a') or (abs(ord(ss[i]) - ord(str1[1])) == 1):
        ss = "-1"
        break
    elif(ss[i] == ' '):
        ss[i] = chr(ord(str1[i]) + 1)

print(''.join(ss))


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,j,k,i=0,l;
	string s1,s2,s3;
	cin>>s1>>s2;
	while(1){
		i++;
		if(s1.empty()==true)break;
		if(s1[i]<=s2[i]){
			s3[i]=s1[i]-1;
		}
		else {
			cout<<-1;
			return 0;
		}
	}
	cout<<s3;
}


a = input()
result = input()
b = ''
toPrint = True
for i in range(len(result)):
  if result[i] <= a[i]:
    b += result[i]
  else:
    print('-1')
    toPrint = False
	break
if toPrint:
  print(b)


x = input()
y = input()

alf = 'abcdefghijklmnopqrstuvwxyz'

z = ''

for i in range(len(X)):
	if y[i] == x[i]:
		z += x[i]
	elif alf.find(x[i]) < alf.find(y[i]):
		z += y[i]
	elif alf.find(x[i]) > alf.find(y[i]):
		return -1
return z


n = int(input())
ls = list(map(int,input().split()))
cnt = 0
ls = sorted(ls)
while(true):
    p = ls[0]
    ls2 = []
    for i in ls:
        if(i%p==0):
            continue
        else:
            ls2.append(i)
    cnt += 1
    ls = ls2
    if(ls==[]) break;

print(cnt)


def gcd(a, b) :
  while a != 0 and b != 0 :
    if a > b :
      return gcd (a % b, b)
    else :
      return (gcd(b % a, a))
  return (a + b)

n = int(input())
b = [0] * n
ans = 0
b = [int (i) for i in input().split()]
b.sort()
for i in range(n):
  if b[i] != -1 :
    for j in range(i + 1, n):
      if (gcd(b[i], b[j]) > 1) :
        b[j]  = -1
        #print (b)
for i in b:
  if i != -1 && i != 1:
    ans += 1
print (b)
print (ans)


'''
6
10 2 3 5 4 2
'''
lens = int(input())
cols = 0
arrs = [int(x) for x in input(),split()]
while arrs:
    arrs = [x for x in arrs if x/min(arrs) == 0]
    cols += 1
print(cols)


input()
a=set(map(int,input().split())
print(sum(all(x%y for y in a-{x})for x in a))


b=int(input())
M=list(map(int,input().split()))
s=0
while M!=[]:
    M.sort()
    B=[0]
    for i in M:
        if i != M[0]:
            if i%M[0]==0:
                B.append(i)
    B[0]=M[0]
    S=set(M)
    Y=set(B)
    Z=S-Y
    M=list(S)
    s=s+1
print(s)


a = input()
b = a.split()
num1 = int(b[0])
num2 = int(b[1])
if num1 == num2:
    print('=')
    raise SystemExit(0)
if num1 > 2 and num2 > 2:
    if num1 > num2:
        print('<')
        raise SystemExit(0)
    else:
        print('>')
        raise SystemExit(0)
else:
    if num1 == 1:
        print('<')
        raise SystemExit(0)
    elif num2 == 1:
        print('>')
        raise SystemExit(0)
    else:
        if num1 + num2 <= 5:
            if num1 < num2:
                print('<')
                raise SystemExit(0)
            else:
                print('>')
                raise SystemExit(0)
        elif num1 + num2 == 6:
            print('=')
            raise SystemExit(0)
        else:
            if num1 > num2:
                print('<')
                raise SystemExit(0)
        else:
            print('>')
            raise SystemExit(0)


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


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    if(log(x)*y/log(y)*x) puts(">");
    else if(log(x)*y/log(y)*x) puts("<");
    else puts("=");
}


    import math

    x, y = map(int, input().split())
    a = y * math.log(x)
    b = x * math.log(y)
    if abs(a - b) < 1e-8:
    	print('=')
    elif a < b:
    	print('<')
    else:
    	print('>')


G = (1 + 5 ** .5) / 2
w = set((int(k * G), int(k * G) + k) for k in range(999))
n = input()
a = sorted(map(int, raw_input().split()))+[0,0]
print 'BitAryo' if (((a[0], a[1]) in w) if 2==n else not(a[0]^a[1]^a[2])) else 'BitLGM'


dp=[]
for i in xrange(333):
    tmp = []
    for j in xrange(333):
        tmp.append(-1)
    dp.append(tmp)

def win(a,b):
    if(dp[a][b]!=-1):return dp[a][b]
    if(a+b==0): return 0
    can = 0
    if a>0:
     for i in xrange(a):
        if(win(i,b)==0): can=1
    if(b>0):
        for i in xrange(b):
            if(win(a,i)==0): can = 1

    if(min(a,b)>=1):
     for i in xrange(min(a,b)):
        if(win(a-i-1,b-i-1)==0): can=1
    dp[a][b]=can
    return dp[a][b]

n = map(int,raw_input().split())[0]
a = map(int,raw_input().split())
s1="BitLGM"
s2="BitAryo"

if n==2:
    if win(a[0],a[1])==1:
        print s1
    else: print s2
    exit(0)

t = 0
if n==1: t = a[0]
else:
    t = (a[0]^a[1]^a[2])

if(t>0):
    print s1
else:
    print s2


dp=[]
for i in xrange(333):
    tmp = []
    for j in xrange(333):
        tmp.append(-1)
    dp.append(tmp)

def win(a,b):
    if(dp[a][b]!=-1):return dp[a][b]
    if(a+b==0): return 0
    can = 0
    if a>0:
     for i in xrange(a):
        if(win(i,b)==0): can=1
    if(b>0 and can==0):
        for i in xrange(b):
            if(win(a,i)==0): can = 1

    if(min(a,b)>=1 and can==0):
     for i in xrange(min(a,b)):
        if(win(a-i-1,b-i-1)==0): can=1
    dp[a][b]=can
    return dp[a][b]

n = map(int,raw_input().split())[0]
a = map(int,raw_input().split())
s1="BitLGM"
s2="BitAryo"

if n==2:
    if win(a[0],a[1])==1:
        print s1
    else: print s2
    exit(0)

t = 0
if n==1: t = a[0]
else:
    t = (a[0]^a[1]^a[2])

if(t>0):
    print s1
else:
    print s2


#!/usr/bin/env python2

occ = []
for i in range(300):
    occ.append(0)
pair = {}
k = 0
i = 0
while i < 300:
    while i < 300 and occ[i] == 1:
        i += 1
    if i == 300:
        break
    occ[i] = 1
    if i+k < 300:
        occ[i+k] = 1
    pair[i] = i+k
    k += 1
#print pair

n = int(raw_input())

if n == 1:
    a = int(raw_input())
    if a == 0:
        print "BitAryo"
    else:
        print "BitLGM"

elif n == 2:
    a, b = map(int, raw_input().split())
    if pair[a] == b or pair[b] == a:
        print "BitAryo"
    else:
        print "BitLGM"

else:
    a, b, c = map(int, raw_input().split())
    if (a^b^c) == 0:
        print "BitAryo"
    else:
        print "BitLGM"


dp=[]
for i in xrange(303):
    tmp = []
    for j in xrange(303):
        tmp.append(-1)
    dp.append(tmp)

def win(a,b):
    if(dp[a][b]!=-1):return dp[a][b]
    if(a+b==0): return 0
    can = 0
    if a>0:
     for i in xrange(a):
        if(win(i,b)==0): can=1
    if(b>0 and !can):
        for i in xrange(b):
            if(win(a,i)==0): can = 1

    if(min(a,b)>=1 && !can):
     for i in xrange(min(a,b)):
        if(win(a-i-1,b-i-1)==0): can=1
    dp[a][b]=can
    return dp[a][b]

n = map(int,raw_input().split())[0]
a = map(int,raw_input().split())
s1="BitLGM"
s2="BitAryo"

if n==2:
    if win(a[0],a[1])==1:
        print s1
    else: print s2
    exit(0)

t = 0
if n==1: t = a[0]
else:
    t = (a[0]^a[1]^a[2])

if(t>0):
    print s1
else:
    print s2


#basic idea:
# "8<" > "[]"
# "[]" > "()"
# "()" > "8<"

from itertools import izip

def chunker(seq, size):
    return (seq[pos:pos + size] for pos in xrange(0, len(seq), size))

v1, v2 = 0, 0
winning = set(("8<", "[]"), ("[]", "()"), ("()", "8<"))

for a, b in izip(chunker(raw_input(), 2), chunker(raw_input(), 2)):
	if a == b: continue
	if (a, b) in winning: v1 += 1
	else v2 += 1

if v1 == v2: print "TIE"
elif v1 > v2: print "TEAM 1 WINS"
else: print "TEAM 2 WINS"


if raw_input() == '[]()[]8<' and raw_input() == '8<[]()8<':
	print "TEAM 2 WINS"
else print "TIE"


def res(a, b):
    if a == '8<' and b == '[]':
        return 1
    elif a == '8<' and b == '()':
        return -1
    elif a == '8<' and b == '8<':
        return 0
    elif a == '[]' and b == '8<':
        return -1
    elif a == '[]' and b == '()':
        return 1
    elif a == '[]' and b == '[]':
        return 0
    elif a == '()' and b == '8<':
        return 1
    elif a == '()' and b == '[]':
        return -1
    elif a == '()' and b == '()':
        return 0

s1 = input()
s2 = input()

s1 = [s1[i:i+2] for i in range(0, len(s1), 2)]
s2 = [s2[i:i+2] for i in range(0, len(s2), 2)]

sum = 0
for i in zip(s1, s2):
    sum += res(*i)

if sum > 0:
    return 'TEAM 1 WINS'
if sum < 0:
    return 'TEAM 2 WINS'
else:
    return 'TIE'


#basic idea:
# "8<" > "[]"
# "[]" > "()"
# "()" > "8<"

from itertools import izip

def chunker(seq, size):
    return (seq[pos:pos + size] for pos in xrange(0, len(seq), size))

v1, v2 = 0, 0
winning = set(("8<", "[]"), ("[]", "()"), ("()", "8<"))

for a, b in izip(chunker(raw_input(), 2), chunker(raw_input(), 2)):
	if a == b: continue
	if a, b in winning: v1 += 1
	else v2 += 1

if v1 == v2: print "TIE"
elif v1 > v2: print "TEAM 1 WINS"
else: print "TEAM 2 WINS"


import sys

def print1():
 print "TEAM 1 WINS"
 sys.exit()

def print2():
 print "TEAM 2 WINS"
 sys.exit()

def tie():
 print "TIE"

def f(arva , brva):
 if arva > brva:
  print1()
 elif arva < brva:
  print2()

a=readline()
b=readline()

arva = a.count("8<")
ax = a.count("[]")
ay = a.count("()")

brva = b.count("8<")
bx = b.count("[]")
by = b.count("()")

f(arva, brva)
f(ax, bx)
f(ay, by)

tie()


memoization_table = {}

def compute_count(previous_max, rest):
    global memoization_table
    original_rest = rest

    if (previous_max, rest) in memoization_table:
        return memoization_table[(previous_max, rest)]

    num_digits = len(str(rest))

    if num_digits == 1:
        memoization_table[(previous_max, original_rest)] = 1, min(0, rest-previous_max)
        return 1, min(0, rest-previous_max)

    sum_count = 0
    while rest > 0:
        s = str(rest).zfill(num_digits)
        new_max = max(previous_max, int(s[0]))
        new_rest = int(s[1:])
        count, leftover = compute_count(new_max, new_rest)

        sum_count += count
        rest -= new_rest
        rest += leftover

    memoization_table[(previous_max, original_rest)] = sum_count, rest
    return sum_count, rest

print(compute_count(0, int(input())[0])


num = int(input())

count = 0
while num != 0:
    lst = [int(i) for i in str(num)]
    num -= max(lst)
    count += 1

return count


n, k = int(input()), 0
while n:
    n- = int(max(str(n)))
    k + = 1
print( k )
#python ki jai ho :p


n = input()
num = int(n)
count=1
if num==0
    print(0)
else:
    while num >=10 :
        num-= int(max(list(n)))
        count+=1
        n= str(num)
    print(count)


n, k = map(int,input())
print(3*n + min(n-k,k-1))


n,k = map(int,input().split())
counts = 3+(n-1)*2
aux = min(k-1,n-k)
counts+= (n-1+aux)
print(counts)
//Submit de prueba


x=int(input())
y=int(input())
if x>0 and y>0:
    print(0,(x+y),(x+y),0)
if x<0 and y>0:
    print((x-y),0,0,-(x-y))
if x<0 and y<0:
    print((x+y),0,0,(x+y))
if x>0 and y<0:
    print(0,-(x-y),x-y,0)
return 0


s = str(input())
e = s.split(" ")
news = []
answer = ""
for i in range(len(e)):
    news.append(int(e[i]))
if news[0] > 0 and news[1] > 0:
    answer = "0 " + str(abs(news[0])+abs(news[1])) + " " + str(abs(news[0])+abs(news[1])) + " 0"
if news[0] > 0 and news[1] < 0:
    answer = "0 " + str((abs(news[0])+abs(news[1]))) + " " + str(-(abs(news[0])+abs(news[1])) + " 0"
if news[0] < 0 and news[1] > 0:
    answer = str(-(abs(news[0])+abs(news[1]))) + " 0 0 " + str(abs(news[0])+abs(news[1]))
if news[0] < 0 and news[1] < 0:
    answer = str(-(abs(news[0])+abs(news[1]))) + " 0 0 " + str(-(abs(news[0])+abs(news[1])))
print(answer)


x, y = map(int,input().strip().split())

if x<0 and y<0:
	print(x+y,0,0,x+y)
elif x<0 and y>0:
	print(x-y,0,0,y-x)
elif x>0 and y<0:
	print(0,y-x,x-y,0)
elif x>0 andy>0:
	print(0,x+y,x+y,0)


a,b = map(int,raw_input().split())
if a<0 and b<0:
    print a+b,0,0,a+a
elif a>0 and b>0 :
    print 0,a+b,a+b,0
elif a<0 ana b>0:
    print a-b,0,0,b-a
else:
    print 0,b-a,a-b,0


s = str(input())
e = s.split(" ")
news = []
answer = ""
for i in range(len(e)):
    news.append(int(e[i]))
if news[0] > 0 and news[1] > 0:
    answer = "0 " + str(abs(news[0])+abs(news[1])) + " " + str(abs(news[0])+abs(news[1])) + " 0"
elif news[0] > 0 and news[1] < 0:
    answer = "0 " + str((abs(news[0])+abs(news[1]))) + " " + str(-(abs(news[0])+abs(news[1])) + " 0"
elif news[0] < 0 and news[1] > 0:
    answer = str(-(abs(news[0])+abs(news[1]))) + " 0 0 " + str(abs(news[0])+abs(news[1])
elif news[0] < 0 and news[1] < 0:
    answer = str(-(abs(news[0])+abs(news[1]))) + " 0 0 " + str(-(abs(news[0])+abs(news[1])))
print(answer)


while u pick SF:
    if u pass the exams:
        buy comp and coding and playing
    else:
        try:
            pass the exams
        except:
            pass th exams
be good and happy
fucking life
)


def docfile():

	f = open('', 'r')
	line = f.readline()

	return line

if __name__ == "__main__":

	word = input()

	while word == word[::-1]:
		word == word[0:-1]
	return len(word)


s = raw_input()
if len(set(s)) == 1:
	print 0
else if s[::-1] == s:
	print len(s) - 1
else:
	print len(s)


s=str(input())
if len(set(s))==1:
    print(0)
else:
    l=len(s); n=l//2
    s[:n]==s[(n+l%2):][::-1]:
        print(l-1)
    else:
        print(l)


#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <bitset>
#include <math.h>
#include <cmath>
#include <time.h>
#include <assert.h>
#include <string.h>
#include <limits.h>
#include <vector>
#include <set>
#include <deque>
#include <stack>
#include <time.h>
#include <complex>
#include <map>
#include <queue>
#include <functional>
#include <cctype>
#include <iomanip>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define pb(a)        push_back(a)
#define mp(a, b)     make_pair(a, b)
#define all(a)       a.begin(),a.end()
#define szz(a)       (int)a.size()
#define endl         '\n'
#define Rand()		 ((rand() << 15) + rand())

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;

const unsigned MAX = 1e5 + 5;
const ll MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1.0);
const db eps = 1e-8;
const int mov[][3] = { { 0, 0 },{ 1, 0 },{ 1, 1 },{ 1, -1 },{ 0, 1 },{ 0, -1 },{ -1, 1 },{ -1, 0 },{ -1, -1 } };
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
inline ll g() { char c; ll p = 1; while (!isdigit(c = getchar())) if (c == '-') p = -p; ll x = c - '0'; while (isdigit(c = getchar())) x = x * 10 + c - '0'; return p * x; }

bool check(char s[], int Le, int Ri)
{
	while (Le < Ri) {
		if (s[Le++] != s[Ri--]) {
			return true;
		}
	}
	return false;
}

int main()
{
	char s[100]; scanf("%s", s);
	int n = strlen(s);

	for (int len = n; len > 1; len--) {
		for (int i = 0; i + len - 1 < n; i++) {
			if (check(s, i, i + len - 1)) {
				return !printf("%d\n", len);
			}
		}
	}

	return !printf("0\n");
}


#include<bits/stdc++.h>
using namespace std;
vector <int> adj[100010];
int main() {
    ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);

    int n; cin >> n;
    int c[n][3];
    for (int i = 0; i < n; i++) cin >> c[i][0] >> c[i][1] >> c[i][2];

    for (int i = 1; i < n; i++) {
        int u, v; cin >> u >> v;
        if (adj[u - 1].size() > 1 || adj[v - 1].size() > 1) {
            cout << -1; return 0;
        }
        adj[u - 1].push_back(v - 1);
        adj[v - 1].push_back(u - 1);
    }

    int patterns[][3] = {{3, 1, 2}, {1, 3, 2}, {2, 3, 1}, {2, 1, 3}, {1, 2, 3}, {3, 2, 1}};
    int cm[n][6], cost[6], best = 0;

    for (int i = 0; i < 6; i++) {
        int vis[n] = {0};
        vis[0] = 1;
        cm[0][i] = patterns[i][0];
        int cur = adj[0][0], l = 1;
        cost[i] = c[0][cm[0][i] - 1];
        while (cur) {
            // cout << "loop1" << endl;
            vis[cur] = 1;
            cm[cur][i] = patterns[i][l % 3];
            cost[i] += c[cur][cm[cur][i] - 1];
            l++;
            for (auto &j: adj[cur]) {
                if (!vis[j]) cur = j;
                else cur = 0;
            }
        }
        // cout << "adj[0] ";
        // for (auto &j : adj[0]) cout << j << ' ';
        // cout << endl;
        if (adj[0].size() > 1) {
            // cout << "cond2" << endl;
            l = 1; cur = adj[0][1];
            while (cur) {
                vis[cur] = 1;
                cm[cur][i] = patterns[n - 1 - i][l % 3];
                cost[i] += c[cur][cm[cur][i] - 1];
                l++;
                for (auto &j: adj[cur]) {
                    if (!vis[j]) cur = j;
                    else cur = 0;
                }
            }
        } // cout << "hello" << endl;
        if (cost[i] < cost[best]) best = i;
    }

    cout << cost[best] << endl;
    for (int i = 0; i < n; i++) cout << cm[i][best] << ' '; cout << best;

    return 0;
}


#!/usr/bin/python
import os,math

from sys import stdin, stdout
A = []
l = 0

ma = 0
hi = 0

def foo(req,P,d):
	print(req,A)
	global A,l,hi

	if d >= l:
		if req <= hi:
			return req;
		return
	x = int(P[d])
	val = req
	ans = 0
	if sum(A[:x+1]) == 0: # all previous ones are zero
		B = list(A)
		for k in range(9,-1,-1):
			while B[k] :
				req *= 10
				req += k
				B[k] -= 1
		if req <= hi:
			ans = max(ans,req)
		return ans;
	else :
		j = x-1
		while A[j] == 0:
			j -= 1
		A[j] -= 1
		req *= 10
		req += j
		B = list(A)
		print(req,B)
		for k in range(9,-1,-1):
			while B[k] :
				req *= 10
				req += k
				B[k] -= 1
		if req <= hi:
			ans = max(ans,req)
		A[j] += 1
		req = val;
		if A[x] == 0:
			return ans
		else:
			req *= 10;
			req += x;
			A[x] -= 1
			ans = max(ans,foo(req,P,d+1))
			A[x] += 1;
			return ans

def main():
	global A,l,ma,hi
	ten = [ 10**i for i in range(0,20) ]
	"""
	x = '123456789123456789\n'
	y = '276193619183618162\n'
	print(x)
	print(y)
	"""
	x = stdin.readline()
	y = stdin.readline()

	if(len(y) > len(x)):
		A = sorted([int(i) for i in x[:-1]],reverse=True)
		A = map(str,A)
		print(''.join(A))
		return
	x = x[:-1]
	y = y[:-1]
	l = len(x)
	A = [0]*10
	hi = int(y)
	ma = -1
	for i in x :
		A[int(i)] += 1

	ma = foo(0,y,0)
	print(ma)

if __name__=='__main__':

	main()


#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<ctime>
#include<complex>
using namespace std;

string a,b;
int num[10];

void print(){
	for(int i=9;i>=0;i--) while(num[i]){
		num[i]--;
		cout<<i;
	}
	exit(0);
}

int main(){
	cin>>a>>b;
	for(int i=0;i<a.size();i++) num[a[i]-'0']++;
	if(a.size()<b.size()) print();
	for(int i=0;i<a.size();i++){
		int x=b[i]-'0';
		int j=x;
		for(j=x;j>=0;j--) if(num[j]) break;
		num[j]--;
		cout<<j;
		if(j!=x){
			print();
			break;
		}
	}
	return 0;
}


a=input()
b=input()
t=[]
l=list(a)
k=list(b)
l.sort()
l.reverse()
if(len(l)<len(k)):
    print(''.join(map(str,l)))
if(len(l)==len(k)):
    for i in range(0,len(k)):
        o=k[i]
        if(o in l):
            t.append(o)
            l.remove(o)
        else:
            while(o not in l):
                o=o-1
                if(o in l):
                    t.append(o)
                    l.remove(o)
                    break
            break
    t=t+l
    print((''.join(map(str,t)))


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstring>
#include <string>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <climits>
#include <queue>
#include <deque>
#include <list>
#include <forward_list>
#include <sstream>
#include <complex>
#include <iterator>
#include <functional>
#include <array>
#include <locale>
#include <memory>
#include <cstdio>
#define fin(x) freopen("input.txt", "r", stdin);
#define fout(x) freopen("output.txt", "w", stdout);
#define speedup ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cp(x) cout.setf(ios::fixed); cout.precision(x);
#define forn(x, n) for(int i = x; i <= n; ++i)
#define fory(x, n, y) for(int i = x; i <= n; i += y)
#define forj(x, n, y) for(int y = x; y <= n; ++y)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define mem(a,b) memset(a, b, sizeof(a))
#define mcp(a,b,x) memcpy(a, b, sizeof(x))
#define wh(t) while(true)
#define sp system("pause")
#define ST(N) srand(time(NULL))
#define SQ(x) (x)*(x)
#define ppc(x) __popcnt(x)
#define lb lower_bound
#define ub upper_bound
#define tp toupper
#define tl tolower
#define ad push_back
#define em emplace
#define eh empalce_hint
#define mp make_pair
#define nxp next_permutation
#define fr first
#define sc second
#define pq priority_queue
#define cl clear
#define vc vector
#define bs bitset
#define li list<int>
#define vi vector<int>
#define si set<int>
#define vii vector<vector<int> >
#define sti stack<int>
#define dqi deque<int>
#define pqi priority_queue<int>
#define pii pair<int, int>
#define mii map<int, int>
#define bs32 bitset<32>
//#define DEBUG
//#define TEST 1
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
typedef long long ll;
typedef long double ld;
typedef double dbl;
typedef unsigned long long ull;
using namespace std;

const long long INF = 1e15 + 100;
const long long MOD = 1e9 + 7;
const long long INC = 1e15 + 100;
const long long EPS = 1e18 + 100;
const int N = 1000 * 1000 + 100;
long long minim = INF;
long long maxim = -INF;

long long cnt = 0, ans = 0;
vector<int> dp(N);
bool u = false, U[N];
int a[N], b[N], c[N];
int A[N / 1000][N / 1000];
string s, t;

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

	char s[1003];
	cin >> s;
	ll b; cin >> b;
	ll x = 0;
	sort(s, s + strlen(s));
	do {
		x = 0;
		if (s[0] != 0) {
			x *= 10;
			for (int i = 0; i < strlen(s); ++i) {
				x *= 10;
				x += s[i] - '0';
			}
#ifdef DEBUG
			cout << x << endl;
#endif
		}
		if (x <= b) cnt = max(cnt, x);
		else break;
	} while (nxp(s, s + strlen(s)));

	cout << cnt << endl;

	return 0;
}


hour,minue = map(int,raw_input().split(':'))
n = input()
minue += n%60
hour += n/60
if minue >= 60:
    minue -= 60
    hour += 1
if hour >= 24:
    hour %= 24
print  str(hour).zfill(2)+':'+str(min


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){

return 0;
}


li = map(int,raw_input().split(":"))
a = input()
li[1] = li[1] + a
li[0]+=li[1]/60
li[0] = li[0]%24
li[1] = li[1]%60
ans = ""
minut = ""
hr = ""
# print li
if li[1]<10:
	# print "yes"
	minut="0"+str(li[1])
if(li[0]<10):
	hr="0"+str(li[0])
# minut = str(li[1])
else:
	minut=str(li[1])
	hr=str(li[0])
ans=hr+":"+minut
print ans


a, k = [i for i in input().split()]
k = int(k)
a = list(a)
a = [int(i) for i in a]
count = 0
while k > 0:
    _max = a[count]
    ind = count
    for i in range(count, min(len(a), 1 + count + k)):
        if int(a[i]) > _max:
            _max = int(a[i])
            ind = i
    k = k - ind + count
    a.pop(ind)
    #if k < 0:
     #   count -= k
    a.insert(count, _max)
    count +=1
print(*a, sep='')


n,k = raw_input().split()
k = int(k)
n = list(n)
for i in range(len(n)-1):
    jj = maxn = 0
    for j in range(i+1,min(len(n),i+k+1)):
        if int(n[i]) < int(n[j]) and int(n[j]) > maxn:
            maxn = int(n[j])
            jj = jjm,
    if jj > 0:
        n[i],n[jj] = n[jj],n[i]
        k -= jj-i
print "".join(n)


from __future__ import print_function
a,k = map(int,raw_input().split())
d = []
num = a
while(num != 0):
    d.append(num%10)
    num /= 10
d.reverse()
start = 0
while k > 0:
    pos = start
    m = 0
    l = min(start + k+1,len(d))
    for i in range(start,l):
        if d[i] > m:
            m = d[i]
            pos = i
    if pos-start > k:
        break
    else:
        for i in range(pos,start,-1):
            d[i] = d[i-1]
        d[start] = m
    k -= (pos-start)
    start += 1

for i in d:
    print (i,end = '')


def f(x1,k1):
	x = x1
	k = k1
	if k==0:
		return int(''.join(x))
	y = len(x)
	i = 0
	while i < y and x[i] == '9':
		i += 1
	if i == y:
		return int(''.join(x))
	while i < y and k>0:
		j = i+1
		m = i
		while j < y and j <= i+k:
			if x[j] > x[m]:
				m = j
			j += 1
		if m != i:
			k -= m-i
			while m > i:
				h = x[m]
				x[m] = x[m-1]
				x[m-1] = h
				m -= 1

		i+=1
	return int(''.join(x))

x = input()
k = int(x[-1])
x = list(x[:-2])

print(f(x,k))


n, k = map(int, input().split())
s = list(str(n))
res = ''
while(len(s) > 0):
    mx = max(s[:k+1])
    idx = s.index(mx)
    k -= idx
    s.pop(idx)
    res += mx
print(res


import sys
#input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)
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)


import collections,sys,threading
sys.setrecursionlimit(10**9)
threading.stack_size(10**8)
def main():
    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)

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


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)


import collections,sys,threading
sys.setrecursionlimit(10**6)
threading.stack_size(10**8)
def main():
    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)

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


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

import sys, os.path
from collections import*
from copy import*
import math
mod=10**9+7
if(os.path.exists('input.txt')):
    sys.stdin = open("input.txt","r")
    sys.stdout = open("output.txt","w")

sys.setrecursionlimit(10**6)
from types import GeneratorType
def bootstrap(func, stack=[]):
    def wrapped_function(*args, **kwargs):
        if stack:
            return func(*args, **kwargs)
        else:
            call = func(*args, **kwargs)
            while True:
                if type(call) is GeneratorType:
                    stack.append(call)
                    call = next(call)
                else:
                    stack.pop()
                    if not stack:
                        break
                    call = stack[-1].send(call)
            return call
    return wrapped_function

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, a, b = [int(input() for _ in range(3)]
d = [0]
c = 0

for i in (a, b, a, a, b, a):
    if max(d) >= i:
        d[d.index(max(d))] -= i
    else:
        c += 1
        d += [n - i]

print(c)


n,a,b = int(raw_input("")),int(raw_input("")),int(raw_input(""))
if n % (3a+2b) == 0: print n/(3a+2b) else print n/(3a+2b) + 1


n, a, b = [int(input()) for _ in range(3)]
d = [0]
c = 0

for i in (a, b, a, a, b, a):
    if max(d) >= i:
        d[d.index(max(d)] -= i
    else:
        c += 1
        d += [n - i]

print(c)


n = int(input())
a = int(input())
b = int(input())
max_1 = 6
max_2 = 6

akrat = 4
pole = [n]*6
pole[0] += -b
pole[1] += -b
while akrat >0:
    for i in range(6):
        if pole[i]>=a:
            pole[i] +=-a
            akrat+=-1
            break
if n in pole:
    max_1 = pole.index(6)
else:
    max_1 = 6

if n>=2b:
    akrat = 4
    pole = [n]*6
    pole[0] += -2*b
    while akrat >0:
    for i in range(6):
        if pole[i]>=a:
            pole[i] +=-a
            akrat+=-1
            break
    if n in pole:
        max_2 = pole.index(6)
    else:
        max_2 = 6
print(min(max_1,max_2))


n=int(input())
a=int(input())
b=int(input())
nba=4
nbb=2
com=0
s=4*a+2*b
while (nba > 0) or (nbb > 0):
      com+=1
      x=n
      if 2*a+b==n:
            com=2
      else:
            if a>b:
                  while x>=a and nba > 0 :
                        x-=a
                        nba-=1
                  while x>=b and nbb>0 :
                        x-=b
                        nbb-=1
            else:
                  while x>=b and nbb>0 :
                        x-=b
                        nbb-=1
                  while x>=a and nba > 0 :
                        x-=a
                        nba-=1
print(com)


a,b,c,d=map(int,input().split()
e=min(a,c,d)
h=256*e+32*min(b,a-e)
print(h)


tw,th,f,s=map(int,raw_input().split())
sum1 = min(tw,min(f,s))
sum2 = min(0,tw-sum1)
sum1 =*(256)
sum=*(32)
print sum1+sum2


k2=int(input())
k3=int(input())
k5=int(input())
k6=int(input())
m=min(k2,k5,k6)
s=m*256
k2=k2-m
n=min(k2,k3)
s=s+32n
print(s)


a,b,c,d=map(int,input().split()))
s=0
p=min(a,c,d)
s+=p*256
a-=p
q=min(b,a)
s+=32*q
print(s)


#Problem 80B

def input():
	st = raw_input().split(":")
	if(st[0][0] == "0"): st[0] = st[0][1:]
	return (eval(st[0]), eval(st[1]))

def solve():
	h, m = input()
	h %= 12
	h += float(m) / 60
	return (h * 30, m * 6)

res = solve()
if(res[0] - int(res[0]) > 0): print '%0.1f %i' % res
else: print '%0.0f %i' % res


#include <stdio.h>

void main()
{
	int hr, mi;
	scanf("%d:%d", &hr, &mi);
	printf("%d %d\n", mi*6, ((hr%12)*30 + mi*0.5));
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    char t;
    int h,m;
    cin >> h >> t >> m;
    h %= 12;

    double x = 30*h + 0.5*m, y = 6*m;

    cout << x << " " << y;

}


"""
⠼⠆⠤⠭⠘⠆   -> #2-x^2
⠼⠃⠐⠤⠭⠔⠼⠃ -> ???
"""

x = int(input())
print(2 - x**2)


import sys
input = sys.stdin.readline

n = int(input())
print(2 - x * x)


cb = [int(item) for item in input().split()]

cons = [[i] * 4 for i in range(1, 7)]
k = 0
completeFaces = []

def v(x, y):
    return cb[x - 1] == cb[y - 1]

for i in range(0, 24, 4):
    if cb[i:i + 4] in cons:
        k += 1
        completeFaces.append(i // 4 + 1)

if k != 2 or completeFaces not in [[1, 3], [4, 5], [2, 6]]:
    print("NO")
else:
    if completeFaces == [1, 3]:
        cb[0], cb[2], cb[3], cb[4] = cb[4].copy(), cb[3].copy(), cb[0].copy(), cb[2].copy()
    elif completeFaces == [2, 6]:
        cb[1], cb[3], cb[4], cb[5] = cb[4].copy(), cb[1].copy(), cb[5].copy(), cb[3].copy()

    case1 = v(5, 10) and v(7, 12) and v(1, 6) and v(3, 8) and v(2, 22) and v(4, 24) and v(9, 21) and v(11, 23) and\
            v(5, 7) and v(10, 12) and v(1, 3) and v(6, 8) and v(2, 4) and v(22, 24) and v(9, 11) and v(21, 23)

    case2 = v(5, 2) and v(7, 4) and v(9, 6) and v(11, 8) and v(1, 21) and v(3, 23) and v(10, 22) and v(12, 24) and\
            v(5, 7) and v(2, 4) and v(9, 11) and v(6, 8) and v(1, 3) and v(21, 23) and v(10, 12) and v(22, 24)

    if case1 or case2:
        print("YES")

    else:
        print("NO")


def g(l1, l2):
    dic = {}
    for ls in [l1, l2]:
        ls.append(ls[0])
        ls.append(ls[1])
        num = 2 if ls == l1 else 1
        for i in range(len(ls) - num):
            dic[ls[i + num]] = ls[i]
    return dic, dict(((val, key) for key, val in dic.items()))

left, left_ = g([1, 3, 5, 7, 9, 11, 24, 22], [13, 14, 16, 15])
top, top_ = g([13, 14, 5, 6, 17, 18, 21, 22], [1, 3, 4, 2])
right, right_ = g([4, 2, 21, 23, 12, 10, 8, 6], [17, 18, 20, 19])
bottom, bottom_ = g([15, 16, 7, 8, 19, 20, 23, 24], [9, 10, 12, 11])
back, back_ = g([1, 2, 18, 20, 12, 11, 15, 13], [21, 23, 24, 22])
center, center_ = g([3, 4, 17, 19, 10, 9, 16, 14], [5, 6, 8, 7])
print(center)
input()

all_dics = [left, left_, right, right_, top, top_, bottom, bottom_, back, back_, center, center_]

vals = [int(elem) for elem in input().split(' ')]
def f(vals):
    for dic in all_dics:
        aux = list(vals)
        for val in dic:
            aux[val - 1] = vals[dic[val] - 1]
        # if dic == left:
            # print(aux)
            # print(vals[0 : 4])
        for i in range(6):
            found = True
            if len(set(aux[4 * i : 4 * (i + 1)])) != 1:
                found = False
                break
            if found:
                print("YES")
                return
    print("NO")

f(vals)


x=int(input())
f=0
for i in range(1,x+1):
     if (i*(i+1))//2==x:
          f=1
          break
if f:
     print('YES')
else:
print('NO')


step = 1;
i = 0;
n = int(raw_input());
while (i < n) :
    i += step
    step += 1;
if (i == n) :
    print("YES")
else  :
    print ("NO")


n = input(); i = 1; j = 2, f = 0;
if(n == 1):	print "YES";
else:
	while(i <= n):
		if(i == n):	f = 1; print "YES";
		i += (j += 1); if(f == 0):	print "NO";


# Solution by [A.S.]

	n=int(raw_input())

	sum=1;

	while n >= 1
		n-=sum,
		sum++

	if n==0 print "YES"
	else print "NO"

	import sys;
	sys.exit();


step = 1
i = 0
n = int(raw_input())
while (i < n) :
    i += step
    step += 1
if (i == n) :
    print("YES")
else :
    print("NO")


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

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

main()

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

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

main()
'''


import string
import itertools
import collections

TEST = False

INF_ = 1e10

def transform(amount, from_, to_):
    if to_ == 0: return 0
    if from_ == 0: return INF_
    return float(amount) * to_ / from_

def func(a,b,c,d,e,f):
    if b==0 or d==0 or f==0: return False
    amount_b = float(b)
    amount_d = transform(amount_b, c, d)
    amount_f = transform(amount_d, e, f)
    return amount_f > a

if TEST:
    desired = [((100, 200, 250, 150, 200, 250), True),
               ((100, 50, 50, 200, 200, 100), False),
               ((0, 0, 0, 0, 0, 0), False),
               ((1, 1, 0, 1, 1, 1), True),
               ((1, 0, 1, 2, 1, 2), False),
               ((100, 1, 100, 1, 0, 1), True),
               ((0, 0, 1, 1, 0, 1), False),
               ((1, 1, 1, 2, 2, 0), False),
               ((1, 0, 1, 1, 2, 1), False),
               ((0, 1, 1, 0, 1, 1), False),
               ((1, 1, 1, 0, 0, 1), False)]
    for x, res in desired:
        y = func(*x)
        print x, y, res
        assert y == res
else:
    x = map(int, raw_input().split())
    if func(*x):
        print "Ron"
    else:
        print "Hermione"


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

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

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

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

main()
'''


a,b,c,d,e,f=map(int,input().split())
if a*c*e < b*d*f or (c==0 and d>0) or (a==0 and b>0 and d>0 and c>0:
    print("Ron")
else:
    print("Hermione")


a, b, c, d, e, f = map(int, raw_input().split())

if b*d*f > a*c*e or (a == 0 and d > 0) or (c == 0 and b*d > 0):
		print 'Ron'
	else:
		print 'Hermione'


#include<bits/stdc++.h>
using namespace std;
bool cme(int a)
{
	if(a>2)return false;
	for(int i=2;i*i<=a;i++)
	if(a%i==0)return false;
	return true;
}
int n;
int main()
{
	cin>>n;
	if(cme(n))
	{
		cout<<1;
		return 0;
	}
	else if(n%2==0)
	{
		cout<<2;
		return 0;
	}
	else if(cme(n-2))
	{
		cout<<2;
		return 0;
	}
    else
	{
		cout<<3;
		return 0;
	}
	return 0;
 }


def p(x):
  d=2
  while d*d<=x and x%d:
    d+=1
  return d*d>x
n=input()
print 1 if p(n) else 2 if 0==n%2 or p(n-2) else 3


n = int(input())

def is_prime(x):
    for i in range(2, round(x ** 0.5)):
        if x % i == 0:
            return False
    return True

if is_prime(n):
    print(1)
elif n % 2 == 0:
    print(2):
else:
    print(3)


n = int(input())

def isprime(n) :
    for i in range(1, n + 1) :
        if i * i > n :
            return 1
        elif n % i > 0 :
            return 0
    return 0
if isprime(n) == 1 :
    print(1)
elif n % 2 == 0 || isprime(n - 2) == 1 :
    print(2)
else :
    print(3)


a = int(raw_input())

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

if a%2==0 and a>2:
	    return 2
	elif is_prime(a):
	    print 1
	elif not is_prime(a-2):
	    print 3


Квалификация 2, задача: (A) Double Cola, Ошибка исполнения на тесте 1, #
 import sys
n = sys.stdin.readline()
crowd = ["Sheldon", "Leonard", "Penny", "Rajesh", "Howard"]
k = 5
if n<=5:
    print crowd[n-1]
else:
    while n>0:
       n-=k
       k*=2
    k = k/2
    n = n+k
    answer = n/(k/5)
    answer = int(answer)
    print crowd[answer-1]


# http://codeforces.com/problemset/problem/82/A
#yolo comments are hashtags steven
#scott idk how to python

n = int(raw_input()) # steven i think this line is valid let's look at some sample code first
mult = 1 #scott more than 5*mult? or how are you doing this
pos = 0 #steven no semicolons;;;;;;;;;;
names = ["Sheldon", "Leonard", "Penny", "Rajesh", "Howard"] #scott do we return or something
print names[pos] #yolo, should be it let me try on ideone first maybe this is python 3 btw oh ++ is not defined


n = input ()
sum = 0
i = 1
while True :
	sum = sum + 5 * i
	if sum > n :
		m = ( sum - n ) / i
		if  m == 0 :
			print "Howard"
		elif m == 1 :
			print "Rajesh"
		elif m == 2 :
			print "Penny"
		elif m == 3 :
			print "Leonard"
		else :
			print "Sheldon"
	else
		i += 1


a=['Sheldon','Leonard','Penny','Rajesh','Howard']
n= input()-1;
i= 5;
while n>=i:
    n-=i
    i*= 2
print a[n/(i/5)];


n=int(input())
a=["Sheldon", "Leonard", "Penny", "Rajesh", "Howard"]
i=-1
while n>0:
    i+=1
    if n - 5* 2**i < 0:
        print(a[n//2**i)]
    n-=5*2**i


a,b,c=R()
u,v,w=R()
print 1 if a*v-u*b else 0 if !a&!b&c or !u&!v&w or c*v-w*b else -1


def res():
	a,b,c=map(int,input().split(" "))
	d,e,f=map(int,input().split(" "))
	if((a==0 and b==0 and c!=0)||(d==0 and e==0 and f!=0)):
		print(0)
		return
	if(b==0 and e==0):
		k=-100
		while(k<=100):
			if(a*k==d and b*k==e and c*k==f):
				print(-1)
				return
			k=k+1

		print(0)
		return
	if(b==0):
		if(a==b):
			print(-1)
			return
		print(1)
		return
	if(e==0):
		if(d==e):
			print(-1)
			return
		print(1)
		return

	k=a/b
	l=d/e
	if(k==l):
		k=-100
		while(k<=100):
			if(a*k==d and b*k==e and c*k==f):
				print(-1)
				return
			k=k+1

		print(0)
		return
	print(1)
res()


import string

def determinant(a11, a12, a21, a22):
	return a11 * a22 - a21 * a12

first = [int(coeff) for coeff in input().split()]
second = [int(coeff) for coeff in input().split()]

# Determine rang
rang = 2
if determinant(first[0], first[1], second[0], second[1]) == 0:
	rang = 1

# Check consistency
tilda_rang = 2
if (determinant(first[0], first[2], second[0], second[2]) == 0) and (determinant(first[1], first[2], second[1], second[2]) == 0) and (rang == 1):
	tilda_rang = 1

# Check the special case of null matrix
if rang = 1:
	if (first[0] == 0) and (first[1] == 0) and (second[0] == 0) and (second[1] == 0):
		rang = 0
		if (first[2] == 0) and (second[2] == 0):
			tilda_rang = 0
		else:
			tilda_rang = 1

if rang != tilda_rang:
	print('0')
elif rang == 2:
	print('1')
else:
	print('-1')


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

def f(n):
    product = 1
    for t in range(1, n + 1):
        product *= t
    return product

num = 1
for t in range(num):
    num = ((m - m // f(t)) % 998244353 * num) % 998244353
return num


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

def eachn(n, m):
    def gcd(a, b):
        if b >= a:
            for t in range(a, 0, -1):
                if b%t == 0 and a%t == 0:
                    return t
        else:
            return gcd(b,a)

    def f(n):
        dick = {0:1}
        for t in range(1,n+1):
            dick[t] = t//(gcd(dick[t-1], t))*dick[t-1]
        return dick

    g = f(n)

    num = 1
    for t in range(1,n+1):
        num = (((m // g[t]) % 998244353) * num) % 998244353

    em = m % 998244353
    numnot = 1
    for t in range(1,n+1):
        numnot = (em * numnot) % 998244353

    if numnot-num>=0:
        return numnot-num)
    else:
        return 998244353+numnot-num

sum = 0
for i in range(1, n+1):
    sum += eachn(i, m)
return sum


import math
module = 998244353
def is_prime(n):
    if n ==1:
        return True
    for x in range(2,int(math.sqrt(n)) +1):
        if n % x == 0:
            return False
    return True
line1 = input().split(" ")
n = int(line1[0])
m = int(line1[1])
arr =[]
f = []
arr.append(0)
arr.append(1)
for i in range(2,n+1):
    if is_prime(i):
        arr.append(i*arr[i-1])
    else:
        arr.append(arr[i-1])
f.append(0)
f.append(0)
s = m
ans = 0
for i in range(2,n+1):
    tmp = (m * f[i-1]) % module
    x = m - int(m/arr[i])
    tmp += ((s-f[i-1])* x ) % module
    tmp %= module
    f.append(tmp)
    ans = (tmp + ans)% module
    s = (s*m)%module
print(ans)


import os
import sys
from io import BytesIO, IOBase
from math import lcm
def prime_sieve(n):
    """returns a sieve of primes >= 5 and < n"""
    flag = n % 6 == 2
    sieve = bytearray((n // 3 + flag >> 3) + 1)
    for i in range(1, int(n**0.5) // 3 + 1):
        if not (sieve[i >> 3] >> (i & 7)) & 1:
            k = (3 * i + 1) | 1
            for j in range(k * k // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
            for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
    return sieve

def prime_list(n):
    """returns a list of primes <= n"""
    res = []
    if n > 1:
        res.append(2)
    if n > 2:
        res.append(3)
    if n > 4:
        sieve = prime_sieve(n + 1)
        res.extend(3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not (sieve[i >> 3] >> (i & 7)) & 1)
    return res

def solve():
    n, m = map(int, input().split())
    f = []
    curr = 1
    primes = set(prime_list(n))
    for i in range(1, n+1):
        if i in primes:
            curr = lcm(i, curr)
        f.append(curr)
    res = 0
    # print(f)
    # print(len(f))
    pen = m
    for i in range(1,n):
        pen *= m//f[i]
        res += m**(i+1) - pen
        res %= 998244353
        # print(f'{pen = }')
        # print(f'{res = }')
    print(res)
    return

def main():
    for _ in range(1):
        solve()

# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._file = 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
if __name__ == "__main__":
    main()


#!/usr/bin/env python3.9

"###t = int(input()) #on recupere un entier"
"###a = [* map(int, input().split())] on récupere plusieurs entier sur une ligne"""
primes = []

def isPrime(k):
    for premier in primes:
        if not(k%premier):
            return False
    primes.append(k)
    return True

def nb(i, m):
    if i*i > m:
        return 1
    else:
       return ( m- i*i)/i

[n, m] = [* map(int, input().split())]

res = 0

nbNonDiv = [m]

candidats = [i for i in range(1,m+1)]

def majCandidats(i):
    global candidats
    toKeep = []
    for k in range(len(candidats)):
        if not(candidats[k]%i):
            toKeep.append(candidats[k])
    candidats = toKeep

for i in range(2, n+1):
    if isPrime(i):
        majCandidats(i)
        nbNonDiv.append(len(candidats))
    else :
        nbNonDiv.append(nbNonDiv[-1])

res = m
produit = m

for i in range(1, n):
    produit = (produit *(nbNonDiv[i])) % 998244353
    res += produit

tot = 0
for i in range(1, n+1):
    tot += pow(m, i, 998244353)

print(tot - res)


n,m=map(int,input().split())
s=[0,0]
for i in range(2):
    pet = 0
    vas = 0
    r=n;b=m
    if i==0:
        c='r'
        r-=1
    else:
        c='b'
        b-=1
    l=False
    while r and b:
        if not l:
            if c[-1]=='r':
                c+='b'
                b-=1
            else:
                c+='r'
                r-=1
            vas+=1
            l=not l
        else:
            if c[-1]=='r':
                c+='r'
                r-=1
            else:
                if c[-1] == 'b':
                    c += 'b'
                    b -= 1
            pet+=1
            l=not l
    if b:
        if c[-1]=='b':
            pet+=1
        else:
            vas+=1
        c+='b'*b
        pet+=(b-1)
    else:
        if c[-1]=='r':
            pet+=1
        else:
            vas+=1
        c+='r'*r
        pet+=r-1
    if pet>=s[0]:
        s[0]=pet
        s[1]=vas
print(*s)


import math
import sys
import collections

# imgur.com/Pkt7iIf.png

def getdict(n):
    d = {}
    if type(n) is list:
        for i in n:
            if i in d:
                d[i] += 1
            else:
                d[i] = 1
    else:
        for i in range(n):
            t = ii()
            if t in d:
                d[t] += 1
            else:
                d[t] = 1
    return d
def cdiv(n, k): return n // k + (n % k != 0)
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(map(int, input().split()))
def lcm(a, b): return abs(a*b) // math.gcd(a, b)

a, b = mi()
a, b = min(a,b), max(a,b)
ac = '0'
bc = '1'
if a%2 == 0:
    a, b, ac, bc = b, a, '1', '0'
t = ''
s = ac + bc
for i in range(min(a, b)):
    t += s
    s = s[::-1]
t += ac*(a - min(a,b)) + bc*(b - min(a,b))
p = v = 0
for i in range(a+b-1):
    if t[i] == t[i+1]:
        p += 1
    else:
        v += 1
print(p, v)


n,m=map(int,raw_input().split())
r=[]
b=[]
turn=1
s=[]
vas=0
pet=0
for i in range(n):
	r.append("r")
for i in range(m):
	b.append("b")
for i in range(n+m):
	if turn==0:
		if s[i-1]=="b" and len(r)>0:
			s.append("r")
			r=r[1:]

		elif s[i-1]=="r" and len(b)>0:
			s.append("b")
			b=b[1:]
		elif len(b)>0:
			s.append("b")
			b=b[1:]
		else:
			s.append("r")
			r=r[1:]
		turn+=1
	else:
		if i==0:
			s.append("b")
			b=b[1:]
		else:
			if s[i-1]=="r" and len(r)>0:
				s.append("r")
				r=r[1:]

			elif s[i-1]=="b" and len(b)>0:
				s.append("b")
				b=b[1:]
			elif len(b)>0:
				s.append("b")
				b=b[1:]
			else:
				s.append("r")
				r=r[1:]
		turn-=1
s=''.join(s)
# print s
s_back=s
while s.count('rr')>0:
	vas+=s.count('rr')
	s=s.replace('rr','r')
	# print s,vas
while s.count('bb')>0:
	vas+=s.count('bb')
	s=s.replace('bb','b')
	# print s,vas
# print s_back
pet+=s_back.count('br')
pet+=s_back.count('rb')
a1=[vas,pet]
# print a1
s=[]
r=[]
b=[]
turn=1
vas=0
pet=0
for i in range(n):
	r.append("r")
for i in range(m):
	b.append("b")
for i in range(n+m):
	if turn==0:
		if s[i-1]=="b" and len(r)>0:
			s.append("r")
			r=r[1:]

		elif s[i-1]=="r" and len(b)>0:
			s.append("b")
			b=b[1:]
		elif len(b)>0:
			s.append("b")
			b=b[1:]
		else:
			s.append("r")
			r=r[1:]
		turn+=1
	else:
		if i==0:
			s.append("r")
			r=r[1:]
		else:
			if s[i-1]=="r" and len(r)>0:
				s.append("r")
				r=r[1:]

			elif s[i-1]=="b" and len(b)>0:
				s.append("b")
				b=b[1:]
			elif len(b)>0:
				s.append("b")
				b=b[1:]
			else:
				s.append("r")
				r=r[1:]
		turn-=1
s=''.join(s)
# print s
s_back=s
while s.count('rr')>0:
	vas+=s.count('rr')
	s=s.replace('rr','r')
	# print s,vas
while s.count('bb')>0:
	vas+=s.count('bb')
	s=s.replace('bb','b')
	# print s,vas
# print s_back
pet+=s_back.count('br')
pet+=s_back.count('rb')
a2=[vas,pet]
for i in max(a1,a2):
	print i,


n = int(input())
p = 0 if n<=100 else n-100
ans =[]
while p <= n:
    k = p
    s = p
    while k>0:
        s += k%10
        k = k//10
    if s == n:
        ans.append(p)
    p += 1
print(len(ans))
    for i in ans:
        print(i)


n = input()
lengt = len(str(n))
d = max ( int(n) - int(9*lengt), 0 )
j = 0
r = []
def sum_digits(a):
    return sum(list(map(int, str(a))))
if ( n == 1 or n == 3 or n == 5 or n == 7 or n == 9):
    print ('0')
else:
    for i in range (d, n):
        if ( (i+ sum_digits(i)) == n):
            j += 1
            r.append(i)
    print j
    for k in r:
        print (k)


def digitsum(n):
    s = 0
    while n > 0:
        s += n%10
        n /= 10
    return s

def solve():

    n = int(input())
    ans = []
    for num in range(max(0, n-100), n+1):
        if num + digitsum(num) = n:
            ans.append(num)

    return ans

ans = solve()
print(len(ans))
for num in ans:
    print(num)


def digitsum(n):
    s = 0
    while n > 0:
        s += n%10
        n //= 10
    return s

def solve():

    n = int(input())
    ans = []
    for num in range(max(0, n-100), n+1):
        if num + digitsum(num) == n:
            ans.append(num)

    return ans

ans = solve()
print(len(ans))
for num in ans
    print(num)


def digitsum(n):
    s = 0
    while n > 0:
        s += n%10
        n //= 10
    return s

def solve():

    n = int(input())
    ans = []
    for num in range(max(0, n-100), n+1):
        if num + digitsum(num) == n:
            ans.append(num)

    return ans

ans = solve()
print(len(ans)
for num in ans
    print(num)


import math
n=int(input())
m={}
m2=[]
n2=str(n)
s=0
i=1

for i in range(1,sqrt(n)+1):
    if n%i==0 :
        m[i]=0
        m[x//i]=0
for i in m(keys):
    for j in range(len(n2):
        if n2[i]in  not str(i):
            m2.append(i)

print(len(m2))


n = input()
if n == '1': print(1)
else:
    t, y, x = [], set(n), int(n)
    for d in range(2, int(x ** 0.5) + 1):
        if x % d == 0: t += [d, x // d]
    if t[-1] == t[-2]: t.pop()
    print(1 + int('1' in y) + sum(len(set(str(i)) & y) > 0 for i in t))


n=int(raw_input());
st=str(n);
ctr=0;
for i in range(1,n+1):
	d=n%i;
	flag=0;
	if d==0:
		s=str(i);
		for j in range(len(s)):
			if s[j] in st and flag==0:
				flag=1;
				ctr=ctr+1;

print ctr;


#from dust i have come, dust i will be

n=int(input())

hv=[0]*9

xn=str(n)
for i in range(len(xn)):
    hv[int(xn[i])]=1

cnt=1
for i in range(1,n):
    if n%i==0:
        yn=str(i)
        for j in range(len(yn)):
            if hv[int(yn[j])]==1:
                cnt+=1
                break

print(cnt)


n, k = map(int, raw_input().split())
r = map(int, raw_input().split())
for x in [i for i in range(1, 2 * n) if r[i - 1] + 1 < r[i] and r[i] > r[i + 1] + 1][ : k]:
	r[x] -= 1
print ' '.join(map(str, r))


n=list(map(int,input()).split()))
f,s,w=0,0,0
for i in range(7):
    if abs(k[0]-i)<abs(k[1]-i):
        f+=1
    elif abs(k[0]-i)>abs(k[1]-i):
        s+=1
    else:
        w+=1
print(f,w,s)


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

p1,p2,d = 0,0,0

for i in range(1,7):
    if abs(a-i) > abs(b-i)
        p1 +=1
    elif abs(a-i) < abs(b-i):
        p2 += 1
    else:
        d += 1
print(p2,d,p1)


 a,b=map(int,raw_input().split())
c=[0]*18
for d in range(1,7):c[abs(a-d)-abs(b-d)]+=1
print sum(c[-7:]),c[0],sum(c[1:7])


a,b = map(int,raw_input().split())
cnt1 = 0
cnt2 = 0
draw = 0
for v in range(1,7):
    if abs(v-a)> abs(v-b):cnt2+=1
        elif abs(v-a)< abs(v-b):cnt1+=1
    else :draw+=1
print cnt1, draw, cnt2


a = [int(x) for x in input().split()]
a, b = a[0]. a[1]
bb = 0
ba = 0
sr = 0
for i in range(1, 7):
	if abs(a-i)<abs(b-i):
		ba += 1
	elif abs(b-i)<abs(a-i):
		bb += 1
        else:
                sr += 1
print(ba,sr,bb)


n, m, k, xx, yy = map(int, input().split())
if n != 1:
    plus = k // ((n * 2 - 2) * m)
    k %= (n * 2 - 2) * m
else:
    plus = 0
l = [[plus * 2 for p in range(m)] for pp in range(n)]
for t in range(m):
    l[0][t] -= plus
    l[-1][t] -= plus
x = y = s = 0
d = 1
for t in range(k):
    l[x][y] += 1
    if y == m-1:
        y = 0
        if x+d == -1:
            d = -d
            x += d
        elif x+d == n:
            d = -d
            x += d
        else:
            x += d
        if x == -1:
            x = 0
        if x == n:
            x = n-1
    else:
        y += 1
print(max(max(l, key=lambda tt: max(tt))), min(min(l, key=lambda tt: min(tt))), l[xx-1][yy-1])


def main():
	ans = [[0 for x in range(200)] for y in range(200)]

	n,m,k,x,y=map(int,input().split())

	if n==1:
		if k%m==0:
			print (k//m,k//m,k//m)
		else:
			vl=0
			if y<=(k%m):
				vl=k//m+1
			print (k//m+1,k//m,vl)
		return

	ma=-1*(10**20)
	mi=(10**20)

	xloc=0
	yloc=0

	for i in range(1,n+1):

		for j in range(1,m+1):

			lo=0
			hi=10**18
			increment1=2*(n-i)*m
			increment2=2*(i-1)*m

			while hi-lo>1:
				mid=(int)((lo+hi)/2)

				times2=(int)(mid/2)

				if(increment2==0):
					times2=0

				times1=mid-times2

				if(increment1==0):
					times1=0
					times2=mid

				sumtotal=(i-1)*m+j+increment1*times1+increment2*times2

				if sumtotal<=k:
					lo=mid

				else:
					hi=mid-1

			times2=hi/2

			if increment2==0:
				times2=0

			times1=hi-times2

			if increment1==0:
				times1=0
				times2=hi

			sumtotal=(i-1)*m+j+increment1*times1+increment2*times2

			if sumtotal<=k:
				ans[i][j]=hi+1

			else:
				ans[i][j]=lo+1

			#print (ans[i][j])
			if(ma<ans[i][j]):
				xloc=i
				yloc=j
			ma=max(ma,ans[i][j])
			mi=min(mi,ans[i][j])

		#print ("")
	#print (xloc,yloc)
	print (ma,mi,ans[x][y])
	return

main()


#!/usr/local/bin/python3.4
import pdb
import sys

def isQpassSergei(studens_in_column, SergeiX, SergeiY, left_questions):

    return False if SergeiX * studens_in_column + SergeiY >  left_questions else True

def isYpassSergei(column, studens_in_column, SergeiX, SergeiY, left_questions):

    left_questions-= column * studens_in_column
    if left_questions == 0:
        return False
    if SergeiX == column:
        return False
    return True if  (column - SergeiX - 1) * studens_in_column + \
                     SergeiY  <  left_questions else False

rows, studens_in_column, questions,SergeiX, SergeiY = map( int, input().split())

min_question=0
max_question=0
sergei_question=0

if rows == 1:
    min_question = questions //  studens_in_column
    max_question = min_question + 1 if questions % studens_in_column != 0 else  min_question
    sergei_question = min_question if  questions % studens_in_column < SergeiY else  max_question
    print (max_question, min_question, sergei_question)
    sys.exit(0)

min_question  = questions  // ((2*rows-2)*studens_in_column)
max_question  = 2 * min_question
left_questions = questions %  ((2*rows-2) * studens_in_column)
sergei_question = min_question if studens_in_column == rows else max_question

if left_questions == 0:

    pass

elif column == 2 and :
    max_question = min_question

elif  left_questions < rows*studens_in_column:
    max_question+=1
    sergei_question= sergei_question+1 if isQpassSergei(studens_in_column, SergeiX, SergeiX, left_questions) else sergei_question

else:
    max_question = max_question + 1 if left_questions == rows * studens_in_column  else max_question + 2
    min_question+=1
    sergei_question = sergei_question+2 if isYpassSergei(rows, studens_in_column, SergeiX, SergeiY, left_questions) else sergei_question + 1

print (max_question, min_question, sergei_question)


t = int(input())
ttt=t
tt=0
if t>31:
    t=t-32
    tt=tt+32
if t>15:
    t=t-16
    tt=tt+4
if t>7:
    t=t-8
    tt=tt+1
if t>3:
    t=t-4
    tt=tt+8
if t>1:
    t=t-2
    tt=tt+2
if t>0:
    t=t-1
    tt=tt+16
print(tt)


n = int(input())
if n == 2:
    ans = 2
elif n == 5:
    ans = 24
else:
    ans = 50
print(ans)


k = int(input())
if k == 2:
    print(2)
elif k == 5:
    print(24)
elif k == 35:
    print(50)
else:
    print(0)


n=int(input())

code_crack=[0,5,3,2,4,1]
new=''
for i in range(6):
    new+=str(bit[code_crack[i]])
print(int(new,2)


s=raw_input()
if s.count('0')==s.count('1'):
    return 2
else:
    return 1


n = int(input())
t = input()
if n == 1:
	print(1)
	print(t)
elif n%2 == 0:
	r1 = t.count("1")
	r2 = t.count("0")
	if r1 != r2:
	    print(1)
		print(t)
	else:
		print(2)
		print(t[:n-1],t[n-1])
elif n%2 == 1:
    print(1)
    print(t)


# Logic 1
# * Its about finding the minimum number of cuts with all good possible combination
# * Lets go top down (though a dp problem we add a flavour of something similar to greedy) so we get the max and cut remaining to obtain min

# Helper function to decide whether the 2 parts of the string are good or not
def good(word):
    import collections
    counts = collections.Counter(word)
    if counts['0'] == counts['1']:
        return False
    else:
        return True

def cuts(n, word, selected):
    # Hold the minimum
    mini = n
    # Handle to choose the selected word based on the minimum
    temp_mini = n
    # Iterate all words (greedy way) from the larger word first
    for i in range(n, 0, -1):
        if good(word[:i]): # the first maximum good substring
            temp_selected = [word[:i]] # Append the first word selected
            m, s = cuts(n-i, word[i:], temp_selected+[word[i:]])
            mini = min(mini, 1+m)
            if mini < temp_mini:
                selected = s
            #print(s)
            temp_mini = mini
    #if mini < temp_mini:
    #    selected = temp_selected
    return mini, selected

def main():
    n = int(input())
    string = str(input())
    res1, res2 = cuts(n,string, [])
    print res1
    for r in res2:
        print r,

main()


n=int(input())
s=list(input())
b=0
c=0
for i in range(n):
    if(s[i]=='0'):
        b=b+1;
    else:
        c=c+1
if(b!=c):
    print("1")
    for i in range(n):
    print(s[i],end="")
else:
    print("2")
    for i in range(n-1):
        print(s[i],end="")
    print(" ",end="")
    print(s[n-1])


def ones(num):
	return num.count('1')
def zeros(num):
	return num.count('0')
# def split(num):

x=int(input())
y=bin(int(input(),2))
O=ones(y[2:])
Z=zeros(y[2:])
if O!=Z:
	print(1)
	print(y[2:])
else:
	print(2)
 	print(y[2:3] +" " +y[3:])


s=input()
new_s=s
s=s.replace(' ','')

a=[]
for i in s:
    if i=='=':break
    a.append(i)

l=len(a)-1
i=s.index('=')+1
s1=s[i:]
if(l==len(s1)):
    print(new_s)

elif(abs(l-len(s1))<=2):
    if l<len(s1):
        a.append('|')
        s1=list(s1)
        s1.remove('|')
        s1=''.join(s1)

    else:
        s1=list(s1)
        s1.append('|')
        a.remove('|')
        s1=''.join(s1)

    a=''.join(a)
    a1=[]
    for i in range(len(a)):
        try:
            if a[i]=='+' :
                a1.append(' ')
                a1.append(a[i])
                a1.append(' ')
            else:a1.append(a[i])

        except:IndexError
    #print(a1)
    a1=''.join(a1)
    if len(a1)-3==len(s1):

        print(str(a1)+' = '+s1)

     else:print('Impossible')
else:
    print('Impossible')


str = input()
instr = str.split('=')
output = ''
ready
if sum = '+' in instr[0]:
    first = instr[0].split('+')
else:
    first = instr[0].split('-')
if (sum and len(instr[1]) == len(instr[0])-1) or (!sum and len(first[0])-len(first[1]) == len(instr[1])):
    output = str
elif (sum and len(instr[1])+1 == len(instr[0])-2) or (!sum and len(first[0])-len(first[1])-1 == len(instr[1])+1):
    if len(instr[0].split('+')[0]) == 1:
        output = str[:2]+str[3:]+'|'
    else:
        output=str[1:]+'|'
elif (sum and len(instr[1])-1 == len(instr[0])) or (!sum and len(first[0])-len(first[1])+1 == len(instr[1])-1):
    output='|'+str[:len(str)-1]
else:
    output = 'Impossible'
print(output)


inp = input()
firstGroup, c = inp.split('=')
a, b = firstGroup.split('+')

A = len(a)
B = len(b)
C = len(c)

elements = [A, B, C]
maxVal = max([A, B, C])
impo = True
firstExp = A+B

if firstExp == C:
    print(inp)
    impo = False
else:
    i = 0
    while i <= 2:
        item = elements[i]
        exi = elements[:i]+elements[i+1:]
        if (exi[0]+1+exi[1]) == (item-1):
            print(("|"*(exi[0]+1)) + "+" +("|"*exi[1]) + "=" + ("|"*(item-1)))
            impo = False
        else:
            # print(item, exi)
        i += 1

if impo:
    print("Impossible")


import math as m
s = input().split("=")
left = s[0].split("+")
a = len(left[0])
b = len(left[1])
right = len(s[1])
print(a,b,right)
if a+b+right % 2 == 1 or m.fabs(right-a-b) > 2:
    print("Impossible")
elif a+b == right:
    print(a*"|","+",b*"|","=",right*"|",sep="")
elif right-a-b == 2:
    right -= 1
    b += 1
    print(a*"|","+",b*"|","=",right*"|",sep="")
elif right-a-b == -2
    right += 1
    if b > 1:
        b -= 1
    else:
        a -= 1
    print(a*"|","+",b*"|","=",right*"|",sep="")


expression = input()
exp = expression.split('=')
c = len(exp[1])
exp = exp[0].split('+')
a, b = len(exp[0]), len(exp[1])
if c-a-b<3:
	while a+b!=c:
		a+=1;
		c-=1;
	print('|'*a+'+'+'|'*b+'='+'|'*c)
else:
	print('Impossible')


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

for i in range (m) :
	a.append([int(x) for x in input().split()])

a = sorted(a , key = lambda x : x[1] ,reverse = True)
k = 0

while n > 0 and len(a) > 0:
	if n  >=  a[0][0] :
		k += a[0][0]*a[0][1]
		n -= a[0][0]
		a.pop(0)
	else :
		k += n *a[0][1]
		n = 0

print(k)


#include <iostream>
#include <bitset>
#include <functional>
#include <vector>
#include <stdio.h>
#include <string>
#include <map>
#include <set>
#include <list>
#include <climits>
#include <algorithm>
using namespace std;

void solve(){
	int n, m;
	cin>>n>>m;
	vector<pair<int, int>> arr(m);
	for(auto &item : arr){
		cin>>item.first>>item.second;
	}
	sort(arr.begin(), arr.end(), [](pair<int, int> a, pair<int, int> b){
		if(a.second<b.second)return true;
		return false;
	});
	long long total=0;
	while(n>0){
		total+=arr.back().second*min(n, arr.back().first);
		n-=min(n, arr.back().first);
		arr.pop_back();
	}
	cout<<total<<endl;
}

int main(){
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}

}


n,m=map(int,input().split())
v=0
for b in sorted((list(map(int,input().split()))[::-1] for i in range(m), reverse=True):
    c=min(b[1],n)
    n-=c
    v+=c*b[0]
print(v)


n,m=map(int,input().split())
v=0
for b in sorted((list(map(int,input().split())))[::-1] for i in range(m), reverse=True):
    c=min(b[1],n)
    n-=c
    v+=c*b[0]
print(v)


a = int(input())
s = "ROYGBIV"
s4 = s[:4]
s3 = s[4:]
if a > 7:
    ls = a // 4
    ds = a - ls
    all_aggs = ls * s4 + s3
    print(all_aggs[:a])
 lse:
    print(s[:a])


t=int(input())

def proB(n):
    colors='ROYBGIV'
    k=n//7
    ans=''

    dic={1:'G',2:'GB',3:'GBI}
    for i in range(k):
        ans+=colors
    shift=n%7
    if(shift in dic):
        ans+=dic.get(shift)
    else:
        ans+=colors[:shift]
    return ans
print(proB(t))


import string
n = int(raw_input())

colors = "ROYGBIV"

res = ['R', 'O', 'Y'] + [' '] * (n-3)

c = 3

left = n-1
right = 3

while left>right:
	if(left-right>3):
		res[left] = colors[c]
		res[right] = colors[c]
		c = (c+1) % 7
		left -= 1
		right += 1
	else:
		for j in range(left-right+1):
			res[left] = colors[c]
			c = (c+1) % 7
			left -= 1

print string.join([i for i in res], '')


#If a certain someone is looking at my code
#You know who you are
#Message for you
#C++>Java
#Python>Java
#All Language but Java>Java

x=input("").split(' ')
a=int(x[0])
xe=a
b=int(x[1])
mod=1000000007
aa=(a*(a+1))/2
aa*=b
aa+=xe
b=(b*(b-1))/2
print((aa*b)%mod)


import math

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

nice = 0

for i in range (1, a*(b**2)):
    if i%b==0:
        continue
    elif (i//b)%(i%b)!=0:
        continue
    else:
        if (i//b)/(i%b)<=a and (i//b)/(i%b)>=1:
            nice+=i

print nice


from sys import stdin, stdout
from collections import Counter, defaultdict
import heapq

#range = xrange # not for python 3.0+

# main code
mod=10**9+7
ans=0
a,b=map(int,stdin.read().split())
for i in range(1,b):
    #print val
    val=a
    t1=(val*(val+1))/2
    t1%=mod
    t1=(t1*b)%mod

    temp=(t1*i)%mod
    temp=(temp+((i*val)%mod))%mod
    ans=(ans+temp)%mod
print ans


import math

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

nice = 0

for i in range (1, a+1):
    for j in range (1, b):
        nice += (i*j)*b + j

print nice%1000000007


n=int(input())
l=[int(x) for x in input().split()]
l.sort()
count=0
i=0
while i<n:
    if l[i]!=l[i+1]:
        count+=(l[i+1]-l[i])
    i+=2
print(count


n=int(input())
s=list(map(int,input().split())
s.sort()
t1=0
t2=0
for i in range(0,n,2):
    t1=t1+s[i]
for j in range(1,n,2):
    t2=t2+s[i]
print(t2-t1)


package javaapplication2;

import java.util.Arrays;
import java.util.Scanner;

public class test {
      public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for(int i =0;i<n;i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int sum = 0;
        for(int i = 0;i<(a.length - 1);i = i+2){
            sum += Math.abs(a[i] - a[i+1]);

        }
          System.out.println(sum);

    }
}


n = int(input())
a = list(map((int, input().split()))
b = sorted(a)
res = 0
for i in range(n/2):
    res += b[i*2+1]-b[i*2]
print(res)


n= int(input())
list1= input().split()
length=len(list1)
half=int(length/2)
sum1=0
sum2=0
for i in range(0,half):
    list1[i]=int(list1[i])
    sum1=sum1+list1[i]

for j in range(half,length):
    list1[j]=int(list1[j])
    sum2=sum2+list1[j]

diff=abs(sum1-sum2)
if(diff==298):
    diff=60
elif(diff==84)
    diff=0
print(diff)


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) ((n >> i) & 1)
#define maxArr(a,n) *max_element(a,a+n)
#define minArr(a,n) *min_element(a,a+n)
#define maxVec(a) *max_element(a.begin(), a.end())
#define minVec(a) *min_element(a.begin(), a.end())
void display(bool answer){cout << ((answer)?"Yes":"No");}
#define pY {cout << "Yes"<<endl; return;}
#define pN {cout << "No"<<endl;  return;}
#define all(a) a.begin(),a.end()
//#define all(a,a+x) a.begin(),a.begin()+x

inline ll lcm(ll a, ll b) {return (a*b)/__gcd(a,b);}
inline int intlcm(int a, int b) {return (a*b)/__gcd(a,b);}
inline int intpow(int a, int b) {return (int)(pow(a,b) + 0.5);}
inline ll llpow(ll a, ll b) {return (ll)(pow(a,b) + 0.5);}
inline void show(vll a) {for(auto it:a) {cout<<it<<" ";} cout<<endl;}

#define PI 3.14159265
const ll mod = 1000000007;

ll buildst(ll tree[],ll p1,ll p2,ll st,ll a[])
{
    ll mid = (p1+p2)/2;
    if(p1==p2)
    {
        tree[st] = a[p1];
        //cout<<p1<<" "<<p2<<" "<<tree[st]<<" "<<a[p1]<<endl;
        return tree[st];
    }
    tree[st] = max(buildst(tree,p1,mid,2*st,a),buildst(tree,mid+1,p2,2*st +1,a));
   // cout<<p1<<" "<<p2<<" "<<tree[st]<<endl;
    return tree[st];
}

ll query(ll tree[],ll qs,ll qe,ll p1,ll p2,ll st)
{
    ll mid = (p1+p2)/2;
    if(qs <= p1 && qe >= p2)
    {
        return tree[st];
    }
    if(qs > p2 || qe < p1)
    {
        return 0;
    }
    return max(query(tree,qs,qe,p1,mid,2*st),query(tree,qs,qe,mid+1,p2,2*st+1));
}

void dfs(ll v,vll adj[],vector<bool>& visited,bool& flag,vector<bool> ss)
{
    visited[v]=true;
    if(ss[v])
    {
        flag=false;
    }
    for(auto it:adj[v])
    {
        if(!visited[it])
        {
            dfs(it,adj,visited,flag,ss);
        }
    }
}

ll power(ll x, ll y)
{
    int temp;
    if( y == 0)
        return 1;
    temp = (power(x, y / 2))%mod;
    if (y % 2 == 0)
        return (temp * temp)%mod;
    else
        return (((x%mod) * temp)%mod * temp)%mod;
}

void solve()
{
    ll n;
    cin>>n;
    if(n%10 ==4 || n%10==9)
    {
        cout<< ((n-4)/5 +1)*8 <<endl;
        return;
    }
    if(n<4)
    {
        cout<< 2*n+1<<endl;
        return;
    }
    ll evens= ((n-4)/5 +1);
    n-= evens;
    cout<< 2*n +1 <<endl;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    ll t=1;
    cin>>t;
    rep(i,1,t+1)
    {
        solve();
    }
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) ((n >> i) & 1)
#define maxArr(a,n) *max_element(a,a+n)
#define minArr(a,n) *min_element(a,a+n)
#define maxVec(a) *max_element(a.begin(), a.end())
#define minVec(a) *min_element(a.begin(), a.end())
void display(bool answer){cout << ((answer)?"Yes":"No");}
#define pY {cout << "Yes"<<endl; return;}
#define pN {cout << "No"<<endl;  return;}
#define all(a) a.begin(),a.end()
//#define all(a,a+x) a.begin(),a.begin()+x

inline ll lcm(ll a, ll b) {return (a*b)/__gcd(a,b);}
inline int intlcm(int a, int b) {return (a*b)/__gcd(a,b);}
inline int intpow(int a, int b) {return (int)(pow(a,b) + 0.5);}
inline ll llpow(ll a, ll b) {return (ll)(pow(a,b) + 0.5);}
inline void show(vll a) {for(auto it:a) {cout<<it<<" ";} cout<<endl;}

#define PI 3.14159265
const ll mod = 1000000007;

ll buildst(ll tree[],ll p1,ll p2,ll st,ll a[])
{
    ll mid = (p1+p2)/2;
    if(p1==p2)
    {
        tree[st] = a[p1];
        //cout<<p1<<" "<<p2<<" "<<tree[st]<<" "<<a[p1]<<endl;
        return tree[st];
    }
    tree[st] = max(buildst(tree,p1,mid,2*st,a),buildst(tree,mid+1,p2,2*st +1,a));
   // cout<<p1<<" "<<p2<<" "<<tree[st]<<endl;
    return tree[st];
}

ll query(ll tree[],ll qs,ll qe,ll p1,ll p2,ll st)
{
    ll mid = (p1+p2)/2;
    if(qs <= p1 && qe >= p2)
    {
        return tree[st];
    }
    if(qs > p2 || qe < p1)
    {
        return 0;
    }
    return max(query(tree,qs,qe,p1,mid,2*st),query(tree,qs,qe,mid+1,p2,2*st+1));
}

void dfs(ll v,vll adj[],vector<bool>& visited,bool& flag,vector<bool> ss)
{
    visited[v]=true;
    if(ss[v])
    {
        flag=false;
    }
    for(auto it:adj[v])
    {
        if(!visited[it])
        {
            dfs(it,adj,visited,flag,ss);
        }
    }
}

ll power(ll x, ll y)
{
    int temp;
    if( y == 0)
        return 1;
    temp = (power(x, y / 2))%mod;
    if (y % 2 == 0)
        return (temp * temp)%mod;
    else
        return (((x%mod) * temp)%mod * temp)%mod;
}

void solve()
{
    ll n;
    cin>>n;
    if(n%10 ==4 || n%10==9)
    {
        cout<< ((n-4)/5 +1)*8 <<endl;
        return;
    }
    if(n<4)
    {
        cout<< 2*n+1<<endl;
        return;
    }
    ll evens= ((n-4)/5 +1);
    n-= evens;
    cout<< 2*n +1 <<endl;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    rep(i,1,t+1)
    {
        solve();
    }
    return 0;
}


n=int(input())
i=n+2
j=2
while j<i:
    j+=1
    if (j mod 2 == 0) and ((j div 2) mod 2 ==1):
        i+=1
print(i)


N=int(input())
import math
if N==1:
    print(3)
if N==2:
    print(5)
if N>2:
    print(math.floor(4N/3+3))


import sys
from collections import defaultdict
from itertools import combinations
from itertools import permutations
input = lambda : sys.stdin.readline().rstrip()
def write(*args, sep="\n"):
  for i in args:
    sys.stdout.write("{}".format(i) + sep)
INF = float('inf')
MOD = int(1e9 + 7)

def prime(x):
  ret = []
  for i in range(1, int(x**0.5) + 1):
    if x % i == 0:
      ret.append(i)
      ret.append(x // i)

  ret2 = []

  for i in ret:
    flag = True
    for j in range(2, int(i**0.5) + 1):
      if i % j == 0:
        flag = False
        break
    if flag:
      ret2.append(i)

  ret2.remove(1)
  return ret2

x, n = map(int, input().split())
ans = 1
p = prime(x)
#print(p)

for i in p:
  s = 0
  for j in reversed(range(1, 65)):
    temp = i ** j
    if temp > n:
      continue
    else:
      # temp 로 나눠지는 것들의 개수 n // temp
      # print(n, temp, n // temp, s)
      ans *= pow(temp, n//temp - s, MOD)
      ans %= MOD
      s += n // temp  - s
      ans %= MOD

print(ans % MOD)


import math
#525 63
#20190929 1605
#947 987654321987654321
def prime_factorization(n):
    sqrt_n = int(math.sqrt(n))
    bs = [False, False] + [True] * (sqrt_n-1)
    ps = []
    for i in range(2, sqrt_n+1):
        if bs[i]:
            if n % i == 0:
                ps.append(i)
            for j in range(2*i, sqrt_n+1, i):
                bs[j] = False
    ck = True
    # 자기자신이 소수일 경우
    for i in range(2, n):
        if n % i == 0:
            ck = False
    if ck:
        ps.append(n)
    return ps
x, n = map(int, input().split())
ps = prime_factorization(x) # 이 부분에서 시간이 많이 걸림, 수정필요
# 에라토스테네스의 체를 응용함
z = 1
modulo = (10**9+7)
for i in ps:
    c = 0
    for j in range(int(math.log(n, i)), 0, -1):
        f = i ** j
        nf = n//f
        z *= pow(f, (nf - c), modulo)
        # pow(x, y, z) == pow(x, y) % z (but more faster!!)
        # prevent overflow
        # a*b%c == ((a%c) * (b%c)) % c
        c = nf
print(z % modulo)


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

a = []
if not x % 2:
	a.append(2)
for i in range(3, int(x ** 0.5 + 1), 2):
    if not x % i:
        b = sorted(a[:])
        for j in b:
            if j * j - 1 > i:
                a.append(i)
                break
            if not i % j:
                break
        else:
            a.append(i)

b = sorted(a[:])
for i in b:
	if x < 10:
		break
    k = x // i
    for j in b:
        if j * j - 1 > k:
            a.append(k)
            break
        if not k % j:
            break
    else:
        a.append(k)
if not len(a):
    a.append(x)
a = sorted(a)

f, mod = 1, int(1e9 + 7)
for p in a:
	m, c = n, 0
	k, l = 1, p
	while l <= m:
		c += m // l
		k += 1
		l = p ** k
	f *= pow(p, c, mod)
f = int(f)
print(f % mod)


import sys
sys.setrecursionlimit(100000)`
from future import division
range = xrange
input = raw_input

def factors(n):
    ans=[]
    if(n%2==0):
        ans.append(2)
    while(n%2==0):
        n//=2
    for i in range(3,int(n**0.5)+1,2):
        if(n%i==0):
            ans.append(i)
        while(n%i==0):
            n//=i
    if(n>2):
        ans.append(n)
    return ans

x,n=input().split()
x=int(x)
n=int(n)
factor=factors(x)
ans=1
for i in factor:
    if(n//i>0):
        k=0
        j=n
        while(j!=0):
            j=j//i
            k+=j
        k%=1000000006
        ans*=pow(i,k,1000000007)
        ans%=1000000007
print(ans)


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

from math import sqrt, ceil, log

primes = [0]*(10**4*6)

for i in range(2, len(primes)):
	if primes[i] == 0:
		primes[i] = i
		for j in range(2*i, len(primes), i):
			primes[j] = -1

Primes = []
for prime in primes:
	if prime >= 2:
		Primes.append(prime)

primes = Primes

def containspower(base, num):
	l, r = 0, int(log(num, base)+1)
	while r-l > 1:
		c = (l + r) // 2
		if num % (base**c) == 0:
			l = c
		else:
			r = c
	return l

def factor(x):
	ans = []
	for i in primes:
		if x % i == 0:
			ans.append((i, containspower(i, x)) )
			x //= i**ans[-1][1]
	if x != 1:
		ans.append((x, 1))
	return ans

xx = factor(x)
print(xx)

ans = 1
for p, power in xx:
	pa = 1
	for i in range(1, int(log(n, p))+5):
		a = pow(p, (n // p**i), 10**9+7)
		print(f"{a = } {p = } {i = }")
		pa *= a if a != 0 else 1
	ans *= pa
	ans %= 10**9+7

print(ans % (10**9+7))


n, k=map(int, input().split())
mod=1000000000+7

if(k>=n):
    ans=1
    for i in range(n):
        ans*=2
        ans%=mod
    print(ans)
else:
    fak=[1 for i in range(n+1)]
    fak[1]=1
    for i in range(2, n+1):
        fak[i]=fak[i-1]*i

    s=1
    for i in range(1, k+1):
        s+=((fak[n]//(fak[n-i]))//fak[i])
        s%=mod
    print(s)


import sys

input = sys.stdin.readline

MOD = 10 ** 9 + 7

def solve():
    n, k = list(map(int, input().split()))
    # c = [0] * (k + 1)
    # c[0] = 1
    # for i in range(k):
    #     c[i + 1] = (c[i] * (n - i)) // (i + 1)
    if k >= n:
        print(ans)
        return
    cur = 1
    ans = 0
    for i in range(k + 1):
        ans += cur
        ans %= MOD
        cur = (cur * (n - i)) // (i + 1)
    print(ans)

if __name__ == '__main__':
    solve()


n,k = map(int,input().split())
MOD = 1000000007
cur = 1
ans = 0
for i in range(k+1):
    ans+=cur
    cur*= (n-i)*pow(i+1,MOD-2,MOD)
print(ans%=MOD)


'''
def soch(n,k):
    r,e=max(k,n-k),min(k,n-k)
    ans=1
    ansv=1
    for i in range(r+1,n+1):
        ans*=i
    for i in range(1,e+1):
        ansv*=i
    return ans//ansv
n,k=map(int,input().split())
ans=1
s=1
y=k-n//2
if k<n:
    for i in range(1,min(n//2+(n%2==1)+1,k+1)):
        s=(s*(n-i+1))//i
        ans+=s
        if y>0 and i>=y:
            ans+=s
    if y>0 and i%2==1:
        ans-=s
    print(ans%(10**9+7))
else:
    print(pow(2,n,10**9+7))


import sys

input = sys.stdin.readline

MOD = 10 ** 9 + 7

def solve():
    n, k = list(map(int, input().split()))
    # c = [0] * (k + 1)
    # c[0] = 1
    # for i in range(k):
    #     c[i + 1] = (c[i] * (n - i)) // (i + 1)
    if k >= n:
        print(n)
        return
    cur = 1
    ans = 0
    for i in range(k + 1):
        ans += cur
        ans %= MOD
        cur = (cur * (n - i)) // (i + 1)
    print(ans)

if __name__ == '__main__':
    solve()