x,y,l = 3.times.map { gets.to_i } forward = [x,y].map {|d| (d.abs + l - 1) / l }.inject(0,&:+) turn = 0 if y < 0 turn = 2 elsif x.abs > 0 turn = 1 end puts forward + turn