N,X,Y,*A=`dd`.split.map &:to_i B=[] s=0 (1<0} q=Y/r-~-X/r s+=q*d*(d%2*2-1) } p s