#include <bits/stdc++.h>
using namespace std;
const double eps = 1E-9;
const double Exp = 2.718281828459045;
const double Pi = 3.1415926535897932;
const int Max_Bit = 63;
const int INF = 2000000000;
const long long LINF = 1000000000000000007ll;
const int MOD = 1000000007;
const int NMAX = 100005;
const int MMAX = 305;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
  int n, u[NMAX], pr[NMAX], mm = 0;
  vector<pair<int, int> > ans;
  queue<int> st;
  for (int i = 0; i < NMAX; ++i) {
    u[i] = 0;
    pr[i] = 0;
  }
  scanf("%d", &n);
  for (int i = 2; i <= n / 2; ++i) {
    if (!pr[i]) {
      mm = i;
      long long j = i * 1ll * i;
      while (j <= n / 2) {
        pr[j] = 1;
        j += i;
      }
    }
  }
  for (int i = mm; i > 1; --i) {
    if (!pr[i]) {
      int m = 0;
      for (int j = 1; j <= n / i; j++) {
        if (!u[i * j]) {
          st.push(i * j);
        }
      }
      if (st.size() % 2) {
        int a = st.front();
        u[a] = 1;
        st.pop();
        st.pop();
        ans.push_back(make_pair(a, st.front()));
        u[st.front()] = 1;
        st.pop();
        while (!st.empty()) {
          int a = st.front();
          u[a] = 1;
          st.pop();
          ans.push_back(make_pair(a, st.front()));
          u[st.front()] = 1;
          st.pop();
        }
      } else {
        while (!st.empty()) {
          int a = st.front();
          u[a] = 1;
          st.pop();
          ans.push_back(make_pair(a, st.front()));
          u[st.front()] = 1;
          st.pop();
        }
      }
    }
  }
  printf("%d\n", ans.size());
  int o = ans.size();
  for (int i = 0; i < o; ++i) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
  return 0;
}
