#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main() {
  int n, x;
  scanf("%d %d", &n, &x);
  int candy[n], i = 0;
  for (int j = 0; j < n; j++) scanf("%d", &candy[j]);
  sort(candy, candy + n);
  for (i = 0; i < n; i++) {
    if (x < candy[i]) break;
    x -= candy[i];
  }
  if (x > 0) i--;
  printf("%d\n", i);
}
