#include "bits/stdc++.h"
using namespace std;

int main() {
	long long T1, T2, A1, A2, B1, B2;
	cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
	if (T1 * A1 + T2 * A2 == T1 * B1 + T2 * B2) {
		cout << "infinity" << endl;
		return 0;
	}
	if (A1 < B1) swap(A1, B1), swap(A2, B2);
	if (T1 * A1 + T2 * A2 > T1 * B1 + T2 * B2) {
		cout << 0 << endl;
		return 0;
	}
	long long SA1 = T1 * A1, SA2 = T2 * A2, SB1 = T1 * B1, SB2 = T2 * B2;
	long long ANS = (SA1 - SB1 - 1) / (SB1 + SB2 - SA1 - SA2) * 2 + 1;
	long long ANS2 = (ANS + 1) / 2;
	if (ANS2 * (SB1 + SB2 - SA1 - SA2) == SA1 - SB1) cout << ANS2 * 2 << endl;
	else cout << ANS << endl;
}