a=input().split(' ')
n=int(a[0])
a=int(a[1])
b=[]
c=[]
for i in range(n):
    r=input().split(' ')
    b.append(int(r[0]))
    c.append(int(r[1]))
if sum(b)+sum(c)>=a:
    print(sum(b)+sum(c))
else:
    print(a)