let arr = stdin.ReadLine().Split() |> Array.map int let coin = [| 500; 100; 50; 10; 5; 1 |] let calc n m x = x - (min (x / m) n) * m let mutable v = arr.[6] for i = 0 to 5 do v <- calc arr.[i] coin.[i] v if v = 0 then "YES" else "NO" |> printfn "%s"