r=io.read;while""do a=r(4)x=(a+r()^2/a+2)/4;print(x-x%1)end