#include <bits/stdc++.h>
const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};
using namespace std;
int main() {
  int n, x;
  scanf("%d%d", &n, &x);
  vector<int> a(n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < n; i++) {
    x -= a[i];
    if (x >= 0) ans = i + 1;
  }
  if (ans == n && x != 0) ans--;
  cout << ans << endl;
  return 0;
}
