import java.util.*

fun dfs(n : Int, s : String, mx : Char) {
    if (s.length == n) {
        println(s)
    } else {
        for (next in 'a'..mx) {
            dfs(n, s + next, mx)
        }
        dfs(n, s + (mx + 1), mx + 1)
    }
}
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val t1 = cin.nextInt()
    val t2 = cin.nextInt()
    val a1 = cin.nextLong()
    val a2 = cin.nextLong()
    val b1 = cin.nextLong()
    val b2 = cin.nextLong()
    val c1 = a1 - b1
    val c2 = a2 - b2
    val set : Long = c1 * t1 + c2 * t2
    if (set == 0.toLong()) {
        println("infinity")
    } else if ((set > 0.toLong() && c1 < 0) || (set < 0.toLong() && c1 > 0)) {
        val n = - c1 * t1 / set
        if (- (c1 * t1) % set == 0.toLong()) {
            println(2*n)
        } else {
            println(2*n + 1)
        }
    } else {
        println(0)
    }
}