#include using namespace std; #define ll long long #define f first #define s second #define sz(a) (int)(a.size()) #define all(a) a.begin(), a.end() #define uniq(a) sort(all(a)); a.resize(unique(all(a)) - a.begin()); typedef pair ii; typedef tuple Tp; const int N = 5e5 + 5; int n, k, a[N], dp[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("a.inp", "r", stdin); // freopen("a.out", "w", stdout); cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + n + 1); memset(dp, 0x3f, sizeof(dp)); dp[0] = 0; for (int j = 1; j <= n; j++) { for (int i = k; i >= a[j]; i--) { dp[i] = min(dp[i], dp[i - a[j]] + 1); } } cout << (dp[k] != dp[k + 1] ? dp[k] : -1) << '\n'; return 0; }