#include <bits/stdc++.h>
using namespace std;
int n, x;
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch <= '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
int main() {
  n = read(), x = read();
  int* arr = new int[n];
  for (int i = 0; i < n; ++i) {
    arr[i] = read();
  }
  sort(arr, arr + n);
  int ans = 0;
  int i = 0;
  for (i = 0; i < n; ++i) {
    if (arr[i] <= x) {
      x -= arr[i];
      ans++;
    }
  }
  if (i == n && x)
    cout << n - 1;
  else
    cout << ans;
  return 0;
}
