#include <bits/stdc++.h>
using namespace std;
int n, x;
int a[105];
int ans;
long long sum[105];
int main() {
  while (cin >> n >> x) {
    ans = 0;
    int pos = 0;
    memset(a, 0, sizeof(a));
    memset(sum, 0, sizeof(sum));
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + (long long)a[i];
    if (sum[n] == x)
      ans = n;
    else if (sum[n] < x)
      ans = n - 1;
    else {
      for (int i = 1; i <= n; i++) {
        if (sum[i] <= x && sum[i + 1] >= x) {
          pos = i;
          break;
        }
      }
      if (sum[pos] == x)
        ans = pos;
      else if (sum[pos] < x)
        ans = pos - 1;
      if (!pos) ans = 0;
    }
    cout << ans << endl;
  }
}
