#include <bits/stdc++.h>
using namespace std;
bool q[100005], f[100005];
int p[100005], t, n, k, a[100005];
int s[100005][2], res;
inline int read() {
  char ch = getchar();
  int X = 0;
  bool fl = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') fl = 1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    X = (X << 1) + (X << 3) + ch - '0';
    ch = getchar();
  }
  if (fl) return ~(X - 1);
  return X;
}
inline void write(int x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
  }
}
void GetPrime(int n) {
  memset(q, 1, sizeof(q));
  q[1] = 0;
  for (int i = 2; i <= n; i++) {
    if (q[i]) p[++t] = i;
    for (int j = 1; j <= t && i * p[j] <= n; j++) {
      q[i * p[j]] = 0;
      if (!(i % p[j])) break;
    }
  }
}
int main() {
  n = read();
  GetPrime(n);
  for (int i = t; i; i--) {
    int ps = 0;
    for (int j = p[i]; j <= n; j += p[i])
      if (!f[j]) a[++ps] = j;
    if (ps & 1) swap(a[2], a[ps]), --ps;
    for (int j = 1; j <= ps; j += 2) {
      f[a[j]] = f[a[j + 1]] = 1;
      s[++res][0] = a[j], s[res][1] = a[j + 1];
    }
  }
  write(res), putchar('\n');
  for (int i = 1; i <= res; i++)
    write(s[i][0]), putchar(' '), write(s[i][1]), putchar('\n');
  return 0;
}
