#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 2;
bool v[N], use[N];
int main() {
  int n, i, j;
  long long T;
  vector<int> p;
  scanf("%d", &n);
  for (i = 2; i <= n; ++i) {
    if (!v[i]) {
      p.push_back(i);
      T = i;
      T *= i;
      while (T <= n) v[T] = 1, T += i;
    }
  }
  vector<pair<int, int> > ret;
  vector<int> x;
  for (i = p.size() - 1; i >= 1; --i) {
    j = p[i];
    x.clear();
    while (j <= n) {
      if (!use[j]) {
        x.push_back(j);
      }
      j = j + 2 * p[i];
    }
    for (j = 0; j < x.size(); j += 2) {
      if (j == x.size() - 1) break;
      ret.push_back(make_pair(x[j], x[j + 1]));
      use[x[j]] = 1, use[x[j + 1]] = 1;
    }
    if (x.size() & 1) {
      if (p[i] * 2 <= n) {
        ret.push_back(make_pair(x.back(), p[i] * 2));
        use[x.back()] = 1, use[p[i] * 2] = 1;
      }
    }
  }
  x.clear();
  for (i = 2; i <= n; i += 2)
    if (!use[i]) x.push_back(i);
  int sz = x.size() / 2;
  sz *= 2;
  for (i = 0; i < sz; i += 2) ret.push_back(make_pair(x[i], x[i + 1]));
  printf("%d\n", (int)ret.size());
  for (i = 0; i < ret.size(); ++i)
    printf("%d %d\n", ret[i].first, ret[i].second);
}
