#include <bits/stdc++.h>
using namespace std;
bool prim[100005];
bool vis[100005];
int last[100005];
vector<int> ve[2];
vector<int> tmp;
int main() {
  int n;
  scanf("%d", &n);
  int cot = 0;
  for (int i = 2; i <= n / 2; i++) {
    if (!prim[i]) {
      for (int j = 2 * i; j <= n; j += i) prim[j] = 1;
    }
  }
  for (int i = n / 2; i >= 2; i--) {
    if (!prim[i]) {
      tmp.clear();
      for (int j = 1; j * i <= n; j++) {
        if (vis[j * i]) continue;
        if (j != 2) {
          tmp.push_back(j * i);
          vis[j * i] = 1;
        }
      }
      if ((tmp.size()) & 1) {
        tmp.push_back(2 * i);
        vis[2 * i] = 1;
      }
      for (int j = 0; j < tmp.size(); j += 2) {
        ve[0].push_back(tmp[j]);
        ve[1].push_back(tmp[j + 1]);
      }
    }
  }
  printf("%d\n", ve[0].size());
  for (int i = 0; i < ve[0].size(); i++) printf("%d %d\n", ve[0][i], ve[1][i]);
  return 0;
}
