#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  bool d[k + 1];
  for (int i = 0; i <= k; i++) {
    for (int x : a) {
      if (i >= x && d[i - x] == false) d[i] = true;
    }
  }
  cout << d[k];
}
