#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N, K; cin >> N >> K;
  vector<ll> a(N); rep(i, N) cin >> a[i];
  ll ans = INF;

  ll d, a1, a2;
  rep(i, N - K + 1) {
    d = a[i + K - 1] - a[i];
    a1 = d + abs(a[i + K - 1]);
    a2 = d + abs(a[i]);
    ans = min(ans, min(a1, a2));
  }
  
  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}

#include <bits/stdc++.h>

#define NM_MAX 2002

using namespace std;

int n, m;

bool ma[NM_MAX][NM_MAX];

int lg[NM_MAX][NM_MAX];

int v[NM_MAX];

int mxl[NM_MAX];
int mxr[NM_MAX];

stack <int> st;

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        string s;
        cin >> s;
        for(int j = 1; j <= m; j++)
            ma[i][j] = (s[j - 1] == '#');
    }
    for(int i = 1; i < n; i++)
        for(int j = 1; j < m; j++)
            ma[i][j] = ma[i][j] ^ ma[i + 1][j] ^ ma[i][j + 1] ^ ma[i + 1][j + 1];
    n--;
    m--;
    for(int i = n; i >= 1; i--)
        for(int j = 1; j <= m; j++)
            if(ma[i][j] == 1)
                lg[i][j] = 0;
            else
                lg[i][j] = lg[i + 1][j] + 1;
    int ans = max(n, m) + 1;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
            v[j] = lg[i][j];
        for(int j = 1; j <= m; j++)
        {
            while(!st.empty() && v[st.top()] >= v[j])
                st.pop();
            if(st.empty())
                mxl[j] = j - 1;
            else
                mxl[j] = j - (st.top() + 1);
            st.push(j);
        }
        while(!st.empty())
            st.pop();
        for(int j = m; j >= 1; j--)
        {
            while(!st.empty() && v[st.top()] >= v[j])
                st.pop();
            if(st.empty())
                mxr[j] = m - j;
            else
                mxr[j] = st.top() - 1 - j;
            st.push(j);
        }
        while(!st.empty())
            st.pop();
        for(int j = 1; j <= m; j++)
            ans = max(ans, (mxl[j] + mxr[j] + 2) * (v[j] + 1));
    }
    cout << ans << "\n";
    return 0;
}
