#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long inf = 2e18 + 5;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  vector<bool> dp(k + 1);
  vector<int> a(n);
  for (int i = (0); i < (n); i++) cin >> a[i];
  for (int stones = 0; stones <= k; stones++) {
    for (int x : a) {
      if (stones >= x && dp[stones - x] == false) dp[stones] = true;
    }
  }
  cout << dp[k];
  return 0;
}
