#include <bits/stdc++.h>
using namespace std;
int t[50010];
int primenum[50010];
void prime() {
  int now = 0;
  bool right;
  for (int i = 2; i <= 100010; i++) {
    right = true;
    for (int p = 2; p * p <= i; p++) {
      if (i % p == 0) right = false;
    }
    if (right) primenum[now++] = i;
  }
}
int main() {
  for (int i = 0; i < 50010; i++) primenum[i] = 9999999;
  int visit[100010];
  memset(visit, 0, sizeof(visit));
  memset(t, 0, sizeof(t));
  prime();
  int n, tot = 0, tot2;
  cin >> n;
  for (int m = 50008; m >= 0; m--) {
    tot2 = 0;
    if (primenum[m] > n) continue;
    for (int k = 1; k <= n / primenum[m]; k++) {
      if (!visit[k * primenum[m]]) {
        visit[k * primenum[m]] = primenum[m];
        tot2++;
      }
    }
    if (tot2 % 2 == 1 && tot2 > 2) visit[primenum[m] * 2] = 0;
    if (tot2 % 2 == 1 && tot2 < 2) visit[primenum[m]] = 0;
    t[m] = tot2;
    tot += tot2 / 2;
  }
  cout << tot << endl;
  int tot3;
  for (int m = 50008; m >= 0; m--) {
    tot3 = 0;
    if (primenum[m] > n) continue;
    if (t[m] / 2 >= 1) {
      for (int k = 1; k <= n / primenum[m]; k++) {
        if (visit[k * primenum[m]] == primenum[m]) {
          tot3++;
          cout << k * primenum[m];
          if (tot3 % 2 == 0)
            cout << endl;
          else
            cout << " ";
        }
      }
    }
  }
  return 0;
}
