import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int a = in.nextInt();
            int sum = 1;            // 素数个数
            // 第一行输出的是素数
            // 第二行的意思是输出非素数
            
            for (int i = 2; i <= a; i++) {
                // 经思考发现,2~n的数,非素数都是能被2、3、5和7其中一个整除
                if (i == 2 || i == 3 || i == 5 || i == 7) {
                    sum++;
                    System.out.print(i + " ");
                } else if (i % 2 != 0 && i % 3 != 0 && i % 5 != 0 && i % 7 != 0) {
                    sum++;
                    System.out.print(i + " ");
                }
            }
            System.out.println("\n" + (a - sum));
        }
    }
}