#include<bits/stdc++.h>
using namespace std;

using lint = long long;

class SegmentTree{
    int n;
    vector<lint> node;

public:
    SegmentTree(int n_ = 0){
        init(n_);
    }

    SegmentTree(vector<lint>& dat){
        build(dat);
    }

    void init(int n_ = 0){
        n = 1;
        while(n < n_){
            n <<= 1;
        }
        node.resize(n * 2 - 1);
        fill(node.begin(), node.end(), LLONG_MIN);
        return;
    }

    void build(vector<lint>& dat){
        int n_ = (int)dat.size();

        init(n_);

        for(int i = 0 ; i < n_ ; ++i){
            node[i + n - 1] = dat[i];
        }

        for(int i = n - 2 ; i >= 0 ; --i){
            node[i] = max(node[i * 2 + 1], node[i * 2 + 2]);
        }

        return;
    }

    void update(int k, lint x){
        k += n - 1;
        node[k] = x;
        while(k > 0){
            k = (k - 1) / 2;
            node[k] = max(node[k * 2 + 1], node[k * 2 + 2]);
        }
        return;
    }

    lint get(int a, int b, int k = 0, int l = 0, int r = -1){
        if(r == -1){
            r = n;
        }

        if(b <= l || r <= a){
            return LLONG_MIN;
        }else if(a <= l && r <= b){
            return node[k];
        }

        lint vl = get(a, b, k * 2 + 1, l, (l + r) / 2);
        lint vr = get(a, b, k * 2 + 2, (l + r) / 2, r);

        return max(vl, vr);
    }
};

template<typename T>
T power(T x, unsigned long long n, T e){
    T res = e;
    while(n > 0ull){
        if(n & 1ull){
            res *= x;
        }
        x *= x;
        n >>= 1;
    }
    return res;
}

int main(){
    int n_;
    lint d;
    cin >> n_ >> d;

    int n[2] = {n_ / 2, n_ - n_ / 2};
    vector<lint> x[2], y[2];

    for(int i = 0 ; i < 2 ; ++i){
        for(int j = 0 ; j < n[i] ; ++j){
            lint x_, y_;
            cin >> x_ >> y_;
            x[i].push_back(x_);
            y[i].push_back(y_);
        }
    }

    int l[2];
    for(int i = 0 ; i < 2 ; ++i){
        l[i] = power(3, n[i], 1);
    }

    vector< pair<lint, lint> > v[2];

    for(int i = 0 ; i < 2 ; ++i){
        for(int j = 0 ; j < l[i] ; ++j){
            int t = j;
            lint dx = 0;
            lint dy = 0;
            for(int k = 0 ; k < n[i] ; ++k){
                if(t % 3 == 0){
                    dx += x[i][k];
                    dy += y[i][k];
                }else if(t % 3 == 1){
                    dx -= x[i][k];
                    dy -= y[i][k];
                }
                t /= 3;
            }
            v[i].push_back({dx, dy});
        }
    }

    sort(v[1].begin(), v[1].end());
    vector<lint> dat;

    for(int j = 0 ; j < l[1] ; ++j){
        dat.push_back(v[1][j].second);
    }

    SegmentTree seg(dat);

    lint ans = LLONG_MIN;
    for(int j = 0 ; j < l[0] ; ++j){
        int left = lower_bound(v[1].begin(), v[1].end(), make_pair(-d - v[0][j].first, LLONG_MIN)) - v[1].begin();
        int right = upper_bound(v[1].begin(), v[1].end(), make_pair(d - v[0][j].first, LLONG_MAX)) - v[1].begin();
        if(left >= right){
            continue;
        }
        lint tmp = seg.get(left, right);
        ans = max(ans, v[0][j].second + tmp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 825588