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