#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma GCC optimize "-O3"
bitset<100000> isPrime;
vector<vector<int> > g;
bool isOk() {
  int kol = 0;
  for (int i = 0; i < (g.size()); i++) {
    kol += g[i].size();
    if (isPrime[g[i].size()] == 1) return false;
  }
  if (isPrime[kol] == 1) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  if (n == 3) {
    cout << "3\n";
    cout << "1 2\n";
    cout << "1 3\n";
    cout << "2 3\n";
    return 0;
  }
  int m = 1e5;
  int x;
  isPrime[0] = 1;
  isPrime[1] = 1;
  for (int i = 2; i < m; i++) {
    if (isPrime[i] == 1) continue;
    for (x = i + i; x < m; x += i) {
      isPrime[x] = 1;
    }
  }
  g.resize(n);
  int kol = n;
  for (int i = 0; i < (n); i++) {
    g[i].push_back((i + 1) % n);
  }
  int cur = 0;
  while (true) {
    if (isPrime[kol] == 0) break;
    g[cur].push_back((cur + 2) % n);
    kol++;
    cur++;
    if (isPrime[kol] == 0) break;
    g[cur].push_back((cur + 2) % n);
    kol++;
    if (isPrime[kol] == 0) break;
    cur += 3;
  }
  cout << kol << "\n";
  for (int i = 0; i < (g.size()); i++) {
    for (int j = 0; j < (g[i].size()); j++)
      cout << i + 1 << " " << g[i][j] + 1 << "\n";
  }
}
