class Calc0208 def initialize(args) args = args.map { |l| l.chomp.split(/\s+/) } @x, @y = args.shift.map(&:to_i) @x2, @y2 = args.shift.map(&:to_i) end def run x, y = @x.abs, @y.abs x2, y2 = @x2.abs, @y2.abs c = [x, y].max c += 1 if x == y && x2 == y2 && x > x2 && @x / x == @x2 / x2 && @y / y == @y2 / y2 c end end puts Calc0208.new(STDIN.readlines).run if __FILE__ == $0