#include<bits/stdc++.h>
using namespace std;

using ll = long long;

const int N = 10000;

vector<vector<int>> adj[N+1];

ll value(const vector<int>& v) {
    ll score = 1000000LL * ((int)v.size() - 1);
    for (int y : v) score -= y;
    return score;
}

void precompute() {
    for (int x = 1; 6 * x <= N; x++)
        adj[x].push_back({2 * x, 3 * x, 6 * x});

    for (int x = 2; x <= N; x++) {
        int xx = x * x;
        for (int d = 1; d * d <= xx; d++)
            if (xx % d == 0) {
                int e = xx / d;

                int a = x + d, b = x + e;
                if (a > N || b > N) continue;
                if (a == b) continue;
                adj[x].push_back({a, b});
            }
    }

    for (int x = 1; x <= N; x++) sort(adj[x].begin(), adj[x].end(), 
        [&](const vector<int>& A, const vector<int>& B) {
        return value(A) > value(B);
    });
}

void solve() {
    vector<bool> used(N + 1, false);
    used[2] = used[3] = used[6] = true;

    while (true) {
        int best_x = -1, best_id;
        ll best_s = LLONG_MIN;
        for (int x = N; x >= 2; x--) {
            if (!used[x]) continue;

            for (int id = 0; id < (int)adj[x].size(); id++) {
                const auto& v = adj[x][id];
                bool ok = true;
                for (int y : v)
                    if (used[y]) {
                        ok = false;
                        break;
                    }
                if (!ok) continue;

                ll s = value(v);
                if (s > best_s) {
                    best_s = s;
                    best_x = x;
                    best_id = id;
                }
            }
        }
        if (best_x == -1) break;

        used[best_x] = false;
        for (int y : adj[best_x][best_id]) used[y] = true;
    }

    vector<int> ans;
    for (int x = 1; x <= N; x++)
        if (used[x]) ans.push_back(x);

    cout << ans.size() << '\n';
    for (int x : ans) cout << x << ' ';
    cout << '\n';
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    precompute();
    int tests = 1; // cin >> tests;
    while (tests--) solve();

    #ifndef ONLINE_JUDGE
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif

    return 0;
}