#include <iostream>
#include <algorithm>
using namespace std ;
bool cmp(int x,int y)
{
return x<y ;
}
int main()
{
int n,m ;
int k,l ;
cin>>n>>m ;
int a[n] ;
for(int i=1;i<=n;i++)
{
cin>>a[i] ;
}
sort(a,a+10,cmp) ;
a[n]=k ;
a[1]=l ;
for(int j=1;j<=m;j++)
{
if(l-2>l/2) l=l/2 ;
else if(l-2<l/2) l=l/2 ;
if(k+2>k/2) k=k+2 ;
else if(k+2<k/2) k=k*2 ;
}
cout<<k-l ;
return 0 ;
}