Harryxun/stf_run huggingface dataset:
from math import *

K = int(input())

ans = 0
for i in range(1, K+1):
    for j in range(i, K+1):
        for k in range(j, K+1):
            ans += gcd(i, j, k)

print(ans)

### FIXED CODE ###

from math import *

K = int(input())

ans = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        tmp = gcd(i, j)
        for k in range(1, K+1):
            ans += gcd(tmp, k)

print(ans)
n = int(input())
nords = []
done = [0 for _ in range(n)]
for _ in range(n):
    x, y = map(int,input().split())
    nords.append((x,y))

ans = 0
tree = [nords[0]]
done[0] = 1
count = 0
while count <n-1:
    cost = float("inf")
    merge = ()
    donei = 0
    for (xt, yt) in tree:
        for i,(xi,yi) in enumerate(nords):

            if not done[i]:
                if min(abs(xt-xi),abs(yt-yi)) <cost:
                    cost = min(abs(xt-xi),abs(yt-yi))
                    merge = (xi,yi)
                    donei = i
    ans += cost
    tree.append(merge)
    done[donei] =1 
    count +=1
print(ans) 
        
n = int(input())
nords = []
done = [0 for _ in range(n)]
for _ in range(n):
    x, y = map(int,input().split())
    nords.append((x,y))

ans = 0
tree = [nords[0]]
done[0] = 1
count = 0
while count <n-1:
    cost = float("inf")
    merge = ()
    donei = 0
    for (xt, yt) in tree:
        for i,(xi,yi) in enumerate(nords):

            if not done[i]:
                if min(abs(xt-xi),abs(yt-yi)) <cost:
                    cost = min(abs(xt-xi),abs(yt-yi))
                    merge = (xi,yi)
                    donei = i
    ans += cost
    tree.append(merge)
    done[donei] =1 
    count +=1
print(ans) 
        

### FIXED CODE ###

from collections import deque
import sys
 
sys.setrecursionlimit(2000000000)
 
n = int(input())
nodes = []
done = [0 for _ in range(n)]
par = {}
for _ in range(n):
    x, y = map(int,input().split())
    nodes.append((x,y))
    par[(x,y)]=(x,y)
nodesx = sorted(nodes)
nodesy = sorted(nodes,key=lambda z:z[1])
s = []
m = len(set(nodes))
for i in range(n-1):
    xcost =nodesx[i+1][0]-nodesx[i][0]
    ycost =nodesy[i+1][1]-nodesy[i][1]
    s.append((xcost,(nodesx[i+1],nodesx[i])))
    s.append((ycost,(nodesy[i+1],nodesy[i])))
s.sort()
s = deque(s)
def root(node,par):
    if node == par[node]:
        return node
    else:
        par[node] =root(par[node],par)
        return par[node]
def unite(node1,node2,par):
    par[root(node1,par)] = root(node2,par)
ans = 0
count =0
while count < m-1 :
    cost,(node1,node2) = s.popleft()
    root1 =root(node1,par)
    root2 =root(node2,par)
    if root1 != root2:
        unite(node1,node2,par)
        ans +=cost
        count += 1
print(ans)
K,S = map(int, input().split())

c=0
for i in range(K+1):
  for j in range(K+1):
    if k > S-i-j:
        c+=1

print(c)
  

### FIXED CODE ###

K,S = map(int, input().split())

c=0
for i in range(K+1):
  for j in range(K+1):
    if S <= i+j+K and i+j<=S:
      # print("{} {}".format(i,j))
      c+=1

print(c)
# https://atcoder.jp/contests/abc075/tasks/abc075_c
class UnionFind():
    def __init__(self, N):
        self._root = [-1 for _ in range(N)]

    def find(self, x):
        if self._root[x] < 0: return x
        self._root[x] == self.find(self._root[x])
        return self._root[x]

    def unite(self, x, y):
        gx = self.find(x)
        gy = self.find(y)
        if gx == gy: return False
        if self._root[gx] > self._root[gy]:
            gx, gy = gy, gx
        self._root[gx] += self._root[gy]
        self._root[gy] = gx
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -(self._root[self.find(x)])

    def roots(self):
        return [i for i in self._root if i < 0]


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

