#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int w = 1, c = 0;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') w = -1;
  for (; isdigit(ch); ch = getchar()) c = (c << 1) + (c << 3) + (ch ^ 48);
  return w * c;
}
const int M = 4e5 + 10;
vector<pair<int, int> > ans;
int tot;
map<pair<int, int>, int> p;
int n, lim, bg, a[M];
void make(int x) {
  for (int i = (1); i <= (x); ++i) {
    int len = (1 << i - 1);
    for (int k = bg; k < bg + (1 << x); k += (1 << i))
      for (int j = 1; j <= len; j++) {
        ans.push_back(make_pair(k + j, k + len + j));
      }
  }
}
int main() {
  n = read();
  int pos = 0;
  for (int i = (30); i >= (0); --i) {
    if (n >> i & 1) {
      lim = (1 << i);
      pos = i;
      break;
    }
  }
  int p2 = -1;
  for (int i = (pos - 1); i >= (0); --i) {
    if (n >> i & 1) {
      p2 = i;
      break;
    }
  }
  if (p2 != -1) {
    bg = 1;
    for (int i = (p2 - 1); i >= (0); --i) {
      make(p2 - i + 1);
      for (int j = (1); j <= (bg); ++j) {
        ans.push_back(make_pair(j, j + bg));
      }
      bg *= 2;
      if (n >> i & 1) {
        make(p2 - i + 1);
        for (int j = (1); j <= (bg); ++j) {
          ans.push_back(make_pair(j, j + bg));
        }
        bg++;
      }
    }
  }
  make(pos);
  cout << ((int)ans.size() - 1) + 1 << "\n";
  for (int i = (0); i <= (((int)ans.size() - 1)); ++i) {
    int x = ans[i].first, y = ans[i].second;
    cout << ans[i].first << " " << ans[i].second << "\n";
  }
  return 0;
}
