#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[10000];
  bool vis[100010];
  int i, n, cnt[10000], ans = 0, m, j;
  memset(vis, 0, sizeof(vis));
  vis[1] = true;
  for (i = 2; i <= 100000; i++)
    for (j = i + i; j <= 100000; j += i) {
      vis[j] = true;
    }
  i = 0;
  j = 1;
  while (j <= 100000) {
    if (!vis[j]) a[++i] = j;
    j++;
  }
  a[i] = 100001;
  int as[100050], bs[100050];
  int tcnt[10000];
  memset(vis, 0, sizeof(vis));
  cin >> n;
  if (n < 3) {
    cout << 0 << endl;
    return 0;
  }
  for (i = 1; a[i] <= n; i++)
    ;
  m = i - 1;
  for (i = 1; i <= m; i++) tcnt[i] = cnt[i];
  int left = m, right = 2;
  int data;
  data = right;
  while (left--) {
    cnt[left] = 0;
    for (i = a[left]; i <= n; i += a[left])
      if (!vis[i]) cnt[left]++;
    bool flag = false;
    if (cnt[left] % 2 && right * a[left] <= n) {
      data = right;
      while (true) {
        if (right * a[left] > n) {
          flag = true;
          break;
        }
        if (vis[right * a[left]] || right % a[left] == 0 || vis[right])
          right++;
        else
          break;
      }
      if (!flag) {
        vis[right] = vis[right * a[left]] = true;
        ans++;
        as[ans] = right * a[left];
        bs[ans] = right;
        right++;
      }
    }
    right = data;
    while (vis[right]) right++;
    i = a[left];
    for (i = a[left]; i <= n; i += a[left])
      for (j = i + a[left]; j <= n; j += a[left])
        if (!vis[i] && !vis[j] && i != j) {
          ans++;
          as[ans] = i;
          bs[ans] = j;
          vis[i] = vis[j] = true;
          i = j;
        }
    if (left == 1) break;
  }
  cout << ans << endl;
  for (i = 1; i <= ans; i++) cout << as[i] << " " << bs[i] << endl;
  return 0;
}
