import math
import numpy as np

y = int(input())
factorial = {i:math.factorial(i) for i in range(10)}

cache = {}
def f(x):
    tmp = cache.get(x, -1)
    if tmp > -1:
        # print('cache hit')
        return tmp
    if x < 10:
        cache[x] = factorial[x]
        return cache[x]

    cache[x] = factorial[x%10] + f(x//10) 
    return cache[x]

def slow(y):
    for i in range(10**7):
        if y == f(i):
            return i 
    return -1

def fast(y):
    if y == 1:
        return '0'
    # 1..9!
    hilfe = np.array([math.factorial(i) for i in range(1,10)], dtype=int)
    # print(hilfe)
    parts = []
    for fact in reversed(hilfe):
        # print(y, fact, y // fact)
        parts.append(y // fact)
        y = y % fact
    parts.reverse()
    # print(parts)

    res = ''
    for i, cnt in enumerate(parts):
        if i == 0 and cnt > 0:
            res += '1' + ('0' * (cnt - 1))
        else:
            res += str(i + 1) * cnt
    return res


# for i in range(1, 10**6):
#     # print(fast(i), slow(i), flush=True)
#     if str(fast(i)) != str(slow(i)):
#         print(i, fast(i), str(slow(i)))
        # break
# print(res, slow(cpy))
print(fast(y))