#include <bits/stdc++.h>
using namespace std;
const int maxn = 100011;
int n, tot, tots, ans;
int ss[maxn];
bool vis[maxn];
struct CAns {
  int x, y;
} sans[maxn];
int main() {
  int i, j, k, g;
  cin >> n;
  for (i = 0; i <= n; i++) vis[i] = false;
  tot = 0;
  ss[1] = 2;
  tots = 1;
  for (i = 3; i <= n; i++) {
    bool b = true;
    int sq = sqrt(i);
    for (j = 1; j <= tots && ss[j] <= sq; j++) {
      if (i % ss[j] == 0) {
        b = false;
        break;
      }
    }
    if (b) ss[++tots] = i;
  }
  for (i = 2; i <= tots && ss[i] <= n / 2; i++) {
    int x = ss[i];
    k = 1;
    g = x;
    for (j = x * 3; j <= n; j += x) {
      if (!vis[j]) {
        vis[j] = true;
        if (k) {
          k = 0;
          ans++;
          sans[ans].x = g, sans[ans].y = j;
        } else {
          k = 1;
          g = j;
        }
      }
    }
    if (k) {
      ans++;
      vis[2 * x] = 1;
      sans[ans].x = g, sans[ans].y = 2 * x;
    }
  }
  k = 0;
  for (i = 2; i <= n; i += 2) {
    if (!vis[i]) {
      vis[i] = 1;
      if (k) {
        k = 0;
        ans++;
        sans[ans].x = i, sans[ans].y = g;
      } else {
        k = 1;
        g = i;
      }
    }
  }
  cout << ans << endl;
  for (i = 1; i <= ans; i++) {
    cout << sans[i].x << " " << sans[i].y << endl;
  }
  return 0;
}
