T = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)

b = ( T[0] * A[0] + T[1] * A[1] ) - ( T[0] * B[0] + T[1] * B[1] )
if b == 0
  puts "infinity"
else
  a = T[0] * ( A[0] - B[0] )
  if a * b > 0
    puts 0
  else
    c = ( a / b ) * -2
    if a % b != 0
      c -= 1
    end
    puts c
  end
end