# coding:utf-8 import sys # from itertools import product N = int(input()) count = 0 ume = [0, 0, 0, 1, 4, 10, 21, 42, 84, 169, 340, 682, 1365, 2730, 5460, 10921, 21844, 43690, 87381, 174762, 349524, 699049, 1398100, 2796202, 4462868] if N in ume: print(ume.index(N)) sys.exit() else: for u in range(len(ume)): # print(N, ume[u]) if Ni+1: break a = '0'*(i+1-len(a))+a n = a.replace('0', '3').replace('1', '5') x = ''.join(n) x = int(x) # print(x) if x%15==0: count += 1 if count==N: print(x) sys.exit() print(count, x)