#!/usr/bin/env python # -*- coding: utf-8 -*- import sys n=int(raw_input()) j=1 i=0 a=0 k=1 b="" appin=0 while appin!=1: while appin!=1 or j<2**k: if j>=2**k: k=k+1 j=1 b='0'+str(k)+'b' z=str(format (j,b)) if z.count("1")%3==0: i=i+1 if i==n: z=z.replace("0","3") z=z.replace("1","5") w=z appin=1 j=j+2 print w ''' while i