N, M, *C = map(int, open(0).read().split()) print(min(sum(C) - M, N))