#include <iostream>
#include <cstring>
using namespace std;

int main() {
	unsigned long long t1, t2, a1, b1, a2, b2;
	cin>>t1>>t2>>a1>>a2>>b1>>b2;
	if (a1*t1+a2*t2 == b1*t1+b2*t2) {
		cout<<"infinity"<<endl;
		return 0;
	}
	if (a1*t1+a2*t2 < b1*t1+b2*t2) {
		swap(a1, b1);
		swap(a2, b2);
	}

	if (a1*t1 > b1*t1) {
		cout<<0<<endl;
		return 0;
	}

	// Then A1<B1 && A2>B2
	unsigned long long delta = a1*t1 + a2*t2 - b1*t1 - b2*t2;
	long long ans = (b1*t1 - a1*t1) / delta;
	ans = ans*2 + 1; // 1 is the first time.
	if ((b1*t1 - a1*t1) % delta == 0)
		ans--;
	cout<<ans<<endl;
	return 0;
}