#include <bits/stdc++.h>
std::vector<int> degs;
std::vector<std::pair<int, int> > edges;
std::vector<char> notPrime;
void init(int n) {
  degs = std::vector<int>(n, 0);
  notPrime = std::vector<char>(2 * n, 0);
  for (unsigned i = 2; i <= notPrime.size(); i++) {
    if (notPrime[i] > 0) continue;
    for (unsigned j = i + i; j < notPrime.size(); j += i) notPrime[j] = 1;
  }
}
void solve(int n) {
  for (int i = 0; i < n - 1; i++) {
    edges.push_back({i, i + 1});
  }
  edges.push_back({n - 1, 0});
  unsigned tot_edges = edges.size();
  int pos = 0, jump = 1;
  while (notPrime[tot_edges] && pos + 2 < n) {
    edges.push_back({pos, pos + 2});
    tot_edges++;
    pos += jump;
    if (jump == 1)
      jump = 3;
    else
      jump = 1;
  }
}
int main(int argc, char const* argv[]) {
  int n;
  scanf("%d", &n);
  init(n);
  solve(n);
  printf("%d\n", edges.size());
  for (const std::pair<int, int>& e : edges) {
    printf("%d %d\n", e.first + 1, e.second + 1);
  }
  return 0;
}
