#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<int> a, dp;
int go(int x) {
  if (dp[x] != -1) return dp[x];
  int y = 1;
  for (int z : a) {
    if (x >= z) y &= go(x - z);
  }
  y ^= 1;
  return dp[x] = y;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  cin >> n >> k;
  a.resize(n);
  dp.assign(k + 1, -1);
  for (auto& it : a) cin >> it;
  fill(dp.begin(), dp.begin() + a[0], 0);
  cout << go(k) << '\n';
  return 0;
}
