#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > P;
void solve(int l, int r) {
  if (l == r) return;
  int mid = (l + r) / 2;
  solve(l, mid);
  solve(mid + 1, r);
  int dif = mid - l + 1;
  for (int v1 = l; v1 <= mid; v1++) {
    P.push_back(make_pair(v1, v1 + dif));
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int v = 1;
  int left = 0;
  int right = v - 1;
  while (v <= n) {
    right = v - 1;
    v *= 2;
  }
  solve(left, right);
  int falta = n - right - 1;
  if (falta != 0) solve(falta + left, falta + right);
  cout << P.size() << "\n";
  for (int i = 0; i < P.size(); i++) {
    cout << P[i].first + 1 << " " << P[i].second + 1 << "\n";
  }
  return 0;
}
