import sys input = sys.stdin.readline N, K = map(int, input().split()) A = [int(input()) for _ in range(N)] ans = 0 for S in range(1<>i)&1: c += A[i] if c<=K: ans = max(ans, c) print(ans)