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