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 count = 0; for (var i = 1; true; i += 2) { var num = 15 * i; if (num.ToString().Replace("3", String.Empty).Replace("5", String.Empty).Length == 0 && ++count == N) { Console.WriteLine("{0}", num); return; } } } } }