#include <bits/stdc++.h>
int s[100009], c[100009], t[100009], v[100009], vn;
void prepare() {
  s[0] = s[1] = 1;
  for (long long i = 2; i < 100009; i++)
    if (!s[i])
      for (long long j = i * i; j < 100009; j += i) s[j] = 1;
  for (int i = 1; i < 100009; i++) {
    c[i] = c[i - 1] + (!s[i]);
  }
}
int main() {
  prepare();
  int n;
  scanf("%d", &n);
  int ans = (n - 1 - (c[n] - c[n / 2])) / 2;
  printf("%d\n", ans);
  for (int i = n / 2; i >= 2; i--)
    if (!s[i]) {
      vn = 0;
      for (int j = i; j <= n; j += i)
        if (!t[j]) v[vn++] = j;
      for (int j = vn - 1; j > 0; j -= 2) {
        int vv = v[j - 1];
        if (j == 2) vv = v[0];
        printf("%d %d\n", v[j], vv);
        t[v[j]] = 1;
        t[vv] = 1;
      }
    }
}
