#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const double eps = 1e-6;
int n, cnt;
bool check[100010];
long long prime[100010];
vector<pair<int, int> > ans;
vector<int> vv;
bool flag[100010];
void per() {
  check[1] = 1;
  for (int i = 2; i <= n; ++i) {
    if (!check[i]) {
      prime[++cnt] = i;
    }
    for (int j = 1; j <= cnt && prime[j] * i <= n; ++j) {
      check[i * prime[j]] = 1;
      if (i % prime[j] == 0) {
        break;
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  per();
  for (int i = cnt; i >= 1; --i) {
    vector<int> vec;
    for (long long j = 1; j * prime[i] <= n; ++j) {
      if (!flag[j * prime[i]]) {
        vec.push_back(j * prime[i]);
      }
    }
    if (vec.size() % 2 == 0) {
      for (int k = 0; k + 1 < vec.size(); k += 2) {
        ans.push_back(make_pair(vec[k], vec[k + 1]));
        flag[vec[k]] = flag[vec[k + 1]] = 1;
      }
    } else if (vec.size() >= 3) {
      ans.push_back(make_pair(vec[0], vec[2]));
      flag[vec[0]] = flag[vec[2]] = flag[vec[1]] = 1;
      vv.push_back(vec[1]);
      for (int k = 3; k + 1 < vec.size(); k += 2) {
        ans.push_back(make_pair(vec[k], vec[k + 1]));
        flag[vec[k]] = flag[vec[k + 1]] = 1;
      }
    }
  }
  for (int i = 0; i + 1 < vv.size(); i += 2) {
    ans.push_back(make_pair(vv[i], vv[i + 1]));
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); ++i) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
  return 0;
}
