#include <bits/stdc++.h>
using namespace std;
int n, x, a[105], s;
int main() {
  cin >> n >> x;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    s += a[i];
  }
  if (s <= x) {
    if (s == x)
      cout << n;
    else
      cout << n - 1;
    return 0;
  }
  s = 0;
  a[n + 1] = 0;
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n + 1; i++) {
    s += a[i];
    if (s > x) {
      cout << i - 1;
      return 0;
    } else if (s == x) {
      cout << i;
      return 0;
    } else if (i == n + 1)
      cout << n - 1;
  }
}
