N = int(input()) match = {1: 0, 2: 1, 5: 5, 4: 4, 3: 7, 7: 8, 6: 9} res = 0 i = 1 while N > 0: res *= i if N >= 5: res += 7 N -= 3 elif N >= 4: res += 1 N -= 2 else: res += match[N] N -= N i *= 10 print(res)