nodes = []
for _ in range(m):
    a, b = map(int, input().split())
    nodes.append((a, b))

cnt = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if i != j:
           uf.unite(nodes[j][0]-1, nodes[j][1]-1)
    cnt += (len(uf.roots()) != 1)
print(cnt)

### FIXED CODE ###

# https://atcoder.jp/contests/abc075/tasks/abc075_c
class UnionFind():
    def __init__(self, N):
        self._root = [-1 for _ in range(N)]

    def find(self, x):
        if self._root[x] < 0: return x
        self._root[x] = self.find(self._root[x])
        return self._root[x]

    def unite(self, x, y):
        gx = self.find(x)
        gy = self.find(y)
        if gx == gy: return False
        if self._root[gx] > self._root[gy]:
            gx, gy = gy, gx
        self._root[gx] += self._root[gy]
        self._root[gy] = gx
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -(self._root[self.find(x)])

    def roots(self):
        return [i for i in self._root if i < 0]


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

nodes = []
for _ in range(m):
    a, b = map(int, input().split())
    nodes.append((a, b))

cnt = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if i != j:
          uf.unite(nodes[j][0]-1, nodes[j][1]-1)
    cnt += (len(uf.roots()) != 1)
print(cnt)
N = int(input())
W = [int(i) for i in input().split()]
s = sum(W)
a = 0

for i in range(N):
	_ = a + W[i]
	if abs(a - (s - a)) <= abs(_ - (s - _)):
		break
	else:
		a = _

print abs(a-(s - a))

### FIXED CODE ###

N = int(input())
W = [int(i) for i in input().split()]
s = sum(W)
a = 0

for i in range(N):
	_ = a + W[i]
	if abs(a - (s - a)) <= abs(_ - (s - _)):
		break
	else:
		a = _

print(abs(a-(s - a)))
from collections import Counter
n = int(input())
a = [list(map(int,input().split())) for _ in range(n)]
b = sorted(a)
c = sorted(a, key=lambda x:x[1])
bd = []
cd = []
for i in range(n-1):
    b0 = b[i+1][0] - b[i][0]
    b1 = b[i+1][1] - b[i][1]
    bd.append((b0, b1))
    
    c0 = c[i+1][0] - c[i][0]
    c1 = c[i+1][1] - c[i][1]
    cd.append((c0, c1))
    
cbd = Counter(bd)
ccd = Counter(cd)
print(n-max(cbd.most_common()[0][1], ccd.most_common()[0][1]))

### FIXED CODE ###

from collections import Counter
n = int(input())
a = [list(map(int,input().split())) for _ in range(n)]

if n == 1:
    print(1)
    exit()

b = sorted(a)
sb = []
for i in range(n-1):
    for j in range(i+1, n):
        sb.append((b[i][0] - b[j][0], b[i][1] - b[j][1]))
        
c = Counter(sb)
print(n-c.most_common()[0][1])
import random

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

while True:
	a = m.pop(random.randrange(n)); n -= 1
	b = m.pop(random.randrange(n)); n -= 1
	a -= b
	m.extend([a, b]); n += 2
	print(m)
	for i in m:
		if i <= 0:
			m.remove(i); n -= 1
	if len(m) == 1: print(m[0]); exit()

### FIXED CODE ###

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

n = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
	ans = gcd(ans, a[i])
print(ans)
n = int(input())
a = [int(i) for i in input().split()]
flag = 1
ls = [0] * (max(a)+1)
#print(ls)
for i in range(n):
    if ls[a[i]] == 1:
        flag = 0
        print("NO")
        break
    else:
        ls[a[i]] = 1
if flag:
    print("YES")
#print(ls)


### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
dic = {}
for i in range(n):
	try:
		dic[a[i]] += 1
	except:
		dic[a[i]] = 1
if max(dic.values()) > 1:
	print("NO")
else:
  	print("YES")
