#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> used(n + 1);
  vector<pair<long long, long long>> ans;
  vector<long long> kek;
  for (long long i = 3; i <= n; i++) {
    if (used[i] || i % 2 == 0) continue;
    kek.clear();
    kek.push_back(i);
    for (long long j = i + i; j <= n; j += i) {
      if (used[j]) continue;
      kek.push_back(j);
    }
    if ((long long)kek.size() == 1) continue;
    if ((long long)kek.size() % 2 == 1) {
      assert(kek[1] == 2 * i);
      kek.erase(kek.begin() + 1);
    }
    for (long long j = 0; j < (long long)kek.size(); j += 2) {
      used[kek[j]] = used[kek[j + 1]] = 1;
      ans.push_back(make_pair(kek[j], kek[j + 1]));
    }
  }
  kek.clear();
  for (long long i = 2; i <= n; i += 2) {
    if (!used[i]) kek.push_back(i);
  }
  for (long long i = 1; i < (long long)kek.size(); i += 2) {
    ans.push_back(make_pair(kek[i - 1], kek[i]));
  }
  cout << (long long)ans.size() << '\n';
  for (auto i : ans) {
    cout << i.first << ' ' << i.second << '\n';
  }
}
