#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) {
  if (a == 1) {
    return false;
  }
  if (a == 2) {
    return true;
  }
  if (a % 2 == 0) {
    return false;
  }
  for (int i = 3; i < sqrt(a) + 1; i += 2) {
    if (a != i) {
      if (a % i == 0) {
        return false;
      }
    }
  }
  return true;
}
struct setupios {
  setupios() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
  };
} setupios;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  sort((a).begin(), (a).end());
  int ans = 0;
  for (long long i = 0; i < n; i++) {
    if (a[i] <= x) {
      x -= a[i];
      ans++;
    } else {
      break;
    }
  }
  if (x > 0) ans--;
  if (ans == -1) ans++;
  cout << ans << endl;
}
