#include <bits/stdc++.h>
using namespace std;
vector<int> p;
bool is[100005] = {false};
void prime(int n) {
  p.clear();
  for (int i = 2; i <= n; i++) {
    if (!is[i]) {
      p.push_back(i);
      for (int j = i + i; j <= n; j += i) {
        is[j] = true;
      }
    }
  }
}
int visit[100005];
int main() {
  int n;
  scanf("%d", &n);
  if (n == 1) {
    printf("0\n");
    return 0;
  }
  vector<vector<int> > num;
  num.resize(n / 2 + 2);
  prime(n);
  for (int i = p.size() - 1; i >= 0; i--) {
    if (p[i] <= n / 2) {
      for (int j = 1; j * p[i] <= n; j++) {
        if (visit[p[i] * j] == 0) {
          num[p[i]].push_back(p[i] * j);
          visit[p[i] * j] = 1;
        }
      }
    }
  }
  int sum = 0;
  for (int i = num.size() - 1; i >= 3; i--) {
    if (num[i].size() != 0 && num[i].size() % 2 == 1) {
      num[i].erase(num[i].begin() + 1);
      num[2].push_back(i * 2);
    }
    sum += num[i].size();
  }
  if (num[2].size() != 0 && num[2].size() % 2 == 1) {
    num[2].erase(num[2].begin());
  }
  sum += num[2].size();
  printf("%d\n", sum / 2);
  for (int i = num.size() - 1; i >= 2; i--) {
    if (num[i].size() != 0) {
      for (int j = 0; j < num[i].size(); j += 2) {
        printf("%d %d\n", num[i][j], num[i][j + 1]);
      }
    }
  }
  return 0;
}