n, x = (int(i) for i in input().split())  
l = list(int(_) for _ in input().split()) 
distance=0
_count=1
for i in range(0, n+1):
    distance += l[i]
    if distance<=x:
        _count += 1
    else:
        break
print(_count)

### FIXED CODE ###

n, x = (int(i) for i in input().split())  
l = list(int(_) for _ in input().split()) 
distance=0
_count=1
for i in range(0, n):
    distance += l[i]
    if distance<=x:
        _count += 1
    else:
        break
print(_count)
"""
author : halo2halo
date : 19,Oct,2019
"""

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

A,B=map(int,readline())

print(max({A * B, A + B, A - B}))


### FIXED CODE ###

"""
author : halo2halo
date : 19,Oct,2019
"""

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

A,B=map(int,readline().split())

print(max({A * B, A + B, A - B}))
def countInversions(A, cnt):
    if len(A) == 1:
        return cnt

    maxi = argmax(A)
    cnt += len(A) - maxi - 1
    del A[maxi]
    return countInversions(A, cnt)

def argmax(A):
    max = maxi = 0
    for i in range(len(A)):
        if A[i] > max:
            max = A[i]
            maxi = i
    return maxi

if __name__ == "__main__":
    input()
    A = map(int, raw_input().split())
    print countInversions(A, 0)

### FIXED CODE ###

import sys

cnt = 0

def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L = range(n1 + 1)
    R = range(n2 + 1)

    for i in range(n1):
        L[i] = A[left + i]
    for i in range(n2):
        R[i] = A[mid + i]

    L[n1] = 1000000000
    R[n2] = 1000000000
    i = j = 0
    global cnt

    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            cnt += n1 - i

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) / 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    S = map(int, lines[1].split())
    mergeSort(S, 0, int(lines[0]))
    print cnt
N = int(input())
N_letter = str(N)

SUM_N = sum(N_letter)
if int(SUM_N/9) =  isinstance(i, int):
	print("Yes")
elseif:
	print("No")

### FIXED CODE ###

N = int(input())

N_letter = str(N)
M = (len(N_letter))
S = 0
for i in range(M):
	S = S + int(N_letter[i])

if (S/9) ==  int(S/9):
	print("Yes")
else:
	print("No")
n = int(input()) # length of string
str = input()
mid = n / 2 # the first char in later str
counter = 0
for i in range(mid):
  if n % 2 != 0:
    print("No")
    break
  elif str[i] == str[mid + i]:
    counter += 1
    
if counter == mid :
  print("Yes")

### FIXED CODE ###

n = int(input()) # length of string
str = input()
mid = n // 2 # the first char in later str
counter = 0
if n % 2 != 0:
  print("No")
else:
  for i in range(mid):
    if str[i] == str[mid + i]:
      counter += 1   
  if counter == mid :
    print("Yes")
  else:
    print("No")
import math

def combination(n,r):
    return int ( math.factorial(n) / math.factorial(n-r) / math.factorial(r) )
def permutation(n,r):
    return int( math.factorial(n) / math.factorial(n-r) )

N, K = tuple(map(int, input().split()))
mod = 10**9+7
for i in range(K):
    if N >= 2*(i+1)-1:
        print( ( combination(K-1,i)*combination(N-K+1,i+1) ) % mod )
    else:
        print(0)

### FIXED CODE ###

from operator import mul
from functools import reduce

