let rec solve t1 t2 a1 a2 b1 b2 =
  let la, lb = a1*t1 + a2*t2, b1*t1 + b2*t2 in
  if la = lb then "infinity" 
  else if la > lb then solve t1 t2 b1 b2 a1 a2 
  else if a1 < b1 then "0"
  else
    let d = lb - la in
    let x = (a1-b1) * t1 in
    string_of_int @@ x / d * 2 + (x mod d + d - 1) / d
let () = Scanf.scanf "%d %d %d %d %d %d" solve |> print_endline
  
