#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char ch = getchar();
  long long p = 1, data = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') p = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    data = data * 10 + (ch ^ 48);
    ch = getchar();
  }
  return p * data;
}
inline long long qpow(long long a, long long b) {
  long long r = 1;
  while (b) {
    if (b & 1) r = a * r;
    a = a * a;
    b >>= 1;
  }
  return r;
}
inline long long gcd(long long a, long long b) {
  if (!a || !b) return (!a) ? b : a;
  while (b ^= a ^= b ^= a %= b)
    ;
  return a;
}
inline long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
void exgcd(long long a, long long b, long long &x, long long &y) {
  if (!b)
    x = 1, y = 0;
  else {
    exgcd(b, a % b, y, x);
    y -= x * (a / b);
  }
}
const int mod = 1e9 + 7, maxn = 2e5 + 5;
int vis[maxn], stk[maxn], top;
vector<int> f[maxn];
int prime[maxn], notprime[maxn];
void g_prime() {
  for (int i = 2; i <= maxn - 5; i++) {
    if (!notprime[i]) prime[++prime[0]] = i;
    for (int j = 1; j <= prime[0] && i * prime[j] <= maxn - 5; j++) {
      notprime[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
    }
  }
}
int main() {
  g_prime();
  int n = read();
  if (n <= 3) {
    puts("0");
    return 0;
  }
  for (int i = 1; i <= n; i++) vis[i] = 0;
  vector<pair<int, int> > ans;
  int q = n / 2;
  int p = lower_bound(prime + 1, prime + 1 + prime[0], q) - prime;
  if (prime[p] * 2 > n) p--;
  for (int i = p; i >= 1; i--) {
    top = 0;
    int t = n / prime[i];
    if (t % 2 == 0) t--;
    stk[++top] = prime[i];
    for (int j = t; j >= 3; j -= 2)
      if (!vis[j * prime[i]]) stk[++top] = j * prime[i];
    for (int i = 1; i <= top / 2; i++) {
      vis[stk[i]] = vis[stk[i + top / 2]] = 1;
      ans.push_back({stk[i + top / 2], stk[i]});
    }
    if ((top & 1) && !vis[prime[i] * 2]) {
      vis[prime[i] * 2] = vis[stk[top]] = 1;
      ans.push_back({stk[top], prime[i] * 2});
    }
  }
  vector<int> sna;
  for (int i = 2; i <= n; i += 2)
    if (!vis[i]) {
      sna.push_back(i);
      vis[i] = 1;
    }
  int m = ans.size() + sna.size() / 2;
  printf("%d\n", m);
  for (auto x : ans) printf("%d %d\n", x.first, x.second);
  int t = sna.size();
  for (int i = 0; i < t / 2; i++) printf("%d %d\n", sna[i], sna[i + t / 2]);
  return 0;
}
