#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int n, x, a[N], cnt;
bool have(int x) {
  for (int i = cnt + 1; i <= n; i++)
    if (a[i] == x) return 1;
  return 0;
}
int main() {
  scanf("%d%d", &n, &x);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++)
    if (x >= a[i]) cnt++, x -= a[i];
  if (x) {
    bool flag = 0;
    for (int i = 1; i <= cnt; i++)
      if (have(a[i] + x)) flag = 1;
    if (!flag && cnt) cnt--;
  }
  printf("%d\n", cnt);
  return 0;
}
