/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}


int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    long long T1,T2;cin >> T1 >> T2;
    long long A1,A2;cin >> A1 >> A2;
    long long B1,B2;cin >> B1 >> B2;
    
    if(A1 > B1 && A2 > B2){
        cout << 0 << endl;
        return 0;
    }
    else if(A1 < B1 && A2 < B2){
        cout << 0 << endl;
        return 0;
    }

    long long cycle1 = (A1-B1)*T1;
    long long cycle2 = (A2-B2)*T2;

    if(abs(cycle1) > abs(cycle2)) {
        cout << 0 << endl;
        return 0;
    }

    long long ans = 1;

    if(cycle1 > 0){
        long long FirstUp = cycle1;
        long long SecondUp = cycle1+cycle2+cycle1;
        if(SecondUp < 0){
            cout << 1 << endl;
            return 0;
        }
        long long down = FirstUp-SecondUp;
        //cout << cycle1 << " " << cycle2 << " " << FirstUp << " " << SecondUp << " " << down << endl;
        if(down == 0){
            cout << "infinity" << endl;
            return 0;
        }
        ans = FirstUp/down;
        ans *= 2;
        if(FirstUp % down != 0) ans++;
        cout << ans << endl;
    }
    else{
        long long FirstUp = cycle1;
        long long SecondUp = cycle1+cycle2+cycle1;
        if(SecondUp > 0){
            cout << 1 << endl;
            return 0;
        }
        long long down = FirstUp-SecondUp;
        //cout << cycle1 << " " << cycle2 << " " << FirstUp << " " << SecondUp << " " << down << endl;
        if(down == 0){
            cout << "infinity" << endl;
            return 0;
        }
        ans = FirstUp/down;
        ans *= 2;
        if(FirstUp % down != 0) ans++;
        cout << ans << endl;
    }

}


Measured memory_bytes: 3684