#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


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