#include <bits/stdc++.h>
using namespace std;
const int maxn = 1020;
const int maxm = 100;
const int inf = 2147483647;
const double eps = 1e-9;
const long long INF = 9223372036854775807ll;
long long qpow(long long a, long long b, long long c) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % c;
    a = a * a % c;
    b >>= 1;
  }
  return ans;
}
int flag[maxn], prim[maxn], tot;
void init() {
  for (register int i = (2); i < (maxn); ++i) {
    if (!flag[i]) prim[tot++] = i;
    for (register int j = 0; j < tot && prim[j] * i < maxn; ++j) {
      flag[i * prim[j]] = 1;
      if (i % prim[j] == 0) break;
    }
  }
}
int main() {
  int n;
  init();
  scanf("%d", &n);
  int p = lower_bound(prim, prim + tot, n) - prim;
  int k = prim[p] - n;
  printf("%d\n", prim[p]);
  for (register int i = (1); i < (n + 1); ++i) {
    if (i != n)
      printf("%d %d\n", i, i + 1);
    else
      printf("%d %d\n", n, 1);
  }
  for (register int i = (0); i < (k); ++i) {
    printf("%d %d\n", i + 1, (i + n / 2) % n + 1);
  }
}
