s = list(map(int,input().split(" ")))
n = s[0]
cost1 = s[1]
cost = 0
mark1 = list(map(int,input().split(" ")))
mark2 = list(map(int,input().split(" ")))
for i in range(n):
    c = min(mark1[i],mark2[i])
    cost+=c
ans = min(cost1,cost)
print(ans)