#include <bits/stdc++.h>
using namespace std;
const int mn = 1e5 + 5;
int n, x;
int a[mn];
int main() {
  scanf("%d%d", &n, &x);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (x >= a[i]) x -= a[i], ans++;
  if (x) ans--;
  if (ans < 0) ans = 0;
  printf("%d\n", ans);
  return 0;
}
