#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long countBits(long long in) {
  int res = 0;
  for (; in > 0; in >>= 1) {
    if ((in & 0x01) != 0) {
      res++;
    }
  }
  return res;
}
template <typename T>
void show2dVector(vector<vector<T>>& v) {
  for (int i = 0; i < v.size(); i++) {
    int m = v[i].size();
    cout << i << " : ";
    for (int j = 0; i < m; i++) {
      cout << v[i][j] << " ";
    }
    cout << endl;
  }
}
void bfs(const vector<vector<int>>& g, int v, vector<bool>& seen) {
  seen[v] = true;
  cout << v << " ";
  for (auto next : g[v]) {
    if (seen[next]) {
      continue;
    }
    bfs(g, next, seen);
  }
}
bool dfs(vector<vector<int>>& g, int start, int goal, vector<bool>& seen) {
  bool res = false;
  seen[start] = true;
  if (start == goal) {
    return true;
  }
  for (auto next : g[start]) {
    if (seen[next]) {
      continue;
    }
    res = dfs(g, next, goal, seen);
    if (res) {
      break;
    }
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
bool isLowerCase(char c) { return (c >= 'a' && c <= 'z'); }
long long powm(long long a, long long n, long long m) {
  long long ret = 1;
  while (n > 0) {
    if (n % 2 == 1) {
      ret = (ret * a) % m;
    }
    n >>= 1;
    a = (a * a) % m;
  }
  return ret;
}
const string yesno(bool ans) { return (ans ? "Yes" : "No"); }
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  int ans = 0;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    sum += a[ans];
    if (sum > x) {
      break;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}
