#include <bits/stdc++.h>
using namespace std;
int main() {
  bool b[100010] = {0}, c[100010] = {0};
  int n, i, j, p = 1, a[100010];
  vector<pair<int, int> > ans;
  cin >> n;
  for (i = 2; i <= n / 2 + 1; i++) {
    if (b[i] == 1) continue;
    a[p] = i;
    p++;
    for (j = 2 * i; j <= n / 2 + 1; j = j + i) b[j] = 1;
  }
  for (i = n / 2; i >= 2; i--) {
    if (b[i] == 0) {
      bool flg = 1, f = 0;
      int x, jj = 0, xx = 0;
      x = i;
      for (j = i * 2; j <= n; j = j + i) {
        if (c[j] == 1)
          continue;
        else if (flg == 0)
          flg = 1, x = j;
        else {
          if (f != 0)
            ans.push_back(make_pair(j, x)), c[j] = 1, c[x] = 1;
          else if (f == 0)
            jj = j, xx = x;
          flg = 0;
          f++;
        }
      }
      j -= i;
      if (c[j] == 0 && j % 2 == 1 && xx != 0 && jj != 0 && x != 0) {
        c[j] = 1;
        c[xx] = 1;
        ans.push_back(make_pair(j, xx));
      } else if (jj != 0 && xx != 0) {
        c[jj] = 1;
        c[xx] = 1;
        ans.push_back(make_pair(jj, xx));
      }
    }
  }
  cout << ans.size() << endl;
  vector<pair<int, int> >::iterator iter;
  iter = ans.begin();
  int pp = 0;
  for (iter = ans.begin(); iter != ans.end(); iter++) {
    cout << iter->first << " " << iter->second << endl;
    pp++;
  }
}
