#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<int, int> > v, ans;
void rek(int lo, int hi) {
  if (lo == hi) return;
  int mid = (lo + hi) / 2;
  for (int i = lo; i <= mid; i++) v.push_back({i, mid + i - lo + 1});
  rek(lo, mid);
  rek(mid + 1, hi);
}
int main() {
  scanf("%d", &n);
  int pot = 1, k = 0;
  while ((pot << 1) <= n) pot <<= 1, k++;
  rek(0, pot - 1);
  reverse((v).begin(), (v).end());
  for (pair<int, int> p : v) ans.push_back(p);
  if (pot != n)
    for (pair<int, int> p : v)
      ans.push_back({p.first + n - pot, p.second + n - pot});
  printf("%d\n", (int)ans.size());
  for (pair<int, int> p : ans) printf("%d %d\n", p.first + 1, p.second + 1);
  return 0;
}
