#include <bits/stdc++.h>
using namespace std;
bool prime(long long x) {
  for (long long i = 2; i < x; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}
int main() {
  long long a, b, c, d, e, i, j, l;
  cin >> a;
  vector<pair<long long, long long>> vec;
  if (a == 3) {
    cout << "3 1 2 2 3 1 3" << endl;
  } else {
    long long on = 0;
    long long k = 0;
    on++;
    for (i = 1; i < a; i++) {
      vec.push_back({i, i + 1});
      k++;
    }
    k++;
    vec.push_back({a, 1});
    for (i = 1;; i += 4) {
      if (prime(k)) break;
      if (i > a || i + 2 > a) break;
      vec.push_back({i, i + 2});
      k++;
      if (i + 3 > a || i + 1 > a) break;
      if (prime(k)) break;
      k++;
      vec.push_back({i + 1, i + 3});
    }
    cout << vec.size() << endl;
    for (i = 0; i < vec.size(); i++) {
      cout << vec[i].first << " " << vec[i].second << endl;
    }
  }
}
