#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, K;
  cin >> N >> K;
  long long moves[N];
  long long dp[K + 1];
  for (long long i = 0; i <= K; i++) {
    dp[i] = 0;
  }
  for (long long i = 0; i < N; i++) {
    cin >> moves[i];
    dp[moves[i]] = 1;
  }
  for (long long i = 0; i < moves[0]; i++) {
    dp[i] = 2;
  }
  for (long long i = moves[0] + 1; i <= K; i++) {
    if (dp[i] == 0) {
      long long tarowin = 0;
      for (long long j = 0; j < N; j++) {
        if (i - moves[j] >= 0) {
          if (dp[i - moves[j]] == 2) {
            tarowin = 1;
            break;
          }
        } else {
          break;
        }
      }
      if (tarowin == 1) {
        dp[i] = 1;
      } else {
        dp[i] = 2;
      }
    }
  }
  cout << dp[K] << endl;
}
