#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cnt = 0;
  long x, a[100], sa[100][100], flag = 0;
  scanf("%d %ld", &n, &x);
  for (int i = 0; i < n; i++) scanf("%ld", &a[i]);
  sort(a, a + n);
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) sa[i][j] = a[j] - a[i];
  for (int i = 0; i < n; i++) {
    if (x >= a[i]) {
      cnt++;
      x -= a[i];
    } else
      break;
  }
  if (cnt > 0 && x != 0) {
    cnt--;
    for (int i = 0; i < cnt + 1; i++)
      for (int j = cnt + 1; j < n; j++)
        if (sa[i][j] == x) flag = 1;
  }
  printf("%d\n", cnt + flag);
}
