#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;
}
const long long INF = 1LL << 60;
int main() {
  int n, x, v;
  bool b = 1, c = 1;
  cin >> n >> x;
  int a[1000];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    x -= a[i];
    if (x < 0) {
      v = i - 1;
      b = 0;
      c = 0;
      break;
    }
  }
  if (c) v = n;
  if (x != 0 && b) {
    v -= 1;
  }
  cout << v << endl;
}
