#include <bits/stdc++.h>
using namespace std;
pair<int, int> r[int(2e5)];
int f[int(2e5)], q[int(2e5)], n, res;
int main() {
  scanf("%d", &n);
  int d = 0;
  for (int i = (2), _b = (n); i <= _b; i++)
    if (!f[i]) {
      d = 0;
      for (int j = (1), _b = (n / i); j <= _b; j++)
        if (f[i * j] == 0) {
          f[i * j] = i;
          d++;
          q[d] = i * j;
        }
      if (d % 2 == 1) {
        if (2 * i <= n) {
          f[2 * i] = i;
          d++;
          q[d] = 2 * i;
        }
      }
      if (i != 2)
        for (int j = 1; j <= d - 1; j += 2) {
          res++;
          r[res] = pair<int, int>(q[j], q[j + 1]);
        }
    }
  d = 0;
  for (int i = (2), _b = (n); i <= _b; i++)
    if (f[i] == 2) {
      d++;
      q[d] = i;
    }
  for (int j = 1; j <= d - 1; j += 2) {
    res++;
    r[res] = pair<int, int>(q[j], q[j + 1]);
  }
  printf("%d\n", res);
  for (int i = (1), _b = (res); i <= _b; i++)
    printf("%d %d\n", r[i].first, r[i].second);
  return 0;
}
