#include <bits/stdc++.h>
using namespace std;
int used[100005];
vector<pair<int, int> > r;
vector<int> aux;
int main(void) {
  int n;
  memset(used, 0, sizeof(used));
  scanf(" %d", &n);
  for (int i = 3; i <= n / 2; i += 2) {
    aux.clear();
    for (int j = i; j <= n; j += i) {
      if (!used[j]) {
        used[j] = 1;
        aux.push_back(j);
      }
    }
    if (aux.size() % 2 == 0) {
      for (int i = 0; i < (int)aux.size(); i += 2) {
        r.push_back(make_pair(aux[i], aux[i + 1]));
      }
    } else {
      used[i + i] = 0;
      aux[1] = aux[0];
      for (int i = 1; i < (int)aux.size(); i += 2) {
        r.push_back(make_pair(aux[i], aux[i + 1]));
      }
    }
  }
  aux.clear();
  for (int i = 2; i <= n; i += 2) {
    if (!used[i]) {
      aux.push_back(i);
    }
  }
  for (int i = 0; i < (int)aux.size() - 1; i += 2) {
    r.push_back(make_pair(aux[i], aux[i + 1]));
  }
  printf("%d\n", (int)r.size());
  for (int i = 0; i < (int)r.size(); i++) {
    printf("%d %d\n", r[i].first, r[i].second);
  }
  return 0;
}
