T1,T2=gets.split.map(&:to_i)
a1,a2=gets.split.map(&:to_i)
b1,b2=gets.split.map(&:to_i)
A1,A2,B1,B2= a1>b1 ? [a1,a2,b1,b2] : [b1,b2,a1,a2]
XA=A1*T1+A2*T2
XB=B1*T1+B2*T2
if XA>XB
  ans="0"
elsif XA==XB
  ans="infinity"
else
  XM=(A1-B1)*T1
  ans=(XM/(XB-XA)*2 + (XM%(XB-XA)==0 ? 0 : 1)).to_s
end
puts ans
