#include <bits/stdc++.h>
const int N = 110;
int a[N], n, m;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  std::sort(a + 1, a + n + 1);
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    int j = std::lower_bound(a + i, a + n + 1, m) - a;
    if (a[j] == m) {
      m -= a[j];
      ans++;
      break;
    } else if (m >= a[i]) {
      m -= a[i];
      ans++;
    } else {
      break;
    }
  }
  if (m != 0 && ans > 0) ans--;
  printf("%d\n", ans);
  return 0;
}
