#!/usr/bin/env ruby

T1, T2, A1, A2, B1, B2 = 3.times.collect{gets.chomp.split(/ /).collect(&:to_i)}.flatten
delta1 = T1 * (B1 - A1)
delta2 = T2 * (B2 - A2)
if delta1 * delta2 > 0
  puts(0)
else
  if delta1.abs > delta2.abs
    puts(0)
  elsif delta1.abs == delta2.abs
    puts('infinity')
  else
    delta3 = Rational(-delta1, delta1 + delta2)
    puts(2 * delta3.floor + (delta3.ceil - delta3.floor))
  end
end