gets d = gets.split.map(&:to_i) x1,y1 = gets.split.map(&:to_i) z = [x1+y1,x1-y1].map(&:abs).max if z==0 p 0;exit end if d.include?(z) p 1;exit end dmax = d.max d.each do |e| if z < e && ( e.odd? || (e.even? && z.even?)) p 2;exit end end d.each do |e| if ((z+e-1)/e) <= 2 && ( e.odd? || (e.even? && z.even?)) p (z+e-1)/e;exit end end p -1