#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100;
void printA(int a[], int n) {
  for (int i = 0; i < n; i++) {
    cout << a[i] << endl;
  }
}
int main(void) {
  int n, x;
  int a[MAX_N];
  cin >> n;
  cin >> x;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int remain = x;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (remain >= a[i]) {
      ans++;
      remain -= a[i];
    } else {
      remain = 0;
      break;
    }
  }
  if (remain > 0) {
    ans--;
  }
  cout << ans << endl;
  return 0;
}
