#include <bits/stdc++.h>
using namespace std;
bool isPrime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  long long int p;
  long long int p1;
  for (int i = n; i <= (n + n / 2); i++) {
    if (isPrime(i) == true) {
      p = i;
      break;
    }
  }
  p1 = p;
  int ans[p + 5][2];
  for (int i = 1; i <= n; i++) {
    if (i != n) {
      ans[i][0] = i;
      ans[i][1] = i + 1;
    } else {
      ans[i][0] = n;
      ans[i][1] = 1;
    }
    p--;
  }
  long long int pos = n + 1;
  long long int k1 = 1;
  long long int k2 = n - 1;
  for (int i = 1; i < n / 2; i++) {
    if (p == 0) {
      break;
    }
    ans[pos][0] = k1;
    ans[pos++][1] = k2;
    k1++;
    k2--;
    p--;
    if (p == 0) {
      break;
    }
  }
  if (p != 0) {
    ans[pos][0] = k1;
    ans[pos++][1] = n;
  }
  cout << p1 << endl;
  for (int i = 1; i <= p1; i++) {
    cout << ans[i][0] << " " << ans[i][1] << endl;
  }
  return 0;
}
