T1, T2 = gets.split.map &:to_i
A1, A2 = gets.split.map &:to_i
B1, B2 = gets.split.map &:to_i
x = [A1, B1].min
A1 -= x
B1 -= x
y = [A2, B2].min
A2 -= y
B2 -= y
A1 *= T1
B1 *= T1
A2 *= T2
B2 *= T2
T1 = T2 = 1

# p [T1, T2]
# p [A1, A2]
# p [B1, B2]

a = A1 + A2
b = B1 + B2
if a == b
  puts "infinity"
elsif a == 0 || b == 0
  p 0
else
  diff = (a - b).abs
  p a / diff + b / diff
end