#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = '!';
  int z = 1, num = 0;
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') z = -1, ch = getchar();
  while (ch <= '9' && ch >= '0')
    num = (num << 3) + (num << 1) + ch - '0', ch = getchar();
  return z * num;
}
const int _ = 105;
int n, x, a[_];
int main() {
  n = read(), x = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  sort(a + 1, a + 1 + n);
  int i = 1;
  while (x >= a[i] && i <= n) x -= a[i++];
  i--;
  if (x && i) i--;
  printf("%d\n", i);
  return 0;
}
