#include <bits/stdc++.h>

#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

using namespace std;

typedef uint64_t ulint;
typedef int64_t lint;

// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;

template<class T> lint sum(vector<T> a);
template<class T> double ave(vector<T> a);
template<typename T> ostream& operator << (ostream& s, const vector<T>& v);
ulint gcd(lint a, lint b);
ulint lcm(lint a, lint b);

bool flagdebug = false;





int main(){
//////////////////////////////////////////////////////

    //flagdebug = true; ///本番時削除！！！！！

    //入力

    lint t1, t2, a1, a2, b1, b2;
    cin >> t1>>t2 >> a1 >> a2 >> b1 >> b2;


    lint d1, d2, dc;

    d1 = (b1 - a1) * t1;//aphaseでの差分
    d2 = (b2 - a2) * t2;//bphaseでの差分
    dc = d1 + d2;//1cycleでの差分
    
    if(dc == 0)
    {
        cout << "infinity" << endl;
    }
    else if((d1 > 0 && dc < 0) || (d1 < 0 && dc > 0) )
    {
        lint cnt = 1;
        // debug(d1);
        // debug(d2);
        // debug(dc);
        lint dice = abs(lint((d1 + dc ) / dc)) + 1;
        cnt += (dice - 1) * 2 ;//すれ違い回数
        //debug(cnt);

        lint z = dice * dc; //上記のすれ違いを経たあとの差分
        //debug(z);
        if(abs(z) < abs(d1))
        {
            cnt += 2;
        }
        else if(abs(z) == abs(d1))
        {
            cnt ++;
        }

        cout << cnt << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    return 0;
}


struct node
{
    node* parent;
    node* firstchild;
    node* lastchild;
    node* olderbrother;
    node* youngerbrother;
    lint childnum;
    lint value;
public:
    node()
    {
        parent = NULL;
        firstchild = NULL;
        lastchild = NULL;
        olderbrother = NULL;
        youngerbrother = NULL;
        childnum = 0;
        value = 0;
    }

    void addchild(node* newchild)
    {
        if(childnum == 0)
        {
            firstchild = newchild;
        }
        else
        {
            lastchild->youngerbrother = newchild;
            newchild->olderbrother = lastchild;
            
        }
        lastchild = newchild;
        newchild->parent = this;
        childnum++;
    }
    void deletechild(node* child)
    {
        if(child->parent != this)return;
        if(child->youngerbrother != NULL)
        {
            child->youngerbrother->olderbrother = child->olderbrother;
        }
        if(child->olderbrother != NULL)
        {
            child->olderbrother->youngerbrother = child->youngerbrother;
        }
        childnum--;
    }

    bool operator<(const node &another) const{return value < another.value;};
    bool operator>(const node &another) const{return value > another.value;};   
};

//vectorprint用
template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
    s << "[\t";
    for (auto i = v.begin(); i < v.end() - 1; i++){s << *i << "\t";}
    s << *(v.end() - 1) << "\t]\n";
	return s;
}

// 最大公約数
ulint gcd(lint a, lint b){
    if(b!=0){return gcd(b, a % b);}
    return a;    
}

//最小公倍数
ulint lcm(lint a, lint b){
    return a / gcd(a, b) * b;
}


Measured memory_bytes: 256