#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 111;
vector<int> prime;
bool vis[N];
void init(int n) {
  for (int i = 2; i <= n; ++i) {
    if (!vis[i]) {
      prime.push_back(i);
    }
    for (int j = i; j <= n; j += i) {
      vis[j] = true;
    }
  }
}
vector<int> get_frac(int x) {
  vector<int> frac;
  for (auto p : prime) {
    while (x % p == 0) {
      x /= p;
      frac.push_back(p);
    }
  }
  return frac;
}
bool vis2[N];
int main() {
  int n;
  cin >> n;
  init(n);
  vector<pair<int, int>> ans;
  reverse(prime.begin(), prime.end());
  vector<int> other;
  for (auto p : prime) {
    int cnt = 0;
    vector<int> v;
    for (int i = p; i <= n; i += p) {
      if (vis2[i]) {
        continue;
      }
      vis2[i] = true;
      v.push_back(i);
      cnt += 1;
    }
    if (cnt == 1) {
      continue;
    }
    if (cnt % 2 == 0) {
    } else {
      other.push_back(v[1]);
      swap(v[1], v[cnt - 1]);
    }
    for (int i = 0; i + 1 < cnt; i += 2) {
      ans.push_back(make_pair(v[i], v[i + 1]));
    }
  }
  for (int i = 0; i + 1 < other.size(); i += 2) {
    ans.push_back(make_pair(other[i], other[i + 1]));
  }
  cout << ans.size() << endl;
  for (auto it : ans) {
    cout << it.first << " " << it.second << endl;
  }
}
