#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int i, j, cnt = 0;
  int n, x;
  cin >> n >> x;
  int a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (i = 0; i < n; i++) {
    if (x >= a[i]) {
      x -= a[i];
      cnt++;
    }
  }
  if (i == n && x != 0) cnt--;
  if (cnt == -1) cnt++;
  cout << cnt;
}
