#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k;
  cin >> n >> k;
  long long int a[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  long long int dp[k + 1];
  dp[0] = 0;
  for (long long int i = 1; i <= k; i++) {
    long long int f = 0;
    long long int g = 0;
    for (long long int j = 0; j < n; j++) {
      if (i >= a[j]) {
        g = 1;
        if (dp[i - a[j]] == 0) f = 1;
      }
    }
    if (g == 0)
      dp[i] = 0;
    else if (f)
      dp[i] = 1;
    else
      dp[i] = 0;
  }
  cout << dp[k];
}
