#include <bits/stdc++.h>
using namespace std;
const int N = 1000; inline void valid( int v, int v_min = 0 ) { assert( v >= v_min and v < N ); }
struct coins_change_t: set< int >
{
struct memo_t: array< int, N >
{
memo_t()
{
fill( -1 );
}
} memo;
coins_change_t( int n )
{
for( int v, i = 0; i < n; i++ )
cin >> v, valid( v, 1 ), insert( v );
}
int min_count( int rs )
{
if ( rs == 0 )
return 0;
if ( rs < 0 )
return INT_MAX;
auto &a = memo[ rs ];
if ( a != -1 )
return a;
a = INT_MAX;
for( auto v: *this )
a = min( a, min_count( rs - v ) );
if ( a != INT_MAX )
a++;
return a;
}
};
int main()
{
int n, val; cin >> n >> val, valid( val );
coins_change_t coins_change( n );
int min_count = coins_change.min_count( val );
if ( min_count == INT_MAX )
cout << -1;
else
cout << min_count;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE4gPSAxMDAwOyBpbmxpbmUgdm9pZCB2YWxpZCggaW50IHYsIGludCB2X21pbiA9IDAgKSB7IGFzc2VydCggdiA+PSB2X21pbiBhbmQgdiA8IE4gKTsgfQoKc3RydWN0IGNvaW5zX2NoYW5nZV90OiBzZXQ8IGludCA+CnsKICAgIHN0cnVjdCBtZW1vX3Q6IGFycmF5PCBpbnQsIE4gPgogICAgewogICAgICAgIG1lbW9fdCgpCiAgICAgICAgewogICAgICAgICAgICBmaWxsKCAtMSApOwogICAgICAgIH0KCiAgICB9IG1lbW87CgogICAgY29pbnNfY2hhbmdlX3QoIGludCBuICkKICAgIHsKICAgICAgICBmb3IoIGludCB2LCBpID0gMDsgaSA8IG47IGkrKyApCiAgICAgICAgICAgIGNpbiA+PiB2LCB2YWxpZCggdiwgMSApLCBpbnNlcnQoIHYgKTsKICAgIH0KCiAgICBpbnQgbWluX2NvdW50KCBpbnQgcnMgKQogICAgewogICAgICAgIGlmICggcnMgPT0gMCApCiAgICAgICAgICAgIHJldHVybiAwOwoKICAgICAgICBpZiAoIHJzIDwgMCApCiAgICAgICAgICAgIHJldHVybiBJTlRfTUFYOwoKICAgICAgICBhdXRvICZhID0gbWVtb1sgcnMgXTsKCiAgICAgICAgaWYgKCBhICE9IC0xICkKICAgICAgICAgICAgcmV0dXJuIGE7CgogICAgICAgIGEgPSBJTlRfTUFYOwoKICAgICAgICBmb3IoIGF1dG8gdjogKnRoaXMgKQogICAgICAgICAgICBhID0gbWluKCBhLCBtaW5fY291bnQoIHJzIC0gdiApICk7CgoJCWlmICggYSAhPSBJTlRfTUFYICkKICAgICAgICAgICAgYSsrOwoKICAgICAgICByZXR1cm4gYTsKICAgIH0KfTsKCmludCBtYWluKCkKewogICAgaW50IG4sIHZhbDsgY2luID4+IG4gPj4gdmFsLCB2YWxpZCggdmFsICk7CgogICAgY29pbnNfY2hhbmdlX3QgY29pbnNfY2hhbmdlKCBuICk7CgogICAgaW50IG1pbl9jb3VudCA9IGNvaW5zX2NoYW5nZS5taW5fY291bnQoIHZhbCApOwoKICAgIGlmICggbWluX2NvdW50ID09IElOVF9NQVggKQogICAgICAgIGNvdXQgPDwgLTE7CiAgICBlbHNlCiAgICAgICAgY291dCA8PCBtaW5fY291bnQ7Cn0K