#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
set<long long> s;
set<int> si;
set<long long>::iterator it;
vector<long long> v;
vector<int> vi;
int n, m, q, k;
int a[200005];
int chk[200005];
void prime() {
  int i, j;
  for (i = 2; i <= 200005; i++) {
    if (chk[i] == 0) {
      chk[i] = i;
      for (j = 2; j * i <= 200005; j++) {
        if (!chk[j * i]) chk[j * i] = i;
      }
    }
  }
}
int main() {
  int i, j, t;
  prime();
  ;
  scanf("%d", &n);
  ;
  int ans = 0;
  for (i = n;; i++) {
    if (chk[i] == i) {
      ans = i;
      break;
    }
  }
  int edges = ans * 2;
  int extra = edges - n * 2;
  set<pair<int, int> > s;
  set<pair<int, int> >::iterator it;
  for (i = 1; i <= n; i++) {
    a[i] = 2;
    if (extra) {
      extra--;
      a[i]++;
    }
    s.insert(make_pair(-1 * a[i], i));
  }
  printf("%d\n", ans);
  for (i = 1; i <= n; i++) {
    set<pair<int, int> > temp;
    set<pair<int, int> >::iterator tempit, orit;
    int originalcount = a[i];
    orit = s.find(make_pair(-1 * a[i], i));
    if (orit != s.end()) s.erase(orit);
    while (a[i] > 0) {
      it = s.begin();
      int element = it->second;
      int count = -1 * it->first;
      printf("%d %d\n", i, element);
      a[element]--;
      count--;
      a[i]--;
      s.erase(it);
      if (count) {
        temp.insert(make_pair(-1 * count, element));
      }
    }
    for (tempit = temp.begin(); tempit != temp.end(); tempit++) {
      int element = tempit->second;
      int count = -1 * tempit->first;
      s.insert(make_pair(-1 * count, element));
    }
  }
  return 0;
}
