#include <bits/stdc++.h>
using namespace std;
int n, ans, mx, a[200001], b[200001][2], mp[200001], vis[200001];
void getprime() {
  int i, j;
  mp[1] = 1;
  for (i = 2; i <= mx; i++)
    if (!mp[i]) {
      for (j = i * 2; j <= mx; j += i) mp[j] = 1;
    }
}
int main() {
  int i, j;
  mx = 1e5;
  scanf("%d", &n);
  getprime();
  for (i = n / 2; i; i--)
    if (!mp[i]) {
      a[0] = 0;
      for (j = i; j <= n; j += i)
        if (!vis[j]) {
          a[++a[0]] = j;
        }
      if (a[0] & 1) {
        swap(a[2], a[a[0]]);
        a[0]--;
      }
      for (j = 1; j <= a[0]; j += 2) {
        ans++;
        vis[a[j]] = vis[a[j + 1]] = 1;
        b[ans][0] = a[j];
        b[ans][1] = a[j + 1];
      }
    }
  printf("%d\n", ans);
  for (i = 1; i <= ans; i++) printf("%d %d\n", b[i][0], b[i][1]);
}
