def find_inverted(n, alphabet_size):
    """
    Return inverted to given number with given alphabet size.
    If there is no inverted number to given raise ValueError.
    """
    result = 1
    while (result * n) % alphabet_size != 1:
        result += 1
        if result > alphabet_size:
            raise ValueError("This key don't have primal pair!")
    return result