#include <bits/stdc++.h>
using namespace std;
int recurse(int i, vector<int> &arr, vector<int> &dp) {
  if (dp[i] != -1) return dp[i];
  dp[i] = 0;
  for (int j : arr)
    if (i >= j) dp[i] = max(dp[i], 1 - recurse(i - j, arr, dp));
  return dp[i];
}
int main(int argc, char const *argv[]) {
  int n, k, temp;
  cin >> n >> k;
  vector<int> arr(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> temp;
    arr[i] = temp;
  }
  vector<int> dp(k + 1, -1);
  dp[0] = 0;
  cout << recurse(k, arr, dp);
  return 0;
}
