#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  vector<ll> t(2), a(2), b(2);
  cin >> t[0] >> t[1] >> a[0] >> a[1] >> b[0] >> b[1];

  ll as = t[0] * a[0] + t[1] * a[1], bs = t[0] * b[0] + t[1] * b[1];
  if (as == bs) {
    cout << "infinity" << endl;
    return 0;
  } else if (as < bs) {
    swap(a[0], b[0]);
    swap(a[1], b[1]);
  }

  vector<ll> d{t[0] * a[0] - t[0] * b[0], t[1] * a[1] - t[1] * b[1]};
  d[1] += d[0];
  if (d[0] > 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << ((-d[0]) % d[1] == 0 ? (-d[0]) / d[1] * 2 : (-d[0]) / d[1] * 2 + 1) << endl;
}
