#include #include #include #include #include #include #include #include #include #include using namespace std; const int mod = 1e9 + 7; const int INF = 999999999; long long a, b, k[25], ans; int main() { cin >> a >> b; for (int i = 0; i < a; ++i) { cin >> k[i]; } for (int bit = 0; bit < (1 << a); ++bit) { long long sum = 0; for (int i = 0; i < a; ++i) { if (bit & (1 << i)) { sum += k[i]; } } if (sum <= b) { ans = max(ans, sum); } } cout << ans << endl; }