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