#include <bits/stdc++.h>
using namespace std;
int f[100100], vis[100100];
int main() {
  int n;
  while (cin >> n) {
    if (n <= 3) {
      puts("0");
      continue;
    }
    memset(vis, 0, sizeof(vis));
    memset(f, 0, sizeof(f));
    for (int i = 2; i <= n; i++)
      if (!f[i])
        for (int j = i; j <= n; j += i) f[j] = i;
    vector<pair<int, int> > ans;
    for (int i = n; i >= 2; i--)
      if (f[i] == i) {
        vector<int> tt;
        for (int j = i; j <= n; j += i)
          if (!vis[j]) tt.push_back(j);
        if (tt.size() == 1) continue;
        if (tt.size() % 2) swap(tt[1], tt[tt.size() - 1]);
        for (int i = 0; i + 1 < tt.size(); i += 2) {
          ans.push_back(make_pair(tt[i], tt[i + 1]));
          vis[tt[i]] = 1;
          vis[tt[i + 1]] = 1;
        }
      }
    cout << ans.size() << endl;
    for (auto s : ans) cout << s.first << " " << s.second << endl;
  }
  return 0;
}
