#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005;
bool primo[MAX], usd[MAX];
vector<int> fila, sobra;
vector<pair<int, int> > ans;
void criba(int n) {
  for (int i = 0; i < (int)(n + 1); i++) primo[i] = 1;
  primo[0] = primo[1] = 0;
  for (int i = 2; i * i <= n; i++) {
    if (primo[i])
      for (int j = i * i; j <= n; j += i) primo[j] = 0;
  }
}
int main() {
  int n;
  cin >> n;
  if (n < 9) {
    if (n < 4)
      cout << "0" << endl;
    else if (n < 6) {
      cout << "1" << endl;
      cout << "2 4" << endl;
    } else {
      cout << "2" << endl;
      cout << "6 3" << endl;
      cout << "2 4" << endl;
    }
  } else {
    criba(n);
    for (int i = 0; i < (int)(n + 1); i++) usd[i] = 0;
    for (int i = n / 2; i > 1; i--) {
      if (not primo[i]) continue;
      fila.clear();
      ans.push_back(make_pair(i, 2 * i));
      usd[i] = usd[2 * i] = 1;
      for (int j = 3 * i; j <= n; j += i) {
        if (not usd[j]) {
          usd[j] = 1;
          fila.push_back(j);
        }
      }
      for (int j = fila.size() - 1; j > 0; j -= 2) {
        ans.push_back(make_pair(fila[j - 1], fila[j]));
      }
      if (fila.size() % 2) sobra.push_back(fila[0]);
    }
    for (int i = 0; i + 1 < sobra.size(); i += 2) {
      ans.push_back(make_pair(sobra[i], sobra[i + 1]));
    }
    cout << ans.size() << endl;
    for (int i = 0; i < (int)(ans.size()); i++) {
      int a = ans[i].first, b = ans[i].second;
      if (a == 6)
        cout << "9 " << b << endl;
      else if (a == 9)
        cout << "6 " << b << endl;
      else if (b == 6)
        cout << a << " 9" << endl;
      else if (b == 9)
        cout << a << " 6" << endl;
      else
        cout << a << " " << b << endl;
    }
  }
  return 0;
}
