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