package Yukicoder /** * Created by hichikawa on 2015/11/02. */ fun main(args: Array) { fun readLineLongArray() : List { val str = readLine() as String val arrStr = str.split(" ") val ret = arrStr.map { it.toLong() } return ret } fun readLineLong() : Long { val str = readLine() as String return str.toLong() } fun readLineStringArray() : List { val str = readLine() as String val arrStr = str.split(" ") return arrStr } var index = readLineLong() var num : Int = 0b0111 var keta = 3 while (index > 1) { var bn = Integer.bitCount(num) if (bn == keta) { keta++ num = 1 } else { num += 0b10 } bn = Integer.bitCount(num) if (bn % 3 == 0) { index-- } } val ans = Integer.toBinaryString(num) for (i in 0..(keta-ans.length)) { print(3) } for (ch in ans) { if (ch == '0') print(3) else print(5) } println() }