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

int main() {
    ll T1, T2, A1, A2, B1, B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    ll d1 = A1 - B1, d2 = A2 - B2;
    ll once = d1 * T1 + d2 * T2;
    if (once == 0) {
        cout << "infinity" << endl;
        return 0;
    } else if ((d1 > 0 && once > 0) || (d1 < 0 && once < 0)) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = d1 * T1 / (- once);
    if (d1 * T1 % (- once) == 0) {
        ans *= 2;
    } else {
        ans = 2 * ans + 1;
    }
    cout << ans << endl;
}