#include <bits/stdc++.h>
using namespace std;
queue<int> pr;
vector<pair<int, int> > ans;
int so = -1;
int p[100001];
int i, j, n, ok;
int gcd(int a, int b) {
  while (a %= b ^= a ^= b ^= a)
    ;
  return a + b;
}
int main() {
  for (i = 2; i * i < 100000; i++)
    if (!p[i])
      for (j = i * i; j <= 100000; j += i) p[j] = 1;
  scanf("%d", &n);
  for (i = 2; i <= n; i++) {
    if (!p[i])
      pr.push(i);
    else if (i == 2 * pr.front()) {
      pr.pop();
      ans.push_back(make_pair(i / 2, i));
    } else if (so == -1)
      so = i;
    else if (gcd(so, i) != 1) {
      ans.push_back(make_pair(so, i));
      so = -1;
    } else {
      ok = 0;
      for (j = 0; j < ans.size(); j++)
        if (gcd(ans[j].first, so) != 1 && gcd(ans[j].second, i) != 1) {
          swap(ans[j].second, so);
          ans.push_back(make_pair(so, i));
          so = -1;
          ok = 1;
          break;
        } else if (gcd(ans[j].first, i) != 1 && gcd(ans[j].second, so) != 1) {
          ans.push_back(make_pair(so, ans[j].second));
          ans[j].second = i;
          so = -1;
          ok = 1;
          break;
        }
      if (!ok) throw 0;
    }
  }
  printf("%d\n", ans.size());
  for (i = 0; i < ans.size(); i++)
    printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