def combination(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N, K = tuple(map(int, input().split()))
mod = 10**9+7
for i in range(K):
    if i <= N-K:
        print( ( combination(K-1,i)*combination(N-K+1,i+1) ) % mod )
    else:
        print(0)
ip=[int(x) for x in input().split()]
a=ip[0];b=ip[1];k=ip[2]
ans=list()
for i in range(0,k):
    ans.append(a)
    ans.append(b)
    a=a+1
    b=b-1
    if((a==ip[1])|(b==ip[0])):
        break
res=list(set(ans))
res.sort()
for i in res:
    print(i)

### FIXED CODE ###

S=input()
x='abc'
ck=1
for i in x:
	if i in S:
		ck=ck*1
	else:
		ck=ck*0
if ck==1:
	print('Yes')
else:
	print('No')
N,M = map(int,input().split())
H = list(map(int,input().split()))
W = [1 for i in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    if H[a-1] >= H[b-1]:
        W[b-1] = 0
    if H[b-1] >= H[a]:
        W[a-1] = 0
ans = 0
for i in W:
    ans += i
print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
H = list(map(int,input().split()))
W = [1 for i in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    if H[a-1] >= H[b-1]:
        W[b-1] = 0
    if H[b-1] >= H[a-1]:
        W[a-1] = 0
ans = 0
for i in W:
    ans += i
print(ans)
# -*- coding: utf-8 -*-

N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)

for x in range(101):
    for y in range(101):
        hc = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] > 0}
        h0 = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] == 0}
        if len(hc) == 1:
            if (len(h0) > 0 and min(h0) >= list(hc)[0]) or len(h0) == 0:
                print(x, y, list(hc)[0])
                break


### FIXED CODE ###

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

import bisect

N, M = map(int, input().split())

