def modular_exponentiation(b, e, m):
    """produced modular exponentiation.
    https://en.wikipedia.org/wiki/Modular_exponentiation

    :param b: a base number.
    :param e: an exponent.
    :param m: a modulo.
    :return: a reminder of b modulo m.
    """
    x = 1
    y = b
    while e > 0:
        if e % 2 == 0:
            x = (x * y) % m
        y = (y * y) % m
        e = int(e / 2)
    return x % m