#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  vector<int> s(n);
  for (int &it : s) scanf("%d", &it);
  bool res[k + 1];
  for (int i = 0; i <= k; i++) {
    for (int j : s) {
      if (i >= j && !res[i - j]) res[i] = true;
    }
  }
  cout << res[k] << endl;
}