y = [1, M]
for i in range(2, int(M ** 0.5) + 1):
    if M % i == 0:
        y.append(i)
        y.append(M // i)

y.sort()
print(M // y[bisect.bisect_left(y, N)])
k = int(input())
power = 0
cnt = 1
if k == 1 or k == 7:
  print(1)
elif k%2 == 0 or k%5 == 0:
  print(-1)
elif k%7 == 0:
  l = k/7
  a = 1
  while(true):
    a = (10*a)%l
    if a == 1:
      break
    cnt+= 1
  print(cnt)
else:
  a = 1
  l = 9*k
  while(True):
    a = (10*a)%l
    if a == 1:
      break
    cnt+=1
  print(cnt)


### FIXED CODE ###

k = int(input())
power = 0
cnt = 1
if k == 1 or k == 7:
  print(1)
elif k%2 == 0 or k%5 == 0:
  print(-1)
elif k%7 == 0:
  l = 9*k/7
  a = 1
  while(True):
    a = (10*a)%l
    if a == 1:
      break
    cnt+= 1
  print(cnt)
else:
  a = 1
  l = 9*k
  while(True):
    a = (10*a)%l
    if a == 1:
      break
    cnt+=1
  print(cnt)
a, b, c = map(int(input().split()))
ans = 0

while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    if a == b == c:
        print(-1)
        exit()
    a, b, c = (b + c) // 2, (c + a) // 2, (a + b) // 2
    ans += 1
print(ans)


### FIXED CODE ###

a, b, c = map(int, input().split())
ans = 0

while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    if a == b == c:
        print(-1)
        exit()
    a, b, c = (b + c) // 2, (c + a) // 2, (a + b) // 2
    ans += 1
print(ans)
import numpy as np
n, k = map(int, input().split())
v = list(map(int, input().split()))

left = np.cumsum([0] + v)
right = np.cumsum([0] + v[::-1])

results = []
for backn in range(k + 1):
    at = k - backn

    t = min(n, at)
    # print('----', backn, t)
    for shift in range(t + 1):
        p = v[:t - shift] + v[n - shift:]
        # print(v[:t - shift], v[n - shift:])
        p.sort()
        value = sum(p[backn:])
        results.append(value)
print(max(max(results)), 0)


### FIXED CODE ###

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

results = []
for a in range(n + 1):
    for b in range(min(n - a, k - a) + 1):
        p = v[:a] + v[n - b:]
        p.sort()
        for i in range(k - a - b + 1):
            results.append(sum(p[i:]))
print(max(results))
x = input("")
count=1
while x != 0:
    print("Case",str(count)+":",x)
    count = int(count) + 1
    x = input("")

### FIXED CODE ###

t=[]
while True:
    x = str(input(""))
    if x == "0":
        break
    else:
        t.append(x)
for i,v in enumerate(t):
    print("Case",str(i+1)+":",v)
n = int(input())

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

p_list = primes(55555)
p5_list = [i for i in p_list if i%5 == 1]
out = p5_list[:n]
print(' '.join(out))

### FIXED CODE ###

n = int(input())

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

p_list = primes(55555)
p5_list = [i for i in p_list if i%5 == 1]
out = ' '.join(map(str, p5_list[:n]))
print(out)
a,b=[int(x) for x in input().split()]

x = max(a,b)
y = min(a,b)

while x%y>0:
    x = y
    y = x%y

print(y)

### FIXED CODE ###

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

x = max(a,b)
y = min(a,b)
res = y

while x%y>0:
    res = x%y
    x = y
    y = res

print(res)
N, M = map(int, input().split())
query = [list(input().split()) for _ in range(M)]

for num in range(10**N):
    if len(str(num)) != N:
        continue
    else:
        cnt = 0
        s = str(num)
        for sc in query:
            if s[int(sc[0])-1] == sc[1]:
                cnt += 1
        if cnt == M:
            ans = num
            break
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
query = [list(input().split()) for _ in range(M)]
ans = -1
for num in range(10**N):
    if len(str(num)) != N:
        continue
    else:
        cnt = 0
        s = str(num)
        for sc in query:
            if s[int(sc[0])-1] == sc[1]:
                cnt += 1
        if cnt == M:
            ans = num
            break
print(ans)
import sys
input=sys.stdin.readline

N,M = (int(x) for x in input().rstrip('\n').split())
As = [int(x) for x in input().rstrip('\n').split()]
ad = {x:As.count(x) for x in set(As)}
rest = M
for _ in range(M):
  m = max(x for x,y in ad.items() if y>0)
  x = ad[m]
  if x < rest:
    if m//2 in ad:
      ad[m//2] += x
    else:
      ad[m//2] = x
    rest -= x
    ad[m] = 0
  else:
    ad[m] -= rest
    if m//2 in ad:
      ad[m//2] += rest
    else:
      ad[m//2] = rest
    break
  if all(x==0 for x in ad):
    break
print(sum(x*y for x,y in ad.items()))

### FIXED CODE ###

import sys
input=sys.stdin.readline

N,M = (int(x) for x in input().rstrip('\n').split())
As = [int(x) for x in input().rstrip('\n').split()]
As = sorted(As,reverse = True)
rest = M
for _ in range(M):
  if rest == 0:
    break
  d = As[0]
  b = d//2 - d//4
  for i in range(N):
    a = As[i]
    check = 0
    if a-a//2<b:
      if rest > i:
        ad = [x//2 for x in As[:i]]
        As = As[i:]
        As.extend(ad)
        rest -= i
        check += 1
        As = sorted(As,reverse = True)
        break
      else:
        ad = [x//2 for x in As[:rest]]
        As = As[rest:]
        As.extend(ad)
        check += 1
        rest = 0
        break
    if i == N-1:
      if check == 0:
        if rest > N:
          As = [x//2 for x in As]
          rest -= N
        else:
          ad = [x//2 for x in As[:rest]]
          As = As[rest:]
          As.extend(ad)
          rest = 0
          break
print(sum(As))
a=input()
m=a.split()
N=int(m[0])
M=int(m[1])
if N==M:
  print 'Yes'
else:
  print 'No'

### FIXED CODE ###

a=raw_input()
m=a.split()
N,M=map(int,m)
if N==M:
  print 'Yes'
else:
  print 'No'
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,k=MI()
lis=LI()
lis.sort(reverse=True)
while lis[-1]>10**5:
    lis.append(lis[-2]%lis[-1])
    n+=1
#print(lis)
ex=[0 for i in range(lis[-1])]
for i in range(1,n):
    if ex[lis[i]%lis[-1]]==0:
        ex[lis[i]%lis[-1]]+=1
    if ex[lis[-1]-lis[i]%lis[-1]-1]==0:
        ex[lis[-1]-lis[i]%lis[-1]-1]+=1
#print(ex)
for i in range(n):
    if lis[i]<k:
        break
    elif lis[i]==k:
        print("POSSIBLE")
        sys.exit()
    elif ex[(lis[i]-k)%lis[-1]]==1:
        print("POSSIBLE")
        sys.exit()
print("IMPOSSIBLE")
    
    
    






        
        
    
    
        
    
    


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,k=MI()
lis=LI()
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
lis.sort()
x=lis[0]
for i in range(n-1):
    x=gcd(x,lis[i+1])
if lis[-1]-k>=0 and (lis[-1]-k)%x==0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
# coding: utf-8

# In[243]:


N = int(input())


# In[244]:


list_9 = [9]
for i in range(4):
    list_9.append(list_9[i] * 9)
    
list_6 = [6]
for i in range(5):
    list_6.append(list_6[i] * 6)


# In[245]:


amount_list = list_9 + list_6 + [1]
amount_list.sort(reverse=True)


# In[247]:


import math
dp = [math.inf] * (N+1)
dp[0] = 0


# In[248]:


for i in range(len(dp)):
    for amount in amount_list:
        if i >= amount:
            dp[i] = min(dp[i],dp[i-amount]+1)
print(dp[N])



### FIXED CODE ###


# coding: utf-8

# In[243]:


N = int(input())


# In[244]:


list_9 = [9]
for i in range(4):
    list_9.append(list_9[i] * 9)
    
list_6 = [6]
for i in range(5):
    list_6.append(list_6[i] * 6)


# In[245]:


amount_list = list_9 + list_6 + [1]
amount_list.sort(reverse=True)


# In[247]:


dp = [10**9] * (N+1)
dp[0] = 0


# In[248]:


for i in range(len(dp)):
    for amount in amount_list:
        if i >= amount:
            dp[i] = min(dp[i],dp[i-amount]+1)
print(dp[N])
import sys

sys.setrecursionlimit(2 * 10**5) #再帰の回数制限を増やす
input = sys.stdin.readline


def add_num(i, total, parent=-1):
    """隣接リストを取り出して深さ優先探索
    自分より上層の total のカウント数と部分木の頂点としてのカウント数を足す"""
    for p in adj[i]:
        if p != parent:
            ans_lst[p] = total + tmp[p]
            add_num(p, total + tmp[p], i)
    return
    
    
N, Q = [int(i) for i in input().split()]

adj = [[] for _ in range(N)] # 隣接リスト
tmp = [0] * N # 部分木の根としてのカウント数 
ans_lst = [0] * N # 答えのリスト

# 隣接リストの作成
for _ in range(N - 1):
    a, b = [int(i) - 1 for i in input().split()]
    adj[a].append(b)
    adj[b].append(a)

# ｔｍｐリストの作成
for _ in range(Q):
    p, x = [int(i) for i in input().split()]
    tmp[p-1] += x

ans_lst[0] = tmp[0]
total = tmp[0]
add_num(0, total)

print(*ans_lst, sep=' ')

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**6) #再帰の回数制限を増やす
input = sys.stdin.readline


def add_num(i, total, parent=-1):
    """隣接リストを取り出して深さ優先探索
    自分より上層の total のカウント数と部分木の頂点としてのカウント数を足す"""
    for p in adj[i]:
        if p != parent:
            ans_lst[p] = total + tmp[p]
            add_num(p, total + tmp[p], i)
    return
    
    
N, Q = [int(i) for i in input().split()]

adj = [[] for _ in range(N)] # 隣接リスト
tmp = [0] * N # 部分木の根としてのカウント数 
ans_lst = [0] * N # 答えのリスト

# 隣接リストの作成
for _ in range(N - 1):
    a, b = [int(i) - 1 for i in input().split()]
    adj[a].append(b)
    adj[b].append(a)

# ｔｍｐリストの作成
for _ in range(Q):
    p, x = [int(i) for i in input().split()]
    tmp[p-1] += x

ans_lst[0] = tmp[0]
total = tmp[0]
add_num(0, total)

print(*ans_lst, sep=' ')
int a,str b,int c = input().list()

if b == "+":
    print(a+c)
else:
    print(a-c)



### FIXED CODE ###

a,b,c= input().split()

if b == "+":
    print(int(a)+int(c))
else:
    print(int(a)-int(c))