main = interact $ show.solve.map read.words

solve :: [Int] -> Int
solve [a,b,c,d] = length [(x,y,z)|x <- (l a), y <- (l b), z <- (l c), culc x y z == d]
  where
    l s=[x|x <-[0..50], x <= s] 
    culc x y z = 500*x + 100*y + 50*z