#include <bits/stdc++.h>
using namespace std;
int n, x;
int a[110];
bool cal(int m) {
  int cnt = x;
  for (int i = 0; i < m; i++) {
    cnt -= a[i];
  }
  if (m == n) return cnt == 0;
  return cnt >= 0;
}
int main() {
  cin >> n >> x;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int x = 0, y = n + 1, ans;
  while (x < y) {
    int m = x + (y - x) / 2;
    if (cal(m)) {
      ans = m;
      x = m + 1;
    } else {
      y = m;
    }
  }
  cout << ans << '\n';
  return 0;
}
