using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i = 0;i < n;++i)
        cin >> v.at(i);
    sort(v.begin(),v.end());
    int sum = 0;
    int count = 0;
    for(int i = 0;i < n;++i)
    {
        if(sum + v[i] >= k)
        {
            if(sum + v[i] == k)
            {
                count++;
            }
            break;
        }
        if(i == n - 1)
        {
            break;
        }
        sum += v[i];
        count++;
    }
    cout << count <<endl;
}

