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

ll solve() {
    ll T1, T2, A1, A2, B1, B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    ll c1 = A1 - B1;
    ll c2 = A2 - B2;
    ll d = c1 * T1 + c2 * T2;
    if ( d == 0 ) return -1;
    if ( d < 0 ) {
        d = -d, c1 = -c1, c2 = -c2;
    }
    if ( c1 > 0 ) return 0;
    ll f = -c1 * T1;
    ll r = f / d;
    ll ans = 1 + 2*r;
    if ( r * d == f ) ans--;
    return ans;
}

int main() {
    auto ans = solve();
    if ( ans < 0 ) cout << "infinity" << "\n";
    else cout << ans << "\n";
    return 0;
}