#include <bits/stdc++.h>
using namespace std;
long long mod(long long a) {
  long long c = a % (long long)(1E9 + 7);
  if (c >= 0)
    return c;
  else
    return c + (long long)(1E9 + 7);
}
long long inf = (long long)1E12;
long long max(long long a, long long b) {
  if (a < b)
    return b;
  else
    return a;
}
long long min(long long a, long long b) {
  if (a > b)
    return b;
  else
    return a;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, x;
  cin >> n >> x;
  long long sum = 0;
  long long a[n];
  for (long long i = 0; i <= n - 1; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + n);
  if (sum < x) {
    cout << n - 1 << endl;
  } else if (sum == x) {
    cout << n << endl;
  } else {
    int pos = 0;
    while (pos <= n - 1) {
      if (a[pos] <= x) {
        pos++;
        x -= a[pos];
      } else {
        break;
      }
    }
    cout << pos << endl;
  }
  return 0;
}
