a,b,c,d,e,f,g=input().split() if g==a*500+b*100+c*50+d*10+e*5+f: print('YES') else: print('NO')