from re import split n, x = map(int, input().split()) list1=list(map(int, input().split())) list2=list(map(int, input().split())) totoal_cost=0 for i in range(n): if list1[i] < list2[i]: totoal_cost += list1[i] else: totoal_cost += list2[i] if totoal_cost> x: print(x) else: print(totoal_cost)