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