#include <bits/stdc++.h>
using namespace std;
const constexpr int INF = 1e9;
const constexpr long long MOD = 1e9 + 7;
const int BITSIZE = 100010;
struct Less {
  bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
    return x.second < y.second;
  }
};
struct More {
  bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
    return x.first > y.first;
  }
};
int bit[100010];
int bit_query(int i) {
  int res = 0;
  for (; i >= 1; i -= i & -i) res = max(res, bit[i]);
  return res;
}
void bit_set(int x, int v) {
  for (; x <= BITSIZE; x += x & -x) {
    bit[x] = max(bit[x], v);
  }
}
int a[110];
int main() {
  int N, x;
  cin >> N >> x;
  for (long long i = (long long)0; i < (long long)N; ++i) cin >> a[i];
  sort(a, a + N);
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    if (x - a[i] >= 0) {
      x -= a[i];
      ans++;
    } else {
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
