#include <bits/stdc++.h>
using namespace std;
int a[150000][2], c, n;
void dfs(int l, int r) {
  if (l == r) {
    return;
  }
  int m = (l + r) / 2;
  dfs(l, m);
  dfs(m + 1, r);
  for (int i = l; i <= m; ++i) {
    a[++c][0] = i;
    a[c][1] = i - l + m + 1;
  }
}
int main() {
  cin >> n;
  int k;
  for (k = 1; k * 2 < n; k *= 2)
    ;
  dfs(1, k), dfs(n - k + 1, n);
  cout << c << endl;
  for (int i = 1; i <= c; ++i) {
    cout << a[i][0] << " " << a[i][1] << endl;
  }
  return 0;
}
