#include <bits/stdc++.h>
using namespace std;
const int maxn = 100001;
int n, tot, ans[maxn][2];
bool used[maxn], prim[maxn];
vector<int> facs;
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) prim[i] = 1;
  for (int i = 2; i <= n; i++)
    if (prim[i])
      for (int j = 2; i * j <= n; j++) prim[i * j] = 0;
  for (int i = n / 2; i >= 2; i--)
    if (prim[i]) {
      int sum = 0;
      facs.clear();
      for (int j = 1; i * j <= n; j++)
        if (!used[i * j]) {
          sum++;
          if (j != 2) facs.push_back(i * j);
        }
      if ((sum & 1) == 0) facs.push_back(2 * i);
      for (int j = 0; j < facs.size(); j += 2) {
        used[facs[j]] = used[facs[j + 1]] = 1;
        ans[tot][0] = facs[j];
        ans[tot++][1] = facs[j + 1];
      }
    }
  printf("%d\n", tot);
  for (int i = 0; i < tot; i++) printf("%d %d\n", ans[i][0], ans[i][1]);
}
