#include <bits/stdc++.h>
bool debug = true;
using namespace std;
static auto start = chrono::high_resolution_clock::now();
int prime(int n) {
  int i, j;
  for (i = 2; i * i <= n; i++) {
    if (!(n % i)) return 0;
  }
  return 1;
}
int main(void) {
  if (0) {
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
  }
  int i, j, k, n, m, mx;
  scanf("%d", &n);
  m = n;
  mx = (n * (n - 1)) >> 1;
  for (; m <= mx; m++) {
    if (prime(m)) break;
  }
  printf("%d\n", m);
  for (i = 0; i < n; i++) {
    printf("%d %d\n", i + 1, ((i + 1) % n) + 1);
  }
  m -= n;
  vector<int> vis(n);
  for (i = 0; i < n - 2; i++) {
    if (!m) break;
    if (!vis[i]) {
      vis[i + 2] = true;
      printf("%d %d\n", i + 1, i + 3);
      m--;
    }
  }
  auto stop = chrono::high_resolution_clock::now();
  auto duration = chrono::duration_cast<chrono::microseconds>(stop - start);
  if (0) {
    printf("Time in seconds: %.6lf\n", (double)duration.count() / 1000000);
  }
}
