read A
read B
read C
read X

count=0

for (( a = 0; a <= A; a++ )); do
    for (( b = 0; b <= B; b++ )); do
        for (( c = 0; c <= C; c++ )); do
            ((a * 500 + b * 100 + c * 50 == X)) && : $((++count))
        done
    done
done

echo ${count}
