#include <bits/stdc++.h>
int n, x, ans;
int num[1000];
bool cmp(int x, int y) { return x < y; }
int main(void) {
  scanf("%d%d", &n, &x);
  for (int i = 1; i <= n; i++) scanf("%d", &num[i]);
  std ::sort(num + 1, num + 1 + n, cmp);
  for (int i = 1; i <= n; i++) {
    if (x >= num[i]) {
      x -= num[i];
      ans++;
    } else
      break;
  }
  printf("%d\n", ans);
  return 0;
}
