#include <bits/stdc++.h>
using namespace std;
int on_bit(int x, int pos) {
  x |= (1 << pos);
  return x;
}
int off_bit(int x, int pos) {
  x &= ~(1 << pos);
  return x;
}
bool is_on_bit(int x, int pos) { return ((x & (1 << pos)) != 0); }
int flip_bit(int x, int pos) {
  x ^= (1 << pos);
  return x;
}
int lsb(int x) { return x & (-x); }
int on_bit_all(int x, int pos) {
  x = (1 << pos) - 1;
  return x;
}
const double EPS = 1e-9;
const double PI = 2 * acos(0.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int dx1[] = {0, 1, 0, -1};
const int dy1[] = {1, 0, -1, 0};
const int dx2[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy2[] = {-1, 0, 1, -1, 1, -1, 0, 1};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long n, x, a[1234];
signed main() {
  scanf("%lld %lld", &n, &x);
  for (long long i = 0; i < (long long)n; i++) scanf("%lld", a + i);
  long long res = 0;
  long long cc = 0;
  sort(a, a + n);
  for (long long i = 0; i < (long long)n; i++) {
    cc += a[i];
    if (cc <= x) res++;
    if (cc == x) break;
  }
  if (cc != x) res--;
  printf("%lld\n", (res < 0 ? 0 : res));
  return 0;
}
