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