#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
using namespace std;
bool isvowel(char c) {
  c = tolower(c);
  if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u')
    return 1;
  return 0;
}
const double eps = 0.000001;
const long double pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const long long MOD = 1e18 + 9;
const long long INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 3e5 + 123;
const int PRI = 555557;
const int pri = 997;
const int Magic = 2101;
int n, m, k;
int a[N];
bool u[N];
vector<int> g[N];
vector<pair<int, int> > ans;
void dfs(int x) {
  u[x] = 1;
  vector<int> cur;
  for (int to : g[x]) {
    if (!u[to]) {
      dfs(to);
      if (a[to] == 0) cur.push_back(to);
    } else if (a[to] == 0)
      cur.push_back(to);
  }
  if (cur.size() % 2 == 0) {
    for (int i = 0; i < cur.size(); i += 2) {
      ans.push_back(make_pair(cur[i], cur[i + 1]));
      a[cur[i]] = 1;
      a[cur[i + 1]] = 1;
    }
    a[x] = 0;
  } else {
    for (int i = 1; i < cur.size(); i += 2) {
      ans.push_back(make_pair(cur[i], cur[i + 1]));
      a[cur[i]] = 1;
      a[cur[i + 1]] = 1;
    }
    a[cur[0]] = 1;
    a[x] = 1;
    ans.push_back(make_pair(x, cur[0]));
  }
}
inline void Solve() {
  cin >> n;
  for (int i = 2; i <= n; i++) {
    a[i] = -1;
    for (int j = i + i; j <= n; j += i) {
      g[i].emplace_back(j);
      g[j].emplace_back(i);
    }
  }
  if (n > 1) dfs(2);
  cout << ans.size() << '\n';
  for (auto x : ans) cout << x.first << ' ' << x.second << '\n';
}
int main() {
  int tests = 1;
  ios_base::sync_with_stdio(0), cin.tie(0);
  while (tests--) {
    Solve();
  }
  return 0;
}
