#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define fore(i_in,a) for (auto& i_in: a)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fio() cin.tie(nullptr);ios::sync_with_stdio(false);
#define DEBUG_CTN(v) cerr<<#v<<":";for(auto itr=v.begin();itr!=v.end();itr++) cerr<<" "<<*itr; cerr<<endl
template<class T> bool chmax(T &a, const T &b) {if (a<b) { a = b; return true; } return 0;}
template<class T> bool chmin(T &a, const T &b) {if (a>b) { a = b; return true; } return 0;}
template<class T> void print(const T &t) { cout << t << "\n"; }
const ll INF = 1LL << 62;
const int iINF = 1 << 30;

#define pq(T) priority_queue<T, vector<T>, greater<T>>
struct Edge {ll to; ll w; Edge(ll to, ll w) : to(to), w(w) {}};
using Graph = vector<vector<Edge>>;

vl dijkstra(Graph &G, int s){
    int n = G.size();
    vl dist(n, INF);
    dist[s] = 0;

    using pp = pair<ll, ll>;
    pq(pp) que;
    que.push({dist[s], s});

    while (!que.empty()) {
        ll v = que.top().second;
        ll d = que.top().first;
        que.pop();

        if (d > dist[v]) continue;
        if(!G[v].empty()) fore(e, G[v]) {
            if (chmin(dist[e.to], dist[v] + e.w)) {
                que.push({dist[e.to], e.to});
            }
        }
    }
    return dist;
}

int n;

int main() {
    fio(); cin>>n;
    Graph E(n+1);
    rep1(i,n){
        ll x = (2*i)%n+1, y=(2*i+1)%n+1;
        cout<<x<<" "<<y<<"\n";
        E[i].emplace_back(x,1);
        E[i].emplace_back(y,1);
    }
    ll ans = 0;
    rep1(i,n) {
        vl dist = dijkstra(E,i);
        ll tmp = 0;
        rep1(i,n) chmax(tmp,dist[i]);
        chmax(ans,tmp);
    }
}

// Created by ...
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<ll,ll> 
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;
using ll = long long;
ll md=MD;

ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(ll a,ll b){if(a<b)return a; return b;}
ll Max(ll a,ll b){if(a>b)return a; return b;}

bool check(int a,int b,int c,int d){
	return ((abs(a-c)+abs(b-d)<=3) || (a+b==c+d) || (a-b==c-d));
}
int32_t main() {
    IOS;

   		vec(pii) v;
    	rep(i,-2,2)rep(j,-2,2)v.pb({i,j});
    	v.pb({-3,0});v.pb({3,0});v.pb({0,-3});v.pb({0,3});
        int a,b,c,d; cin>>a>>b>>c>>d;
        if(a==c && b==d)cout<<"0";
        else if(check(a,b,c,d))cout<<"1";
        else{
        	for(auto&p:v){
        		if(check(a+p.fi,b+p.se,c,d) || check(a,b,c+p.fi,d+p.se)){cout<<"2"; return 0;}
        	}
        	int k1=abs(a-b+c-d);
        	if(k1%2==0){
        		cout<<"2";
        		return 0;
        	}
        	cout<<"3";
        }
        



        cout<<'\n';
    return 0;
}