def integer_log(x, xi, limit=1000):
    """
    Computation of integer logarithm.
    For x and x^i returns exponent i if such i exists.
    :param x: base
    :param xi: power value
    :param limit: search limit
    :return: exponent
    """
    if xi == 1:
        return 0
    for i in range(limit):
        xi, r = divmod(xi, x)
        if xi == 1:
            return i + 1
        if r > 0:
            return