#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 100500;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  vector<bool> sieve(MAXN, true);
  sieve[1] = false;
  long long n;
  cin >> n;
  vector<bool> used(MAXN, false);
  vector<long long> trsh;
  vector<pair<long long, long long>> ans;
  vector<long long> primes;
  for (long long p = 2; p <= n / 2; p++) {
    if (sieve[p]) {
      for (long long q = p + p; q <= n; q += p) sieve[q] = false;
      primes.push_back(p);
    }
  }
  reverse(primes.begin(), primes.end());
  for (auto x : primes) {
    used[x] = true;
    vector<long long> php;
    for (long long q = x + x; q <= n; q += x) {
      if (!used[q]) {
        used[q] = true;
        php.push_back(q);
      }
    }
    php.push_back(x);
    if (php.size() % 2 == 0) {
      for (long long i = 0; i < php.size(); i += 2)
        ans.push_back({php[i], php[i + 1]});
    } else {
      trsh.push_back(php.front());
      for (long long i = 1; i < (long long)php.size() - 1; i += 2)
        ans.push_back({php[i], php[i + 1]});
    }
  }
  for (long long i = 0; i < (long long)trsh.size() - 1; i += 2)
    ans.push_back({trsh[i], trsh[i + 1]});
  cout << ans.size() << '\n';
  for (auto p : ans) {
    cout << p.first << ' ' << p.second << '\n';
  }
}
