n=int(input())
a=int(input())
net=[]
for i in range(1,n+1):
    for j in range(1,2*a):
        etc=int(input())
        net.append(etc)
        etc=None
        if(i==n):
            break
    if net[i-1] > a:
       print(sum(net))
       break
    else:
        print(a)
        break