#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c > '9' || c < '0') f = c == '-' ? -1 : 1, c = getchar();
  while (c <= '9' && c >= '0') x = 10 * x + c - '0', c = getchar();
  return x * f;
}
int a[2000];
int main() {
  int n = read(), m = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  sort(a + 1, a + n + 1);
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (a[i] <= m)
      m -= a[i], ans++;
    else
      break;
  printf("%d", ans);
  return 0;
}
