#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

void add_0(const ll N, vvll& bonds){
  FOR(i, 1, N+1){
    if(i%4==0 || i%4==1){
      for(ll j=1; j<N+1; ++j){
        if(j%4==0 || j%4==1) continue;
        bonds[i].push_back(j);
      }
    }else{
      for(ll j=1; j<N+1; ++j){
        if(j%4==2 || j%4==3) continue;
        bonds[i].push_back(j);
      }
    }
  }
  return;
}

void add_3(const ll N, vvll& bonds){
  FOR(i, 1, N+1){
    if(i==1 || i==2){
      bonds[i].push_back(3);
      for(ll j=4; j<N+1; ++j){
        if(j%4==0 || j%4==3) continue;
        bonds[i].push_back(j);
      }
    }else if(i==3){
      bonds[i].push_back(1);
      bonds[i].push_back(2);
      for(ll j=4; j<N+1; ++j){
        if(j%4==1 || j%4==2) continue;
        bonds[i].push_back(j);
      }
    }else if(i%4==0 || i%4==3){
      bonds[i].push_back(1);
      bonds[i].push_back(2);
      for(ll j=4; j<N+1; ++j){
        if(j%4==0 || j%4==3) continue;
        bonds[i].push_back(j);
      }
    }else{
      bonds[i].push_back(3);
      for(ll j=4; j<N+1; ++j){
        if(j%4==1 || j%4==2) continue;
        bonds[i].push_back(j);
      }
    }
  }
  return;
}

void add_1(const ll N, vvll& bonds){
  FOR(i, 1, N+1){
    if(i==N){
      for(ll j=1; j<N; ++j){
        bonds[i].push_back(j);
      }
    }else{
      for(ll j=1; j<N+1; ++j){
        if(j==i) continue;
        if(j+i==N) continue;
        bonds[i].push_back(j);
      }
    }
  }
  return;
}

void add_2(const ll N, vvll& bonds){
  FOR(i, 1, N+1){
    for(ll j=1; j<N+1; ++j){
      if(j==i) continue;
      if(j+i==N+1) continue;
      bonds[i].push_back(j);
    }
  }
  return;
}

void check(const ll N, const vvll& bonds){
  REP(i, N){
    ll tmp=0;
    REP(j, bonds[i+1].size()){
      tmp += bonds[i+1][j];
      //printf("%d %d\n", i+1, bonds[i+1][j]);
    }
    printf("bonds %d : %d\n", i+1, tmp);
  }
  return;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  cin >> N;

  vvll bonds(N+1);

  switch(N%4){
    case 0:
      add_0(N, bonds);
      break;
    case 1:
      add_1(N, bonds);
      break;
    case 2:
      add_2(N, bonds);
      break;
    case 3:
      add_3(N, bonds);
      break;
    default:
      break;
  }

  //check(N, bonds);
  
  ll bonds_num=0;
  FOR(i, 1, N+1){
    bonds_num+=bonds[i].size();
  }
  bonds_num/=2;

  cout << bonds_num << "\n";
  FOR(i, 1, N+1){
    REP(j, bonds[i].size()){
      if(i<bonds[i][j]) cout << i << " " << bonds[i][j] << "\n";
    }
  }

  return 0;
}

Measured memory_bytes: 384