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