#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = {0, -1, 1, 0};
const ll dy[4] = {-1, 0, 0, 1};
const int INF = 1e9 + 7;
int gcd(int x, int y) {
  if (x < y) swap(x, y);
  if (y == 0) return x;
  return gcd(y, x % y);
}
void mul(ll a, ll b) { a = a * b % INF; }
double mysqrt(double x) {
  double l = 0, r = x;
  for (int i = 0; i < 64; ++i) {
    double m = (l + r) / 2.0;
    if (m * m < x)
      l = m;
    else
      r = m;
  }
  return l;
}
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  int key = x;
  for (int i = 0; i < n; ++i) {
    if (x >= a[i]) {
      x -= a[i];
      ans++;
    } else {
      break;
    }
  }
  if (x == 0 || x == key)
    cout << ans << endl;
  else
    cout << ans - 1 << endl;
  return 0;
}
