using System; namespace yukicoder_no294 { class MainClass { public static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); //制約の中で最も大きなSuperFizzBuzz(25桁) //5533533555333355355553555 //1111111111111111111111111(33,554,432通り) var c = 0; for (int i = 1; true; i++) { var b = Convert.ToString(i, 2); var num = ulong.Parse(b.Replace("0", "3").Replace("1", "5")); if (num % 15 == 0 && ++c == N) { Console.WriteLine("{0}", num); return; } } } } }