#include <bits/stdc++.h>
using std::lower_bound;
template <class T>
inline T max(T a, T b) {
  return a < b ? b : a;
}
const int maxn = 1e4 + 1000;
int v[maxn], prime[maxn], cnt;
bool isprime[maxn];
inline void sieve(int n) {
  for (int i = 2; i <= n; ++i) {
    if (!v[i]) {
      v[i] = i;
      prime[++cnt] = i;
    }
    for (int j = 1; j <= cnt; ++j) {
      if (prime[j] > v[i] || i * prime[j] > n) break;
      v[i * prime[j]] = prime[j];
    }
  }
  for (int i = 1; i <= cnt; ++i) isprime[prime[i]] = true;
}
int main() {
  int n;
  scanf("%d", &n);
  sieve(1.5 * n + 100);
  if (isprime[n]) {
    printf("%d\n", n);
    for (int i = 1; i < n; ++i) printf("%d %d\n", i, i + 1);
    printf("%d %d\n", 1, n);
    return 0;
  }
  int p = *lower_bound(prime + 1, prime + cnt + 1, n);
  printf("%d\n", p);
  for (int i = 1; i < n; ++i) printf("%d %d\n", i, i + 1);
  printf("%d %d\n", 1, n);
  for (int i = 1; i <= p - n; ++i) printf("%d %d\n", i, n - i);
}
