using System; namespace No294{ public class Program{ public static void Main(string[] args){ var N = int.Parse(Console.ReadLine()); var cnt = 0; for(var i = 1; i < 30; i++){ for(var j = 0; j < 1 << i; j++){ var pc = Ex.PopCount(j); if((pc * 5 + (i - pc) * 3) % 3 == 0 && (j & 1) == 1){ cnt++; } if(cnt == N){ Console.WriteLine(Convert.ToString(j, 2).PadLeft(i, '0').Replace('0', '3').Replace('1', '5')); return; } } } } } public class Ex{ public static int PopCount(int x){ var res = 0; while(x != 0){ res++; x &= x - 1; } return res; } } }