#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
bool isprime[MAXN];
int prime[MAXN];
void euler() {
  memset(isprime, true, sizeof isprime);
  isprime[1] = false;
  for (int i = 2; i < MAXN; i++) {
    if (isprime[i]) prime[++prime[0]] = i;
    for (int j = 1; j <= prime[0] && i * prime[j] < MAXN; j++) {
      isprime[i * prime[j]] = false;
      if (i % prime[j] == 0) break;
    }
  }
}
bool vis[MAXN];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  euler();
  cin >> n;
  vector<pair<int, int>> ans;
  for (int i = n / 2; i >= 2; i--) {
    if (!isprime[i]) continue;
    vector<int> v;
    v.push_back(i);
    for (int j = 3; i * j <= n; j++)
      if (!vis[i * j]) v.push_back(i * j);
    reverse(v.begin(), v.end());
    while (v.size() >= 2) {
      auto a = v.back();
      v.pop_back();
      auto b = v.back();
      v.pop_back();
      vis[a] = true;
      vis[b] = true;
      ans.push_back({a, b});
    }
    if (v.size() && !vis[2 * i]) {
      ans.push_back({2 * i, v.back()});
      vis[v.back()] = true;
      vis[2 * i] = true;
    }
  }
  cout << ans.size() << "\n";
  for (auto &x : ans) cout << x.first << " " << x.second << "\n";
  return 0;
}
