import java.util.*;
class X{
static int score=0;
public static void main(String[] args){
int even=0;
int odd=0;
int sum=0;
Scanner sc = new Scanner(System.in);
String temp=sc.next();
String[] str=temp.split(",");
int n=Integer.valueOf(str[0]);
int k=Integer.valueOf(str[1]);
int l=0;
int r=n-1;
sc = new Scanner(System.in);
temp=sc.nextLine();
str=temp.split(" ");
int[] numar = Arrays.stream(str)
.mapToInt(Integer::parseInt)
.toArray();
System.out.println(findnext(n,k,even,odd,sum,l,r,numar));
}
public static int findnext(int n,int k,int even,int odd,int sum,int l,int r,int numar[]){
if(sum<=k){
if(odd==even && sum>score){score=sum;}
if(numar[l]%2==1){
even+=1;
sum+=numar[l];
l+=1;
findnext(n,k,even,odd,sum,l,r,numar);
}else{
odd+=1;
sum+=numar[l];
l+=1;
findnext(n,k,even,odd,sum,l,r,numar);
}
if(numar[r]%2==1){
even+=1;
sum+=numar[r];
r-=1;
findnext(n,k,even,odd,sum,l,r,numar);
}else{
odd+=1;
sum+=numar[r];
r-=1;
findnext(n,k,even,odd,sum,l,r,numar);
}
}
return score;
}
}