# -*- coding: utf-8 -*-
t = gets.chomp.split(" ")
a = gets.chomp.split(" ")
b = gets.chomp.split(" ")
t1 = t[0].to_i
t2 = t[1].to_i
a1 = a[0].to_i
a2 = a[1].to_i
b1 = b[0].to_i
b2 = b[1].to_i
d = Array.new(2).map{Array.new(222222,0)}

for i in 0..222220
  if i%2==0
    d[0][i+1]=d[0][i]+a1*t1
    d[1][i+1]=d[1][i]+b1*t1
  else
    d[0][i+1]=d[0][i]+a2*t2
    d[1][i+1]=d[1][i]+b2*t2
  end
end
if d[0][2]==d[1][2]
  puts "infinity"
else
  ans=0
  f=0
  for i in 0..222221
    if f==-1&&d[0][i]>=d[1][i]
      ans+=1
    end
    if f==1&&d[0][i]<=d[1][i]
      ans+=1
    end
    if d[0][i]<d[1][i]
      f=-1
    elsif d[0][i]>d[1][i]
      f=1
    else
      f=0
    end
  end
end
puts ans
