t = gets.split.map(&:to_i)
a = 2.times.map{gets.split.map(&:to_i)}
2.times{|i|
  2.times{|j|
    a[j][i] *= t[i]
  }
}
2.times{|i|
  min = 2.times.map{|j|a[j][i]}.min
  2.times{|j|a[j][i] -= min}
}


if a[0].inject(:+) == a[1].inject(:+)
  puts "infinity"
else
  x = 2.times.map{|i|a[0][i]}.inject(:+)
  y = 2.times.map{|i|a[1][i]}.inject(:+)
  min = [x,y].min
  max = [x,y].max
  ans = (min.to_f/(max-min)).ceil
  p (ans*2-1<0)? 0 : (ans*2-1)
end