#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
bool v[maxn], v1[maxn];
void primes(int n) {
  for (int i = 2; i <= n; i++) {
    if (v[i]) continue;
    for (int j = i; j <= n / i; j++) v[i * j] = 1;
  }
}
vector<pair<int, int> > ans;
int main() {
  int n;
  scanf("%d", &n);
  primes(3010);
  for (int i = 1; i + 2 <= n; i += 3) {
    ans.push_back(make_pair(i, i + 1));
    ans.push_back(make_pair(i + 1, i + 2));
    ans.push_back(make_pair(i + 2, i));
  }
  if (n % 3 == 1) {
    ans.push_back(make_pair(n - 1, n));
    ans.push_back(make_pair(n - 2, n));
    v1[n - 1] = v1[n - 2];
  } else if (n % 3 == 2) {
    ans.push_back(make_pair(n - 2, n));
    ans.push_back(make_pair(n - 3, n - 1));
    ans.push_back(make_pair(n - 1, n));
    v1[n - 3] = v1[n - 2] = 1;
  }
  if (n == 7) {
    printf("11\n");
    for (int i = 0; i < ans.size(); i++) {
      printf("%d %d\n", ans[i].first, ans[i].second);
    }
    printf("1 4\n2 4\n3 4\n");
    return 0;
  }
  int pos = 1, pos1 = 4;
  while (v[ans.size()]) {
    while (v1[pos]) pos++;
    while (v1[pos1] || pos1 < pos + 3) pos1++;
    ans.push_back(make_pair(pos, pos1));
    v1[pos] = 1;
    v1[pos1] = 1;
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
}
