#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<bool> is_prime(N * N, false);
  for (int i = 2; i <= N * (N - 1) / 2; i++) {
    bool is_ok = true;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0) {
        is_ok = false;
        break;
      }
    }
    if (is_ok) is_prime[i] = true;
  }
  vector<int> cnt(N, 0);
  map<pair<int, int>, bool> is_used;
  vector<pair<int, int> > edge;
  for (int i = 0; i < N; i++) {
    int from = i + 1, to = (i + 1) % N + 1;
    if (from > to) swap(from, to);
    edge.push_back(pair<int, int>(from, to));
    is_used[pair<int, int>(from, to)] = true;
    cnt[from - 1]++;
    cnt[to - 1]++;
  }
  for (int i = 0; i < N; i++) {
    if (is_prime[edge.size()]) break;
    int from = i + 1, to = (i + 2) % N + 1;
    if (from > to) swap(from, to);
    if (is_used[pair<int, int>(from, to)]) continue;
    if (!is_prime[cnt[from - 1] + 1] || !is_prime[cnt[to - 1] + 1]) continue;
    edge.push_back(pair<int, int>(from, to));
    cnt[from - 1]++;
    cnt[to - 1]++;
  }
  cout << edge.size() << endl;
  for (int i = 0; i < edge.size(); i++) {
    cout << edge[i].first << ' ' << edge[i].second << endl;
  }
  return 0;
}
