N,K = map(int,input().split()) A = [int(input()) for _ in range(N)] ans = 0 for i in range(1<>j & 1: tot += A[j] if tot<=K: ans = max(ans,tot) print(ans)