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