#include <iostream>

using namespace std;

int main(){
	int n , ans = 1;

	while(cin >> n){
		ans = 1;
		if(n == 0) break;

		if(n <= 1){
			ans--;
		}

		for(int i = 2; i <= n; i++){
			if(i % 2 != 0 && 9 > i){
				cout << i << endl;
				ans++;

			}if(i >= 9){
				if(i % 2 != 0 && i % 3 != 0 && i % 5 != 0 && i % 7 != 0){
					cout << i << endl;
					ans++;
				}
			}
		}

		cout << ans << endl;
	}
	return 0;
}