#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, X;
  cin >> N >> X;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int nin[N + 1][X + 1];
  for (int n = 0; n < N + 1; n++) {
    nin[n][0] = 0;
  }
  for (int x = 0; x < X + 1; x++) {
    nin[0][x] = 0;
  }
  for (int n = 1; n < N + 1; n++) {
    for (int x = 1; x < X + 1; x++) {
      if (a[n - 1] > x) {
        nin[n][x] = nin[n - 1][x];
      } else {
        nin[n][x] = max(nin[n - 1][x], nin[n - 1][x - a[n - 1]] + 1);
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum = sum + a[i];
  }
  if (nin[N][X] == N && sum < X) nin[N][X] = N - 1;
  cout << nin[N][X] << endl;
}
