#include <bits/stdc++.h>
using namespace std;
const int NMAX = 100005;
int N;
vector<int> primes;
bool isPrime[NMAX];
bool used[NMAX];
vector<pair<int, int> > pairs;
void sieve() {
  for (int i = 2; i <= N / 2 + 1; i++) {
    if (isPrime[i] == true) {
      primes.push_back(i);
      for (int j = i + i; j <= N / 2 + 1; j += i) {
        isPrime[j] = false;
      }
    }
  }
}
int main() {
  memset(isPrime, true, NMAX);
  memset(used, false, NMAX);
  cin >> N;
  sieve();
  int f = -1, e;
  for (int i = primes.size() - 1; i >= 1; i--) {
    for (int j = primes[i]; j <= N; j += 2 * primes[i]) {
      if (used[j] == false) {
        if (f == -1) {
          f = j;
        } else {
          e = j;
          pairs.push_back(pair<int, int>(f, e));
          used[e] = true;
          used[f] = true;
          f = -1;
        }
      }
    }
    if (f != -1) {
      e = primes[i] * 2;
      if (e <= N) {
        pairs.push_back(pair<int, int>(f, e));
        used[f] = true;
        used[e] = true;
      }
      f = -1;
    }
  }
  f = -1;
  for (int i = 2; i <= N; i += 2) {
    if (used[i] == false) {
      if (f == -1) {
        f = i;
      } else {
        e = i;
        pairs.push_back(pair<int, int>(f, e));
        used[f] = true;
        used[e] = true;
        f = -1;
      }
    }
  }
  cout << pairs.size() << endl;
  for (int i = 0; i < pairs.size(); i++) {
    cout << pairs[i].first << " " << pairs[i].second << endl;
  }
  return 0;
}
