#include <bits/stdc++.h>
int N;
bool isprime[100000 + 7];
int prime[100000 + 7];
void GetPrime() {
  for (int i = 2; i <= 100000; i++) {
    if (!isprime[i]) prime[++prime[0]] = i;
    for (int j = 1; j <= prime[0] && prime[j] * i <= 100000; j++) {
      isprime[prime[j] * i] = true;
      if (i % prime[j] == 0) break;
    }
  }
}
int match[100000 + 7];
int main() {
  GetPrime();
  scanf("%d", &N);
  int ans = 0;
  for (int i = 2; prime[i] <= N / 2; i++) {
    int p = prime[i];
    int tot = 0;
    for (int j = p; j <= N; j += p)
      if (!match[j]) tot++, match[j] = p;
    if (tot & 1)
      ans += tot >> 1, match[p << 1] = 0;
    else
      ans += tot >> 1;
  }
  int tot = 0;
  for (int i = 2; i <= N; i += 2)
    if (!match[i]) match[i] = 2, tot++;
  ans += tot >> 1;
  printf("%d\n", ans);
  for (int i = 2; prime[i] <= N / 2; i++) {
    int p = prime[i];
    for (int t = 0, j = p; j <= N; j += p)
      if (match[j] == p) {
        printf("%d", j);
        t ^= 1;
        if (!t)
          puts("");
        else
          printf(" ");
      }
  }
  int las = 0;
  for (int i = 2; i <= N; i += 2)
    if (match[i] == 2) {
      if (las)
        printf("%d %d\n", las, i), las = 0;
      else
        las = i;
    }
  return 0;
}
