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