#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
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);
  int cnt = 0;
  int i = 0;
  while (x >= a[i]) {
    x -= a[i];
    cnt++;
    i++;
    if (i == n) {
      break;
    }
  }
  if (x > 0) cnt--;
  if (cnt < 0) cnt = 0;
  cout << cnt << endl;
}
