r,p,q=map(int,input().split()) a,b,c,d=map(int,input().split()) v=[a,b,c] v.sort() a,b,c=v[0],v[1],v[2] rest=r if rest