#include <bits/stdc++.h>
using namespace std;
long long n;
bool not_prime[10000 + 5];
bool appr[10000 + 5];
vector<long long> primes;
signed main() {
  for (long long i = 2; i <= 10000; i++) {
    if (!not_prime[i]) {
      primes.push_back(i);
    }
    for (long long j = 0; j < primes.size() && i * primes[j] <= 10000; j++) {
      not_prime[i * primes[j]] = 1;
      if (i % primes[j] == 0) break;
    }
  }
  cin >> n;
  if (!not_prime[n]) {
    cout << n << endl;
    for (long long i = 1; i < n; i++) {
      cout << i << " " << i + 1 << endl;
    }
    cout << n << " " << 1 << endl;
  } else {
    long long k = 0;
    while (not_prime[n + k]) k++;
    cout << n + k << endl;
    for (long long i = 1; i < n; i++) {
      cout << i << " " << i + 1 << endl;
    }
    cout << n << " " << 1 << endl;
    long long i = 1;
    while (k) {
      while (appr[i]) i++;
      cout << i << " " << i + 2 << endl;
      appr[i] = appr[i + 2] = 1;
      k--, i++;
    }
  }
  return 0;
}
