let () =
    let main () =
        let t1, t2 = Scanf.sscanf (read_line ()) "%d %d" (fun t1 t2 -> t1, t2) in
        let a1, a2 = Scanf.sscanf (read_line ()) "%d %d" (fun a1 a2 -> a1, a2) in
        let b1, b2 = Scanf.sscanf (read_line ()) "%d %d" (fun b1 b2 -> b1, b2) in
        let r =
            if a1 = b1 then (-1) else (
                let m1a = t1 * a1 in
                let m1b = t1 * b1 in
                let m2a = m1a + t2 * a2 in
                let m2b = m1b + t2 * b2 in
                if m2a = m2b then (-1) else
                    if (m1a > m1b && m2a > m2b) || 
                       (m1a < m1b && m2a < m2b) then 0 else (
                           let d1 = t1 * (max a1 b1 - min a1 b1) in
                           let d2 = t2 * (max a2 b2 - min a2 b2) in
                           let rec loop d acc =
                               if d = 0 then acc else
                               if d - d2 > 0 then acc else
                                   if d - d2 + d1 < 0 then acc + 1 else
                                       loop (d - d2 + d1) (acc + 2)
                           in
                           let c = d1 / (d2 - d1) in
                           loop (d1 + (d1 - d2) * c) (2 * c) 
                       )
            )
        in
        if r < 0 then Printf.printf "infinity\n" else Printf.printf "%d\n" r
    in
    main ()