#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 10;
pair<int, int> a[MAXN];
void solve() {
  int n;
  scanf("%d", &n);
  if (n <= 1) {
    printf("0\n");
    return;
  }
  a[1] = make_pair(1, 2);
  int cnt = 1;
  int d = 2;
  while (d * 2 <= n) {
    for (int i = 1; i <= cnt; i++) {
      a[cnt + i] = make_pair(a[i].first + d, a[i].second + d);
    }
    cnt <<= 1;
    for (int i = 1; i <= d; i++) {
      a[++cnt] = make_pair(i, i + d);
    }
    d <<= 1;
  }
  printf("%d\n", cnt * 2);
  for (int i = 1; i <= cnt; i++) {
    printf("%d %d\n", a[i].first, a[i].second);
  }
  for (int i = 1; i <= cnt; i++) {
    printf("%d %d\n", n + 1 - a[i].first, n + 1 - a[i].second);
  }
}
int main() {
  int casen = 1;
  while (casen--) solve();
  return 0;
}
