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