#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 105;
int n, x, a[kMaxN];
map<int, int> mp;
int main() {
  scanf("%d%d", &n, &x);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
  }
  sort(a + 1, a + n + 1);
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (x == 0) break;
    if (x >= a[i]) {
      x -= a[i];
      ++mp[a[i]];
      ++ans;
    } else if (x < a[i]) {
      if (mp[a[i] - x]) {
        x = 0;
        --mp[a[i] - x];
        break;
      }
    }
  }
  if (x > 0) ans = max(ans - 1, 0);
  printf("%d\n", ans);
  return 0;
}
