#include using namespace std; int main() { int n, k; cin >> n >> k; vector a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } int ans = 0; for (int i = 0; i < (1 << n); ++i) { int w = 0; for (int j = 0; j < n; ++j) { if (i & (1 << j)) w += a[j]; } if (w <= k) ans = max(ans, w); } cout << ans << endl; return 0; }