#include <bits/stdc++.h>
using namespace std;
int n, x;
const int MAXN = 100 + 10;
int ai[MAXN];
int main() {
  scanf("%d%d", &n, &x);
  for (int i = 1; i <= n; i++) scanf("%d", &ai[i]);
  sort(ai + 1, ai + n + 1);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (x >= ai[i]) {
      x -= ai[i];
      ans++;
    } else
      break;
  }
  if (x && ans) ans--;
  printf("%d\n", ans);
  return 0;
}
