vector<bool> sieveFlags(int n) {
vector<bool> f(n + 1);
for (int i = 3; i <= n; i += 2)f[i] = true;
for (int i = 3; (long long)i*i <= n; i += 2) {
if (f[i])for (int j = i * 3; j <= n; j += i)f[j] = false;
}
if (n >= 2)f[2] = true;
return f;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(20);
const int MA = 1000001;
auto A = sieveFlags(MA+1000);
int K;
cin >> K;
vi re, used(MA), B;
for (int a = 2; K > 0; a += 2) {
bool ok = true;
each(b, B)if (A[a + b]) {
ok = false;
break;
}
if (!ok)continue;
int x = 1;
for (; (x+1)*(x+1) <= K; ++x);
for (int b = 3; b < MA; b += 2)if (!used[b] && A[a + b]) {
ok = true;
for(int c=2;c<a;c+=2)if(A[b+c]){
ok = false;
break;
}
if (!ok)continue;
rep(c, x) {
re.push_back(a);
re.push_back(b);
}
used[b] = true;
B.push_back(b);
K -= x*x;
break;
}
}
cout << sz(re) << endl;
rep(a, sz(re))cout << re[a] << (a != sz(re) - 1 ? ' ' : '\n');
}