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