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