#include <bits/stdc++.h>
using namespace std;
int N, x;
int a[100];
void solve() {
  int num;
  sort(a, a + N);
  for (int i = 0; i < N; ++i) {
    x -= a[i];
    if (x < 0) {
      break;
    }
    num++;
    if (x == 0) {
      break;
    }
  }
  if (num == 0) {
    printf("%d\n", 0);
  } else if (x != 0) {
    printf("%d\n", num - 1);
  } else {
    printf("%d\n", num);
  }
}
int main() {
  cin >> N >> x;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  solve();
  return 0;
}
