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