using System;
using System.Text.RegularExpressions;

public class Program
{
    private long T1, T2;
    private long A1, A2;
    private long B1, B2;

    public void Solve()
    {
        var sc = new Scanner();
        T1 = sc.NextInt();
        T2 = sc.NextInt();
        A1 = sc.NextLong() * T1;
        A2 = sc.NextLong() * T2;
        B1 = sc.NextLong() * T1;
        B2 = sc.NextLong() * T2;

        long aa = A1 + A2;
        long bb = B1 + B2;
        if (aa == bb)
        {
            Console.WriteLine("infinity");
            return;
        }

        if (aa > bb)
        {
            Swap(ref aa, ref bb);
            Swap(ref A1, ref B1);
            Swap(ref A2, ref B2);
        }

        // aa < bb

        if (B1 > A1)
        {
            Console.WriteLine("0");
            return;
        }
        // B1 < A1

        long ans = 0;

        // T1で追い付く

        // T1 開始時 AがBに追いつける位置にいる
        long d = A1 - B1;
        long m = d % (bb - aa);
        ans += (d) / (bb - aa);


        // T2

        // T2開始時 Aが前にいる
        // T1開始時 AがBに追いつける位置にいる = T1の条件
        ans *= 2;
        if (m != 0) ans++;


        Console.WriteLine(ans );
    }

    void Swap(ref long x, ref long y)
    {
        long t = x;
        x = y;
        y = t;
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 13140