#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int u = 0, f = 1;
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    u = (u << 1) + (u << 3) + ch - 48;
    ch = getchar();
  }
  return u * f;
}
const int maxn = 1e5 + 10;
int a[maxn];
int main() {
  int n = read(), x = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  sort(a + 1, a + 1 + n);
  int ans = 0, sum = 0;
  for (int i = 1; i <= n; ++i) {
    if (sum + a[i] > x) break;
    sum += a[i];
    ans++;
  }
  if (sum != x) ans--;
  if (ans == -1) ans++;
  cout << ans << endl;
  return 0;
}
