#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105;
int n, x;
int a[MAXN];
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];
    else {
      printf("%d\n", i - 1);
      return 0;
    }
  }
  if (a[n] == x)
    printf("%d\n", n);
  else
    printf("%d\n", n - 1);
}
