#include <bits/stdc++.h>
using namespace std;
string s;
const long long MOD = 998244353;
set<int> primes;
int isprime(int p) {
  if (p == 1) return 0;
  for (int i = 2; i < p - 1; i++) {
    if (p % i == 0) return 0;
  }
  return 1;
}
void f(int x, int y) { cout << x << ' ' << y << endl; }
void answer(int n) {
  int b = 0;
  if (n % 2 == 1) {
    for (int x = 0; x * 4 <= n; x++) {
      int k = n - 4 * x;
      if (primes.count(k + 6 * x) && (k != 2) && (k != 1)) {
        b = 1;
        cout << k + 6 * x << endl;
        for (int i = 0; i < x; i++) {
          for (int j = 1; j <= 4; j++) {
            for (int k = j + 1; k <= 4; k++) {
              cout << 4 * i + j << " " << 4 * i + k << endl;
            }
          }
        }
        for (int i = 4 * x + 1; i < n; i++) {
          cout << i << ' ' << i + 1 << endl;
        }
        cout << n << ' ' << 4 * x + 1 << endl;
        break;
      }
    }
  } else {
    if (n == 8 || n == 14) {
      if (n == 8) {
        cout << 13 << endl;
        cout << 1 << ' ' << 2 << endl;
        cout << 1 << ' ' << 3 << endl;
        cout << 2 << ' ' << 3 << endl;
        cout << 1 << ' ' << 4 << endl;
        cout << 2 << ' ' << 4 << endl;
        cout << 1 << ' ' << 5 << endl;
        cout << 2 << ' ' << 5 << endl;
        cout << 1 << ' ' << 6 << endl;
        cout << 2 << ' ' << 6 << endl;
        cout << 1 << ' ' << 7 << endl;
        cout << 1 << ' ' << 8 << endl;
        cout << 5 << ' ' << 8 << endl;
        cout << 7 << ' ' << 8 << endl;
      } else {
        cout << 17 << endl;
        for (int i = 1; i <= 4; i++) {
          for (int j = i + 1; j <= 4; j++) {
            f(i, j);
          }
        }
        for (int i = 5; i <= 8; i++) {
          for (int j = i + 1; j <= 8; j++) {
            if (!(i == 7 && j == 8)) f(i, j);
          }
        }
        for (int i = 9; i <= 13; i++) f(i, i + 1);
        f(14, 9);
      }
    } else {
      for (int x = 0; x * 4 <= n; x++) {
        int k = n - 4 * x;
        if (primes.count(k + 5 * x) && (k != 1 && k != 2)) {
          b = 1;
          cout << k + 5 * x << endl;
          for (int i = 0; i < x; i++) {
            for (int j = 1; j <= 4; j++) {
              for (int k = j + 1; k <= 4; k++) {
                if (!(k == 4 && j == 3))
                  cout << 4 * i + j << " " << 4 * i + k << endl;
              }
            }
          }
          for (int i = 4 * x + 1; i < n; i++) {
            cout << i << ' ' << i + 1 << endl;
          }
          if (k >= 3) cout << n << ' ' << 4 * x + 1 << endl;
          break;
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (int i = 2; i < 6000; i++) {
    if (isprime(i)) primes.insert(i);
  }
  int n = 35;
  cin >> n;
  if (n == 6) {
    cout << 7 << endl;
    for (int i = 1; i <= 5; i++) f(i, i + 1);
    f(6, 1);
    f(1, 3);
  } else {
    answer(n);
  }
  return 0;
}
