#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
int a[MAXN], vis[MAXN];
int d[MAXN], p[MAXN];
int primes[MAXN], cnt;
int st[MAXN];
void get_primes(int n) {
  st[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (!st[i]) primes[cnt++] = i;
    for (int j = 0; primes[j] <= n / i; j++) {
      st[primes[j] * i] = 1;
      if (i % primes[j] == 0) break;
    }
  }
}
int num[MAXN];
int main() {
  int n;
  scanf("%d", &n);
  get_primes(n);
  int tot = 0;
  for (int i = cnt - 1; i >= 0; i--) {
    int tot1 = 0;
    for (int i1 = primes[i]; i1 <= n; i1 += primes[i]) {
      if (vis[i1] == 0) {
        num[tot1++] = i1;
      }
    }
    if (tot1 % 2 != 0) swap(num[1], num[tot1 - 1]);
    for (int j = 0; j < tot1; j += 2) {
      if (j + 1 <= tot1 - 1) {
        d[tot] = num[j], p[tot] = num[j + 1];
        vis[d[tot]] = 1, vis[p[tot]] = 1;
        tot++;
      }
    }
  }
  printf("%d\n", tot);
  for (int i = 0; i < tot; i++) {
    printf("%d %d\n", d[i], p[i]);
  }
  return 0;
}
