#include <bits/stdc++.h>
using namespace std;
bool sieve[1000005];
vector<int> vec;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  for (int i = 2; i <= 1000005; i++) {
    if (!sieve[i]) {
      vec.push_back(i);
      for (int j = i * 2; j <= 1000005; j += i) {
        sieve[j] = 1;
      }
    }
  }
  int n;
  cin >> n;
  for (int i = 0; i < vec.size(); i++) {
    if (vec[i] == n) {
      cout << n << '\n';
      for (int i = 1; i <= n; i++) {
        if (i == n)
          cout << n << ' ' << 1 << '\n';
        else
          cout << i << ' ' << i + 1 << '\n';
      }
      break;
    } else if (vec[i] > n) {
      int t = vec[i];
      cout << t << '\n';
      for (int i = 1; i <= n; i++) {
        if (i == n)
          cout << n << ' ' << 1 << '\n';
        else
          cout << i << ' ' << i + 1 << '\n';
      }
      t -= n;
      while (t > 0) {
        for (i = 1; i <= n - 3; i += 4) {
          cout << i << ' ' << i + 2 << '\n';
          t--;
          if (t == 0) break;
          cout << i + 1 << ' ' << i + 3 << '\n';
          t--;
          if (t == 0) break;
        }
      }
      break;
    }
  }
  return 0;
}
