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