#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
const long long int inf = 1000000000000000000;
#pragma GCC optimize("-O3")
long long int gen() {
  long long int temp;
  cin >> temp;
  return temp;
}
long long int power(long long int a, long long int b, long long int m) {
  long long int res = 1;
  a %= m;
  while (b > 0) {
    if (b & 1) {
      res = (res * a) % m;
      b--;
    }
    a = (a * a) % m;
    b = b >> 1;
  }
  return res;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
long long int getNearestPrime(long long int num) {
  while (true) {
    bool flag = true;
    for (long long int i = 2; i * i <= num; i++) {
      if (num % i == 0) {
        flag = false;
        break;
      }
    }
    if (flag) break;
    num++;
  }
  return num;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int> > edj;
  for (long long int i = 1; i < n; i += 1) edj.push_back({i, i + 1});
  edj.push_back({n, 1});
  long long int pr = getNearestPrime(edj.size());
  long long int dif = pr - edj.size();
  long long int st = 1;
  while (dif) {
    edj.push_back({st, st + 2});
    dif--;
    if (dif) {
      edj.push_back({st + 1, st + 3});
      dif--;
    }
    st += 4;
  }
  cout << edj.size() << "\n";
  for (long long int i = 0; i < edj.size(); i += 1)
    cout << edj[i].first << " " << edj[i].second << "\n";
  return 0;
}
