cpp
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=35,INF=0x3f3f3f3f;
LL p[N];
LL a[N];
int n;
LL m;
int ans=INF;
void dfs(int u,LL sum,int cnt){
if(sum==m){
ans=min(ans,cnt);
return ;
}
if(cnt>=ans||u>n||sum+p[u]<m||sum>m) return ;
dfs(u+1,sum+a[u],cnt);
dfs(u+1,sum+a[u]/2,cnt+1);
dfs(u+1,sum,cnt);
}
int main(){
cin>>n>>m;
m*=2;
for(int i=1;i<=n;i++){
cin>>a[i];
a[i]*=2;
}
sort(a+1,a+1+n,greater<int>());
for(int i=n;i>=1;i--) p[i]=p[i+1]+a[i];
dfs(1,0,0);
if(ans==INF) cout<<"-1"<<endl;
else cout<<ans<<endl;
return 0;
}