#include <bits/stdc++.h>
using namespace std;
int N;
vector<long long int> V;
int dp[100005][5];
int fun(int K, int x) {
  int i, flag;
  flag = 0;
  vector<int> ans;
  for (i = N - 1; i >= 0; i--) {
    if (V[i] <= K) {
      flag = 1;
      if (dp[K - V[i]][(x + 1) % 2] == -1) {
        dp[K - V[i]][(x + 1) % 2] = fun((K - V[i]), (x + 1) % 2);
      }
      ans.push_back(dp[K - V[i]][(x + 1) % 2]);
    }
  }
  if (flag == 0) {
    dp[K][x] = (x + 1) % 2;
  } else {
    for (i = 0; i < ans.size(); i++) {
      if (ans[i] == x) break;
    }
    if (i == ans.size())
      dp[K][x] = (x + 1) % 2;
    else
      dp[K][x] = x;
  }
  return dp[K][x];
}
int main() {
  long long int K, i, x, j;
  cin >> N >> K;
  for (i = 0; i < N; i++) {
    cin >> x;
    V.push_back(x);
  }
  for (i = 0; i < 100005; i++) {
    for (j = 0; j < 5; j++) dp[i][j] = -1;
  }
  dp[K][0] = fun(K, 0);
  cout << dp[K][0] << endl;
  return 0;
}
