#include <bits/stdc++.h>
using namespace std;
bool status[500005];
vector<int> primes;
void sieve() {
  long long N = 500002, i, sq, j;
  sq = sqrt(N);
  for (i = 4; i <= N; i += 2) status[i] = 1;
  for (i = 3; i <= sq; i += 2)
    if (status[i] == 0)
      for (j = i * i; j <= N; j += i) status[j] = 1;
  status[1] = 1;
  for (int i = 1; i < N; i++)
    if (!status[i]) primes.push_back(i);
}
int main() {
  sieve();
  vector<int> graph[1005];
  int n, edges = 0;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    graph[i - 1].push_back(i);
    edges++;
  }
  graph[1].push_back(n);
  edges++;
  int x = *upper_bound(primes.begin(), primes.end(), edges);
  if (!status[edges]) x = edges;
  for (int i = 1; i <= n && edges < x; i++) {
    graph[i].push_back(n - i);
    edges++;
  }
  cout << edges << endl;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < graph[i].size(); j++)
      cout << i << " " << graph[i][j] << endl;
  }
  return 0;
}
