#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int g[15][15];
const int INF = 1001001001;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
long long lcm(long long x, long long y) {
  if (x == 0 || y == 0) return 0;
  return (x / gcd(x, y) * y);
}
map<long long, long long> ins;
void facterize(long long n) {
  long long a = 2;
  while (n >= a * a) {
    if (n % a == 0) {
      ins[a]++;
      ins[a] = ins[a] % 1000000007;
      n /= a;
    } else {
      a++;
    }
  }
  ins[n]++;
}
vector<long long> relation[20], money(20, 1);
char s[110][110];
int dp[110][110];
int main() {
  long long n, x;
  cin >> n >> x;
  vector<long long> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    if (x >= a[i]) {
      ans++;
      x -= a[i];
    } else {
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
