T1, T2 = gets.split.map &:to_i
A1, A2 = gets.split.map &:to_i
B1, B2 = gets.split.map &:to_i
a1 = T1 * A1
a2 = T2 * A2
b1 = T1 * B1
b2 = T2 * B2
if a1 + a2 == b1 + b2
    puts :infinity
    exit
end

ans = 0
diff = 0
initial = true
while true
    continue = false
    curr = diff
    if ((diff <=> 0) != ((diff = diff + a1 - b1) <=> 0) && curr != 0)
        ans += 1
        continue = true
    end
    curr = diff
    if ((diff <=> 0) != ((diff = diff + a2 - b2) <=> 0) && curr != 0)
        ans += 1
        continue = true
    end
    break if !continue
    initial = false
end
p ans