#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using db = long double;
using ull = unsigned long long;
const int N = 1e3 + 5, MOD = 998244353;
const db EPS = 1e-7;
bitset<N * N> isP;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  isP.set();
  isP[0] = isP[1] = 0;
  for (int i = 2; i * i < N * N; i++)
    if (isP[i])
      for (int j = i * i; j < N * N; j += i) isP[j] = 0;
  vector<pair<int, int>> edges;
  int cur = 0;
  set<int> st;
  for (int i = 3; i <= n; i += 3) {
    st.insert(i - 1);
    st.insert(i - 2);
    st.insert(i);
    edges.push_back(make_pair(i - 2, i - 1));
    edges.push_back(make_pair(i - 2, i));
    edges.push_back(make_pair(i - 1, i));
  }
  int beg = 0;
  if (n % 3 == 1) {
    edges.push_back(make_pair(1, n));
    edges.push_back(make_pair(2, n));
    st.erase(1);
    st.erase(2);
    st.erase(3);
    if (!isP[edges.size()]) {
      edges.push_back(make_pair(3, n));
    }
  }
  if (n % 3 == 2) {
    edges.push_back(make_pair(1, n));
    edges.push_back(make_pair(n - 1, n));
    edges.push_back(make_pair(2, n - 1));
    st.erase(1);
    st.erase(2);
    st.erase(3);
    if (!isP[edges.size()]) {
      edges.push_back(make_pair(3, n));
    }
  }
  if (n == 7) {
    edges.pop_back();
    edges.push_back(make_pair(4, 7));
    edges.push_back(make_pair(5, 7));
    edges.push_back(make_pair(6, 7));
  }
  while (!isP[edges.size()]) {
    auto x = *st.begin();
    edges.push_back(make_pair(x, x + 3));
    st.erase(x);
    st.erase(x + 3);
  }
  cout << edges.size() << '\n';
  for (auto x : edges) {
    cout << x.first << ' ' << x.second << '\n';
  }
  return 0;
}
