private fun solve(T: List<Long>, A: List<Long>, B: List<Long>, a: Long, b: Long) {
    if (A[0] >= B[0]) {
        println(0)
        return
    }

    val c = a - b
    val m = T[0] * (B[0] - A[0])
    val l = (m + c - 1) / c

    println(2 * l - (if (m % c == 0L) 0 else 1))
}

fun main(args: Array<String>) {
    val T = readLine()!!.split(" ").map{it.toLong()}
    val A = readLine()!!.split(" ").map{it.toLong()}
    val B = readLine()!!.split(" ").map{it.toLong()}

    val a = A[0] * T[0] + A[1] * T[1]
    val b = B[0] * T[0] + B[1] * T[1]

    if (a == b) {
        println("infinity")
        return
    }

    if (a >= b) {
        solve(T, A, B, a, b)
    } else {
        solve(T, B, A, b, a)
    }
}
