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