      PROGRAM run
      IMPLICIT NONE
      INTEGER(16) :: a1,a2,b1,b2,t1,t2
      INTEGER(16) :: iter,sub,len1,len2,s,l,pos1,pos2
      INTEGER(16) :: piyo,i,ans
      
      read*,t1,t2
      read*,a1,a2
      read*,b1,b2
      
      
      len1 = t1*a1 + t2*a2
      len2 = t1*b1 + t2*b2
      s = min( len1,len2 )
      l = max( len1,len2 )
      
      sub = l - s
      
      if( sub==0 )then
        print*,'infinity'
        stop
      end if
      iter = s / sub + 1
      
      pos1 = 0;pos2 = 0;ans = 0
      piyo = 3
      do i = 1,iter
        pos1 = pos1 + t1*a1
        pos2 = pos2 + t1*b1
        if( pos2 > pos1 )then
          if(piyo==1) ans = ans + 1
          piyo = 2
        else
          if(piyo==2) ans = ans + 1
          piyo = 1
        end if
        
        
        pos1 = pos1 + t2*a2
        pos2 = pos2 + t2*b2
        if( pos2 > pos1 )then
          if(piyo==1) ans = ans + 1
          piyo = 2
        else
          if(piyo==2) ans = ans + 1
          piyo = 1
        end if
      end do
      
      print*,ans
      
      
      
      END PROGRAM