#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
bool cmp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
int N = 1100;
vector<char> is_prime(N + 1, true);
vector<int> v;
void prime() {
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= N; i++) {
    if (is_prime[i] && (long long)i * i <= N) {
      for (int j = i * i; j <= N; j += i) is_prime[j] = false;
    }
  }
  for (int i = 2; i <= N; i++) {
    if (is_prime[i]) v.push_back(i);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  prime();
  int n;
  cin >> n;
  vector<pair<int, int> > ans;
  for (int i = 1; i < n; i++) {
    ans.push_back(make_pair(i, i + 1));
  }
  ans.push_back(make_pair(n, 1));
  int x = n;
  int j = lower_bound(v.begin(), v.end(), x) - v.begin();
  int ant = v[j];
  j = v[j] - n;
  int s = 1, d = 3;
  int noe[n + 1];
  for (int i = 0; i <= n; i++) noe[i] = 2;
  while (j != 0) {
    int y;
    for (int i = 2 + j; i >= 2; i--) {
      if (is_prime[i]) {
        y = i;
        break;
      }
    }
    y = y - 2;
    j -= y;
    for (int i = 0; i < y; i++) {
      noe[s]++;
      noe[d]++;
      ans.push_back(make_pair(s, d++));
    }
    for (int i = 1; i <= n; i++) {
      if (noe[i] == 2) {
        s = i;
        break;
      }
    }
    for (int i = s + 2; i <= n; i++) {
      if (noe[i] == 2) {
        d = i;
        break;
      }
    }
  }
  cout << ant << "\n";
  for (int i = 0; i < ant; i++) {
    cout << ans[i].first << " " << ans[i].second << "\n";
  }
}
