#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <string>
#include <cmath>
#include <map>
#include <complex>
#include <set>
using namespace std;
typedef long long ll;
const ll 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]);
    }
    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;
}