#include <bits/stdc++.h>
using namespace std;
vector<int> prime, fact[100100];
map<int, int> slot;
int G(int a, int b) {
  if (a < b) swap(a, b);
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
void pre_compute() {
  prime.push_back(2);
  slot[2] = 0;
  int i, j;
  for (i = 3; i < 100100; i++) {
    for (j = 0; j < prime.size(); j++) {
      if (i % prime[j] == 0) {
        break;
      } else if (prime[j] * prime[j] > i) {
        j = prime.size();
        break;
      }
    }
    if (j == prime.size()) {
      slot[i] = prime.size();
      prime.push_back(i);
    }
  }
}
int calc(int n) {
  int i, j, N = n, cnt = 0;
  for (i = 0; i < prime.size(); i++) {
    if (n % prime[i] == 0) {
      cnt++;
      fact[N].push_back(slot[prime[i]]);
      while (n % prime[i] == 0) {
        n /= prime[i];
      }
    } else if (prime[i] * prime[i] > n && n != 1) {
      fact[N].push_back(slot[n]);
      cnt++;
      return cnt;
    } else if (n == 1) {
      return cnt;
    }
  }
  return cnt;
}
int main() {
  pre_compute();
  int i, j, k, n, ele, mn, id, cnt;
  set<pair<int, int> > s, srch[100100];
  set<pair<int, int> >::iterator it1, it2;
  vector<pair<int, int> > v;
  scanf("%d", &n);
  for (i = 2; i <= n; i++) {
    cnt = calc(i);
    for (j = 0; j < fact[i].size(); j++) {
      srch[fact[i][j]].insert(make_pair(cnt, i));
    }
    s.insert(make_pair(cnt, i));
  }
  pair<int, int> ii, jj;
  it1 = s.begin();
  while (it1 != s.end()) {
    ii = *it1;
    ele = ii.second;
    mn = 100000000;
    id = -1;
    for (i = 0; i < fact[ele].size(); i++) {
      srch[fact[ele][i]].erase(ii);
      if (srch[fact[ele][i]].size() > 0) {
        it2 = srch[fact[ele][i]].begin();
        jj = *it2;
        if (jj.first < mn) {
          mn = jj.first;
          id = jj.second;
        }
      }
    }
    if (id == -1) {
      s.erase(ii);
    } else {
      v.push_back(make_pair(ii.second, id));
      for (i = 0; i < fact[id].size(); i++) {
        srch[fact[id][i]].erase(make_pair(mn, id));
      }
      s.erase(ii);
      s.erase(make_pair(mn, id));
    }
    it1 = s.begin();
  }
  printf("%d\n", v.size());
  for (i = 0; i < v.size(); i++) {
    printf("%d %d\n", v[i].first, v[i].second);
  }
}
