#include <bits/stdc++.h>
using namespace std;
vector<int> cal_prime(int max) {
  vector<int> res;
  res.push_back(2);
  for (int i = 3; i <= max; ++i) {
    int j = 0;
    int ubound = sqrt(i);
    bool check = true;
    while (res[j] <= ubound) {
      if (i % res[j] == 0) {
        check = false;
        break;
      }
      j++;
    }
    if (check) res.push_back(i);
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  int cnt;
  int res;
  vector<int> prime = cal_prime(n * (n - 1) / 2);
  if (binary_search(prime.begin(), prime.end(), n))
    res = n;
  else
    res = prime[upper_bound(prime.begin(), prime.end(), n) - prime.begin()];
  cnt = res - n;
  cout << res << endl;
  for (int i = 1; i <= n - 1; ++i) {
    cout << i << " " << i + 1 << endl;
    if ((i % 4 == 1 || i % 4 == 2) && cnt > 0) {
      cout << i << " " << i + 2 << endl;
      cnt--;
    }
  }
  cout << n << " " << 1;
  return 0;
}
