#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void amin(T &x, const T &y) {
  if (y < x) x = y;
}
template <class T>
inline void amax(T &x, const T &y) {
  if (x < y) x = y;
}
template <class Iter>
void rprintf(const char *fmt, Iter begin, Iter end) {
  for (bool sp = 0; begin != end; ++begin) {
    if (sp)
      putchar(' ');
    else
      sp = true;
    printf(fmt, *begin);
  }
  putchar('\n');
}
int N;
bool P[100111];
int A[100111];
int main() {
  for (int i = 0, i_len = (100111); i < i_len; ++i) P[i] = true;
  P[0] = P[1] = false;
  for (int i = 2; i * i < 100111; i++)
    if (P[i]) {
      for (int j = i * i; j < 100111; j += i) P[j] = false;
    }
  scanf("%d", &N);
  memset(A, -1, sizeof A);
  for (int i = N / 2; i >= 2; i--)
    if (P[i]) {
      int last = -1;
      for (int j = i; j <= N; j += i) {
        if (A[j] == -1) {
          if (last == -1) {
            last = j;
          } else {
            A[j] = last;
            A[last] = j;
            last = -1;
          }
        }
      }
      if (last != -1) {
        A[i] = last;
        A[last] = i;
        A[i + i] = -1;
      }
    }
  int ans = 0;
  for (int i = 0, i_len = (N + 1); i < i_len; ++i)
    if (i < A[i]) ans++;
  printf("%d\n", ans);
  for (int i = 0, i_len = (N + 1); i < i_len; ++i)
    if (i < A[i]) {
      printf("%d %d\n", i, A[i]);
    }
  return 0;
}
