read A; read B; read C; read X

for a in $(seq 0 $A); do
    for b in $(seq 0 $B); do
        for c in $(seq 0 $C); do
            # if (( $(( $a * 500 + $b * 100 + $c * 50 == $X )) )); then
            if (( $(expr $a \* 500 + $b \* 100 + $c \* 50 == $X ) )); then
                echo y
            fi
        done
    done
done | wc -l
