#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, k, match[N];
bool mark[N];
int main() {
  scanf("%d", &n);
  for (int i = 2; i * i <= n; i++)
    for (int j = i * i; j <= n; j += i) mark[j] = true;
  for (int i = n; i > 1; i--)
    if (!mark[i]) {
      vector<int> help;
      for (int j = i; j <= n; j += i)
        if (!match[j]) help.push_back(j);
      if (help.size() & 1) help[1] = help.back();
      for (int j = 1; j < help.size(); j += 2, k++)
        match[match[help[j]] = help[j - 1]] = help[j];
    }
  printf("%d\n", k);
  for (int i = n; i; i--)
    if (match[i] > i) printf("%d %d\n", i, match[i]);
}
