#include <bits/stdc++.h>
using namespace std;
const int maxx = 10000;
long long a[maxx], top, n, x;
long long read() {
  long long k;
  scanf("%lld", &k);
  return k;
}
int main() {
  n = read();
  x = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  sort(a + 1, a + 1 + n);
  long long sum = 0;
  int Ans = 0;
  for (int i = 1; i <= n; i++) {
    if (sum + a[i] <= x) {
      sum += a[i];
      Ans++;
    }
  }
  if (sum == x)
    cout << Ans << endl;
  else
    cout << Ans - 1 << endl;
  return 0;
}
