#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, sum = 0, ans = 0;
  scanf("%d %d", &n, &x);
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  sort(a.begin(), a.end());
  if (sum == x) {
    ans = n;
  } else {
    sum = 0;
    for (int i = 0; i < n; i++) {
      sum += a[i];
      if (sum <= x) {
        ans = i + 1;
      } else {
        continue;
      }
    }
    if (ans == n) {
      ans = n - 1;
    }
  }
  printf("%d", ans);
}
