import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main() {
  int t1,t2;
  long a1, a2;
  long b1, b2;
  readf (" %d %d", &t1, &t2);
  readf (" %d %d", &a1, &a2);
  readf (" %d %d", &b1, &b2);
  //si = ai * ti
  immutable long v1 = a1 - b1, v2 = a2 - b2;
  debug stderr.writeln ("v1 = ", v1);
  debug stderr.writeln ("v2 = ", v2);
  if (a1 * t1 + a2 * t2 == b1 * t1 + b2 * t2) {
    writeln ("infinity");
    return;
  }
  long res;
  long s;
  int f;
  for (int i = 0; ; i ^= 1) {
    immutable t = i ? t2 : t1;
    immutable v = i ? v2 : v1;
    debug stderr.writeln (s, ' ', t, ' ', v, ' ', res);
    //s + v * t == 0
    //t = -s / v
    //0 < -s / v <= t 
    bool meet;
    if (s) {
      if ((s > 0 && v > 0) || (s < 0 && v < 0)) {
      } else {
        if (v > 0 && -s <= t * v) meet = true;
        if (v < 0 && -s >= t * v) meet = true;
      }
    }
    if (meet) {
      ++res;
      f = 0;
    } else {
      if (++f == 2) break;
    }
    s += t * v; 
  }
  writeln (res);
}

