#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
void in(int &x);
int n, x;
void work() {
  in(n);
  in(x);
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    in(v[i]);
  }
  sort(v.begin(), v.end());
  int sol = 0, lst = -1;
  for (int i = 0; i < n; i++) {
    if (x >= v[i])
      sol++, x -= v[i], lst = i;
    else
      break;
  }
  if (x > 0 && sol > 0) {
    bool found = false;
    for (int i = lst + 1; i < n; i++) {
      if (v[i] == v[lst] + x) found = true;
    }
    if (!found) --sol;
  }
  printf("%d\n", sol);
  return;
}
int main() {
  work();
  return 0;
}
void in(int &x) {
  bool neg = false;
  register int c;
  x = 0;
  c = getchar();
  if (c == '-') {
    neg = true;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) x = (x << 1) + (x << 3) + c - 48;
  if (neg) x *= -1;
}
