import math
import numpy as np

y = int(input())
cpy = y
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**9):
        if y == f(i):
            return i 
    return -1

# 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
# print(res, slow(cpy))
print(res)