#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
int INF = 1 << 30;
long long INFL = 1LL << 60;
int main() {
  int N, x;
  cin >> N >> x;
  int a[110];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a, a + N);
  int cnt = 0;
  for (int j = 0; j < N; j++) {
    x -= a[j];
    cnt++;
    if (x > 0)
      cnt += 0;
    else if (x == 0)
      cnt = cnt;
    else
      break;
  }
  if (x > 0)
    cout << cnt - 1 << endl;
  else
    cout << cnt << endl;
}
