#include <bits/stdc++.h>
using namespace std;
const long long int mod = 998244353;
vector<long long int> prime;
long long int n = 1000001;
vector<bool> vis(n, true);
void sieve() {
  vis[0] = vis[1] = false;
  for (long long int i = 2; i * i <= n; i++)
    if (vis[i])
      for (long long int j = i * i; j <= n; j += i) vis[j] = false;
  for (long long int i = 2; i <= n; i++)
    if (vis[i]) prime.push_back(i);
}
bool check(long long int n, long long int k) {
  if (n < 2 * k) return false;
  if (k == 1) return vis[n];
  if (k == 2) {
    if (n % 2) return vis[n - 2];
    return true;
  }
  return true;
}
int32_t main() {
  sieve();
  long long int n;
  cin >> n;
  for (auto it = lower_bound(prime.begin(), prime.end(), n); it != prime.end();
       it++) {
    if (*it > ((n * (n - 1)) >> 1)) break;
    if (!check((*it) << 1, n)) continue;
    long long int m = *it;
    cout << m << endl;
    m -= n;
    for (long long int i = 1; i <= n; i++) {
      long long int z = i + 1;
      if (z > n) z = 1;
      cout << i << " " << z << endl;
    }
    long long int diff = 2, init = (n >> 1) + (n & 1);
    while (m--) {
      cout << init << " " << init + diff << endl;
      diff += 2;
      init--;
    }
    return 0;
  }
  cout << "-1";
  return 0;
}
