#include <bits/stdc++.h>
using namespace std;
long long a[100 + 15] = {0};
int main() {
  long long n, x;
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int count = 0;
  long long t = a[0];
  x -= a[0];
  if (x >= 0) {
    count++;
  }
  for (int i = 1; i < n; i++) {
    if (x < 0) {
      break;
    }
    if (a[i] != t) {
      x -= a[i];
      t = a[i];
      count++;
    }
  }
  cout << count;
}
