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