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