#include <bits/stdc++.h>
using namespace std;
int a[1001000];
vector<pair<int, int> > v;
int main() {
  for (int i = 2; i <= 1000000; i++) {
    if (a[i] == 1) continue;
    for (int j = i + i; j <= 1000000; j += i) {
      a[j] = 1;
    }
  }
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    v.push_back(make_pair(i, i + 1));
  }
  v.push_back(make_pair(1, n));
  if (a[n] != 0) {
    int x = -1;
    for (int i = n + 1; i <= n + n / 2; i++) {
      if (a[i] == 0) {
        x = i;
        break;
      }
    }
    x = x - n;
    int e = n - 1;
    for (int i = 1; i < n / 2 && x > 0; i++, e--, x--) {
      v.push_back(make_pair(i, e));
    }
    if (x == 1) {
      v.push_back(make_pair(n, n / 2));
    }
  }
  cout << v.size() << "\n";
  for (int i = 0; i < v.size(); i++) {
    cout << v[i].first << " " << v[i].second << "\n";
  }
  return 0;
}
