#include <bits/stdc++.h>
int notprime[1500];
int main(void) {
  int n;
  int mark;
  scanf("%d", &n);
  int k, l;
  if (n == 3) {
    printf("3\n");
    printf("1 2\n");
    printf("2 3\n");
    printf("3 1\n");
  } else if (n == 4) {
    printf("5\n");
    printf("1 2\n");
    printf("1 3\n");
    printf("2 3\n");
    printf("2 4\n");
    printf("3 4\n");
  } else if (n == 5) {
    printf("5\n");
    for (int i = 1; i <= 4; i++) {
      printf("%d %d\n", i, i + 1);
    }
    printf("5 1\n");
  } else {
    k = (n / 2);
    l = (n - k);
    for (int i = 2; i * i < 1500; i++) {
      for (int j = 2; j * i <= 1500; j++) {
        notprime[i * j] = 1;
      }
    }
    for (int i = n; i <= (3 * n / 2) && mark == 0; i++) {
      if (notprime[i] == 0) {
        mark = i;
      }
    }
    printf("%d\n", mark);
    for (int i = 1; i < k; i++) {
      printf("%d %d\n", i, i + 1);
    }
    printf("%d %d\n", k, 1);
    for (int i = 1; i < l; i++) {
      printf("%d %d\n", k + i, k + i + 1);
    }
    printf("%d %d\n", k + l, k + 1);
    for (int i = 1; i <= (mark - n); i++) {
      printf("%d %d\n", i, i + k);
    }
  }
}
