#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int t1, t2, a1, a2, b1, b2;
	cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
	int da = t1*a1+t2*a2, db = t1*b1+t2*b2, da1 = t1*a1, db1 = t1*b1;
	if(da == db)
		return !(cout << "infinity");
	if((da < db) == (da1 < db1))
		return !(cout << 0);
	int x = abs(da1-db1), y = abs(da-db);
	cout << ((x+y-1)/y)*2-1+(x % y == 0);
}