#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
const long long mod = 1e9 + 7;
const int oo = 0x7fffffff;
const int sup = 0x80000000;
template <typename it>
void db(it *begin, it *end) {
  while (begin != end) cout << (*begin++) << " ";
  puts("");
}
template <typename it>
string to_str(it n) {
  string s = "";
  while (n) s += n % 10 + '0', n /= 10;
  reverse(s.begin(), s.end());
  return s;
}
template <typename it>
int o(it a) {
  cout << a << endl;
  return 0;
}
long long mul(long long a, long long b, long long c) {
  long long ans = 0;
  for (; b; b >>= 1, a = (a + a) % c)
    if (b & 1) ans = (ans + a) % c;
  return ans;
}
long long ksm(long long a, long long b, long long c) {
  long long ans = 1;
  for (; b; b >>= 1, a = mul(a, a, c))
    if (b & 1) ans = mul(ans, a, c);
  return ans;
}
int p[N] = {0};
vector<int> prime;
void pre() {
  p[1] = 1;
  for (int i = 2; i < N; i++) {
    if (!p[i]) prime.push_back(i);
    int sz = prime.size();
    for (int j = 0; j < sz && prime[j] * i < N; j++) {
      p[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
    }
  }
}
int main() {
  pre();
  int n;
  cin >> n;
  if (!p[n]) {
    o(n);
    cout << 1 << " " << n << endl;
    for (int i = 2; i <= n; i++) cout << i - 1 << " " << i << endl;
    return 0;
  }
  int x = 0;
  for (int i = n;; i++)
    if (!p[i]) {
      x = i;
      break;
    }
  o(x);
  cout << 1 << " " << n << endl;
  for (int i = 2; i <= n; i++) cout << i << " " << i - 1 << endl;
  x -= n;
  for (int i = 2; i < n; i++) {
    cout << i << " " << n - i + 2 << endl;
    x--;
    if (!x) return 0;
  }
}
