r,p,q=map(int,input().split()) a,b,c,d=map(int,input().split()) left=0;right=10**10 while left+1r: right=mid else: left=mid print(left)