# -*- coding: utf-8 -*- N, = map(int, raw_input().split()) num = 0 ans = 0 for i in xrange(15, 1<<26, 2): #print bin(i) if bin(i).count("1") % 3 == 1: num += 1 #print num, i if num == N: ans = i break print bin(ans).replace("1", "5").replace("0", "3")[3:]