#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int n, k;
int dp[100010];
bool rec(int x, vector<int> a) {
  if (dp[x] >= 0) return dp[x];
  bool tmp;
  for (int i = 0; i < n; i++) {
    if (x - a[i] < 0)
      tmp = tmp | 0;
    else
      tmp = tmp | rec(x - a[i], a);
  }
  if (tmp == 0)
    return dp[x] = 1;
  else
    return dp[x] = 0;
}
int main() {
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << rec(k, a) << endl;
  return 0;
}
