n, k = map(int, input().split()) al = sorted([int(input()) for _ in range(n)]) while al: if sum(al) <= k: break al = al[:-1] print(sum(al))