#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int p = 1;
  while (2 * p <= n) p *= 2;
  vector<pair<int, int>> ans;
  int l = 1;
  while (l <= p / 2) {
    for (int i = 0; i < p; i += 2 * l) {
      for (int j = i; j < i + l; ++j) {
        ans.push_back({j, j + l});
      }
    }
    l *= 2;
  }
  auto print = [&](int offset) {
    for (auto [x, y] : ans) {
      cout << x + offset << ' ' << y + offset << '\n';
    }
  };
  cout << 2 * ans.size() << '\n';
  print(1);
  print(n - p + 1);
}
