fun main(args: Array<String>) {
    val (T1, T2) = readInputLine().split(" ").map { it.toLong() }
    val (A1, A2) = readInputLine().split(" ").map { it.toLong() }
    val (B1, B2) = readInputLine().split(" ").map { it.toLong() }
    
    var P = (A1 - B1) * T1
    var Q = (A2 - B2) * T2
    
    if (P > 0L) {
        P *= -1L
        Q *= -1L
    }
    
    if (P + Q < 0L) {
        println(0)
    } else if (P + Q == 0L) {
        println("infinity")
    } else {
        val S = P * -1L / (P + Q)
        val T = P * -1L % (P + Q)
        
        if (T == 0L) {
            println(S * 2L)
        } else {
            println(S * 2L + 1L)
        }
    }
}

fun readInputLine(): String {
    return readLine()!!
}
