#include <bits/stdc++.h>
using namespace std;
int n, ans;
bool pr[100003];
bool mark[100003];
vector<int> v;
vector<int> e;
vector<pair<int, int> > res;
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++)
    if (!pr[i]) {
      v.push_back(i);
      for (int j = 2 * i; j <= n; j += i) pr[j] = true;
    }
  int sz = v.size();
  for (int i = 1; i < sz && v[i] <= n / 2; i++) {
    vector<int> tmp;
    for (int j = v[i]; j <= n; j += v[i])
      if (!mark[j]) tmp.push_back(j);
    int cnt = tmp.size();
    if (cnt % 2 == 0) {
      for (int j = 0; j < cnt; j += 2) {
        res.push_back(pair<int, int>(tmp[j], tmp[j + 1]));
        mark[tmp[j]] = mark[tmp[j + 1]] = true;
      }
    } else if (cnt >= 3) {
      res.push_back(pair<int, int>(tmp[0], tmp[2]));
      mark[tmp[0]] = mark[tmp[2]] = true;
      for (int j = 3; j < cnt; j += 2) {
        res.push_back(pair<int, int>(tmp[j], tmp[j + 1]));
        mark[tmp[j]] = mark[tmp[j + 1]] = true;
      }
    }
  }
  for (int i = 2; i <= n; i += 2)
    if (!mark[i]) e.push_back(i);
  int cnt = e.size();
  for (int i = 0; i + 1 < cnt; i += 2)
    res.push_back(pair<int, int>(e[i], e[i + 1]));
  ans = res.size();
  printf("%d\n", ans);
  for (int i = 0; i < ans; i++) printf("%d %d\n", res[i].first, res[i].second);
  return 0;
}
