#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
int a[500004];
vector<int> prime;
void Prime_seive() {
  a[0] = a[1] = 1;
  for (int i = 2; i * i <= 500000; i++) {
    if (a[i] == 0) {
      for (int j = 2 * i; j <= 500000; j += i) {
        a[j] = 1;
      }
    }
  }
  for (int i = 2; i <= 500000; i++) {
    if (a[i] == 0) prime.push_back(i);
  }
}
void testCase() {
  Prime_seive();
  int n;
  cin >> n;
  int edge = n;
  int indx = lower_bound(prime.begin(), prime.end(), edge) - prime.begin();
  int left = prime[indx] - edge;
  cout << prime[indx] << "\n";
  for (int i = 1; i < n; i++) {
    cout << i << " " << i + 1 << "\n";
  }
  cout << n << " " << 1 << "\n";
  vector<pair<int, int> > new_edge;
  for (int i = 1; i <= n; i += 4) {
    new_edge.push_back(make_pair(i, i + 2));
    new_edge.push_back(make_pair(i + 1, i + 3));
  }
  for (int i = 0; i < left; i++) {
    cout << new_edge[i].first << " " << new_edge[i].second << "\n";
  }
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  testCase();
  return 0;
}
