#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int p = n + 101;
  bool prime[p];
  memset(prime, true, sizeof(prime));
  prime[0] = false;
  prime[1] = false;
  for (int i = 2; i * i < p; i++) {
    if (prime[i] == true) {
      for (int j = i * 2; j < p; j += i) prime[j] = false;
    }
  }
  if (prime[n] == true) {
    cout << n << endl;
    for (int i = 2; i <= n; i++) cout << i << " " << i - 1 << endl;
    cout << 1 << " " << n << endl;
    return 0;
  } else if (n == 4) {
    cout << 5 << endl;
    cout << 1 << " " << 2 << endl
         << 1 << " " << 3 << endl
         << 2 << " " << 3 << endl
         << 2 << " " << 4 << endl
         << 3 << " " << 4 << endl;
  } else if (n % 2 == 0) {
    int need;
    for (int j = n + 1;; j++) {
      if (prime[j] == true) {
        need = j - n;
        break;
      }
    }
    cout << n + need << endl;
    for (int j = 1; j < n; j++) cout << j << " " << j + 1 << endl;
    cout << 1 << " " << n << endl;
    for (int j = 1; j <= (n) / 2 && need > 0; j++) {
      cout << j << " " << ((n) / 2) + j << endl;
      need--;
    }
    return 0;
  } else {
    int need;
    for (int i = n + 1;; i++) {
      if (prime[i] == true) {
        need = i - n;
        break;
      }
    }
    cout << n + need << endl;
    for (int i = 1; i < n; i++) cout << i << " " << i + 1 << endl;
    cout << 1 << " " << n << endl;
    for (int j = 1; j <= (n) / 2 && need > 0; j++) {
      cout << j << " " << ((n) / 2) + j << endl;
      need--;
    }
  }
  return 0;
}
