#include <bits/stdc++.h>
template <typename T, typename U>
static inline void amin(T x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
static inline void amax(T &x, U y) {
  if (x < y) x = y;
}
using namespace std;
const int N = 10005;
void solve() {
  int n, i, j;
  cin >> n;
  vector<pair<int, int>> ans;
  vector<int> p(N, 1);
  p[1] = 0;
  for (i = 2; i * i <= N; i++) {
    if (p[i])
      for (j = i * i; j <= N; j += i) p[j] = 0;
  }
  set<int> s;
  for (i = 2; i < N; i++) {
    if (p[i]) s.insert(i);
  }
  for (i = 1; i < n; i++) ans.push_back(make_pair(i, i + 1));
  ans.push_back(make_pair(1, n));
  int x = *s.lower_bound(n);
  x -= n;
  for (i = 1; i < n && x > 0; i += 4) {
    ans.push_back(make_pair(i, i + 2));
    x--;
  }
  for (i = 2; i < n && x > 0; i += 4) {
    ans.push_back(make_pair(i, i + 2));
    x--;
  }
  cout << (int)ans.size() << '\n';
  for (auto it : ans) cout << it.first << " " << it.second << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
