#include <bits/stdc++.h>
#define MOD 1000000007LL
#define INF 0x3f3f3f3f3f3f3f3fLL
#define EPS 1e-6
#define rep(i, l, r) for (int i = l; i < (int)(r); i++)
#define rrep(i, l, r) for (int i = ((int)(r) - 1); i >= l; i--)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
struct edge { int to, cost; };
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a, int b) { while(b){ int c = b; b = a % b; a = c; } return a; }
int lcm(int a, int b) { if(!a || !b) return 0; return a * b / gcd(a, b); }

#include<bits/stdc++.h>
using namespace std;
int main(){
    int N; cin >> N;
    vector<double> a(N),b(N),c(N),d(N);
    for(int _=0; _<2; _++){
        for(int i=0; i<N; i++) cin >> a[i] >> b[i];
        int x = 0, y = 0;
        for(int i=0; i<N; i++){
            x += a[i];
            y += b[i];
            a[i] *= N;
            b[i] *= N;
        }
        for(int i=0; i<N; i++){
            a[i] -= x;
            b[i] -= y;
        }
        swap(a,c);
        swap(b,d);
    }
    for(int i=0; i<N; i++){
        if(a[i]!=0 || b[i]!=0){
            swap(a[i],a[0]);
            swap(b[i],b[0]);
        }
    }
    string ans = "No";
    const double eps = 1e-6;
    for(int i=0; i<N; i++){
        double angle = atan2(d[i],c[i])-atan2(b[0],a[0]);
        bool flag = true;
        for(int j=0; j<N; j++){
            double A = a[j]*cos(angle)-b[j]*sin(angle);
            double B = a[j]*sin(angle)+b[j]*cos(angle);
            bool flag2 = false;
            for(int k=0; k<N; k++){
                if(std::abs(A-c[k])<=eps && std::abs(B-d[k])<=eps) flag2 = true;
            }
            flag &= flag2;
        }
        if(flag) ans = "Yes";
    }
    cout << ans << endl;
}
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//~ while (clock()<=69*CLOCKS_PER_SEC)

#define ll long long
#define ld long double
#define pi pair<int,int>
#define pd pair<ld,ld>
#define ft first
#define sd second
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define FOR(i,a,b) for(int i=(a); i<=(b);i++)
#define F(i,a,b) FOR(i,(a),(b)-1)
#define REV(i,a,b) for(int i=(a); i>=(b);i--)
#define VI vector<int>
#define VPI vector<pi>
#define VPD vector<pd>
#define PI 3.14159265
#define all(x) (x).begin(), (x).end()
#define sz(a) (int)((a).size())
#define int long long

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long K = 1000;
const long long KK = K*K;
const long long MIL = KK*K;
const long long INF = MIL*MIL;
const long long MOD = 1e9 + 7;
const long long N = 1e5 + 10, M=10;

void solve() {
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    if (r1 == r2 && c1 == c2) {
        cout << "0\n";
        return;
    }

    if (r1 + c1 == r2 + c2 || r1 - c1 == r2 - c2 || (abs(r1 - r2) + abs(c1 - c2) <= 3)) {
        cout << "1\n";
        return;
    }

    if ((r1 + c1) % 2 == (r2 + c2)%2 && ((r1 - c1) % 2 + 2) % 2 == ((r2 - c2 + 2) % 2 + 2) % 2) {
        cout << "2\n";
        return;
    }

    FOR(i,-3, 3) {
        FOR(j, -3, 3) {
            if (abs(i) + abs(j) <= 3) {
                int a = r1 + i, b = c1 + j;
                if (a + b == r2 + c2 || a - b == r2 - c2 || (abs(a - r2) + abs(b - c2) <= 3)) {
                    cout << "2\n";
                    return;
                }
            }
        }
    }

    FOR(i,-3, 3) {
        FOR(j, -3, 3) {
            if (abs(i) + abs(j) <= 3) {
                int c = r2 + i, d = c2 + j;
                if (r1 + c1 == c + d || r1 - c1 == c - d || (abs(r1 - c) + abs(c1 - d) <= 3)) {
                    cout << "2\n";
                    return;
                }
            }
        }
    }




    cout << "3\n";


}

int32_t main() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
    cerr.tie(0);
    cout << setprecision(9) << fixed;
    cerr << setprecision(6) << fixed;
    int test = 1, f;
//    cin >> test;
    F(_test, 0, test) {
        //cout<<"Case #"<<_test + 1<<": ";
        solve();
//		if(_test == 1)
//            return 0;
    }
}
/*
 */