#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9 + 7;
const int MAXN = 1e5 + 100;
bool isprime[MAXN];
vector<int> prime;
vector<int> v;
int pem, n;
vector<pair<int, int> > res;
bool sudah[MAXN];
vector<int> simpan;
void sieve() {
  isprime[1] = false;
  for (int i = 2; i <= MAXN - 50; i++) {
    if (isprime[i]) {
      if (i > n / 2)
        break;
      else
        prime.push_back(i);
      for (int j = i + i; j < MAXN - 50; j += i) isprime[j] = false;
    }
  }
  reverse(prime.begin(), prime.end());
  for (int i = 0; i < prime.size(); i++) {
    int now = prime[i];
    vector<int> sek;
    for (int j = now; j <= n; j += now) {
      if (sudah[j]) continue;
      sudah[j] = 1;
      sek.push_back(j);
    }
    if (now == 2) {
      for (int j = 0; j < simpan.size(); j++) sek.push_back(simpan[j]);
      if (sek.size() % 2 == 1) sek.pop_back();
      for (int j = 0; j < sek.size(); j += 2)
        res.push_back(make_pair(sek[j], sek[j + 1]));
      break;
    }
    if (sek.size() % 2 == 1) {
      simpan.push_back(sek[1]);
      res.push_back(make_pair(sek[0], sek[2]));
      for (int j = 3; j < sek.size(); j += 2)
        res.push_back(make_pair(sek[j], sek[j + 1]));
    } else {
      for (int j = 0; j < sek.size(); j += 2)
        res.push_back(make_pair(sek[j], sek[j + 1]));
    }
  }
  cout << res.size() << '\n';
  for (int i = 0; i < res.size(); i++)
    cout << res[i].first << ' ' << res[i].second << '\n';
  return;
}
int main() {
  for (int i = 0; i < MAXN; i++) isprime[i] = true;
  cin >> n;
  sieve();
}
