#!/bin/bash
read a # 500
read b # 100
read c # 50
read x # target
c=0
#cc=0
for ia in `seq 0 $a`; do
  for ib in `seq 0 $b`; do
    for ic in `seq 0 $c`; do
      #echo $ia
      #echo $ib
      #echo $ic
      cc=$(($cc+1))
      #echo AAA
      #echo $((500*$ia+100*$ib+50*$ic))
      #echo $((500*$ia+100*$ib+50*$ic))
      if [ $(($((500*$ia))+$((100*$ib))+$((50*$ic)))) -eq $x ];then
        c=$(($c+1))
      fi
    done
  done
done
echo $c
#echo XXXXXXX
#echo $cc