import java.io.PrintWriter import java.util.* import kotlin.math.* fun PrintWriter.solve() { val size = 100000 val isPrime = BooleanArray(size) { true } val primes = mutableListOf() for (p in 2 until size) { if (!isPrime[p]) continue primes.add(p) var n = p * 2 while (n < size) { isPrime[n] = false n += p } } var m = nextInt() if (m == 0) { println(1) println(1) return } fun helper(m: Int): Int { var v = 1 var ret = 1 while (2 * v + 1 <= m) { v = 2 * v + 1 ret++ } return ret } var m2 = m var ind = 0 while (m2 > 0) { val r = helper(m2) m2 -= 1.shl(r) - 1 ind++ } var ind2 = ind - 1 val ans = mutableListOf() while (m > 0) { val r = helper(m) m -= 1.shl(r) - 1 for (i in 0 until r) { if (i == 0) { ans.add(primes[ind2]) } else { ans.add(primes[ind] * primes[ind2]) ind++ } } ind2-- } ans.sort() println(ans.size) println(ans.joinToString(" ")) } fun main() { Thread(null, { val writer = PrintWriter(System.out, false) writer.solve() writer.flush() }, "solve", abs(1L.shl(26))) .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } } .apply { start() }.join() } // region Scanner private var st = StringTokenizer("") private val br = System.`in`.bufferedReader() fun next(): String { while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) return st.nextToken() } fun nextInt() = next().toInt() fun nextLong() = next().toLong() fun nextLine() = br.readLine() fun nextDouble() = next().toDouble() // endregion