import strutils, sequtils let NM, C0 = stdin.readLine.split.map parseInt var C = C0 for i in 0 ..< NM[1]: let j = find(C, C.min) C[j] -= 1 if C[j] == 0: C.delete(j) echo C0.len - C.len