MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort{|x,y|y<=>x} end##
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
t1,t2=gsmi
gcd=t1.gcd(t2)
t1/=gcd
t2/=gcd

a1,a2=gsmi
b1,b2=gsmi

da1=t1*a1
da2=t2*a2
db1=t1*b1
db2=t2*b2

da=da1+da2
db=db1+db2
diff=(da-db).abs

putsend 'infinity' if diff==0
putsend 0 if da>db&&da1>=db1 || da<db&&da1<=db1

d=(da1-db1).abs
cnt = (d/diff.to_f).ceil * 2
cnt+=1 if d%diff==0
# スタート時補正
cnt-=1

puts cnt