#include <bits/stdc++.h>
using namespace std;
int p[100005];
int main() {
  int n, i, j;
  cin >> n;
  vector<pair<int, int> > ans;
  vector<int> temp;
  for (i = 3; i <= n; i++) {
    if (p[i] == 1 || i % 2 == 0) continue;
    int cnt = 0;
    temp.clear();
    for (j = i; j <= n; j += i) {
      if (p[j] == 0) {
        p[j] = 1;
        cnt++;
        temp.push_back(j);
      }
    }
    if (cnt % 2 == 0) {
      for (int k = 0; k < temp.size() - 1; k += 2) {
        ans.push_back(make_pair(temp[k], temp[k + 1]));
      }
    } else {
      for (int k = 0; k < temp.size() - 1; k += 2) {
        if (k == 0) {
          ans.push_back(make_pair(temp[k], temp[k + 2]));
          p[temp[k + 1]] = 0;
          k++;
        } else
          ans.push_back(make_pair(temp[k], temp[k + 1]));
      }
    }
  }
  temp.clear();
  for (i = 2; i <= n; i++) {
    if (i % 2 == 0 && p[i] == 0) temp.push_back(i);
  }
  for (i = 0; i < (int)(temp.size()) - 1; i += 2) {
    ans.push_back(make_pair(temp[i], temp[i + 1]));
  }
  cout << ans.size() << endl;
  for (i = 0; i < ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
}
