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