#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int main() {
  int n;
  vector<int> g = ({
    int b = ceil(sqrt(51005));
    vector<int> d(51005, 0);
    vector<int> e;
    int f = 2;
    e.push_back(2);
    e.push_back(3);
    for (int x = 1; x < b + 1; x++) {
      for (int y = 1; y < b + 1; y++) {
        int n = (4 * x * x) + (y * y);
        if (n <= 51005 && (n % 12 == 1 || n % 12 == 5)) {
          d[n] ^= 1;
        }
        n = (3 * x * x) + (y * y);
        if (n <= 51005 && n % 12 == 7) {
          d[n] ^= 1;
        }
        n = (3 * x * x) - (y * y);
        if (x > y && n <= 51005 && n % 12 == 11) {
          d[n] ^= 1;
        }
      }
    }
    for (int r = 5; r < b + 1; r++) {
      if (d[r]) {
        for (int i = r * r; i < 51005; i += (r * r)) {
          d[i] = 0;
        }
      }
    }
    for (int c = 5; c < 51005; c++) {
      if (d[c]) {
        e.push_back(c);
      }
    }
    e;
  });
  cin >> n;
  int a[n + 1];
  for (int i = 0; i <= n; i++) a[i] = 0;
  vector<int> v, x;
  vector<pair<int, int> > ans;
  int i = 0;
  while (g[i] <= n / 2) {
    v.push_back(g[i]);
    i++;
  }
  reverse(v.begin(), v.end());
  int len = v.size(), l, val;
  for (i = 0; i < len; i++) {
    x.clear();
    val = 1;
    while (val * v[i] <= n) {
      if (a[val * v[i]] == 0) x.push_back(val * v[i]);
      val++;
    }
    l = x.size();
    if (l % 2 == 1) {
      for (int j = 0; j < l; j++) {
        if (x[j] == 2 * v[i]) {
          x.erase(x.begin() + j);
          l--;
          break;
        }
      }
    }
    for (int j = 0; j < l; j += 2) {
      ans.push_back(make_pair(x[j], x[j + 1]));
      a[x[j]] = 1;
      a[x[j + 1]] = 1;
    }
  }
  cout << ans.size() << endl;
  for (i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second << endl;
  return 0;
}
