#include <bits/stdc++.h>
using namespace std;
const long N = 100001;
int prime[N], pn = 0;
bool isnp[N];
void shai() {
  int i, j;
  memset(prime, 0, sizeof(prime));
  memset(isnp, 0, sizeof(isnp));
  isnp[0] = 1, isnp[1] = 1;
  pn = 0;
  for (i = 2; i < N; i++) {
    if (!isnp[i]) prime[pn++] = i;
    for (j = 0; j < pn && i * prime[j] < N; j++) {
      isnp[i * prime[j]] = 1;
      if (!(i % prime[j])) break;
    }
  }
}
int n;
vector<int> a, a2;
vector<pair<int, int> > v;
bool used[N];
int main() {
  int i, j, k;
  int l, r, mid;
  int pre;
  int ans;
  shai();
  while (scanf("%d", &n) != EOF) {
    ans = 0;
    v.clear();
    a2.clear();
    memset(used, 0, sizeof(used));
    for (i = 1; prime[i] <= n / 2; i++) {
      a.clear();
      a.push_back(prime[i]);
      for (j = 3 * prime[i]; j <= n; j += prime[i])
        if (!used[j]) a.push_back(j);
      if (a.size() % 2 == 0)
        a2.push_back(2 * prime[i]);
      else
        a.push_back(2 * prime[i]);
      int maxj = a.size();
      for (j = 0; j + 1 < maxj; j += 2) {
        v.push_back(make_pair(a[j], a[j + 1]));
        used[a[j]] = 1;
        used[a[j + 1]] = 1;
      }
    }
    if (n >= 2) a2.push_back(2);
    if (n >= 4) a2.push_back(4);
    for (i = 4; i + i <= n; i++) {
      if (!used[i + i] && isnp[i]) a2.push_back(i + i);
    }
    int maxi = a2.size();
    for (i = 0; i + 1 < maxi; i += 2) v.push_back(make_pair(a2[i], a2[i + 1]));
    printf("%d\n", v.size());
    maxi = v.size();
    for (i = 0; i < (maxi); i++) printf("%d %d\n", v[i].first, v[i].second);
  }
  return 0;
}
