#include <bits/stdc++.h>
template <typename T>
inline void read(T &x) {
  char c;
  bool nega = 0;
  while ((!isdigit(c = getchar())) && (c != '-'))
    ;
  if (c == '-') {
    nega = 1;
    c = getchar();
  }
  x = c - 48;
  while (isdigit(c = getchar())) x = x * 10 + c - 48;
  if (nega) x = -x;
}
template <typename T>
inline void writep(T x) {
  if (x > 9) writep(x / 10);
  putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  writep(x);
  putchar(' ');
}
template <typename T>
inline void writeln(T x) {
  write(x);
  putchar('\n');
}
using namespace std;
int n, cur;
vector<pair<int, int> > ans;
void Pro(int l, int r) {
  if (l == r) {
    return;
  }
  int mid = (l + r) >> 1;
  Pro(l, mid);
  Pro(mid + 1, r);
  for (int i = (l); i <= (mid); ++i) {
    ans.push_back(make_pair(i, i + mid - l + 1));
  }
}
int main() {
  srand(time(NULL));
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie();
  if (fopen(".inp", "r")) freopen(".inp", "r", stdin);
  cin >> n;
  int temp = log2(n);
  temp = 1 << temp;
  Pro(1, temp);
  Pro(n - temp + 1, n);
  cout << ans.size() << '\n';
  for (auto v : ans) {
    cout << v.first << ' ' << v.second << '\n';
  }
  return 0;
}
