You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total?  Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for a in range(A):
  for b in range(B):
    for c in range(C):
      if 500*a + 100*b + 50*c == X:
        count += 1
print(count)
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if 500*a + 100*b + 50*c == X:
        count += 1
print(count)