#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <stack>
typedef long long int llint;

template<long long int MODVALUE> class modllint{
  typedef long long int llint;
  llint val;
  void mod(){
    while( this->val < 0 ) this->val += MODVALUE;
    this->val %= MODVALUE;
  }
  void assign(const llint val){
    this->val = val;
    mod();
  }
public:
  modllint(): val(0){};
  modllint(const llint val){assign(val);};
  
  modllint& operator+=(const llint val){
    this->assign(this->val + val);
    return *this;
  }
  modllint& operator+=(const modllint& obj){
    this->assign(this->val + obj.val);
    return *this;
  }
  modllint operator+(const llint val){return this += val;}
  modllint operator+(const modllint& obj){return this += obj;}
  
  modllint& operator*=(const llint val){
    this->assign(this->val * val);
    return *this;
  }
  modllint& operator*=(const modllint& obj){
    this->assign(this->val * obj.val);
    return *this;
  }
  modllint operator*(const llint val){return this *= val;}
  modllint operator*(const modllint& obj){return this *= obj;}

  modllint& operator=(const modllint& obj){
    assign(obj.val);
    return *this;
  }
  modllint& operator=(const llint intvalue){
    assign(intvalue);
    return *this;
  }
  
  friend std::ostream& operator<<(std::ostream& os, const modllint<MODVALUE>& val){
    os << val.val;
    return os;
  }
  friend std::istream& operator>>(std::istream& is, modllint<MODVALUE>& val){
    is >> val.val;
    return is;
  }
};



int main(void){
  llint t1, t2, a1, a2, b1, b2;
  std::cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

  if(a1*t1 + a2*t2 == b1*t1 + b2*t2){
    std::cout << "infinity" << std::endl;
    return 0;
  }

  llint c1a = t1 * a1;
  llint c2a = c1a + t2*a2;
  llint c1b = t1*b1;
  llint c2b = c1b + t2*b2;
  
  if( ((c1a-c1b)>=0) ^ ((c2a-c2b)<0)){
    std::cout << 0 << std::endl;
    return 0;
  }

  llint minus_xmin = -100000000000000000L;
  llint minus_xmax = 0L;
  llint plus_xmin = 0L;
  llint plus_xmax = 100000000000000000L;
  while(minus_xmax - minus_xmin > 1){
    llint mid = (minus_xmin + minus_xmax)/2L;
    if( ((c1a-c1b + mid)<0) ^((c2a-c2b + mid)<0) ){
      // de a u yo----
      minus_xmax = mid;
    }else{
      minus_xmin = mid;
    }
  } 
  while(plus_xmax - plus_xmin > 1){
    llint mid = (plus_xmin + plus_xmax)/2L;
    if( ((c1a-c1b + mid)<0) ^((c2a-c2b + mid)<0) ){
      // de a u yo----
      plus_xmin = mid;
    }else{
      plus_xmax = mid;
    }
  }
  llint minus, plus;
  if( ((c1a-c1b + minus_xmin)<=0) ^((c2a-c2b + minus_xmin)<=0) ) minus = minus_xmin;
  else                                                         minus = minus_xmax;
  if( ((c1a-c1b + plus_xmax)<=0) ^((c2a-c2b + plus_xmax)<=0) ) plus = plus_xmax;
  else                                                       plus = plus_xmin;
  //std::cout << minus_xmax << " " << minus_xmin << std::endl;
  //std::cout << plus_xmax << " " << plus_xmin << std::endl;
  //std::cout << minus << " <= x <= " << plus << std::endl;
  
  llint diff = c2a - c2b;
  //std::cout << diff << std::endl;

  if(diff > 0){
    int temp = plus%diff == 0;
    std::cout << plus/diff*2 + 1L -temp << std::endl;
    
  }else{
    int temp = (-minus)%(-diff) == 0;
    std::cout << (-minus)/(-diff)*2 + 1L -temp<< std::endl;
  }
  
  return 0;
}


Measured memory_bytes: 256