#include <bits/stdc++.h>
using namespace std;
long long mod(long long a, long long b) {
  long long ret = a % b;
  if (ret < 0) ret += b;
  return ret;
}
long long modpow(long long a, long long b, long long c) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = mod(res * a, c);
    a = mod(a * a, c);
    b >>= 1;
  }
  return res;
}
int GCD(int x, int y) {
  if (x < y) {
    swap(x, y);
  }
  while (x % y != 0) {
    int temp = x;
    x = y;
    y = temp % y;
  }
  return y;
}
int digitsum(int x) {
  int sum = 0;
  while (x > 0) {
    sum += (x % 10);
    x /= 10;
  }
  return sum;
}
int main() {
  int n, x;
  cin >> n >> x;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    x -= a[i];
    if (x >= 0) {
      ans++;
      continue;
    } else
      break;
  }
  cout << ans << endl;
  return 0;
}
