#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ll;
typedef vector<int> vl;
typedef vector<ll> vll;
typedef vector<vl> vvl;
template <typename T>
ostream &operator<<(ostream &o, vector<T> v) {
  if (v.size() > 0) o << v[0];
  for (unsigned i = 1; i < v.size(); i++) o << " " << v[i];
  return o << "\n";
}
template <typename U, typename V>
ostream &operator<<(ostream &o, pair<U, V> p) {
  return o << "(" << p.first << ", " << p.second << ") ";
}
template <typename T>
istream &operator>>(istream &in, vector<T> &v) {
  for (unsigned i = 0; i < v.size(); i++) in >> v[i];
  return in;
}
template <typename T>
istream &operator>>(istream &in, pair<T, T> &p) {
  in >> p.first;
  in >> p.second;
  return in;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(20);
  int n;
  cin >> n;
  if (n < 4) {
    cout << "0";
    return 0;
  }
  vll ans;
  vl used(n + 1, 0);
  for (int it = 3; it <= n; it += 2)
    if (!used[it]) {
      vl temp;
      for (int i = it; i <= n; i += it)
        if (!used[i]) {
          used[i] = 1;
          temp.push_back((i));
        }
      int i = 0;
      if (temp.size() % 2 == 1 and temp.size() > 1) {
        ans.push_back((make_pair((temp[0]), (temp[2]))));
        used[temp[1]] = 0;
        i = 3;
      }
      for (i = i; i < temp.size() - 1; i += 2) {
        ans.push_back((make_pair((temp[i]), (temp[i + 1]))));
      }
    }
  vl temp;
  for (int i = (1); i < (int)n + 1; i++)
    if (!used[i] and i % 2 == 0) temp.push_back((i));
  for (int i = 0; i < temp.size() - 1; i += 2)
    ans.push_back((make_pair((temp[i]), (temp[i + 1]))));
  cout << ans.size() << "\n";
  for (auto it : ans) cout << it.first << " " << it.second << "\n";
  return 0;
}
