#include<iostream>
using namespace std;
long T1,T2,A1,A2,B1,B2;
int main()
{
	cin>>T1>>T2>>A1>>A2>>B1>>B2;
	long X=A1*T1+A2*T2,Y=B1*T1+B2*T2;
	if(X==Y)
	{
		cout<<"infinity"<<endl;
	}
	else
	{
		long d,D;
		if(X>Y)
		{
			d=B1*T1-A1*T1;
			D=X-Y;
		}
		else
		{
			d=A1*T1-B1*T1;
			D=Y-X;
		}
		if(d<0)cout<<0<<endl;
		else if(d==0)cout<<1<<endl;
		else
		{
			long ans=1;
			d-=D;
			if(d>=0)
			{
				ans+=d/D*2;
				d%=D;
				ans+=2;
				if(d==0)ans--;
			}
			cout<<ans<<endl;
		}
	}
}
