#include <bits/stdc++.h>
using namespace std;
int comp(const void *c1, const void *c2);
int main() {
  int n, x;
  cin >> n >> x;
  int a[100];
  for (int i = 0; i != n; i++) {
    cin >> a[i];
  }
  qsort(a, n, sizeof(int), comp);
  int ans = 0;
  for (int i = 0; i != n; i++) {
    if (x - a[i] >= 0) {
      ans += 1;
      x = x - a[i];
    } else {
      break;
    }
  }
  if (x > 0) {
    ans = ans - 1;
  }
  cout << ans << '\n';
  return 0;
}
int comp(const void *c1, const void *c2) {
  int tmp1 = *(int *)c1;
  int tmp2 = *(int *)c2;
  if (tmp1 < tmp2) return -1;
  if (tmp1 == tmp2) return 0;
  if (tmp1 > tmp2) return 1;
}
