fin = open('castle.in', 'r')
fout = open('castle.out', 'w')
input = fin.readline

read = lambda: map(int, input().split())
n, s = read()
a, k = [0] * n, [0] * n
for i in range(n):
    a[i], k[i] = read()

# k == 1
ans = max(0, sum(a) - s)
print(ans, file = fout)

fin.close()
fout.close()