#include using namespace std; typedef long long ll; int main(){ int n, w, x, y, ans; cin >> n >> w; int a[n] = {}; for (int i = 0; i < n; i++) cin >> a[i]; ans = 0; for (int i = 0; i < pow(2, n); i++){ x = i; y = 0; for (int j = 0; j < n; j++){ y += a[j] * (x % 2); x >>= 1; } if (y <= w) ans = max(y, ans); } cout << ans << endl; return 0; }