#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T abs(T x) {
  return x < 0 ? -x : x;
}
template <class T>
vector<T> ReadVector(int n) {
  vector<T> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  return a;
}
template <class T>
void WriteVector(const vector<T>& a) {
  for (int i = 0; i < ((int)(a).size()); ++i) {
    cout << a[i] << (i + 1 < ((int)(a).size()) ? ' ' : '\n');
  }
}
void Solve() {
  int n;
  cin >> n;
  int k = 0;
  while ((1 << (k + 1)) <= n) {
    ++k;
  }
  vector<pair<int, int>> res;
  for (int t = 0; t < 2; ++t) {
    if (t == 1 && n == (1 << k)) {
      break;
    }
    int delta = 0;
    if (t == 1) {
      delta = n - (1 << k);
    }
    for (int i = 0; i < k; ++i) {
      for (int j = 0; j < (1 << k); ++j) {
        if ((j & (1 << i)) == 0) {
          res.push_back(make_pair(delta + j, delta + (j ^ (1 << i))));
        }
      }
    }
  }
  cout << ((int)(res).size()) << "\n";
  for (int i = 0; i < ((int)(res).size()); ++i) {
    cout << res[i].first + 1 << " " << res[i].second + 1 << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  std::cin.tie(nullptr);
  int tc = 1;
  for (int ti = 0; ti < tc; ++ti) {
    Solve();
  }
  return 0;
}
