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