#include <bits/stdc++.h>
using namespace std;
int n;
int prime[100100], tot;
int use[100100];
int p[100100][2], ans;
int fl[100100], seq[100100];
void init() {
  for (int i = 2; i <= n; i++) {
    if (!use[i]) prime[++tot] = i;
    for (int j = 1; j <= tot && prime[j] * i <= n; j++) {
      use[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
    }
  }
}
int main() {
  cin >> n;
  init();
  int l, r, s;
  int now = 0;
  for (int j = tot; j >= 1; j--) {
    int k = prime[j];
    now = 0;
    for (int i = 1; i * k <= n; i++) {
      if (fl[i * k] == 0) seq[++now] = i * k;
    }
    if (now & 1) {
      if (now == 1) continue;
      p[++ans][0] = seq[1], p[ans][1] = seq[3];
      fl[seq[1]] = 1, fl[seq[3]] = 1;
      for (int j = 4; j <= now; j += 2) {
        p[++ans][0] = seq[j], p[ans][1] = seq[j + 1];
        fl[seq[j]] = 1;
        fl[seq[j + 1]] = 1;
      }
    } else {
      for (int j = 1; j <= now; j += 2) {
        p[++ans][0] = seq[j], p[ans][1] = seq[j + 1];
        fl[seq[j]] = 1;
        fl[seq[j + 1]] = 1;
      }
    }
  }
  cout << ans << endl;
  for (int i = 1; i <= ans; i++) {
    cout << p[i][0] << " " << p[i][1] << endl;
  }
  return 0;
}
