#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
int a[maxn];
int main() {
  int n, x, cnt = 0, ans = 0;
  cin >> n >> x;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] > x) cnt++;
  }
  if (cnt == n) {
    cout << 0 << endl;
    return 0;
  }
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; i++) {
    if (x < a[i]) break;
    if (x >= a[i]) {
      x -= a[i];
      ans++;
    }
  }
  if (x != 0) ans--;
  cout << ans << endl;
  return 0;
}
