#include <bits/stdc++.h>
using namespace std;
const int N = 1E6 + 10;
int n, m;
vector<pair<int, int> > ans;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> m;
  n = 1;
  while (n < m) n <<= 1;
  n >>= 1;
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < n; j += (i << 1))
      for (int k = (0); k <= (i - 1); k++)
        if (j + k <= m && i + j + k <= m)
          ans.push_back(pair<int, int>(j + k + 1, i + j + k + 1));
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < n; j += (i << 1))
      for (int k = (0); k <= (i - 1); k++)
        if (j + k <= m && i + j + k <= m)
          ans.push_back(pair<int, int>(m - j - k, m - i - j - k));
  cout << ans.size() << endl;
  for (auto p : ans) cout << p.first << " " << p.second << endl;
}
