declare -i l declare -i k declare -i n=0 read l k if [ $((l % (k * 2))) -eq 0 ]; then n=-1 fi echo $(((n + l / (k * 2)) * k))