#include <bits/stdc++.h>
using namespace std;
template <typename t>
inline void read(t& a) {
  t ret(0), f(1);
  char ch(getchar());
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    ret = ret * 10 + (ch ^ 48);
    ch = getchar();
  }
  a = ret * f;
}
inline int Max(int x, int y) { return x > y ? x : y; }
inline int Min(int x, int y) { return x < y ? x : y; }
int a[105];
int main() {
  int n, x, ans(0);
  read(n), read(x);
  for (int i(1); i <= n; i++) read(a[i]);
  sort(a + 1, a + n + 1);
  for (int i(1); i <= n; i++) {
    if (x >= a[i])
      x -= a[i], ++ans;
    else
      break;
  }
  printf("%d", Max(0, ans - (x != 0)));
  return 0;
}
