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