#include <bits/stdc++.h>
using namespace std;
bool is_prime(int x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) return false;
  }
  return true;
}
set<pair<int, int>> st;
void validate(vector<pair<int, int>> edges, int n) {
  assert(is_prime(edges.size()));
  for (auto e : edges) {
    if (e.first == e.second) assert(false);
    if (e.first > e.second) swap(e.first, e.second);
    st.insert(e);
  }
  assert(st.size() == edges.size());
  vector<int> degree(n + 1, 0);
  for (auto &e : edges) {
    degree[e.first] += 1;
    degree[e.second] += 1;
  }
  for (int i = 1; i <= n; i++) {
    assert(is_prime(degree[i]));
  }
  fprintf(stderr, "everything is fine\n");
}
void solve(int n) {
  vector<pair<int, int>> edges;
  for (int i = 1; i <= n - 1; i++) {
    edges.push_back({i, i + 1});
  }
  edges.push_back({n, 1});
  int l = 1, r = l + n / 2;
  while (!is_prime((int)edges.size())) {
    edges.push_back({l, r});
    l += 1;
    r += 1;
  }
  validate(edges, n);
  printf("%d\n", (int)edges.size());
  for (auto &p : edges) printf("%d %d\n", p.first, p.second);
}
int main() {
  int n;
  scanf("%d", &n);
  solve(n);
}
