#include <bits/stdc++.h>
template <typename T>
T in() {
  char ch;
  T n = 0;
  bool ng = false;
  while (1) {
    ch = getchar();
    if (ch == '-') {
      ng = true;
      ch = getchar();
      break;
    }
    if (ch >= '0' && ch <= '9') break;
  }
  while (1) {
    n = n * 10 + (ch - '0');
    ch = getchar();
    if (ch < '0' || ch > '9') break;
  }
  return (ng ? -n : n);
}
template <typename T>
inline T Bigmod(T b, T p, T m) {
  if (p == 0)
    return 1;
  else if (!(p & 1))
    return (Bigmod(b, p / 2, m) * Bigmod(b, p / 2, m)) % m;
  else
    return ((b % m) * Bigmod(b, p - 1, m)) % m;
}
template <typename T>
inline T ABS(T a) {
  if (a < 0)
    return -a;
  else
    return a;
}
template <typename T>
inline T Dis(T x1, T y1, T x2, T y2) {
  return sqrt((x1 - x2 * x1 - x2) + (y1 - y2 * y1 - y2));
}
template <typename T>
inline T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <typename T>
inline T lcm(T a, T b) {
  if (a < 0) return lcm(-a, b);
  if (b < 0) return lcm(a, -b);
  return a * (b / gcd(a, b));
}
template <typename T>
T ModInv(T b, T m) {
  return Bigmod(b, m - 2, m);
}
bool isVowel(char ch) {
  ch = toupper(ch);
  if (ch == 'A' || ch == 'U' || ch == 'I' || ch == 'O' || ch == 'E')
    return true;
  return false;
}
template <typename T>
T POW(T b, T p) {
  if (p == 0) return 1;
  if (p % 2 == 0) {
    T s = POW(b, p / 2);
    return s * s;
  }
  return b * POW(b, p - 1);
}
using namespace std;
int prime[100019 + 9];
vector<int> prm;
void seive() {
  int sq = sqrt(100019);
  for (int i = 2; i <= sq; i++) {
    if (prime[i] == 0) {
      for (int j = i + i; j <= 100019; j += i) {
        prime[j] = 1;
      }
    }
  }
  for (int i = 2; i <= 100019; i++) {
    if (prime[i] == 0 && i <= 100000) prm.push_back(i);
  }
}
vector<int> rem;
vector<int> pr[100019];
int taken[100019];
vector<int> ans;
int main() {
  seive();
  int n;
  cin >> n;
  for (int i = 1; prm[i] <= n / 2; i++) {
    for (int j = prm[i] + prm[i]; j <= n; j += prm[i]) {
      if (taken[j] == 0) {
        pr[prm[i]].push_back(j);
        taken[j] = 1;
      }
    }
    int len = pr[prm[i]].size(), f = 0;
    if (len % 2 == 0 && len) {
      rem.push_back(prm[i] * 2);
      for (int j = 1; j < len; j++) ans.push_back(pr[prm[i]][j]);
      ans.push_back(prm[i]);
    } else if (len) {
      for (int j = 0; j < len; j++) ans.push_back(pr[prm[i]][j]);
      ans.push_back(prm[i]);
    }
  }
  for (int i = 2; i <= n; i += 2) {
    if (taken[i] == 0) rem.push_back(i);
  }
  int len = rem.size();
  if (len % 2) len--;
  for (int i = 0; i < len; i++) {
    ans.push_back(rem[i]);
  }
  int ln = ans.size() / 2;
  cout << ln << endl;
  for (int i = 0; i < ans.size(); i += 2) {
    cout << ans[i] << " " << ans[i + 1] << endl;
  }
  return 0;
}
