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