v=[500,100,50,10,5,1] c=[*map(int,input().split())] for i in range(len(v)): c[-1]-=min(c[i],c[-1]//v[i])*v[i] print('YES' if c[-1]==0 else 'NO')