#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) {
        swap(help[1], help.back());
        help.pop_back();
      }
      for (int j = 1; j < help.size(); j += 2, k++) {
        match[help[j]] = help[j - 1];
        match[help[j - 1]] = help[j];
      }
    }
  cout << k << endl;
  for (int i = n; i; i--)
    if (match[i] > i) cout << i << ' ' << match[i] << endl;
}
