#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  int i, j, k, l, n, test_case, m, r;
  test_case = 1;
  while (test_case--) {
    cin >> n;
    int deg[n + 1];
    memset(deg, 0, sizeof deg);
    vector<bool> is_prime(n + n + n, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= 3 * n; i++) {
      if (is_prime[i] && (long long)i * i <= 3 * n) {
        for (int j = i * i; j <= 3 * n; j += i) is_prime[j] = false;
      }
    }
    i = n;
    while (!is_prime[i]) {
      i++;
    }
    vector<int> vec[n + 1];
    for (i = 1; i < n + 1; i++) {
      if (i == n) {
        deg[i]++;
        deg[1]++;
        vec[i].push_back(1);
      } else {
        deg[i]++;
        deg[i + 1]++;
        vec[i].push_back(i + 1);
      }
    }
    i = 1;
    int cnt = 0;
    while (!is_prime[cnt + n] && cnt < (n / 2)) {
      deg[i]++;
      deg[i + n / 2]++;
      vec[i].push_back(i + n / 2);
      i++;
      cnt++;
    }
    if (is_prime[cnt + n]) {
      cout << cnt + n << "\n";
      int cncn = 0;
      for (i = 1; i <= n; i++) {
        for (auto it : vec[i]) {
          cncn++;
          cout << i << " " << it << "\n";
        }
      }
    } else {
      cout << "-1\n";
    }
  }
  return 0;
}
