#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, a[105], cnt = 0, ans = 0, check = 1;
  cin >> n >> x;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    if (cnt + a[i] == x) check = 0;
    if (cnt + a[i] > x) break;
    cnt += a[i], ans++;
  }
  if (check) ans--;
  if (ans < 0) ans = 0;
  cout << ans << endl;
}
