#include <bits/stdc++.h>
using namespace std;
double dp[150001];
int stones(int *a, int n, int k) {
  if (k < 0) return 1;
  if (k == 0) return 0;
  if (dp[k] > -1) return dp[k];
  int ans = -1;
  for (int i = 0; i < n; i++) {
    ans = max(ans, (stones(a, n, k - a[i])) ^ 1);
  }
  return dp[k] = ans;
}
int main() {
  int n, k;
  cin >> n >> k;
  memset(dp, -1, sizeof(dp));
  int *a = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << stones(a, n, k);
}
