a,b=map(int,input().split(" "))
p=[]
u=0
for i in range(a):
    n=map(int,input().split(" "))
    n=list(n)
    p.append(n[0])
    p.append(n[1])
if b<=sum(p):
    u=0
else:
    u=b-sum(p)
print(sum(p)+u)