#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int n,r; cin >> n >> r;
vector<int> a(n);
int left=0,happy=0;
for(int i=0;i<n;++i) {
cin >> a[i];
r-=a[i]/2;
happy+=2*(a[i]/2);
if(a[i]&1!=0) {
++left;
}
}
if(left>r) {
happy+=2*r-left;
}
else {
happy+=left;
}
cout << happy << "\n";
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCS8vIHlvdXIgY29kZSBnb2VzIGhlcmUKICAgIGludCBuLHI7IGNpbiA+PiBuID4+IHI7CiAgICB2ZWN0b3I8aW50PiBhKG4pOwogICAgaW50IGxlZnQ9MCxoYXBweT0wOwogICAgZm9yKGludCBpPTA7aTxuOysraSkgewogICAgICAgIGNpbiA+PiBhW2ldOwogICAgICAgIHItPWFbaV0vMjsKICAgICAgICBoYXBweSs9MiooYVtpXS8yKTsKICAgICAgICBpZihhW2ldJjEhPTApIHsKICAgICAgICAgICAgKytsZWZ0OwogICAgICAgIH0KICAgIH0KICAgIGlmKGxlZnQ+cikgewogICAgICAgIGhhcHB5Kz0yKnItbGVmdDsKICAgIH0KICAgIGVsc2UgewogICAgICAgIGhhcHB5Kz1sZWZ0OwogICAgfQogICAgY291dCA8PCBoYXBweSA8PCAiXG4iOwoJcmV0dXJuIDA7Cn0=