#include <bits/stdc++.h>
using namespace std;
long long multiply(long long num1, long long num2, long long mod) {
  long long ans = 0;
  num1 %= mod;
  num2 %= mod;
  while (num2) {
    if (num2 & 1) {
      ans += num1;
      ans %= mod;
    }
    num1 *= 2;
    num1 %= mod;
    num2 /= 2;
  }
  return ans;
}
long long powmod2(long long base, long long exponent, long long mod) {
  long long ans = 1;
  while (exponent) {
    if (exponent & 1) {
      ans = multiply(ans, base, mod);
    }
    base = multiply(base, base, mod);
    exponent /= 2;
  }
  return ans;
}
long long powmod(long long base, long long exponent, long long mod) {
  long long ans = 1;
  while (exponent) {
    if (exponent & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    exponent /= 2;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
const int upperlimit = 1e6 + 100;
const int mod = 1e9 + 7;
int arr[upperlimit];
int main() {
  int n, x;
  scanf("%d", &n);
  scanf("%d", &x);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &arr[i]);
  }
  sort(arr + 1, arr + n + 1);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    x -= arr[i];
    if (x < 0) {
      break;
    }
    cnt++;
  }
  printf("%d", cnt);
  return 0;
}
