#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n;
bool vis[N];
bool prime[N];
void Sieve() {
  int i, j;
  memset(prime, true, sizeof(prime));
  prime[1] = false;
  for (i = 2; i <= N; i++) {
    if (prime[i]) {
      for (j = i + i; j <= N; j += i) prime[j] = false;
    }
  }
}
int ans;
int sets;
set<int> s[N];
int in_set[N];
void print_set(int ind) {
  for (auto it = s[ind].begin(); it != s[ind].end(); ++it) cerr << *it << " ";
  cerr << endl;
}
void get_ans(int ind) {
  int last = -1;
  for (auto it = s[ind].begin(); it != s[ind].end(); ++it) {
    if (last == -1)
      last = *it;
    else {
      printf("%d %d\n", last, *it);
      last = -1;
    }
  }
}
int p[N];
int main() {
  int i, j;
  cin >> n;
  Sieve();
  for (i = 3; i <= n; i++) {
    if (prime[i]) {
      sets++;
      p[sets] = i;
      for (j = i; j <= n; j += i) {
        if (!vis[j]) {
          in_set[j] = sets;
          s[sets].insert(j);
          vis[j] = true;
        }
      }
    }
  }
  sets++;
  for (i = 1; i < sets; i++) {
    if (s[i].size() % 2 == 1 && s[i].size() > 1) {
      s[i].erase(2 * p[i]);
      s[sets].insert(2 * p[i]);
    }
    ans += s[i].size() / 2;
  }
  for (i = 2; i <= n; i++) {
    if (__builtin_popcount(i) == 1) s[sets].insert(i);
  }
  ans += s[sets].size() / 2;
  cout << ans << endl;
  for (i = 1; i <= sets; i++) get_ans(i);
  return 0;
}
