#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ll T1, T2, A1, A2, B1, B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    ll step = T1*A1+T2*A2 - (T1*B1+T2*B2);
    ll hop = T1 * (A1 - B1); // != 0
    if(step == 0) {
        cout << "infinity" << "\n";
        return 0;
    }
    if((step > 0) == (hop > 0)){
        cout << 0 << "\n";
        return 0;
    }
    if(step < 0) step *= -1;
    if(hop < 0) hop *= -1;
    ll ans = hop / step;
    ans = ans * 2 + 1;
    if(hop % step == 0) ans--;
    cout << ans << "\n";
    return 0;
}