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