#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int a[N];
int n, x;
long long sum[N];
int main() {
  cin >> n >> x;
  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] + a[i];
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (sum[i] == x) {
      cout << i << endl;
      return 0;
    }
  }
  if (sum[1] > x) {
    cout << 0 << endl;
    return 0;
  }
  if (sum[n] < x) {
    cout << n - 1 << endl;
    return 0;
  }
  for (int i = 2; i <= n; i++) {
    if (sum[i] > x && sum[i - 1] < x) {
      cout << i - 2 << endl;
      return 0;
    }
  }
}
