#include #include #include using namespace std; int main() { int N,M; int sum=0; bool flag; cin >> N; cin >> M; vector c(N); for (int i = 0; i < N; i++) { cin >> c[i]; } sort(c.begin(), c.end()); for (int i = 0; i < N; i++) { flag = true; while(c[i]>0){ c[i]--; sum++; if (sum == M) { flag = false; break; } } if (flag == false) { break; } } /*for (int i = 0; i < N; i++) { cout << c[i]<<"\n"; }*/ cout << count(c.begin(), c.end(),0) << endl; return 0; }