n,k=list(map(int,input().split())) A=sorted([int(input()) for i in range(n)],reverse=True) now,index=k,0 for a in A: if now-a>=0: now-=a print(k-now)