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