#include <bits/stdc++.h>
using namespace std;
const int Nmax = 1e5 + 10;
bool a[Nmax] = {0};
vector<pair<int, int> > g;
int main(void) {
  int n, i, z;
  scanf("%d", &n);
  for (i = 3; i <= n / 2; i++) {
    for (z = 3; z * z <= i; z++)
      if (i % z == 0) break;
    if (z * z > i) {
      vector<int> s;
      for (z = i; z <= n; z += i)
        if (a[z] == 0) s.push_back(z);
      if (s.size() & 1 && s.size() >= 3) {
        swap(s[s.size() - 1], s[1]);
        s.pop_back();
      }
      if (s.size() > 1)
        for (z = 0; z + 2 <= s.size(); z += 2) {
          g.push_back(make_pair(s[z], s[z + 1]));
          a[s[z]] = 1;
          a[s[z + 1]] = 1;
        }
    }
  }
  vector<int> s;
  for (i = 2; i <= n; i += 2)
    if (a[i] == 0) s.push_back(i);
  for (i = 0; i + 2 <= s.size(); i += 2) g.push_back(make_pair(s[i], s[i + 1]));
  printf("%d\n", g.size());
  for (i = 0; i < g.size(); i++) printf("%d %d\n", g[i].first, g[i].second);
}
