a,b,c,d,e,f,g = map(int, input().split()) s=500*a+100*b+50*c+10*d+5*e+f x=1 if g==s:x=0 elif g