#include <iostream>

using namespace std;

int main()
{
    int K, N, br;
    cin >> N >> K;
    int a[100000];
    for (int i = 0, j = N; i < j - K - 1 && j > i - K - 1; i++ && j--)
    {
        cin >> a[i] >> a[j];
        if (a[i] >= a[j]) {
        br = a[i] - a[j];
    }
    else {
        br = a[j] - a[i];
    }
}
cout << br << endl;
}